|
Katana Plug-in APIs 0.1
|
00001 // Copyright (c) 2016 The Foundry Visionmongers Ltd. All Rights Reserved. 00002 00003 #ifndef SCENENODE_H 00004 #define SCENENODE_H 00005 00006 #include "DrawableMesh.h" 00007 #include <FnViewer/plugin/FnViewportLayer.h> 00008 #include <FnViewer/utils/FnImathHelpers.h> 00009 #include <FnViewer/utils/FnGLShaderProgram.h> 00010 #include <vector> 00011 #include <set> 00012 #include <string> 00013 00014 using namespace Foundry::Katana::ViewerAPI; 00015 using namespace Foundry::Katana::ViewerUtils; 00016 00029 class SceneNode 00030 { 00031 public: 00032 typedef std::vector<SceneNode*> NodeList; 00033 00034 SceneNode(std::string locationPath, bool proxy=false); 00035 virtual ~SceneNode(); 00036 00043 virtual bool preDraw(); 00044 00046 virtual void draw(FnAttribute::DoubleAttribute projectionMatrix, 00047 FnAttribute::DoubleAttribute viewMatrix); 00048 00050 virtual void drawChildren(FnAttribute::DoubleAttribute projectionMatrix, 00051 FnAttribute::DoubleAttribute viewMatrix); 00052 00054 virtual void pickerDraw(ViewportLayer& layer, 00055 GLShaderProgram& pickingShader, 00056 FnAttribute::DoubleAttribute projectionMatrix, 00057 FnAttribute::DoubleAttribute viewMatrix, 00058 std::set<std::string>& ignoreLocations); 00059 00061 virtual void pickerDrawChildren(ViewportLayer& layer, 00062 GLShaderProgram& pickingShader, 00063 FnAttribute::DoubleAttribute projectionMatrix, 00064 FnAttribute::DoubleAttribute viewMatrix, 00065 std::set<std::string>& ignoreLocations); 00066 00068 virtual void postDraw(); 00069 00077 void addChild(const std::string& name, SceneNode* child); 00078 00084 void removeChild(const std::string& name); 00085 00087 void removeAllChildren(); 00088 00090 void setDirty(bool dirty) { m_dirty = dirty; } 00091 00093 bool isDirty() const { return m_dirty; } 00094 00096 void setActive(bool active) { m_active = active; } 00097 00099 bool isActive() const { return m_active; } 00100 00102 void setDrawable(DrawableMesh* drawable); 00103 00105 void setAttributes(FnAttribute::GroupAttribute attr); 00106 00108 void setXform(IMATH_NAMESPACE::M44d xform); 00109 00114 SceneNode* getChild(const std::string& name); 00115 00117 SceneNode* getParent() { return m_parent; } 00118 00120 std::string getLocationPath() const { return m_locationPath; } 00121 00128 void invalidate(); 00129 00131 void invalidateChildren(); 00132 00135 void clearGLResources(); 00136 00137 private: 00139 bool m_dirty; 00141 bool m_active; 00143 DrawableMesh* m_mesh; 00145 std::string m_locationPath; 00147 SceneNode* m_parent; 00149 NodeList m_children; 00151 std::vector<std::string> m_nodeNames; 00153 FnAttribute::GroupAttribute m_locationAttributes; 00155 IMATH_NAMESPACE::Matrix44<double> m_worldMatrix; 00157 bool m_proxy; 00158 00163 static IMATH_NAMESPACE::Matrix44<double> globalWorldMatrix; 00164 }; 00165 00166 #endif //SCENENODE_H
1.7.3