Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Access to "live" shape geometry ?  (Read 1131 times)
0 Members and 1 Guest are viewing this topic.
Offline cascade

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 ?
Offline 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 Smiley
Offline cascade

Junior Devvie




Java games rock!


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

thanks for the quick reply Smiley

this was close Wink 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 Huh

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 ?) ?

Ca$cade
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 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
Offline cascade

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.
Offline 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
Offline cascade

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 Smiley

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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (33 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (51 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (60 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!