VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtDiGuyOsgGraphicsLink.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvDiGuy/vrvDiGuy.h>
13 
14 #include <diguyGraphicsLink.h>
15 
16 #include <vrvCore/DtUniqueID.h>
17 
18 #include <osg/Group>
19 #include <osg/MatrixTransform>
20 #include <osgViewer/View>
21 
22 #include <matrix/vlVector.h>
23 #include <matrix/vlTaitBryan.h>
24 
25 // Enable to turn hard-coded instancing test.
26 //#define DIGUY_INSTANCING
27 
28 class diguyGraphicsState;
32 namespace makVrv
33 {
34 
35  class DtDiGuyOsgGraphicsShape;
36  class DtDiGuyOsgGraphicsLink;
37  class DtDe;
39  {
40  public:
41  diguyOsgGraphicsShapeGeodeMap(diguyGraphicsShape * shape, osg::Geode* geode) :
42  m_shape(shape), m_geode(geode)
43  {
44  ;
45  }
46 
48  osg::Geode* m_geode;
49  };
51  {
52  public:
53  diguyOsgGraphicsShapeSwitchMap(diguyGraphicsShape * shape, osg::Switch* switch_node) :
54  m_shape(shape), m_switch(switch_node)
55  {
56  ;
57  }
58 
60  osg::Switch* m_switch;
61  };
62 
63  class DtDiguyOsgRootNode : public osg::MatrixTransform
64  {
65  public :
67  void traverse(osg::NodeVisitor& nv);
68 
70  void add_geode_for_fast_draw(diguyGraphicsShape * shape, osg::Geode* geode, int lod)
71  {
72  if(lod >= m_lod_drawables.size()){
73  m_lod_drawables.resize(lod+1);
74  }
75  m_lod_drawables[lod].push_back(diguyOsgGraphicsShapeGeodeMap(shape, geode));
76  }
77  void add_switch_for_fast_draw(diguyGraphicsShape * shape, osg::Switch* switch_node)
78  {
79  m_switch_nodes.push_back(diguyOsgGraphicsShapeSwitchMap(shape, switch_node));
80  }
81  std::vector<diguyOsgGraphicsShapeSwitchMap> m_switch_nodes;
82  std::vector<std::vector<diguyOsgGraphicsShapeGeodeMap> > m_lod_drawables;
84  };
85 
89  {
90 
91  public:
93  DtDiGuyOsgGraphicsLink(void* internal_data);
94 
96  virtual ~DtDiGuyOsgGraphicsLink();
97 
101  virtual void build();
102 
106  virtual void unbuild();
107 
111  virtual void update();
112  virtual void update_position();
113 
117  virtual void attach_to_scene();
118 
122  virtual void detach_from_scene();
123 
127  virtual void attach_to_link(diguyGraphicsLink* link);
128 
132  virtual void detach_from_link();
133 
137  virtual void set_shader_instance(diguyGraphicsShaderInstance* shader_instance);
138 
139  virtual void instancing_state_changed(int is_instanced);
140 
142  osg::MatrixTransform* getDofNode() {return m_dof_node.get();}
143 
144  static void setDiGuyAttachGroup(osg::Group* diguy_attach_pt);
145  static osg::Group* getDiGuyAttachGroup(){return DiguyAttachGroup;}
146 
148 
149  static osgViewer::View* getView() {return staticView; }
150  static void setView(osgViewer::View* view) {staticView = view;}
151 
153  virtual void setPosition(const DtVector& pos);
154 
156  virtual void setOrientation(const DtTaitBryan& ori);
157 
159  virtual void setCollisionUniqueId(DtUniqueID id);
160 
161  static void setDe(DtDe * de){s_myDe = de;}
162 
163  protected:
165  friend class DtDiguyOsgRootNode;
166 
168  osg::Geode* makeBoundingSphereVisual(osg::Vec3& center, float radius);
169 
171  osg::ref_ptr<osg::Texture2D> defaultVariationTexture();
172 
173  osg::ref_ptr<osg::MatrixTransform> m_dof_node;
174  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrix;
175  //osg::ref_ptr<osg::Uniform> myUniformInverseTransformMatrix;
176  //osg::ref_ptr<osg::Uniform> myEyePointUniform;
177  //osg::ref_ptr<osg::Uniform> myLightDirectionUniform;
178 
179  osg::ref_ptr<osg::Group> myCollisionBoxGroup;
180  osg::ref_ptr<osg::Geode> myBoundingSphereVisual;
181 
182  static osg::Group* DiguyAttachGroup;
183  static osgViewer::View* staticView;
184  static osg::Group* s_diguy_instancing_attach_pt;
185  static DtDe* s_myDe;
186 
188  //DtDiGuyOsgGraphicsShaderProgram* myShaderProgram;
189 
190  static osg::ref_ptr<osg::Texture2D> staticDegenerateTexture;
191 
193  DtTaitBryan myOrientation;
194 
196 
197  };
198 
199 
203 
204 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)