Solved

Java3D Add Line to existing scene

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 84
unix in java example 9 52
Checkbox and ListView in Android Layout 4 56
starter POM and spring-boot-starter,  spring-boot-web 2 40
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

930 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

5 Experts available now in Live!

Get 1:1 Help Now