Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (739) Games in Android Showcase (224) games submitted by our members Games in WIP (820) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Access to "live" shape geometry ?  (Read 2058 times) 0 Members and 1 Guest are viewing this topic.

Junior Devvie

Java games rock!

 « Posted 2004-08-23 08:46:01 »

Hi,

is there a possibility to get the world coordinates for a Shape3D geometry ?
I mean not the vertices I entered for initially defining the geometry but the vertice (in the world coordinate system) after all transforms have been applied.

I tried the COORDINATE_READ/WRITE flags but they seem to have no effect in this direction.

Any ideas ?
aNt

Senior Devvie

AFK

 « Reply #1 - Posted 2004-08-23 08:59:59 »

i no this one!! *jumps about*
 1 `Vector3f q1 = new Vector3f(model.getVworldBounds().getCenter());`

hope thats correct

Junior Devvie

Java games rock!

 « Reply #2 - Posted 2004-08-23 09:21:00 »

this was close but I was looking to get the coordinates per vertex.

Something like myShape3D.getGeometry().getCoordinate(some vertex) and now I get the VWorld coords for this vertex (Point3f).

I need it for some rayIntersectsTriangle based collision computations.

The only way I can think of doing this (at the moment) is to get the LocalToVworld Transform and apply this to the vertex I am interested. But this would mean I would compute the same transformations that Xith uses internally again. I hope this is not necessary.

update:

I tried the myShape3D.getLocalToVworld().transform(Vector3f) function on a vertex of my rotating test cube. This gives me the rotated version of the given vertex but there seems no translation being done

update(2):

ok, using myShape3D.getLocalToVworld().transform(Point3f) does the trick.

anyone having a better idea on how to do this ? Are the Vworld coords of the geometry somewhere buffered (Flags ?) ?

Yuri Vl. Gushchin

Senior Devvie

Speak Java!

 « Reply #3 - Posted 2004-08-25 06:07:07 »

Hi,

Quote
The only way I can think of doing this (at the moment) is to get the LocalToVworld Transform and apply this to the vertex I am interested. But this would mean I would compute the same transformations that Xith uses internally again. I hope this is not necessary.

Quote
Are the Vworld coords of the geometry somewhere buffered (Flags ?) ?

No. Xith3D does not apply local-to-vworld transform to vertices itself - it just passes both transform and original vertices to graphic card hardware via OpenGL, and hardware (GPU) does the transform. This is a basic idea of hardware-accelerated rendering - to avoid such caluclations on the CPU. So if you need transformed vertices, you have to transform them yourself.

Alternatively, you can think about changing your calculations to shape-local coordinate system - this will be much faster to transform your ray using inverse localToVWorld, then caluclate intersection in shape-local coordinates, and transform result back if needed (count how many transforms you save on larger geometries).

Quote
I tried the myShape3D.getLocalToVworld().transform(Vector3f) function on a vertex of my rotating test cube. This gives me the rotated version of the given vertex but there seems no translation being done

Strange - it should work as expected. Did you define translation using TransformGroup or just View transform? If you used LookAt or View Transform, then you moved your view relative to VWorld, so this translation (if any) is not part of LocalToVWorld.

Yuri

Yuri Vl. Gushchin
JProof Group

Junior Devvie

Java games rock!

 « Reply #4 - Posted 2004-08-26 08:58:40 »

I used just the TransformGroup not the View related functions. As I posted above the function on Vector3f did not translate where the function on Point3f did.

I am just coding a small class to take care of the orientation of an object. I did not fully understand how to use the lookAt function to get what I needed: A vehicle based camera. The vehicle defines the platform and has Yaw, Pitch, Roll angles and the camera can be rotated horizontally and vertically in respect to the platform orientation.

If anyone is interested I can post the code to get the rotationMatrix from the YawPitchRoll angles (using the Euler to Quaterion to Matrix way) also I don't know at this point if I am running into problems like gimbal lock etc.
Yuri Vl. Gushchin

Senior Devvie

Speak Java!

 « Reply #5 - Posted 2004-08-30 09:47:43 »

Hi,

We almost ready with a conceptually new ViewingPlatform scenegraph integration approach, which isolates moving of the platform itself and rotating/moving camera installed on it.

The approach is quite different from one found in Java3D, but gives MUCH MORE flexibility and ease of use than in Java3D.

I plan to post changes and sample how to use it within 1-2 days (I am currently on business trip, so I will do this when I will have time).

Yuri

Yuri Vl. Gushchin
JProof Group

Junior Devvie

Java games rock!

 « Reply #6 - Posted 2004-09-23 11:09:15 »

Big thanks goes to Yuri your hint on transforming the intersection ray into object coordinate space

this is of course a hundred times better than my first approach.

Here is how I compute intersections:

wrapped the Shape3D class to include a set of planes (triangles) computed from its geometry.
The intersection ray is transformed into the coord space of the Shape3D and then checked against the planes.
The intersection returns then the set of intersections at float precision and picks the one that is closest to the origin.

now ray intersection and picking works nice.

Ca\$
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Ecumene (46 views) 2017-09-30 02:57:34 theagentd (70 views) 2017-09-26 18:23:31 cybrmynd (180 views) 2017-08-02 12:28:51 cybrmynd (179 views) 2017-08-02 12:19:43 cybrmynd (186 views) 2017-08-02 12:18:09 Sralse (191 views) 2017-07-25 17:13:48 Archive (740 views) 2017-04-27 17:45:51 buddyBro (869 views) 2017-04-05 03:38:00 CopyableCougar4 (1418 views) 2017-03-24 15:39:42 theagentd (1314 views) 2017-03-24 15:32:08
 List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05SF/X Librariesby SkyAphid2017-03-02 06:38:56SF/X Librariesby SkyAphid2017-03-02 06:38:32SF/X Librariesby SkyAphid2017-03-02 06:38:05SF/X Librariesby SkyAphid2017-03-02 06:37:51
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org