A little bit of clenaup.

This commit is contained in:
Roz K 2022-12-23 06:36:24 +01:00
parent 643c9a1bae
commit 3e83c636ee
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
2 changed files with 14 additions and 15 deletions

View File

@ -14,7 +14,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from ctypes import c_ubyte, c_uint, POINTER from ctypes import c_ubyte, c_uint, POINTER
from array import array
from engine import ( from engine import (
INSTANCE_FLAG_SPAWNED, BATCH_MAX_SIZE, create_batch, draw_batch, destroy_batch) INSTANCE_FLAG_SPAWNED, BATCH_MAX_SIZE, create_batch, draw_batch, destroy_batch)

View File

@ -20,12 +20,12 @@ from ctypes import Structure
from engine import * from engine import *
from game import math from game import math
from game import generator
from game import shader from game import shader
from game import resources
from game import batch
from game import triangles from game import triangles
from game import sea from game import sea
from game.generator import Generator
from game.resources import RuntimeArchive
from game.batch import Batch
from game.camera import Camera from game.camera import Camera
from game.environment import Environment from game.environment import Environment
@ -42,9 +42,9 @@ sun_power = 1.0
def main(): def main():
print("Generating terrain...") print("Generating terrain...")
gen_begin = time.process_time() gen_begin = time.thread_time()
generated = generator.Generator(256) generated = Generator(256)
gen_end = time.process_time() gen_end = time.thread_time()
print("Done: ", round(gen_end - gen_begin, 2), "seconds") print("Done: ", round(gen_end - gen_begin, 2), "seconds")
print("Initializing...") print("Initializing...")
@ -66,7 +66,7 @@ def main():
tests_normalmap_sampler = resolve_input(tests_shader, b'u_normal_sampler') tests_normalmap_sampler = resolve_input(tests_shader, b'u_normal_sampler')
print("Loading resources...") print("Loading resources...")
archive = resources.RuntimeArchive.load('data/rk_island.rkar') archive = RuntimeArchive.load('data/rk_island.rkar')
print("Building tiles...") print("Building tiles...")
tiles_texture = archive.get_texture('tiles') tiles_texture = archive.get_texture('tiles')
@ -79,7 +79,7 @@ def main():
rock_model = archive.get_model('rock') rock_model = archive.get_model('rock')
mud_model = archive.get_model('mud') mud_model = archive.get_model('mud')
lava_model = archive.get_model('lava') lava_model = archive.get_model('lava')
terrain_batch = batch.Batch(tiles_vertices, generated.size ** 2, params_format(PARAM_FORMAT_VEC3_SHORT), vec3) terrain_batch = Batch(tiles_vertices, generated.size ** 2, params_format(PARAM_FORMAT_VEC3_SHORT), vec3)
#TODO: generator & for real #TODO: generator & for real
vc = generated.volcano_c vc = generated.volcano_c
@ -112,7 +112,7 @@ def main():
model = rock_model model = rock_model
model.spawn(terrain_batch, vec3(float(((mx - 128) * 8) + 4), float(((127 - my) * 8) + 4), 0.0)) model.spawn(terrain_batch, vec3(float(((mx - 128) * 8) + 4), float(((127 - my) * 8) + 4), 0.0))
class testsparams(Structure): class TestsParams(Structure):
_fields_ = ('translation', vec3), ('orientation', vec3) _fields_ = ('translation', vec3), ('orientation', vec3)
tests_texture = archive.get_texture('tests') tests_texture = archive.get_texture('tests')
@ -121,14 +121,14 @@ def main():
blob_model = archive.get_model('blob') blob_model = archive.get_model('blob')
cube_model = archive.get_model('cube') cube_model = archive.get_model('cube')
clouds_model = archive.get_model('clouds') clouds_model = archive.get_model('clouds')
tests_batch = batch.Batch(tests_vertices, 3, tests_batch = Batch(tests_vertices, 3,
params_format(PARAM_FORMAT_VEC3_FLOAT, PARAM_FORMAT_VEC3_INT10 | PARAM_FORMAT_NORMALIZE), testsparams) params_format(PARAM_FORMAT_VEC3_FLOAT, PARAM_FORMAT_VEC3_INT10 | PARAM_FORMAT_NORMALIZE), TestsParams)
blob_spawn_translation = vec3(-100.0, -500.0, 0.0) blob_spawn_translation = vec3(-100.0, -500.0, 0.0)
cube_spawn_translation = vec3(100.0, -500.0, 0.0) cube_spawn_translation = vec3(100.0, -500.0, 0.0)
blob_id = blob_model.spawn(tests_batch, blob_id = blob_model.spawn(tests_batch,
testsparams(blob_spawn_translation, vec3(*math.vec3_normalize((sun_direction[0], sun_direction[1], 0.0))))) TestsParams(blob_spawn_translation, vec3(*math.vec3_normalize((sun_direction[0], sun_direction[1], 0.0)))))
cube_id = cube_model.spawn(tests_batch, testsparams(cube_spawn_translation, vec3_forward)) cube_id = cube_model.spawn(tests_batch, TestsParams(cube_spawn_translation, vec3_forward))
clouds_id = clouds_model.spawn(tests_batch, testsparams(vec3(0.0, 0.0, 32.0), vec3_forward)) clouds_id = clouds_model.spawn(tests_batch, TestsParams(vec3(0.0, 0.0, 32.0), vec3_forward))
sea_phase = resolve_input(sky_shader, b'u_sea_phase') sea_phase = resolve_input(sky_shader, b'u_sea_phase')
sea_polar_textures = sea.load_polar_textures(('data/sea_bump1.png', 'data/sea_bump2.png')) sea_polar_textures = sea.load_polar_textures(('data/sea_bump1.png', 'data/sea_bump2.png'))