Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine() is not copying normals #500

Open
prof-danielc opened this issue Jan 14, 2023 · 0 comments
Open

Combine() is not copying normals #500

prof-danielc opened this issue Jan 14, 2023 · 0 comments

Comments

@prof-danielc
Copy link

prof-danielc commented Jan 14, 2023

I was generating two meshes with an empty parent, then combining them. It resulted in a black mesh:

terrain = Entity(parent=scene)

terrain_from_heightmap_texture = Entity(parent=terrain, model=Terrain('heightmap_1', skip=8), shader=basic_lighting_shader, collider='mesh', scale=(40,5,20), texture='heightmap_1')

hv = terrain_from_heightmap_texture.model.height_values.tolist()
terrain_from_list = Entity(parent=terrain, model=Terrain(height_values=hv), shader=basic_lighting_shader, collider='mesh', scale=(40,5,20), texture='heightmap_1', x=40)

terrain.combine()
terrain.collider = 'mesh'
#terrain.texture = 'heightmap_1'
terrain.shader = basic_lighting_shader
terrain.color = color.white

In #307 a similar issue was reported. I checked combine.py and found the copying of normals is commented:
# if e.model.normals: # norms += e.model.normals
So I got it working by forcing Mesh to recalculate normals by adding the following line at the end of the pasted code:
terrain.model.generate_normals() # TODO remove this hack

Uncommenting those two lines and using generate_models has the same effect in my use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant