Solved

Java3D Add Line to existing scene

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

739 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