I'm still having trouble making my shapes live in my scenegraph. I don't
know why something so basic is so hard for me to understand, but your help
would be greatly appreciated.

The short file below called Particle returns a box shape which I'm randomly
placing in my scene many times in another class (using Particle's getChild()
method). I want to change the box's position by calling Particle's update()
method.

Everything else in the program works fine. and the "location" vector is
changing everytime update is called (I'm println'ing out the x,y,z values
for each particle for every update() call)

Can someone please tell me what I'm doing wrong with the transform ?

Thanks in advance!

public class Particle extends Object
        {
        int size = 1;
        int age = 0;
        Vector3d location;
        Vector3d direction;
        int weight = 1;
        Appearance appearance;
        private Group group  = new Group();
        Transform3D oofst;

        public Particle(double lx, double ly, double lz, double dx, double
dy, double dz)
                {
                location = new Vector3d(lx,ly,lz);
                direction = new Vector3d(dx,dy,dz);
                makeParticle();
                };

        public Particle(Vector3d v1,Vector3d v2)
                {
                location = v1;
                direction = v2;
                makeParticle();
                };

        private void makeParticle()
                {
                Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
                Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
                Color3f diffuseWhite = new Color3f(0.75f, 0.75f, 0.75f);
                Color3f specularWhite = new Color3f(1.0f,1.0f,1.0f);
                Color3f ambientWhite = new Color3f(0.15f, 0.15f, 0.15f);

                Material whiteMaterial = new Material(ambientWhite, black,
diffuseWhite, specularWhite, 100.0f);
                whiteMaterial.setLightingEnable(true);
                Appearance whiteAppearance = new Appearance();
                whiteAppearance.setMaterial(whiteMaterial);

                appearance = new Appearance();
                appearance.setMaterial(whiteMaterial);


                BranchGroup branchGroup = new BranchGroup();
                TransformGroup objOffset = new TransformGroup();
                BoundingSphere bounds = new BoundingSphere(new Point3d(
location.x,location.y,location.z), size*2);


objOffset.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

objOffset.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
                // create the shape objects and add them to the inner
transform
                Box bx = new Box(size,size,size, appearance);
                objOffset.addChild(bx);
                // add the inner transform
                oofst = new Transform3D();
                oofst.setTranslation(location);
                objOffset.setTransform(oofst);

                BoundingLeaf boundingLeaf = new BoundingLeaf(bounds);
                objOffset.addChild(boundingLeaf);
                // add the transforms to the branch group
                branchGroup.addChild(objOffset);
                // Let Java 3D perform optimizations on this scene graph.
                branchGroup.compile();
                // add this to the output group
                group.addChild(branchGroup);
                };

        public void update()
                {
                location.add(direction);
                oofst.setTranslation(location);
                System.out.println(location.x + "     " + location.y  + "
" + location.z);
                };

        // method to return the branch group to the main program when needed
        public Group getChild()
                {
                return group;
                };
        }

Don Casteel

Manufacturing Engineer
TEXTRON Automotive Company -- Athens Operations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Voice:  (423)744-1109
        Fax:    (423)744-1112
        Pager:  (423)744-1129  -- 109
                Internet:       [EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

===========================================================================
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".

Reply via email to