VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtDiGuyOsgGraphicsLink.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2016 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 #include <diguyGraphicsShape.h>
16 
17 #include <vrvCore/DtUniqueID.h>
18 
19 #include <osg/Group>
20 #include <osg/MatrixTransform>
21 #include <osgViewer/View>
22 
23 #include <matrix/vlVector.h>
24 #include <matrix/vlTaitBryan.h>
25 
26 // Enable to turn hard-coded instancing test.
27 //#define DIGUY_INSTANCING
28 
29 class diguyGraphicsState;
30 class DtDiGuyOsgGraphicsShaderProgram;
33 namespace makVrv
34 {
35  class DtDiGuyScenario;
36  class DtDiGuyOsgGraphicsShape;
37  class DtDiGuyOsgGraphicsLink;
38  class DtDe;
39 
41  {
42  public:
43  diguyOsgGraphicsShapeGeodeMap(diguyGraphicsShape * shape, osg::Geode* geode) :
44  m_shape(shape), m_geode(geode)
45  {
46 
47  }
48 
50 
51  osg::Geode* m_geode;
52  };
53 
55  {
56  public:
57  diguyOsgGraphicsShapeSwitchMap(diguyGraphicsShape * shape, osg::Switch* switch_node) :
58  m_shape(shape), m_switch(switch_node), m_flash(false)
59  {
60  if (m_shape) {
61  m_flash = strcmp(m_shape->get_name(), "flash") == 0;
62  }
63  }
64 
66  osg::Switch* m_switch;
67  bool m_flash;
68  };
69 
70  class DtDiguyOsgRootNode : public osg::MatrixTransform
71  {
72  public :
74  void traverse(osg::NodeVisitor& nv);
75 
77  void add_geode_for_fast_draw(diguyGraphicsShape * shape, osg::Geode* geode, int lod)
78  {
79  if (lod >= m_lod_drawables.size()){
80  m_lod_drawables.resize(lod + 1);
81  }
82  m_lod_drawables[lod].push_back(diguyOsgGraphicsShapeGeodeMap(shape, geode));
83  }
84  void add_switch_for_fast_draw(diguyGraphicsShape * shape, osg::Switch* switch_node)
85  {
86  m_switch_nodes.push_back(diguyOsgGraphicsShapeSwitchMap(shape, switch_node));
87  }
88  std::vector<diguyOsgGraphicsShapeSwitchMap> m_switch_nodes;
89  std::vector<std::vector<diguyOsgGraphicsShapeGeodeMap> > m_lod_drawables;
91  };
92 
96  {
97 
98  public:
100  DtDiGuyOsgGraphicsLink(void* internal_data);
101 
103  virtual ~DtDiGuyOsgGraphicsLink();
104 
108  virtual void build();
109 
113  virtual void unbuild();
114 
118  virtual void update();
119 
120  virtual void update_position();
121 
122  virtual void patch_tbo_data(const osg::Vec3d & camera_pos);
123 
127  virtual void attach_to_scene();
128 
132  virtual void detach_from_scene();
133 
137  virtual void attach_to_link(diguyGraphicsLink* link);
138 
142  virtual void detach_from_link();
143 
147  virtual void set_shader_instance(diguyGraphicsShaderInstance* shader_instance);
148 
149  virtual void instancing_state_changed(int is_instanced);
150 
152  osg::MatrixTransform* getDofNode() {return m_dof_node.get();}
153 
154  static void setDiGuyAttachGroup(DtDiGuyScenario * scenario, osg::Group* diguy_attach_pt, osg::Group* diguy_instancing_attach_pt);
155  static osg::Group* getDiGuyAttachGroup(){return DiguyAttachGroup;}
156 
157  static osg::MatrixTransform* get_instancing_attach_node() { return s_diguy_instancing_attach_pt; }
158 
159  static osgViewer::View* getView() {return staticView; }
160  static void setView(osgViewer::View* view) {staticView = view;}
161 
163  virtual void setPosition(const DtVector& pos, int final_state = 0);
164 
166  virtual void setOrientation(const DtTaitBryan& ori);
167 
169  virtual void setCollisionUniqueId(DtUniqueID id);
170 
171  static void setDe(DtDe * de){s_myDe = de;}
172 
173  virtual void fill_out_tbo_additional_data(diguyGraphicsShape * current_shape, float * tbo_data);
174 
175  protected:
177  friend class DtDiguyOsgRootNode;
178 
180  osg::Geode* makeBoundingSphereVisual(osg::Vec3& center, float radius);
181 
183  osg::ref_ptr<osg::Texture2D> defaultVariationTexture();
184 
185  osg::ref_ptr<osg::MatrixTransform> m_dof_node;
186  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrix;
187  //osg::ref_ptr<osg::Uniform> myUniformInverseTransformMatrix;
188  //osg::ref_ptr<osg::Uniform> myEyePointUniform;
189  //osg::ref_ptr<osg::Uniform> myLightDirectionUniform;
190 
191  osg::ref_ptr<osg::Uniform> m_ufrm_emission_color;
192  osg::ref_ptr<osg::Uniform> m_ufrm_body_weight;
193 
194  osg::ref_ptr<osg::Group> myCollisionBoxGroup;
195  osg::ref_ptr<osg::Geode> myBoundingSphereVisual;
196 
197  static osg::Group* DiguyAttachGroup;
198  static osgViewer::View* staticView;
199  static osg::MatrixTransform* s_diguy_instancing_attach_pt;
200  static DtDe* s_myDe;
201 
203  //DtDiGuyOsgGraphicsShaderProgram* myShaderProgram;
204 
206  DtTaitBryan myOrientation;
207 
209 
210  };
211 
212 
216 
217 }

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)