7 #include <Inventor/nodes/SoSeparator.h>
8 #include <Inventor/nodes/SoVertexProperty.h>
9 #include <Inventor/nodes/SoLineSet.h>
10 #include <Inventor/nodes/SoCylinder.h>
11 #include <Inventor/SbColor4f.h>
12 #include <Inventor/nodes/SoMatrixTransform.h>
13 #include <Inventor/SbRotation.h>
14 #include <Inventor/SbMatrix.h>
21 SoSeparator * attachsep);
54 : theclass(tc), attachSep(as), shown(false),
56 colourAndTransp(SbColor4f(1,1,1,1)),
59 direction(SbVec3f(0,0,0)),
68 theclass->messageVerbose(
"(Re)building 3D objects");
71 sep->removeAllChildren();
73 sep =
new SoSeparator;
77 const bool save =
sep->enableNotify(
false);
79 SoVertexProperty * line_vertices =
new SoVertexProperty();
81 line_vertices->vertex.set1Value(0,0.0,0.0,0.0);
82 line_vertices->vertex.set1Value(1,direction[0],direction[1],direction[2]);
86 SoLineSet *
line =
new SoLineSet();
90 line->vertexProperty = line_vertices;
91 line->numVertices.enableNotify(
TRUE);
92 line->numVertices.touch();
98 SbVec3f
p1 = line_vertices->vertex[0].getValue();
99 SbVec3f
p2 = line_vertices->vertex[1].getValue();
100 SoCylinder * cylinder =
new SoCylinder;
101 cylinder->radius = 4.0;
102 float height = std::sqrt( direction[0]*direction[0]+
103 direction[1]*direction[1]+
104 direction[2]*direction[2]);
105 cylinder->height = height;
108 m.setTranslate(SbVec3f(0,0.5*height,0));
118 SoMatrixTransform * mt =
new SoMatrixTransform;
119 mt->matrix.setValue(
mat);
121 sep->addChild(cylinder);
127 sep->enableNotify(
true);
136 theclass->messageVerbose(
"Updating packed colour");
137 if (!
sep||
sep->getNumChildren()<1)
139 SoNode *
n =
sep->getChild(0);
140 if (!
n||
n->getTypeId()!=SoLineSet::getClassTypeId())
142 SoLineSet *
line =
static_cast<SoLineSet*
>(
n);
143 SoVertexProperty * vertices =
static_cast<SoVertexProperty *
>(
line->vertexProperty.getValue());
146 vertices->orderedRGBA = colourAndTransp.getPackedValue();