Rotate function

hello,
i’m new with Xith3D and I would like to know something about de function Rotate (rotY)
i’ve searched in this forum but I can’t make it work.

I have a class witch draws a cube/rectangle, and I can make it move to a position on a platform.
but I would like to have a "doRotateY(float rotY) " function in this class that when this function is called the cube/rectangle makes a 90 degree turn to the right or left. (sounds simple ?? ???

thank You!

here is my class where it has to come in:


import javax.vecmath.Point3f;
import javax.vecmath.TexCoord2f;
import javax.vecmath.Vector3f;
import javax.vecmath.Color3f;

import com.xith3d.loaders.texture.TextureLoader;
import com.xith3d.scenegraph.*;

import com.xith3d.scenegraph.*;





public class AGV {
    private float AGVbrd =  1.25f; //breedte AGV
    private float AGVlength = 6f; //Lengte AGV
    private float AGVhoogte = 1.35f; //hoogte van AGV
    private Point3f coord;
    private TransformGroup Transform;
    private Transform3D T3D;
    private float posz = 0;
    private float posx = 0;
    private boolean beladen;
    private float snelheid = 0;
    
     
     
    
   
    
    public AGV(BranchGroup s)
    {
     
        
        
      T3D = new Transform3D();
      Transform = new TransformGroup(T3D);
      posz = 0;
      beladen = false;
      s.addChild(Transform);        
    }//einde public AGV()
   
    
    public void DrawAGVbody()
    {
      float afstand = 0f;
      // Vertices van AGV
         Point3f [] pts = new Point3f[] {
            //body
                new Point3f(-381.5f, -1.6f, -151.25f),   //1
                new Point3f(-387.5f, -1.6f, -151.25f),   //2
                new Point3f(-387.5f, -1.8f, -151.25f),   //3
                new Point3f(-381.5f, -1.8f, -151.25f),   //4

                new Point3f(-381.5f, -1.6f, -150f),      //5
                new Point3f(-387.5f, -1.6f, -150f),      //6
                new Point3f(-387.5f, -1.8f, -150f),      //7
                new Point3f(-381.5f, -1.8f, -150f),      //8

         };
         
          for (int pt = 0; pt < pts.length; pt++) {
            pts[pt].x += afstand;
        }

           // Coordinates voor 6 Quads
           Point3f [][] coords =  new Point3f[][] {
             {pts[0] , pts[1], pts[2], pts[3]},
             {pts[1], pts[5], pts[6], pts[2]},
             {pts[5], pts[4], pts[7], pts[6]},
             {pts[4], pts[0], pts[3], pts[7]},
             {pts[4], pts[5], pts[1], pts[0]},
             {pts[3], pts[2], pts[6], pts[7]},
           };
        
           Draw(coords);
                           
           
    }//einde DrawAGVbody()
    
       
    
     
     public void Cockpit()
    {
     float afstand = 0f;
      // Vertices van AGV
         Point3f [] pts = new Point3f[] {
                 new Point3f(-381.35f, -1.2f, -151.25f),   //1
                new Point3f(-381.5f, -1.2f, -151.25f),     //2
                new Point3f(-381.5f, -1.8f, -151.25f),     //3
                new Point3f(-381f, -1.8f, -151.25f),       //4

                new Point3f(-381.35f, -1.2f, -150f),       //5
                new Point3f(-381.5f, -1.2f, -150f),        //6
                new Point3f(-381.5f, -1.8f, -150f),        //7
                new Point3f(-381f, -1.8f, -150f),          //8

         };
         
          for (int pt = 0; pt < pts.length; pt++) {
            pts[pt].x += afstand;
        }

           // Coordinates voor 6 Quads
           Point3f [][] coords =  new Point3f[][] {
             {pts[0] , pts[1], pts[2], pts[3]},
             {pts[1], pts[5], pts[6], pts[2]},
             {pts[5], pts[4], pts[7], pts[6]},
             {pts[4], pts[0], pts[3], pts[7]},
             {pts[4], pts[5], pts[1], pts[0]},
             {pts[3], pts[2], pts[6], pts[7]},
           };
        
           Draw(coords);   
    }//einde Cockpit
     
     
    public void Draw(Point3f [][] Coords){
        Shape3D [] DrawObj = new Shape3D[6]; // moet nog dynamisch worden

        Color3f[] colors = new Color3f[]
               {
                   new Color3f(0,0,0),
                   new Color3f(255,0,0),
                   new Color3f(255,0,0),
                   new Color3f(0,0,0)
               };

        for (int i = 0; i < DrawObj.length; i++) {
            QuadArray quads = new QuadArray(Coords[i].length, GeometryArray.COORDINATES| GeometryArray.COLOR_3 );
            quads.setCoordinates(0,Coords[i]);
            quads.setColors(0,colors);

            DrawObj[i] = new Shape3D(quads);

            Transform.addChild(DrawObj[i]);
        }
    }//einde class Draw()
    
    
     /**
     * Bouw de AGV
     */
    public void Build(){
        DrawAGVbody();        
        Cockpit();
    }
    
    
     public void move( float x, float y, float z) {
            // voor de positie van de AGV
            if (posx < x){
                posx++;
                Vector3f v = new Vector3f();
                v.set(posx,0,0);
                T3D.setTranslation(v);
                Transform.setTransform(T3D);
            }else{

            }
    }//einde class move

    

     
    


    
    
   
    public void doRotateY(float rotY) 
  { 
 	// ???????
   
  }


    
}//einde class AGV

I’d suggest to look at the javadoc from vecmath (That can be found at the Java3D project) and maybe also at the javadoc of com.xith3d.scenegraph.Transform3D.

i’v searched everything but I can’t make it rotate
I have this so far but it won’t rotate:



/**
 *
 * @author Martin
 */

//package org.xith3d.geometry;

import javax.vecmath.Point3f;
import javax.vecmath.TexCoord2f;
import javax.vecmath.Vector3f;
import javax.vecmath.Color3f;

import com.xith3d.loaders.texture.TextureLoader;
import com.xith3d.scenegraph.*;

import com.xith3d.scenegraph.*;





public class AGV {
    private float AGVbrd =  1.25f; //breedte AGV
    private float AGVlength = 6f; //Lengte AGV
    private float AGVhoogte = 1.35f; //hoogte van AGV
    //private BranchGroup Scene; //de scene
    private Point3f coord;
             private TransformGroup Transform;
             private Transform3D T3D;    
             private boolean isRotationScheduled = false;  
    private float posz = 0;
    private float posx = 0;
    private boolean beladen;
    private float snelheid = 0;
    

    private float rotY = 0;

    
      private TransformGroup objRotate;
     
 
    public AGV(BranchGroup s)
    {
       
      T3D = new Transform3D();      
      Transform = new TransformGroup(T3D);
            
      T3D.rotY(rotY);     //deze 2 regels toegevoegd voor rotate
      objRotate = new TransformGroup(T3D);  
      
      posz = 0;
      beladen = false;
      // setBeladen(false);
      s.addChild(Transform);        
    }//einde public AGV()
   
        
       //scene.addChild(Transform);
     
    public void DrawAGVbody()
    {
      float afstand = 0f;
      // Vertices van AGV
         Point3f [] pts = new Point3f[] {
            //body
                new Point3f(-381.5f, -1.6f, -151.25f),   //1
                new Point3f(-387.5f, -1.6f, -151.25f),   //2
                new Point3f(-387.5f, -1.8f, -151.25f),   //3
                new Point3f(-381.5f, -1.8f, -151.25f),   //4

                new Point3f(-381.5f, -1.6f, -150f),      //5
                new Point3f(-387.5f, -1.6f, -150f),      //6
                new Point3f(-387.5f, -1.8f, -150f),      //7
                new Point3f(-381.5f, -1.8f, -150f),      //8

         };
         
          for (int pt = 0; pt < pts.length; pt++) {
            pts[pt].x += afstand;
        }

           // Coordinates voor 6 Quads
           Point3f [][] coords =  new Point3f[][] {
             {pts[0] , pts[1], pts[2], pts[3]},
             {pts[1], pts[5], pts[6], pts[2]},
             {pts[5], pts[4], pts[7], pts[6]},
             {pts[4], pts[0], pts[3], pts[7]},
             {pts[4], pts[5], pts[1], pts[0]},
             {pts[3], pts[2], pts[6], pts[7]},
           };
        
           Draw(coords);
                           
           
    }//einde DrawAGVbody()
    
    
    
     
     public void Cockpit()
    {
     float afstand = 0f;
      // Vertices van AGV
         Point3f [] pts = new Point3f[] {
                 new Point3f(-381.35f, -1.2f, -151.25f),   //1
                new Point3f(-381.5f, -1.2f, -151.25f),     //2
                new Point3f(-381.5f, -1.8f, -151.25f),     //3
                new Point3f(-381f, -1.8f, -151.25f),       //4

                new Point3f(-381.35f, -1.2f, -150f),       //5
                new Point3f(-381.5f, -1.2f, -150f),        //6
                new Point3f(-381.5f, -1.8f, -150f),        //7
                new Point3f(-381f, -1.8f, -150f),          //8

         };
         
          for (int pt = 0; pt < pts.length; pt++) {
            pts[pt].x += afstand;
        }

           // Coordinates voor 6 Quads
           Point3f [][] coords =  new Point3f[][] {
             {pts[0] , pts[1], pts[2], pts[3]},
             {pts[1], pts[5], pts[6], pts[2]},
             {pts[5], pts[4], pts[7], pts[6]},
             {pts[4], pts[0], pts[3], pts[7]},
             {pts[4], pts[5], pts[1], pts[0]},
             {pts[3], pts[2], pts[6], pts[7]},
           };
        
           Draw(coords);   
    }//einde Cockpit
     
     
    public void Draw(Point3f [][] Coords){
        Shape3D [] DrawObj = new Shape3D[6]; // moet nog dynamisch worden

        Color3f[] colors = new Color3f[]
               {
                   new Color3f(0,0,0),
                   new Color3f(255,0,0),
                   new Color3f(255,0,0),
                   new Color3f(0,0,0)
               };

        for (int i = 0; i < DrawObj.length; i++) {
            QuadArray quads = new QuadArray(Coords[i].length, GeometryArray.COORDINATES| GeometryArray.COLOR_3 );
            quads.setCoordinates(0,Coords[i]);
            quads.setColors(0,colors);

            DrawObj[i] = new Shape3D(quads);

            Transform.addChild(DrawObj[i]);
        }
        
        
        
    }//einde class Draw()
    
    
     /**
     * Bouw de AGV
     */
    public void Build(){
        DrawAGVbody();       
        Cockpit();
        
    }
    
    
     public void move( float x, float y, float z) {
            // voor de positie van de AGV
            if (posx < x){
                posx++;
                Vector3f v = new Vector3f();
                v.set(posx,0,0);
                T3D.setTranslation(v);
                Transform.setTransform(T3D);
            }else{

            }
    }//einde class move

    
      public void setBeladen(boolean stand){
        beladen = stand;
        //zet de juiste snelheid
        if(stand){
            snelheid = 20;
        }else{
            snelheid = 40;
        }
    }
     
     
    
    public boolean getBeladen() {
        return beladen;
    }

    
   
  
    public void doRotateY() 
  {
        rotY = 90;
        T3D.rotY(rotY);
        objRotate.setTransform(T3D);
    } 
      
    
}//einde class AGV



Transform3D.rotY sets the Transform to represent an rotation around the Y axis. It does not rotate the Transform!
To rotate the Transform you could do this:

Transform3D temp = new Transform3D();
temp.rotY(Math.PI()/2);
T3D.mul(temp);

thanx four your help but if I do that in my doRotateY function it wil still not work, the object has not rotate 90degrees

I don’t know wat I’m doing wrong? :-\

Does it rotate at least?

it doesn’t rotate,
but when I add the line:
Transform.setTransform(T3D) it wil rotate but it rotates on the 0,0 point of the platform (center)
I have a sort of platform where my object is on the corner of that. my object must just make a 90 degree turn. but when I add that line it will rotate on the 0,0 point of that platform

Then you’d better add another TransformGroup, that only handles the rotation.