Cleanup sea triangles creation.

This commit is contained in:
Roz K 2022-12-31 19:32:39 +01:00
parent 9e77e6680b
commit f66c6ea6e9
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
2 changed files with 32 additions and 33 deletions

View File

@ -157,7 +157,7 @@ def main():
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'))
sea_detail_texture = sea.load_detail_texture('data/sea_bump.png') sea_detail_texture = sea.load_detail_texture('data/sea_bump.png')
sea_triangles = sea.SeaTriangles(64, proj_far_z - 0.1, proj_ratio) sea_triangles = sea.sea_triangles(64, proj_far_z - 0.1, proj_ratio)
scene = SceneNode( scene = SceneNode(
FuncNode(update_camera, (mouse, camera, environment)), FuncNode(update_camera, (mouse, camera, environment)),

View File

@ -71,9 +71,8 @@ def load_detail_texture(path, scale = 0.5, waves_height = 0.002):
data = array(_typecode, list(map(_conv, normals))) data = array(_typecode, list(map(_conv, normals)))
return Texture(_format, width, height, 0, _flags, data) return Texture(_format, width, height, 0, _flags, data)
class SeaTriangles(Triangles): # TODO: with FOV
# TODO: with FOV def sea_triangles(vsubdivs, distance, projection_ratio):
def __init__(self, vsubdivs, distance, projection_ratio):
assert vsubdivs > 0 assert vsubdivs > 0
vertices = [] vertices = []
hsubdivs = round(vsubdivs * projection_ratio) hsubdivs = round(vsubdivs * projection_ratio)
@ -102,4 +101,4 @@ class SeaTriangles(Triangles):
x2 += stepx x2 += stepx
y1 = y2 y1 = y2
y2 += stepy y2 += stepy
super().__init__(array('f', chain.from_iterable(vertices))) return Triangles(array('f', chain.from_iterable(vertices)))