hallo, habe das mit dem 3d noch nicht recht verstanden und find den Fehler nicht. Es zeigt mir nur einen schwarzen Bildschrim an:
Bitte um eure Hilfe. Danke
Java:
import java.awt.*;
import java.awt.event.*;
import javax.media.j3d.*;
import javax.swing.*;
import javax.vecmath.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.SimpleUniverse;
@SuppressWarnings("serial")
public class Game extends JFrame {
JProgressBar bar;
SimpleUniverse Universe;
boolean left = false;
boolean right = false;
TransformGroup Transgroup;
Transform3D Transform;
Vector3f vector;
float x = 0;
float z = 0;
public static void main(String[] args) {
System.setProperty("sun.awt.noerasebackground", "true");
Game fenster= new Game ();
fenster.pack();
fenster.setSize(500,500);
fenster.setResizable(true);
fenster.setVisible(true);
}
@SuppressWarnings("static-access")
public Game() {
super("Test");
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(config);
add(canvas);
Universe = new SimpleUniverse(canvas);
Universe.getViewingPlatform().setNominalViewingTransform();
BranchGroup scene = createSceneGraph();
Universe.addBranchGraph(scene);
}
public BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
Transform = new Transform3D();
vector = new Vector3f();
Sphere ball =new Sphere(0.5f);
vector.setX(x); vector.setY(0); vector.setZ(z-10);
Transform.setTranslation(vector);
Transgroup= new TransformGroup(Transform);
Transgroup.addChild(ball);
objRoot.addChild(Transgroup);
return objRoot;
}
}
Bitte um eure Hilfe. Danke