Joined: May 28, 2015
Post Count: 607
Status:
Offline
How to find the vertices of a 3D shape?
Hi,
I want to automatically find the vertices (coordinates and indices) of a 3D shape.
I am currently studying methods related to exportNode of PhotoRenderer.java or writeNode of OBJWriter.java. Is it a good starting point even if it is not easy to know what to keep or not?
The goal is to be able to use this information for TriangleMeshLight light sources.
Joined: May 28, 2015
Post Count: 607
Status:
Offline
Re: How to find the vertices of a 3D shape?
For SH3D lights, the types of geometric constructions detected are: - TriangleArray (like the opaque light panel) - LineStripArray (like the unviewable light panel).
Using,
GeometryInfo geometryInfo = new GeometryInfo (geometryArray);
with the type LineStripArray, I have the error message:
java.lang.IllegalArgumentException: Unsupported geometry type
Sunflow only considers triangle-based meshes for TriangleMeshLight light sources.
France
Joined: Nov 7, 2005
Post Count: 9426
Status:
Offline
Re: How to find the vertices of a 3D shape?
Without knowing what you stored in geometryArray, it's impossible to understand what is wrong. If you look for simple examples, you could look at this tutorial and at the source code of ShapeGenerator plugin.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
Joined: May 28, 2015
Post Count: 607
Status:
Offline
Re: How to find the vertices of a 3D shape?
To have a reference of what I had to look for, I performed tests in Sunflow directly by editing the example_scene.geo.sc file.
I have found that vertices are only well taken into account if they are grouped into a single object defined in the .obj file.
# 3D model cube_v2.obj
mtllib cube_v2.mtl
g cube
usemtl default
v 0.0 0.0 0.0 v 100.0 0.0 0.0 v 100.0 0.0 100.0 v 0.0 0.0 100.0 v 0.0 100.0 0.0 v 100.0 100.0 0.0 v 0.0 100.0 100.0 v 100.0 100.0 100.0
f 1 2 3 f 1 3 4 f 2 1 5 f 2 5 6 f 1 4 7 f 1 7 5 f 3 2 6 f 3 6 8 f 4 3 8 f 4 8 7 f 7 8 6 f 7 6 5
Results in Sweet Home 3D.
By launching the rendering several times, sometimes the triangle mesh light is not well applied. I think I should put my method searchVertices (light) elsewhere than in exportLightSource especially since there is redundancy with some methods already present in the PhotoRenderer file.
----------------------------------------
EnkoNyito
France
Joined: Nov 7, 2005
Post Count: 9426
Status:
Offline
Re: How to find the vertices of a 3D shape?
sometimes the triangle mesh light is not well applied.
Maybe this could be bound to triangles orientation. Did you try to reverse the order of the vertices?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator