Solved

Java3D Add Line to existing scene

Posted on 2014-11-05
1
194 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
1 Comment
 

Accepted Solution

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now