Hi Leute,
ich möchte zu der Kugel, welche ich im Raum auf der x/y Achse bewegen kann ein Koordinatensystem anzeigen. Dies soll aus mehreren Zylindern bestehen. Das Problem ist, dass ich die x/y Achse(hab bisher nur die x Achse) entsprechend drehen muss. Dies krieg ich jedoch nicht hin. Hier der Code:
Danke JVTH
ich möchte zu der Kugel, welche ich im Raum auf der x/y Achse bewegen kann ein Koordinatensystem anzeigen. Dies soll aus mehreren Zylindern bestehen. Das Problem ist, dass ich die x/y Achse(hab bisher nur die x Achse) entsprechend drehen muss. Dies krieg ich jedoch nicht hin. Hier der Code:
Danke JVTH
Java:
public class MovingObject2 extends Applet implements KeyListener, ActionListener
{
SimpleUniverse su;
//bounds
BoundingSphere bounds;
private double boundsize = 100.0;
private TransformGroup objTrans;
private Transform3D trans = new Transform3D();
//timer
private Timer timer;
//vars for moving
private int movingDirection=-1;
Vector3f position = new Vector3f(0, 0, 0);
public MovingObject2()
{
setLayout(new BorderLayout());
//creating canvas3D
...
//adding canvas to the applet(this)
...
//add keylistener and timer
...
// Create a simple scene and attach it to the virtual universe
...
//moving for the user
orbitControls(c);
}
public BranchGroup createSceneGraph()
{
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup();
// Create a moving sphere
...
//add the coordSystem
objRoot.addChild(createCoordSystem());
//create the bounding sphere
bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), boundsize);
//create direct lightning
...
// Set up the ambient light
...
return objRoot;
}
public TransformGroup createCoordSystem()
{
//TransformGroup
TransformGroup coordSystem = new TransformGroup();
//X-Axis
TransformGroup xtf = new TransformGroup();
//adding line
xtf.addChild(new Cylinder(0.05f, (float) boundsize));
//transforming line
Transform3D xtf3d = new Transform3D();
//-- hier sollte die Rotation stattfinden
xtf.setTransform(xtf3d);
//adding x-axis to coordSystem
coordSystem.addChild(xtf);
return coordSystem;
}
private void orbitControls(Canvas3D c){...}
@Override
public void keyPressed(KeyEvent e) {...}
@Override
public void keyReleased(KeyEvent arg0) {...}
@Override
public void keyTyped(KeyEvent arg0) {...}
@Override
public void actionPerformed(ActionEvent e) {...}
public static void main(String[] args) {...}
}