Hi Bram
Problem here isnt the transform its the box. I believe the values of passed to a Box object are from center out, so a Box(1f,1f,1f) will actually give a physical cube with each side length 2f..
So your value of 0.5f you use for x length is creating a box of 1f wide, youre then only moving 0.25 along x length (length/2.0f), 1/4 of box width
I imagine your screen shot shows the corner offset... I cant access it to examine/.
Martin...
Bram Biesbrouck wrote:
Hi all,
I'm having troubles with the translation of a simple Box in Java3D. I created a TransformGroup-subclass, called Room like this:
<START CODE>
public class Room extends TransformGroup { //constants ...
private Box box = null;
public Room(float width, float length, Color3f color, String caption) { super(); this.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE | TransformGroup.ALLOW_BOUNDS_WRITE | TransformGroup.ALLOW_BOUNDS_READ); this.setBoundsAutoCompute(true);
Appearance ap = new Appearance(); ap.setColoringAttributes(new ColoringAttributes(color, ColoringAttributes.NICEST)); ap.setTransparencyAttributes(new TransparencyAttributes (TransparencyAttributes.FASTEST, 0.5f));
box = new Box(width, BOX_HEIGHT, length, Primitive.GENERATE_NORMALS | Primitive.GEOMETRY_NOT_SHARED, ap);
this.addChild(box); } }
<END CODE>
I then call this function in a mail class like this:
<START CODE>
//CONSTANTS private final float KITCHEN_X_LENGTH = 0.5f; private final float KITCHEN_Y_LENGTH = 0.25f;
...
SimpleUniverse universe = new SimpleUniverse(); universe.getViewingPlatform().setNominalViewingTransform(); BranchGroup group = new BranchGroup();
Room kitchen = new Room(KITCHEN_X_LENGTH, KITCHEN_Y_LENGTH, KITCHEN_COLOR, "Kitchen"); kitchen.getTransform(transform); transform.setTranslation(new Vector3d(-KITCHEN_X_LENGTH/2.0f, 0f, -KITCHEN_Y_LENGTH/2.0f)); kitchen.setTransform(transform); <END CODE>
The meaning of this is that the box gets translated to the upper left (when looking a it from the Y-axe down), so that its lower right corner is in the origin. However, the box doesn't translate like it's supposed to. I took a screenshot of the result, it's at: http://www.beligum.org/example.png You can see that the box gets translated a bit, but not far enough.
Any help
Bram
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
