8 #ifndef VR_SCENE_GRAPH_H
9 #define VR_SCENE_GRAPH_H
25 #include <util/common.h>
29 #include <osg/MatrixTransform>
30 #include <osg/ref_ptr>
31 #include <osg/Multisample>
32 #include <osg/Material>
33 #include <osg/ClipNode>
34 #include <osgFX/Scribe>
55 class coCombinedButtonInteraction;
74 bool saveScenegraph(
const std::string &filename,
bool withMenu=
false);
75 #ifdef PHANTOM_TRACKER
76 static void manipulateCallback(
void *sceneGraph, buttonSpecCell *spec);
79 osg::MatrixTransform *loadAxisGeode(
float scale);
80 osg::Node *loadHandIcon(
const char *name);
81 osg::Node *loadHandLine();
83 void addMenuItem(osg::Group *itemGroup);
86 return m_menuGroupNode.get();
88 bool menuVisible()
const;
90 void setMenu(
bool state);
91 void setMenuMode(
bool state);
92 void applyMenuModeToMenus();
93 void toggleHeadTracking(
bool state);
94 void setObjects(
bool state);
97 bool keyEvent(
int type,
int keySym,
int mod);
100 return m_scene.get();
105 return m_objectsScene.get();
114 return m_objectsTransform.get();
118 return (m_scaleTransform);
122 return (m_handTransform.get());
124 osg::Vec3 getWorldPointOfInterest()
const;
125 void getHandWorldPosition(
float *,
float *,
float *);
126 void addPointerIcon(osg::Node *node);
127 void removePointerIcon(osg::Node *node);
129 osg::StateSet *loadDefaultGeostate(osg::Material::ColorMode mode = osg::Material::OFF);
130 osg::StateSet *loadGlobalGeostate();
131 osg::StateSet *loadUnlightedGeostate(osg::Material::ColorMode mode = osg::Material::OFF);
132 osg::StateSet *loadTransparentGeostate(osg::Material::ColorMode mode = osg::Material::OFF);
134 void setWireframe(WireframeMode mode);
135 void setPointerType(
int pointerType);
138 return (m_pointerType);
141 osg::BoundingSphere getBoundingSphere();
143 void setNodeBounds(osg::Node *node,
const osg::BoundingSphere *bs);
145 bool highQuality()
const;
148 T *
findFirstNode(
const char *name,
bool startsWith =
false, osg::Node * rootNode = NULL)
151 rootNode = m_objectsRoot;
159 if (!(startsWith ? strncmp(rootNode->getName().c_str(), name, strlen(name)) : strcmp(rootNode->getName().c_str(), name)))
161 T *node =
dynamic_cast<T *
>(rootNode);
166 osg::Group *group =
dynamic_cast<osg::Group *
>(rootNode);
169 for (
unsigned int i = 0; i < group->getNumChildren(); i++)
171 T *node = findFirstNode<T>(name, startsWith, group->getChild(i));
191 m_scaleMode = scaleMode;
195 return m_scaleFactor;
197 void setScaleFactor(
float scaleFactor,
bool sync =
true);
198 void scaleAllObjects(
bool resetView =
false);
201 return m_scalingAllObjects;
203 void boundingSphereToMatrices(
const osg::BoundingSphere &boundingSphere,
204 bool resetView, osg::Matrix *currentMatrix,
float *scaleFactor)
const;
207 void toggleAxis(
bool state);
208 void toggleHighQuality(
bool state);
209 void viewAll(
bool resetView =
false);
212 return m_floorHeight;
216 return m_objectsRoot;
224 void setMultisampling(osg::Multisample::Mode);
226 void setScaleFromButton(
float direction);
227 void setScaleFactorButton(
float f);
228 void setScaleRestrictFactor(
float min,
float max);
230 void setRestrictBox(
float minX,
float maxX,
float minY,
float maxY,
float minZ,
float maxZ);
233 void setColor(
const char *nodeName,
int *color,
float transparency);
234 void setColor(osg::Geode *geode,
int *color,
float transparency);
235 void setTransparency(
const char *nodeName,
float transparency);
236 void setTransparency(osg::Geode *geode,
float transparency);
237 void setShader(
const char *nodeName,
const char *shaderName,
const char *paraFloat,
const char *paraVec2,
const char *paraVec3,
const char *paraVec4,
const char *paraInt,
const char *paraBool,
const char *paraMat2,
const char *paraMat3,
const char *paraMat4);
238 void setShader(osg::Geode *geode,
const char *shaderName,
const char *paraFloat,
const char *paraVec2,
const char *paraVec3,
const char *paraVec4,
const char *paraInt,
const char *paraBool,
const char *paraMat2,
const char *paraMat3,
const char *paraMat4);
239 void setMaterial(
const char *nodeName,
int *ambient,
int *diffuse,
int *specular,
float shininess,
float transparency);
240 void setMaterial(osg::Geode *geode,
int *ambient,
int *diffuse,
int *specular,
float shininess,
float transparency);
243 void protectScenegraph();
247 bool isHighQuality()
const;
251 int readConfigFile();
253 void initHandDeviceGeometry();
255 void initSceneGraph();
256 bool saveScenegraph(
bool withMenu);
258 #ifdef PHANTOM_TRACKER
259 int m_forceFeedbackON;
260 int m_forceFeedbackMode;
264 osg::ref_ptr<osg::Group> m_scene, m_objectsScene;
265 osg::ref_ptr<osgFX::Scribe> m_lineHider;
266 osg::ref_ptr<osg::MatrixTransform> m_handTransform;
267 osg::ref_ptr<osg::MatrixTransform> m_handAxisTransform, m_viewerAxisTransform, m_smallSceneAxisTransform;
268 osg::ref_ptr<osg::MatrixTransform> m_worldAxis, m_handAxis, m_viewerAxis, m_objectAxis, m_smallSceneAxis;
269 osg::ref_ptr<osg::Group> m_menuGroupNode;
270 osg::ref_ptr<osg::MatrixTransform> m_pointerDepthTransform;
271 float m_pointerDepth;
272 osg::ref_ptr<osg::Node> m_handPlane;
273 osg::ref_ptr<osg::Node> m_handLine;
274 osg::ref_ptr<osg::Node> m_handNormal;
275 osg::ref_ptr<osg::Node> m_handCube;
276 osg::ref_ptr<osg::Node> m_handFly;
277 osg::ref_ptr<osg::Node> m_handDrive;
278 osg::ref_ptr<osg::Node> m_handWalk;
279 osg::ref_ptr<osg::Node> m_handPyramid;
280 osg::ref_ptr<osg::Node> m_handProbe;
281 osg::ref_ptr<osg::Node> m_handAnchor;
282 osg::ref_ptr<osg::Node> m_handSphere;
284 bool showSmallSceneAxis_;
285 bool transparentPointer_;
287 osg::StateSet *m_rootStateSet, *m_objectsStateSet;
288 osg::ClipNode *m_objectsRoot;
292 bool m_textured =
true;
293 bool m_shaders =
true;
294 bool m_coordAxis =
false;
295 bool m_showMenu =
true;
296 bool m_showObjects =
true;
297 bool m_firstTime =
true;
298 bool m_pointerVisible =
false;
300 osg::Matrix m_invBaseMatrix;
301 osg::Matrix m_oldInvBaseMatrix;
310 float m_scaleMode, m_scaleFactor;
311 float m_scaleFactorButton;
312 float m_scaleRestrictFactorMin, m_scaleRestrictFactorMax;
313 float m_transRestrictMinX, m_transRestrictMinY, m_transRestrictMinZ;
314 float m_transRestrictMaxX, m_transRestrictMaxY, m_transRestrictMaxZ;
316 bool m_scalingAllObjects;
317 osg::MatrixTransform *m_scaleTransform, *m_handIconScaleTransform, *m_handAxisScaleTransform;
318 float m_handIconSize;
319 float m_handIconOffset;
323 osg::ref_ptr<osg::MatrixTransform> m_objectsTransform;
324 osg::ref_ptr<osg::Multisample> m_Multisample;
325 typedef std::set<osg::Node *> NodeSet;
326 NodeSet m_specialBoundsNodeList;
327 void dirtySpecialBounds();
330 osg::ref_ptr<osg::Program> emptyProgram_;
332 bool isScenegraphProtected_;
334 typedef std::map<osg::Drawable *, osg::ref_ptr<osg::Material> > StoredMaterialsMap;
335 StoredMaterialsMap storedMaterials;
336 void storeMaterial(osg::Drawable *drawable);
337 bool m_enableHighQualityOption, m_switchToHighQuality, m_highQuality;
340 ui::Menu *m_miscMenu=
nullptr;
341 ui::SelectionList *m_drawStyle=
nullptr;
342 ui::Button *m_trackHead=
nullptr;
343 ui::SelectionList *m_showStats=
nullptr;
344 ui::Button *m_showAxis=
nullptr, *m_allowHighQuality=
nullptr;
345 ui::Button *m_useTextures=
nullptr, *m_useShaders=
nullptr;
osg::Group * getObjectsScene()
Definition: VRSceneGraph.h:103
osg::MatrixTransform * getHandTransform() const
Definition: VRSceneGraph.h:120
float floorHeight()
Definition: VRSceneGraph.h:210
float scaleMode()
Definition: VRSceneGraph.h:185
void setScaleMode(float scaleMode)
Definition: VRSceneGraph.h:189
Definition: VRSceneGraph.h:64
Definition: VRSceneGraph.h:67
osg::Group * getMenuGroup()
Definition: VRSceneGraph.h:84
float scaleFactor()
Definition: VRSceneGraph.h:193
int m_vectorInteractor
Definition: VRSceneGraph.h:245
WireframeMode
Definition: VRSceneGraph.h:63
bool isScalingAllObjects() const
Definition: VRSceneGraph.h:199
Definition: VRSceneGraph.h:65
osg::MatrixTransform * getTransform() const
Definition: VRSceneGraph.h:112
double OSGVRUIEXPORT mod(double a, double b)
Definition: coCombinedButtonInteraction.h:20
Definition: VRSceneGraph.h:68
Definition: VRSceneGraph.h:66
osg::MatrixTransform * getScaleTransform() const
Definition: VRSceneGraph.h:116
T * findFirstNode(const char *name, bool startsWith=false, osg::Node *rootNode=NULL)
Definition: VRSceneGraph.h:148
osg::ref_ptr< osg::Node > getHandSphere()
Definition: VRSceneGraph.h:219
osg::ClipNode * objectsRoot()
Definition: VRSceneGraph.h:214
Definition: VRSceneGraph.h:60
int getPointerType()
Definition: VRSceneGraph.h:136
osg::Group * getScene()
Definition: VRSceneGraph.h:98