Hey guys !
I really dont know whats wrong with ME or with my code …but i cant manage it to add a simple box with a texture -.-
what is wrong here ? i mean…im new to java3d did i forget to add something or whats wrong? i think the important part begins in line 85
public class World implements KeyListener {
JFrame frame = new JFrame();
TransparencyAttributes objTransp;
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
SimpleUniverse u = new SimpleUniverse(c);
ObjectFile f = new ObjectFile(ObjectFile.RESIZE);
Scene s = null;
TransformGroup ViewTG = u.getViewingPlatform().getViewPlatformTransform();
Transform3D ViewT3D = new Transform3D();
public World(){
PhysicalEnvironment environment = u.getViewer().getPhysicalEnvironment();
AudioDevice device = new JavaSoundMixer(environment);
device.initialize();
environment.setAudioDevice(device);
frame.add("Center",c);
frame.addKeyListener(this);
frame.setFocusable(true);
OrbitBehavior ob = new OrbitBehavior(c);
u.addBranchGraph(createSceneGraph());
u.addBranchGraph(addObjects());
u.getViewer().getView().setFrontClipDistance(0.001);
Light(u);
try
{
s = f.load("Geist3.obj");
}
catch (Exception e)
{
System.out.println("File loading failed:" + e);
}
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1600, 850);
frame.setVisible(true);
ob.setSchedulingBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE));
u.getViewingPlatform().setViewPlatformBehavior(ob);
}
public BranchGroup createSceneGraph(){
BranchGroup RootBg = new BranchGroup();
TransformGroup CastleTG = new TransformGroup();
Transform3D CastleT3DX = new Transform3D();
Transform3D CastleT3DY = new Transform3D();
CastleT3DX.rotX((float)Math.toRadians(-90));
CastleT3DY.rotZ((float)Math.toRadians(90));
CastleT3DX.mul(CastleT3DY);
CastleT3DX.setTranslation(new Vector3f(0.0f,0.0f,-6.0f));
CastleTG.setTransform(CastleT3DX);
try
{
s = f.load("Geist3.obj");
}
catch (Exception e)
{
System.out.println("File loading failed:" + e);
}
// Here comes the important code fragment i think
TransformGroup tgground = new TransformGroup();
Appearance abc = new Appearance();
Texture txGround = new TextureLoader("gelb.jpg",frame).getTexture(); // maybe "frame" is wr0ng??
abc.setTexture(txGround);
Box w = new Box(10000,10000,10000,Box.GENERATE_NORMALS,abc);
w.setAppearance(abc);
tgground.addChild(w);
RootBg.addChild(tgground); // here it ends
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
TextureLoader textureLoad = new TextureLoader("full.png",null);
Background bgImage = new Background(textureLoad.getImage());
bgImage.setApplicationBounds(bounds);
RootBg.addChild(bgImage);
RootBg.addChild(m.playMusic());
CastleTG.addChild(s.getSceneGroup());
RootBg.addChild(CastleTG);
RootBg.compile();
return RootBg;
}}
So whats wrong here ? is something missing ? did i add something wrong ? i dont get any errors !
please help me =(
thanks !!!