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

Bugs in TexturedMesh affine_transform #12

Open
Jingyu6 opened this issue Nov 18, 2022 · 1 comment
Open

Bugs in TexturedMesh affine_transform #12

Jingyu6 opened this issue Nov 18, 2022 · 1 comment

Comments

@Jingyu6
Copy link

Jingyu6 commented Nov 18, 2022

Hi simple-3dviz team,

Recently I've been using this great lib but encountered the problem when I want to apply a rotation on a textured mesh. I tried loading an obj file with TexturedMesh and Mesh:

textured_mesh = TexturedMesh.from_obj_file(obj_path)
raw_mesh = Mesh.from_file(obj_path)

(TexturedMesh.from_file also has the same problem)

Then I applied the following rotation on these objects like

R = np.zeros((3, 3))
R[0, 0] = np.cos(theta)
R[0, 2] = -np.sin(theta)
R[2, 0] = np.sin(theta)
R[2, 2] = np.cos(theta)
R[1, 1] = 1.

textured_mesh.affine_transform(R=R)
raw_mesh.affine_transform(R=R)

Finally, rendered them to get the following:
(Textured mesh)
image
(Raw mesh)
image

It looks like the vertices and faces of the textured mesh all get messed up whereas the mesh without textures looks fine. Here's a textured mesh loaded without applying any rotations as a reference:
image

So I guess there might be some problems when the lib handles rotation for textured meshes. Due the data privacy, I can't share the model obj that I used. Can I get some help with this? Great thanks in advance!

Best,
Jingyu

@Jingyu6
Copy link
Author

Jingyu6 commented Nov 18, 2022

It seems to me that the problem with affine_transform for textured mesh is that it changes the vertices directly whereas methods like rotate_along_axis and rotate_x/y/z will change the model_matrix instead. The latter ones work perfectly well so I think there needs to be some fix for TexturedMesh.affine_transform.

Another point during code inspection: back-face culling is done in the fragment shader, which I'm not sure if it is the good way to do so.

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