DI-Guy SDK Documentation  13.2
diguyOsgGraphicsLink.h
Go to the documentation of this file.
1 #ifndef diguyOsgGraphicsLink_h__
2 #define diguyOsgGraphicsLink_h__
3 
4 
5 #include <diguyGraphicsLink.h>
6 
7 #include <osg/Group>
8 #include <osg/MatrixTransform>
9 #include <osgViewer/Viewer>
10 
11 class diguyGraphicsState;
17 class diguyScenario;
18 
19 
28 class diguyOsgRootNode : public osg::MatrixTransform
29 {
30 public :
32  void traverse(osg::NodeVisitor& nv);
33 
34  void remove_shape(diguyOsgGraphicsShape * shape);
35  void add_geode_for_fast_draw(diguyOsgGraphicsShape * shape, osg::Geode* geode, int lod)
36  {
37  if(lod >= m_lod_drawables.size()){
38  m_lod_drawables.resize(lod+1);
39  }
40  m_lod_drawables[lod].push_back(diguyOsgGraphicsShapeGeodeMap(shape, geode));
41  }
42  void add_switch_for_fast_draw(diguyOsgGraphicsShape * shape, osg::Switch* switch_node)
43  {
44  m_switch_nodes.push_back(diguyOsgGraphicsShapeSwitchMap(shape, switch_node));
45  }
46 
47 private:
48  // two pairs for tracking shape geode and shape switch connections
50  {
51  diguyOsgGraphicsShapeGeodeMap(diguyOsgGraphicsShape * shape, osg::Geode* geode) :
52  m_shape(shape), m_geode(geode) {}
53 
55  osg::Geode* m_geode;
56  };
58  {
59  diguyOsgGraphicsShapeSwitchMap(diguyOsgGraphicsShape * shape, osg::Switch* switch_node) :
60  m_shape(shape), m_switch(switch_node){}
61 
63  osg::Switch* m_switch;
64  };
65 
66  std::vector<diguyOsgGraphicsShapeSwitchMap> m_switch_nodes;
67  std::vector<std::vector<diguyOsgGraphicsShapeGeodeMap> > m_lod_drawables;
68 
70 };
71 
72 
73 
96 {
97 
98 public:
99 
100  diguyOsgGraphicsLink(void* internal_data);
101 
102  virtual void build();
103 
104 
105  virtual void unbuild();
106  virtual void update();
107  virtual void attach_to_scene();
108  virtual void detach_from_scene();
109  virtual void instancing_state_changed(int is_instanced);
110  virtual void set_shader_instance(diguyGraphicsShaderInstance* shader_instance);
111 
112  virtual void post_build();
113 
114  osg::MatrixTransform* get_dof_node() {return m_dof_node.get();}
115  osg::StateSet* get_top_level_state_set();
118 
119  static void set_diguy_attach_ptr(diguyScenario * scenario, osg::Group* diguy_attach_pt);
121  static osgViewer::Viewer* get_viewer() {return s_viewer; }
122  static void set_viewer(osgViewer::Viewer* viewer) {s_viewer = viewer;}
125  osg::Geode * get_bounding_sphere_visual(){return m_bounding_sphere_visual.get();}
126 
127 protected:
128  friend class diguyOsgGraphicsShape;
129  friend class diguyOsgRootNode;
130 
131  osg::Geode* make_bounding_sphere_visual(osg::Vec3& center, float radius);
132 
133 // diguyGraphicsState* get_top_level_graphics_state();
134 // void recursive_post_build(diguyGraphicsState* first_state);
137  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrix;
139  // vars that are probably only relevant to the base link
140  osg::ref_ptr<osg::MatrixTransform> m_dof_node;
141  osg::ref_ptr<osg::Uniform> m_ufrm_inverse_transform_matrix;
142  osg::ref_ptr<osg::Uniform> m_ufrm_eye_point_os;
143  osg::ref_ptr<osg::Uniform> m_ufrm_light_dir_os;
144  osg::ref_ptr<osg::Uniform> m_ufrm_emission_color;
145  osg::ref_ptr<osg::Uniform> m_ufrm_body_weight;
147  osg::ref_ptr<osg::Geode> m_bounding_sphere_visual;
151 
152  static osg::Group* s_diguy_attach_pt;
153  static osg::Group* s_diguy_instancing_attach_pt;
154  static osgViewer::Viewer* s_viewer;
155  int m_instanced;
156 };
157 
158 
165 #endif // diguyOsgGraphicsLink_h__
166 
167 
Definition: diguyOsgGraphicsShaderProgram.h:29
A class that represents the unique per-character shader object.
Definition: diguyGraphicsShaderInstance.h:55
void add_geode_for_fast_draw(diguyOsgGraphicsShape *shape, osg::Geode *geode, int lod)
Definition: diguyOsgGraphicsLink.h:33
Graphics state objects mostly serve as containers for other sub-objects, such as materials and textur...
Definition: diguyOsgGraphicsState.h:21
diguyGraphicsLink * diguyOsgGraphicsLink_create_func(void *internal_data)
Create function declaration.
Definition: diguyOsgGraphicsLink.cpp:891
std::vector< diguyOsgGraphicsShapeSwitchMap > m_switch_nodes
Definition: diguyOsgGraphicsLink.h:64
diguyOsgRootNode(diguyOsgGraphicsLink *link)
Definition: diguyOsgGraphicsLink.cpp:224
Definition: diguyOsgGraphicsShaderInstance.h:16
osg::Geode * m_geode
Definition: diguyOsgGraphicsLink.h:53
Definition: diguyOsgGraphicsLink.h:26
osg::Switch * m_switch
Definition: diguyOsgGraphicsLink.h:61
A class that represents a shared material/textures combination.
Definition: diguyGraphicsState.h:44
Definition: diguyOsgGraphicsLink.h:55
void traverse(osg::NodeVisitor &nv)
Definition: diguyOsgGraphicsLink.cpp:234
diguyOsgGraphicsShape * m_shape
Definition: diguyOsgGraphicsLink.h:60
Definition: diguyOsgGraphicsLink.h:47
Shapes are the high-level containers of visible geometry.
Definition: diguyOsgGraphicsShape.h:21
Represents the scenario currently being portrayed.
Definition: diguyScenario.h:92
std::vector< std::vector< diguyOsgGraphicsShapeGeodeMap > > m_lod_drawables
Definition: diguyOsgGraphicsLink.h:65
diguyOsgGraphicsShapeSwitchMap(diguyOsgGraphicsShape *shape, osg::Switch *switch_node)
Definition: diguyOsgGraphicsLink.h:57
diguyOsgGraphicsShape * m_shape
Definition: diguyOsgGraphicsLink.h:52
osg::ref_ptr< osgViewer::Viewer > viewer
4 Header files and forward declarations
Definition: simple_playback_osg_2.cpp:43
void remove_shape(diguyOsgGraphicsShape *shape)
Definition: diguyOsgGraphicsLink.cpp:337
void add_switch_for_fast_draw(diguyOsgGraphicsShape *shape, osg::Switch *switch_node)
Definition: diguyOsgGraphicsLink.h:40
diguyOsgGraphicsLink * m_link
Definition: diguyOsgGraphicsLink.h:67
static diguyScenario * scenario
Definition: simple_playback_ogl.cpp:56
diguyOsgGraphicsShapeGeodeMap(diguyOsgGraphicsShape *shape, osg::Geode *geode)
Definition: diguyOsgGraphicsLink.h:49