Ich habe folgendes Problem, ich möchte zwei Boxen haben und beide sollen an verschiedenen Koordinaten sein, dass Problem ist ich habe das versucht zu lösen, bei meinem Programm ist es aber so, dass beide auf den gleichen Koordinaten sind.
Quellcode:
MfG KingEldarion
Quellcode:
Java:
import javax.media.j3d.*;
import javax.swing.*;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;
import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
import com.sun.j3d.utils.geometry.Box;
import com.sun.j3d.utils.universe.SimpleUniverse;
public class WorldCity extends JFrame{
Box house1 = new Box(0.2f, 0.3f, 0.2f, null);
Box house2 = new Box(0.5f, 0.5f, 0.5f, null);
Vector3f vec = new Vector3f(0.0f, 0.0f, 0.0f);
Vector3f vec2 = new Vector3f(2.5f, 2.5f, 2.5f);
public WorldCity(){
Canvas3D canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
SimpleUniverse universe = new SimpleUniverse(canvas);
BranchGroup bg = new BranchGroup();
TransformGroup tg = new TransformGroup();
Transform3D trans = new Transform3D();
TransformGroup tg2 = new TransformGroup();
Transform3D trans2 = new Transform3D();
trans.setTranslation(vec);
tg.setTransform(trans);
tg.addChild(house1);
trans2.setTranslation(vec2);
tg2.setTransform(trans);
tg2.addChild(house2);
Color3f color1 = new Color3f(1.0f, 1.0f, 1.0f);
Color3f color2 = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f lightvec = new Vector3f(4.0f, -7.0f, -12.0f);
BoundingSphere bs = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100);
DirectionalLight light1 = new DirectionalLight(color1, lightvec);
light1.setInfluencingBounds(bs);
AmbientLight light2 = new AmbientLight(color2);
light2.setInfluencingBounds(bs);
bg.addChild(light2);
bg.addChild(light1);
bg.addChild(tg);
bg.addChild(tg2);
OrbitBehavior orbit = new OrbitBehavior(canvas, OrbitBehavior.REVERSE_ALL);
orbit.setSchedulingBounds (new BoundingSphere ());
universe.getViewingPlatform().setViewPlatformBehavior (orbit);
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(bg);
add(canvas);
}}
MfG KingEldarion