Solved

Java3D Add Line to existing scene

Posted on 2014-11-05
1
208 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
ID: 40425014
Found it.  SetCapability cannot be or'd.  Must be set separately,
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
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.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

856 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