From 83632cb010580a57e57423845f7987712af59056 Mon Sep 17 00:00:00 2001 From: Matin Afzal Date: Sat, 3 Aug 2024 01:29:53 +0330 Subject: [PATCH] V1.2.3 Performance up & threading, python command line launch fixed, universal object attacher, diffrent biomes, cactus's, req.txt, TestSite imit --- main/Engine2/Settings2.py | 2 +- main/Level/Cactus.py | 10 +-- main/Level/Chunk.py | 101 ++++++++++++++++++++----------- main/Level/ObjectAttach.py | 10 +-- main/Level/Tree.py | 2 + main/{ICU.py => OpenUniverse.py} | 10 ++- main/test/TestSite.py | 32 ++++++++-- 7 files changed, 114 insertions(+), 53 deletions(-) rename main/{ICU.py => OpenUniverse.py} (93%) diff --git a/main/Engine2/Settings2.py b/main/Engine2/Settings2.py index 82da53f..e89d952 100644 --- a/main/Engine2/Settings2.py +++ b/main/Engine2/Settings2.py @@ -52,5 +52,5 @@ SCREEN_MULTISAMPLESAMPLES = 4 SCREEN_DEPTH_SIZE = 24 SCREEN_CAPTION_LOADING = "Loading..." -SCREEN_CAPTION = "3DICU V [VANY] from [1.1.1]" +SCREEN_CAPTION = "OpenUniverse V [VANY] from [1.1.1]" SCREEN_MAX_FPS = 60 diff --git a/main/Level/Cactus.py b/main/Level/Cactus.py index 5953a82..cfd2c09 100644 --- a/main/Level/Cactus.py +++ b/main/Level/Cactus.py @@ -7,10 +7,12 @@ def __init__(self, position, max_height=4, min_height=0, biome="A", img=None, ma cactus generator Args: - position (pcenter_ygame.Vector3): tree center vertex position - max_height (int): tree maximum height - min_height (int): tree minimum depth - biome (str): tree biome + position (pcenter_ygame.Vector3): cactus center vertex position + max_height (int): cactus maximum height + min_height (int): cactus minimum depth + biome (str): cactus biome + img (path): texture + shematic (np.array): cactus generation sample """ self.level_name = "tree1" diff --git a/main/Level/Chunk.py b/main/Level/Chunk.py index bbac20f..12b8600 100644 --- a/main/Level/Chunk.py +++ b/main/Level/Chunk.py @@ -5,11 +5,12 @@ class Chunk(Mesh): - def __init__(self, position=None, max_height=10, min_depth=-10, shematic=None, img=None, material=None) -> None: + def __init__(self, biome="jungle", position=None, max_height=10, min_depth=-10, shematic=None, img=None, material=None) -> None: """ Chunk generator Args: + biome (str): chunk type ["jungle", "desert", "snow"] position (pygame.Vector3): chunk center vertex position max_height (int): chunk maximum height min_depth (int): chunk minimum depth @@ -18,6 +19,8 @@ def __init__(self, position=None, max_height=10, min_depth=-10, shematic=None, i material (): if material -> for loop gen """ + self.known_biomes = ["jungle", "desert", "snow"] + self.biome = biome self.chunk_center = position # for distance culling self.level_name = "chunk" self.material = material @@ -49,8 +52,12 @@ def __init__(self, position=None, max_height=10, min_depth=-10, shematic=None, i self.VM_L = 1 # Vertical Multiplier to last border self.BD = 0.0000099 # border_deficiency self.ONE = 1 - self.BD - - self.vertices, self.triangles, uvs, uvs_ind, normals, normals_ind = self.level_maker(self.position) + + if self.biome in self.known_biomes: + self.vertices, self.triangles, uvs, uvs_ind, normals, normals_ind = self.level_maker(self.position) + else: + if ESP: + print("Biome not found!") # t1 = threading.Thread(target=format_vertices, args=(self.vertices, self.triangles)) # t2 = threading.Thread(target=format_vertices, args=(uvs, uvs_ind)) @@ -196,39 +203,61 @@ def level_maker(self, center): for DEPTH in range(temp-4, temp): # Y self.blocks += 1 - if DEPTH <= -5: # SAND - self.HM_F = 0 - self.HM_L = 1 - self.VM_F = 2 - self.VM_L = 3 - # self.HM_F = 15 - # self.HM_L = 16 - # self.VM_F = 15 - # self.VM_L = 16 - elif -4 <= DEPTH < 0: # DIRT - # dirt = True - self.HM_F = 0 - self.HM_L = 1 - self.VM_F = 1 - self.VM_L = 2 - # self.HM_F = 15 - # self.HM_L = 16 - # self.VM_F = 15 - # self.VM_L = 16 - elif 0 <= DEPTH < 15: # GRASS - self.HM_F = 9 - self.HM_L = 10 - self.VM_F = 15 - self.VM_L = 16 - # self.HM_F = 1 - # self.HM_L = 2 - # self.VM_F = 14 - # self.VM_L = 15 - elif DEPTH >= 15: # SNOW - self.HM_F = 1 - self.HM_L = 2 - self.VM_F = 14 - self.VM_L = 15 + if DEPTH <= -5: + if self.biome == "jungle": # Jungle sand + self.HM_F = 0 + self.HM_L = 1 + self.VM_F = 2 + self.VM_L = 3 + elif self.biome == "desert": + self.HM_F = 0 + self.HM_L = 1 + self.VM_F = 2 + self.VM_L = 3 + elif self.biome == "snow": # Snow pure snow + self.HM_F = 15 + self.HM_L = 16 + self.VM_F = 15 + self.VM_L = 16 + elif -4 <= DEPTH < 0: + if self.biome == "jungle": # Jungle dirt + # dirt = True + self.HM_F = 0 + self.HM_L = 1 + self.VM_F = 1 + self.VM_L = 2 + elif self.biome == "desert": + self.HM_F = 5 + self.HM_L = 6 + self.VM_F = 15 + self.VM_L = 16 + elif self.biome == "snow": # Snow pure snow + self.HM_F = 15 + self.HM_L = 16 + self.VM_F = 15 + self.VM_L = 16 + elif 0 <= DEPTH < 15: + if self.biome == "jungle": # Jungle grass + self.HM_F = 9 + self.HM_L = 10 + self.VM_F = 15 + self.VM_L = 16 + elif self.biome == "desert": + self.HM_F = 0 + self.HM_L = 1 + self.VM_F = 1 + self.VM_L = 2 + elif self.biome == "snow": # Snow ice + self.HM_F = 1 + self.HM_L = 2 + self.VM_F = 14 + self.VM_L = 15 + elif DEPTH >= 15: + if self.biome == "jungle": # Jungle snow + self.HM_F = 1 + self.HM_L = 2 + self.VM_F = 14 + self.VM_L = 15 else: print(f"ERROR: Unidentified block detected... ZXY:{ROW}/{COLUMN}/{DEPTH}") diff --git a/main/Level/ObjectAttach.py b/main/Level/ObjectAttach.py index ea642f2..51d4ebb 100644 --- a/main/Level/ObjectAttach.py +++ b/main/Level/ObjectAttach.py @@ -1,4 +1,5 @@ from random import randint +from pygame import Vector3 from Level.Chunk import * from Level.Tree import * from Level.Cactus import * @@ -11,13 +12,14 @@ class ObjectAttach: Attach objects together ! """ - def __init__(self, object_name="chunk", start_x=0, start_y=0, start_z=0, number_x=1, number_z=1, shader=None, - texture=None) -> None: + def __init__(self, object_name="chunk", object_type="", start_x=0, start_y=0, start_z=0, number_x=1, number_z=1, + shader=None, texture=None) -> None: if ESP: print("Attaching Objects...") self.known_objects = ["chunk", "tree", "cactus"] self.object_name = object_name + self.object_type = object_type self.layer = [] self.shader = shader self.texture = texture @@ -47,8 +49,8 @@ def chunk_binding(self): print("Building Chunks (Multiple Level.Chunk Callings)...") for x in range(self.sx, self.end_x, 8): for z in range(self.sz, self.end_z, 8): - self.layer.append(Chunk(Vector3(x, 0, z), shematic=self.shematic.locate(x, z), material=self.shader, - img=self.texture)) + self.layer.append(Chunk(biome=self.object_type, position=Vector3(x, 0, z), + shematic=self.shematic.locate(x, z), material=self.shader, img=self.texture)) def tree_binding(self): if ESP: diff --git a/main/Level/Tree.py b/main/Level/Tree.py index 2604893..3ee4934 100644 --- a/main/Level/Tree.py +++ b/main/Level/Tree.py @@ -12,6 +12,8 @@ def __init__(self, position, max_height=4, min_height=0, biome="A", img=None, ma max_height (int): tree maximum height min_height (int): tree minimum depth biome (str): tree biome + img (path): texture + shematic (np.array): tree generation sample """ self.level_name = "tree1" diff --git a/main/ICU.py b/main/OpenUniverse.py similarity index 93% rename from main/ICU.py rename to main/OpenUniverse.py index ff9a4f2..9b7f2b6 100644 --- a/main/ICU.py +++ b/main/OpenUniverse.py @@ -17,7 +17,7 @@ class MultiShaders(Screen): def __init__(self): if ESP: print("Starting Engine...") - print("Project repo: https://github.com/MatinAfzal/3DICU") + print("Project repo: https://github.com/MatinAfzal/OpenUniverse") start = datetime.now() print("Starting at:" + str(start.now())) @@ -91,8 +91,11 @@ def __init__(self): self.sun_start = int(time()) # Object Attach - self.terrain = ObjectAttach(object_name="chunk", number_x=10, number_z=10) - self.trees = ObjectAttach(object_name="tree", number_x=10, number_z=10) + self.terrain = ObjectAttach(object_name="chunk", object_type="jungle", number_x=15, number_z=15) + self.trees = ObjectAttach(object_name="tree", number_x=15, number_z=15) + + # self.terrain = ObjectAttach(object_name="chunk", object_type="desert", number_x=10, number_z=10) + # self.trees = ObjectAttach(object_name="cactus", number_x=10, number_z=10) # Cell Attaches cell_start = datetime.now() @@ -101,6 +104,7 @@ def __init__(self): self.world = CellAttach(self.terrain.layer, shader=self.mat, image=self.img_texture) self.forest = CellAttach(self.trees.layer, shader=self.mat, image=self.img_texture) + # self.forest = CellAttach(self.trees.layer, shader=self.mat, image=self.img_cactus) def initialise(self): # Variables diff --git a/main/test/TestSite.py b/main/test/TestSite.py index 715a6c6..9f969d9 100644 --- a/main/test/TestSite.py +++ b/main/test/TestSite.py @@ -1,12 +1,34 @@ import numpy as np import pandas as pd -from main.Engine2.Settings2 import * +from Engine2.Settings2 import * + class TestSite: - def __init__(self, action="view"): - self.known_actions = ["view", "import"] + """ + format: format_version-chunk_num_x-chunk_num_z-obj_num_x-obj_num_z-chunk_type-object_type-lighting_method + details: + - chunk_type -> [P: Plain, D: Desert, S: Snow] + - object_type -> [T: Tree, C: Cactus] + - lighting_method -> [D: Dynamic Lighting] + + # + test_sample: + - V1-S -> 1: 1-10-10-10-10-P-T-D + + test_method: + - soft: stand still / locked FPS + - normal: move around / locked FPS + - hard: move around / open FPS + - aggressive: move around / look around / open FPS / fast + """ + + def __init__(self, action="view", test_sample="1", test_method="soft"): + + self.known_actions = ["test", "view"] + self.known_settings = ["V1-S, "] if action not in self.known_actions: if ESP: - print() - + print("action not found!") + elif action == "test": + pass