de.jreality.geometry
Class BallAndStickFactory
java.lang.Object
de.jreality.geometry.BallAndStickFactory
public class BallAndStickFactory
- extends java.lang.Object
This class constructs a ball-and-stick representation of an instance of IndexedLineSet
and returns
it in the form of an instance of SceneGraphComponent
.
In the default behavior, around each edge (vertex) of the IndexedLineSet is placed
a cylinder (sphere). The radius can be separately controlled for the cylinders and for the
spheres, as can the colors. Additionally, one can specify that arrow symbols be positioned
along the tubes; here one can control the relative position, the size, and the steepness of the
arrow head (which is essentially a cone).
The cross section of the tube is currently fixed
to be an octagon. The returned SceneGraphComponent has two children, containing the
sticks and the balls, respectively.
The general cycle of use is illustrated in the following code snippet:
BallAndStickFactory basf = new BallAndStickFactory(Primitives.sharedIcosahedron);
basf.setBallRadius(.04);
basf.setStickRadius(.02);
basf.setDrawArrows(true);
basf.setArrowScale(.1);
basf.setArrowSlope(1.5);
basf.setArrowPosition(.9);
basf.update();
SceneGraphComponent tubedIcosa = basf.getSceneGraphComponent();
Note: The same effect (without the arrows) can be achieved
with the standard line and point shaders (DefaultLineShader
, etc),
by setting CommonAttributes.TUBES_DRAW
and CommonAttributes.SPHERES_DRAW
,
resp., to true
and setting the other shader parameters to control the
color and radius of the rusulting tubes and spheres. However, there are some constraints on this;
for example, it isn't possible to turn on flat shading and separate control of the
transparency is not possible.
- Author:
- Charles Gunn
- See Also:
TubeUtility.tubeOneEdge(double[], double[], double, double[][], int)
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BallAndStickFactory
public BallAndStickFactory(IndexedLineSet i)
update
public void update()
setStickRadius
public void setStickRadius(double r)
setBallColor
public void setBallColor(java.awt.Color ballColor)
setBallRadius
public void setBallRadius(double ballRadius)
setStickColor
public void setStickColor(java.awt.Color stickColor)
setArrowColor
public void setArrowColor(java.awt.Color arrowColor)
setMetric
public void setMetric(int metric)
getSceneGraphComponent
public SceneGraphComponent getSceneGraphComponent()
sticks
public static SceneGraphComponent sticks(SceneGraphComponent sgc,
IndexedLineSet ifs,
double rad,
int metric)
getArrowPosition
public double getArrowPosition()
setArrowPosition
public void setArrowPosition(double arrowPosition)
getArrowScale
public double getArrowScale()
setArrowScale
public void setArrowScale(double arrowScale)
getArrowSlope
public double getArrowSlope()
setArrowSlope
public void setArrowSlope(double arrowSlope)
isShowArrows
public boolean isShowArrows()
setShowArrows
public void setShowArrows(boolean drawArrows)
isShowBalls
public boolean isShowBalls()
setShowBalls
public void setShowBalls(boolean showBalls)
isShowSticks
public boolean isShowSticks()
setShowSticks
public void setShowSticks(boolean showSticks)
getCrossSection
public double[][] getCrossSection()
setCrossSection
public void setCrossSection(double[][] crossSection)
getBallGeometry
public Geometry getBallGeometry()
setBallGeometry
public void setBallGeometry(Geometry ballGeometry)
getStickGeometry
public Geometry getStickGeometry()
setStickGeometry
public void setStickGeometry(Geometry stickGeometry)