Login  Register

Re: how to transform objects not using Transform3D

Posted by Mr. Broccoli on Aug 02, 2022; 2:07pm
URL: https://forum.jogamp.org/how-to-transform-objects-not-using-Transform3D-tp4041515p4041805.html

Hi again,

So, I figured out that the half-plane set by the triangle normal needs to contain point 0,0,0 in order for the face to be visible. I'm checking this by looking at the dot product of a normal and one of triangle points.
I'm using methods:
boolean[] isFrontFacing   // for determining if the triangle is front-facing (ff)
IndexedTriangleArray[] frontFacingTriangles   // for crating a subset of ff triangles to display

This methods seem to work pretty neat, although I couldn't fully test them yet as I can't figure out exactly how to make it work for transformations.
I don't understand how the BY_REFERENCE bit for normals is supposed to work.
When comes to coordinates, I believe this is 'kind of' intuitive. I mean you have a long flat float[] with coords, you specify indices and then you tell that these particular 3 next indices are going to create a new triangle geometry.
It is not a problem that four triangles take the same vertex, as its x,y,z are the same for all of them.
Now, for normals, it gets problematic, as the same point, after separating triangles, is having 3 different normals.
How should I feed data into geom.setNormalRefFloat(flat_normals); in ccr2 method, or in general how should I handle normal data in java3D BY_REF? Am I supposed to generate 3*number_of_vertices float[] for each triangle separately and that's it? I cannot see any method for setting indices for normals. Do I then .getNormalRefFloat(); and transform it when striking keys? I will try that next.

Just writing the data down, not much thinking, I have coded float[][] cube1_normals with 6 normal vectors.
I have also set int[] cube_normals_idx that lists indices to normals for all 12 triangles (duplicate entries as I thought it would simplify iterating to 12).

I also did experiment with GeometryInfo class, but this led me nowhere.

I suppose that display order is just a matter of sorting ff triangles in Z order, true?

The current file: notusingtransform3D.java
Seems to me that triangles get sorted once and don't get re-evaluated after transformation.

Kind regards, Mr B.