Solved

Java3D Add Line to existing scene

Posted on 2014-11-05
1
221 Views
Last Modified: 2014-11-05
Get "Group: no capability to append children" when trying to add new shape to an existing scene

public class D3Panel extends JPanel {
	
	private BranchGroup root;

	public void run() {
	    this.setLayout(new BorderLayout());	       	    
        GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
        Canvas3D canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
        add(canvas3D, BorderLayout.CENTER);
        SimpleUniverse universe = new SimpleUniverse(canvas3D);
        root = new BranchGroup();
        root.setCapability(BranchGroup.ALLOW_DETACH | 
        				   BranchGroup.ALLOW_CHILDREN_EXTEND | 
        				   BranchGroup.ALLOW_CHILDREN_WRITE);
        
	    LineArray line=new LineArray(2,LineArray.COORDINATES);      
	    line.setCoordinate(0,new Point3f(10.0f,10.0f,5.0f));
	    line.setCoordinate(1,new Point3f(0.0f,0.0f,-10.0f));  
	    root.addChild(new Shape3D(line));

	    universe.getViewingPlatform().setNominalViewingTransform();
	    universe.addBranchGraph(root);
	    repaint();
	    
		BranchGroup group = new BranchGroup();  
		group.setCapability(BranchGroup.ALLOW_DETACH);
		group.setCapability(BranchGroup.ALLOW_DETACH | 
				   		    BranchGroup.ALLOW_CHILDREN_EXTEND | 
				   		    BranchGroup.ALLOW_CHILDREN_WRITE);
	    LineArray line2=new LineArray(2,LineArray.COORDINATES);      
	    line2.setCoordinate(0,new Point3f(10.0f,-10.0f,-5.0f));
	    line2.setCoordinate(1,new Point3f(0.0f,0.0f,-10.0f));  
	    group.addChild(new Shape3D(line2));
	    root.addChild(group);       // ====> Group: no capability to append children
	}
	
}

Open in new window

0
Comment
Question by:va3jsl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
va3jsl earned 0 total points
ID: 40425014
Found it.  SetCapability cannot be or'd.  Must be set separately,
0

Featured Post

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question