Compare commits
3 Commits
cbae4ec0e7
...
master
Author | SHA1 | Date | |
---|---|---|---|
830daec408
|
|||
4783f0ba2d
|
|||
ccc168c896
|
1
.gitmodules
vendored
1
.gitmodules
vendored
@ -1,3 +1,4 @@
|
||||
[submodule "engine"]
|
||||
path = engine
|
||||
url = https://code.rozk.net/RK/rk_engine.git
|
||||
branch = master
|
||||
|
2
engine
2
engine
Submodule engine updated: b46b4bddba...7384a014ff
@ -16,7 +16,7 @@
|
||||
from ctypes import c_ubyte, c_ushort, c_void_p, POINTER, addressof
|
||||
|
||||
from engine import (
|
||||
buffer, INSTANCE_FLAG_SPAWNED, BATCH_MAX_SIZE, param_type, params_format,
|
||||
buffer, INSTANCE_FLAG_SPAWNED, BATCH_MAX_SIZE, vertex_type, vertex_format,
|
||||
create_batch, fill_batch, draw_batch, destroy_batch)
|
||||
|
||||
_flags_t = c_ubyte
|
||||
@ -32,7 +32,7 @@ class Batch:
|
||||
assert max_size <= BATCH_MAX_SIZE
|
||||
nparams = len(params_decls)
|
||||
if nparams:
|
||||
self._batch = create_batch(vertices._vertices, max_size, params_format(*params_decls.values()))
|
||||
self._batch = create_batch(vertices._vertices, max_size, vertex_format(*params_decls.values()))
|
||||
else:
|
||||
self._batch = create_batch(vertices._vertices, max_size, None)
|
||||
self.vertices = vertices
|
||||
@ -43,7 +43,7 @@ class Batch:
|
||||
self.mesh = buffer(_mesh_t, max_size)
|
||||
self._meshes = _mesh_p(self.mesh)
|
||||
if nparams:
|
||||
self.param = tuple(map(lambda f: buffer(param_type(f), max_size), params_decls.values()))
|
||||
self.param = tuple(map(lambda f: buffer(vertex_type(f), max_size), params_decls.values()))
|
||||
self._params = (c_void_p * nparams)(*map(addressof, self.param))
|
||||
self._name = dict(zip(params_decls.keys(), range(nparams)))
|
||||
for name, value in zip(params_decls.keys(), self.param):
|
||||
|
@ -137,7 +137,7 @@ def create_scene(keyboard, mouse):
|
||||
rock_mesh = tiles_vertices.get_mesh('rock')
|
||||
mud_mesh = tiles_vertices.get_mesh('mud')
|
||||
lava_mesh = tiles_vertices.get_mesh('lava')
|
||||
tiles_batch = Batch(Vertices(*tiles_vertices), generated.size ** 2, translation = PARAM_FORMAT_VEC3_SHORT)
|
||||
tiles_batch = Batch(Vertices(*tiles_vertices), generated.size ** 2, translation = VERTEX_FORMAT_VEC3_SHORT)
|
||||
|
||||
#TODO: generator & for real
|
||||
vc = generated.volcano_c
|
||||
@ -179,8 +179,8 @@ def create_scene(keyboard, mouse):
|
||||
cube_mesh = tests_vertices.get_mesh('cube')
|
||||
clouds_mesh = tests_vertices.get_mesh('clouds')
|
||||
tests_batch = Batch(Vertices(*tests_vertices), 3,
|
||||
translation = PARAM_FORMAT_VEC3_FLOAT,
|
||||
orientation = PARAM_FORMAT_MAT3_INT10 | PARAM_FORMAT_NORMALIZE)
|
||||
translation = VERTEX_FORMAT_VEC3_FLOAT,
|
||||
orientation = VERTEX_FORMAT_MAT3_INT10 | VERTEX_FORMAT_NORMALIZE)
|
||||
blob_forward = math.vec3_normalize((sun_direction[0], sun_direction[1], 0.0))
|
||||
blob_right = math.vec3_cross(blob_forward, math.vec3_up)
|
||||
blob_orientation = mat3(vec3(*blob_right), vec3(*blob_forward), vec3_up)
|
||||
|
@ -219,9 +219,12 @@ class ObjArchive(Archive):
|
||||
assert name not in self.vertices_db.keys()
|
||||
#TODO: move to math
|
||||
def pack_10(_x):
|
||||
return round(_x * (512.0 if _x < 0.0 else 511.0)) & 1023
|
||||
assert _x >= -1.0 and _x <= 1.0
|
||||
return round(_x * 511.0) & 1023
|
||||
# return ((round(_x * 1023.0) - 1) // 2) & 1023
|
||||
def pack_u10(_x):
|
||||
return round(_x * 1023.0) & 1023
|
||||
assert _x >= 0.0 and _x <= 1.0
|
||||
return round(_x * 1023.0)
|
||||
def pack_vertex(_px, _py, _pz, _nx, _ny, _nz, _s, _t, _tl):
|
||||
n = (pack_10(_nz) << 20) | (pack_10(_ny) << 10) | pack_10(_nx)
|
||||
t = ((_tl & 1023) << 20) | (pack_u10(_t) << 10) | pack_u10(_s)
|
||||
|
Reference in New Issue
Block a user