Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Java3D - Colors mix up

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java3D - Colors mix up

    Hi everybody

    So I'm an Java3D Beginner and obviously I have some questions.
    First my Code:
    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
    Last edited by Java3D_Noob; October 26th, 2012 at 11:57 AM.


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Java3D - Colors mix up

    Willkommen Java3D_Noob

    Please see the announcements page for forum info. I fixed the code tag on your post.

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java3D - Colors mix up

    Hm well, didn't know how to do that. But anyways is there some help for my problem?

  4. #4
    Junior Member
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java3D - Colors mix up

    Hm well after some trying I fixed it for myself. No more help needed

  5. #5
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Java3D - Colors mix up

    Glad we could be of service kind sir... Please mark the thread as solved and good luck on finishing the project.

Similar Threads

  1. Java3D, proguard serious questions.
    By Zachary1234 in forum Java Theory & Questions
    Replies: 0
    Last Post: September 11th, 2012, 09:13 PM
  2. Understanding Java3d library
    By Ludicrous in forum Object Oriented Programming
    Replies: 0
    Last Post: June 21st, 2012, 01:17 PM
  3. Need some help changing the colors of a picture
    By Methos in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 25th, 2012, 03:49 PM
  4. Questions about selection and boolean operation in java3D?
    By freshfish2 in forum Member Introductions
    Replies: 0
    Last Post: February 19th, 2011, 12:24 AM
  5. How are the colors in Swing's UIManager used?
    By JerryH in forum AWT / Java Swing
    Replies: 0
    Last Post: January 27th, 2011, 09:50 PM