Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (497)
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  
  Bounding box position not updating?  (Read 874 times)
0 Members and 1 Guest are viewing this topic.
Offline DAT64X

Senior Newbie




Java games rock!


« Posted 2003-04-16 04:20:12 »

I have a BoundingBox around an object and I'm drawing it graphically.  When I drag the object around, the BoundingBox moves with the object.  However, when I System.out.println(the bounding box), the lower and upper corner point locations never seem to change.  Are those points' coordinates relative to the center of the object?  How do I get the corner's positions relative to the axes?

--DAT
Offline William

Junior Member




No Exit


« Reply #1 - Posted 2003-04-16 05:42:07 »

Your object probably sits below a TransformGroup in the scenegraph and movement is accomplished by changing the transform in the TransformGroup rather than changing the coordinates of your object.

All coordinates related to your object, including ones in other objects below your object in the scenegraph hierarchy, are relative to the TransformGroup's coordinate system. When you move your object, you are really just changing the location of the TransformGroup's coordinate system relative to the world coordinate system (at the top of the Java3D scenegraph). However, the relation that your object's coordinates have to TransformGroup's coordinate system stays the same which is why the coordinates of the boxes won't change.

You can think of your box as an object that lies in the trunk of a moving car. Its position relative to the car stays the same, but its position relative to the road changes as the car moves.

You can call the getLocalToVWorld method on your object to get a Transform3D that can transform your object's coordinates into the world's coordinate system.
Offline DAT64X

Senior Newbie




Java games rock!


« Reply #2 - Posted 2003-04-16 08:33:29 »

Hi, thanks for clearing that up.

However, I am confused as to how about getting for instance the lower and upper corner Point3ds of a bounding box in the virtual coordinate system.

For instance, if I had something like:
1  
2  
3  
4  
5  
6  
7  
boundingBox = new BoundingBox();
someSphere.setBoundsAutoCompute(false);
someSphere.setBounds(boundingBox);
boundingBox.setLower(-3.0, -3.0, -3.0);
boundingBox.setUpper(3.0, 3.0, 3.0);
boundingBoxLeaf = new BoundingLeaf(boundingBox);
boundingBoxLeaf.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);


I would be able to get the position of the boundingBox by saying
Vector3d pos = new Vector3d();
Transform3D T3D = new Transform3D();
boundingBoxBorderLeaf.getLocalToVworld(T3D);
T3D.get(pos);


However, that only gives me the position of the bounding leaf's center (correct me if I'm wrong)....how can I actually get the virtual world coordinate positions of the upper and lower corners of the bounding box within the bounding leaf?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline William

Junior Member




No Exit


« Reply #3 - Posted 2003-04-16 11:11:07 »

I think you should be able to do it by first getting the lower and upper corners of the box as points using the proper methods in the BoundingBox class and then transforming those points using the localToVworld transform of the box.
Offline DAT64X

Senior Newbie




Java games rock!


« Reply #4 - Posted 2003-04-16 14:35:05 »

Thanks, that worked!
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.

xsi3rr4x (12 views)
2014-04-15 18:08:23

BurntPizza (10 views)
2014-04-15 03:46:01

UprightPath (23 views)
2014-04-14 17:39:50

UprightPath (10 views)
2014-04-14 17:35:47

Porlus (27 views)
2014-04-14 15:48:38

tom_mai78101 (49 views)
2014-04-10 04:04:31

BurntPizza (107 views)
2014-04-08 23:06:04

tom_mai78101 (207 views)
2014-04-05 13:34:39

trollwarrior1 (176 views)
2014-04-04 12:06:45

CJLetsGame (182 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!