Hi everybody :)
So I'm an Java3D Beginner and obviously I have some questions.
First my Code:
Code java:import javax.media.j3d.*; import com.sun.j3d.utils.geometry.*; import javax.vecmath.*; import com.sun.j3d.utils.universe.SimpleUniverse; public class Main { public static void main(String[] args) { SimpleUniverse univ = new SimpleUniverse ( ); univ.getViewingPlatform( ) .setNominalViewingTransform( ); BranchGroup szene = new BranchGroup ( ); { Box boden = new Box(1, 0.1f, 1, ColoringAtributes() ); TransformGroup bodenVerschieber = new TransformGroup(); Transform3D verschieben = new Transform3D(); verschieben.setTranslation(new Vector3f(0f,-0.5f,0f)); bodenVerschieber.setTransform(verschieben); bodenVerschieber.addChild(boden); szene.addChild(bodenVerschieber); Color3f farbeBoden = new Color3f (0.392f, 0.392f, 0.392f); BoundingSphere bounds = new BoundingSphere(new Point3d (0,0,0),10000000); Vector3f richtungBoden = new Vector3f(5,-6,-10); DirectionalLight lichtBoden = new DirectionalLight (farbeBoden, richtungBoden); lichtBoden.setInfluencingBounds (bounds); szene.addChild(lichtBoden); } { Sphere sonne = new Sphere(0.15f,1,40); TransformGroup sonnenVerschieber = new TransformGroup(); Transform3D verschieben = new Transform3D(); verschieben.setTranslation(new Vector3f(-0.75f, 0.45f, 0f)); sonnenVerschieber.setTransform(verschieben); sonnenVerschieber.addChild(sonne); szene.addChild(sonnenVerschieber); Color3f farbeSonne = new Color3f (1.0f,1.0f,0); BoundingSphere bounds = new BoundingSphere(new Point3d (0,0,0), 1000000); Vector3f richtungSonne = new Vector3f(5,-6,-10); DirectionalLight lichtSonne = new DirectionalLight (farbeSonne, richtungSonne); lichtSonne.setInfluencingBounds (bounds); szene.addChild(lichtSonne); } szene.compile(); univ.addBranchGraph(szene); } private static Appearance ColoringAtributes() { return null; } }
So i wanted to design i type of "landscape" (A ground, a sun, a tree and a House).
Right now I got the ground and the sun, and when I wanted to watch my work, the colors mixed up,
meaning the ground wasn't grey as defined and the sun was not yellow.
The case was that both of them had the same color and that is a mixture of both of them.
What do I do wrong? How can I split them? Or is there an essential mistake, for example
doing DirectionLight to express the colors? Sorry I'm a real newbie to that, and I'd be very happy if anybody could help me :)
Greetings,
Java3D_Noob
