Skip to main content

3D positioning

2 replies [Last post]
Joined: 2009-03-26

Hello, I am knew to java 3D. I want to build a tree of transformations and shapes so I can rotate, scale etc my shapes.
I need to position my shapes in particular areas of my campus but when I make , say a new Box, I have to give numbers like 1.0f.

new Box(1.0f, 1.0f,1.0f)

whereas I want something like:
new Box(25,25,25); on my campus.

Thanks for any help

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-10-17

The numbers you pass to the box in its constructor are to do with its size, not its position. see here:

You don't HAVE to pass it any number, you can just have new Box(); and get a default box (1 by 1 by 1). To specify the location of an object in Java 3D, you need to place your object in a TransformGroup, and then set the position of the TransformGroup using a Transform3D. Have a look at the documentation and try and get your head round the scene graph structure, it takes a little practice but its OK once you have learned how to use it.
Hope this helps

Joined: 2009-03-26

Thanks nealk2k3 . Thats more helpful.
I have current made up a tree using the scene graph structure.
I am adding a Box to the child of a transform group and then adding it to the
I had a look at setting the position using transform3D but I can't find the method for setting the position. I can't even find anything in the tutorial.