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