Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 14
Posts: 14   Pages: 2   [ 1 2 | Next Page ]
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 15429 times and has 13 replies Next Thread
enkonyito
Advanced Member
Member's Avatar


Joined: May 28, 2015
Post Count: 601
Status: Offline
Reply to this Post  Reply with Quote 
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.

Enko
----------------------------------------
EnkoNyito
[Oct 30, 2018, 10:15:15 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
enkonyito
Advanced Member
Member's Avatar


Joined: May 28, 2015
Post Count: 601
Status: Offline
Reply to this Post  Reply with Quote 
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.
light {
type meshlight
name meshLamp
emit { "sRGB nonlinear" 1.000 1.000 1.000 }
radiance 100.0
samples 16
points 4
0.6 0.1 6.0
0.3 1.0 6.0
1.0 1.0 5.5
1.0 0.3 5.5
triangles 2
0 1 2
0 2 3
}

----------------------------------------
EnkoNyito
[Nov 3, 2018, 9:26:08 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9141
Status: Offline
Reply to this Post  Reply with Quote 
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 developer
[Nov 4, 2018, 5:49:43 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
enkonyito
Advanced Member
Member's Avatar


Joined: May 28, 2015
Post Count: 601
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to find the vertices of a 3D shape?

I use your tutorial to complete my information on the Javadoc of Java3D.

In geometryArray, the data about the object of any shape that I want to find the vertices is stored.
[...]
} else if (node instanceof Shape3D) {
Shape3D shape = (Shape3D)node;
[...]
// Read object geometries
for (int i = 0, n = shape.numGeometries(); i < n; i++) {
readNodeGeometry(shape.getGeometry(i), parentTransformations, texCoordGeneration,
textureTransform, cullFace, backFaceNormalFlip);
}
[...]

[...]
private void readNodeGeometry(Geometry geometry,
Transform3D parentTransformations,
TexCoordGeneration texCoordGeneration,
Transform3D textureTransform,
int cullFace,
boolean backFaceNormalFlip) {
if (geometry instanceof GeometryArray) {
GeometryArray geometryArray = (GeometryArray)geometry;
[...]


The ideal would be to force to use TRIANGLE_ARRAY.
----------------------------------------
EnkoNyito
[Nov 5, 2018, 4:31:34 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
enkonyito
Advanced Member
Member's Avatar


Joined: May 28, 2015
Post Count: 601
Status: Offline
Reply to this Post  Reply with Quote 
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
[Nov 20, 2018, 7:13:22 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
enkonyito
Advanced Member
Member's Avatar


Joined: May 28, 2015
Post Count: 601
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to find the vertices of a 3D shape?

Using or modifying existing methods in the PhotoRenderer class optimizes the dynamic search for coordinates and vertices indices of a 3D shape. smile

The quality and duration of rendering depends on the composition and complexity (number of triangular faces) of the object transforming into light.

Neon digits (created by alaX)


SH3D models

----------------------------------------
EnkoNyito
[Nov 25, 2018, 11:15:56 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
ndorigatti
Member



Italia
Joined: May 12, 2017
Post Count: 65
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to find the vertices of a 3D shape?

So, let me understand.. are you finding a way to speed up rendering or trying to find a render result different than before?
[Nov 26, 2018, 8:35:14 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
enkonyito
Advanced Member
Member's Avatar


Joined: May 28, 2015
Post Count: 601
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to find the vertices of a 3D shape?

Unfortunately, I do not think it is possible to speed up the rendering with Sunflow.

On the other hand, I found a way for Sweet Home 3D to take into account the mesh light rendering .
----------------------------------------
EnkoNyito
[Nov 26, 2018, 5:50:47 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
ndorigatti
Member



Italia
Joined: May 12, 2017
Post Count: 65
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to find the vertices of a 3D shape?

So that you can have the whole mesh to light up? Could be interesting for my Philips homroo light model, where the glass part would be a mesh light!
[Nov 26, 2018, 7:15:11 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9141
Status: Offline
Reply to this Post  Reply with Quote 
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 developer
[Nov 26, 2018, 8:23:14 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Posts: 14   Pages: 2   [ 1 2 | Next Page ]
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

    Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads
   
© Copyright 2006-2024 eTeks - All rights reserved