Use a ball and stick factory

From JReality Wiki
Revision as of 13:52, 9 June 2009 by Gunn (Talk | contribs)

(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Source file: BallAndStickFactoryExample

JavaDoc: BallAndStickFactory


Run as Java webstart


The name ball and stick derives from the molecular models of the same name. jReality offers a factory which constructs such models based on a given IndexedLineSet. This example takes a standard icosahedron and feeds it to a BallAndStickFactory. It demonstrates the standard ball and stick features, but also shows a third feature, drawing arrows along the sticks.


In contrast to the PolygonalTubeFactory, the BallAndStickFactory breaks all edges up into line segments and tubes each one separately. For indexed line sets with sharp turns, this makes the BASF (ball and stick factory, naturally) perhaps a superior technique.


...
 
public class BallAndStickFactoryExample {
 
  public static void main(String[] args)  {
     BallAndStickFactory basf = new BallAndStickFactory(Primitives.sharedIcosahedron);
     basf.setBallRadius(.04);
     basf.setStickRadius(.02);
     basf.setShowArrows(true);
     basf.setArrowScale(.1);
     basf.setArrowSlope(1.5);
     basf.setArrowPosition(.7);
     basf.update();
     SceneGraphComponent tubedIcosa = basf.getSceneGraphComponent();
     JRViewer.display(tubedIcosa);
  }
}


Previous: Use a tube factory Developer Tutorial: Contents Next: Use a thickened surface factory