VR-Forces Developer's Guide
 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) 2024 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 #include <vrvMath/DtOctree.h>
27 #include <tbb/atomic.h>
28 
29 // Enable to turn hard-coded instancing test.
30 //#define DIGUY_INSTANCING
31 
32 class diguyGraphicsState;
33 
34 namespace makVrv
35 {
36 
37  class DtDiGuyOsgGraphicsShaderProgram;
38  class DtDiGuyOsgGraphicsShaderInstance;
39  class DtDiGuyOsgGraphicsState;
40  class DtDiGuyScenario;
41  class DtDiGuyOsgGraphicsShape;
42  class DtDiGuyOsgGraphicsLink;
43  class DtDe;
44  class DtDiGuyOsgRootNode;
45  class DtDiGuyOsgGraphicsInstanceGroup;
46  class DtDiGuyInstanceDrawable;
47 
51  {
53  diguyOsgGraphicsShapeGeodePair( diguyGraphicsShape* shape, osg::Geode* geode );
54 
56  osg::Geode* m_geode;
57  };
58 
62  {
64  diguyOsgGraphicsShapeSwitchPair( diguyGraphicsShape* shape, osg::Switch* switch_node );
65 
67  osg::Switch* m_switch;
68  bool m_flash;
69  };
70 
73  class DtCollisionBoxGeode : public osg::Geode
74  {
75  public:
78 
80  DtCollisionBoxGeode( const DtCollisionBoxGeode& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY );
81 
83 
85  virtual void traverse( osg::NodeVisitor& nv );
86  };
87 
92  {
94  virtual osg::BoundingSphere computeBound( const osg::Node& node ) const;
95 
97  };
98 
101  class DtDiGuyOsgRootNode : public osg::MatrixTransform
102  {
103  public :
104 
107 
109  virtual ~DtDiGuyOsgRootNode();
110 
112  virtual void unbuild();
113 
115  virtual void traverse( osg::NodeVisitor& nv );
116 
118  void add_geode_for_fast_draw( diguyGraphicsShape* shape, osg::Geode* geode, int lod );
120  void add_switch_for_fast_draw( diguyGraphicsShape* shape, osg::Switch* switch_node, int lod );
122  void remove_shape( DtDiGuyOsgGraphicsShape* shape );
123 
125  virtual void setOctreeNode( DtOctreeNode<float64>* node );
127  virtual DtOctreeNode<float64>* octreeNode() const;
128 
130  virtual void setScenario( DtDiGuyScenario* scenario );
132  virtual DtDiGuyScenario* scenario();
133 
135  virtual void setPositionAndOrientation( const DtVector& pos, const DtTaitBryan& orient );
136 
138  virtual void setIsOccupant( bool occ ) { myOccupant = occ; }
139 
141  diguyCharacter* character();
144  inline const DtVector& position() { return myWorldPosition; }
146  inline const DtTaitBryan& orientation() { return myWorldOrientation; }
148  inline const osg::Quat& quat() { return myQuat; }
150  inline bool isOccupant() { return myOccupant; }
151 
153  inline void setLastTraversal(unsigned int lastTrav) { myLastTraversal = lastTrav; }
155  inline unsigned int lastTraversal() { return myLastTraversal; }
156 
157 
158  protected:
159  std::vector<std::vector<diguyOsgGraphicsShapeSwitchPair> > m_switch_nodes;
160  std::vector<std::vector<diguyOsgGraphicsShapeGeodePair> > m_lod_drawables;
162 
163  unsigned int myLastTraversal;
168 
170  DtTaitBryan myWorldOrientation;
171  osg::Quat myQuat;
172 
173  };
174 
178  {
179  public:
180 
182  DtDiGuyOsgGraphicsLink( void* internal_data );
183 
185  virtual ~DtDiGuyOsgGraphicsLink();
186 
189  virtual void build() override;
190 
193  virtual void unbuild() override;
194 
197  virtual void update() override;
198 
199  virtual void update_position();
200 
202  virtual void patch_tbo_data( const osg::Vec3d& camera_pos );
203 
206  virtual void attach_to_scene() override;
207 
210  virtual void detach_from_scene() override;
211 
213  virtual void attach_to_link( diguyGraphicsLink* link );
214 
216  virtual void detach_from_link();
217 
220  virtual void set_shader_instance( diguyGraphicsShaderInstance* shader_instance ) override;
221 
223  virtual void instancing_state_changed( int is_instanced ) override;
224 
226  virtual void fill_out_tbo_additional_data( diguyGraphicsShape* current_shape, float* tbo_data ) override;
227 
229  osg::MatrixTransform* getDofNode();
230 
233 
235  virtual void set_allow_motion_offsets(bool allow);
237  virtual bool get_allow_motion_offsets() const;
238 
240  virtual void setPositionAndOrientation( const DtVector& pos, const DtTaitBryan& ori );
241 
243  virtual void setCollisionUniqueId( DtUniqueID id );
244 
246  virtual osg::Uniform* getOrCreateLinkMatrixUniform();
247 
249  osg::Geode* boundingSphereVisual();
250 
252  virtual void setHasLight( bool value );
253 
254  public:
255 
257  static void setDiGuySharedNodes(DtDiGuyScenario* scenario, osg::Group* diguy_attach_pt, osg::MatrixTransform* diguy_instancing_attach_pt,
259 
261  static osg::Group* getDiGuyAttachGroup();
262 
264  static osg::MatrixTransform* get_instancing_attach_node();
265 
268 
269  protected:
270 
272  osg::Geode* makeBoundingSphereVisual(osg::Vec3& center, float radius);
273 
274  protected:
275 
277  //osg::ref_ptr<osg::Texture2D> defaultVariationTexture();
278 
281 
283 
286 
288 
291 
293 
294  protected:
295 
296  static osg::Group* the_diguy_attach_group;
297  static osg::MatrixTransform* the_diguy_instancing_attach_pt;
299 
300  };
301 
302 
306 
307 }
diguyGraphicsLink * DtDiGuyOsgGraphicsLink_create_func(void *internal_data)
Creator function registered with DI-Guy to override default diguyGraphicsLink Registered in DtDiGuyFu...
const DtTaitBryan & orientation()
vrv orientation
Definition: DtDiGuyOsgGraphicsLink.h:146
virtual void setScenario(DtDiGuyScenario *scenario)
set DtDiGuyScenario object associated with this character
void setLastTraversal(unsigned int lastTrav)
used to figure out if the character has been visited yet this frame.
Definition: DtDiGuyOsgGraphicsLink.h:153
virtual void unbuild()
called by link::unbuild()
DtDiGuyOsgGraphicsLink * m_link
Definition: DtDiGuyOsgGraphicsLink.h:161
DtDiGuyScenario * myScenario
Definition: DtDiGuyOsgGraphicsLink.h:167
META_Node(osg, DtCollisionBoxGeode)
OctreeNode class.
Definition: DtOctreeNode.h:20
virtual DtDiGuyScenario * scenario()
get DtDiGuyScenario object associated with this character
virtual void setPositionAndOrientation(const DtVector &pos, const DtTaitBryan &orient)
updates myWorldPosition, myWorldOrientation, myQuat, doesn&#39;t do anything else
virtual DtOctreeNode< float64 > * octreeNode() const
gets octree node associated with this character
DtTaitBryan myWorldOrientation
Definition: DtDiGuyOsgGraphicsLink.h:170
void add_geode_for_fast_draw(diguyGraphicsShape *shape, osg::Geode *geode, int lod)
caches a drawable for drawing quickly
float myMinDrawDistance
Definition: DtDiGuyOsgGraphicsLink.h:164
Custom per character root node that does custom traversals and short circuits osg lod picking...
Definition: DtDiGuyOsgGraphicsLink.h:101
diguyGraphicsShape * m_shape
Definition: DtDiGuyOsgGraphicsLink.h:55
struct for associating a shape with a geode for removal.
Definition: DtDiGuyOsgGraphicsLink.h:50
const DtVector & position()
perf critical position of character
Definition: DtDiGuyOsgGraphicsLink.h:144
const osg::Quat & quat()
cached osg style orientation
Definition: DtDiGuyOsgGraphicsLink.h:148
Contains DLL export macros.
unsigned int lastTraversal()
used to figure out if the character has been visited yet this frame.
Definition: DtDiGuyOsgGraphicsLink.h:155
DtDiGuyOsgRootNode & myRoot
Definition: DtDiGuyOsgGraphicsLink.h:96
DtDiGuyCharacterBoundingCallback(DtDiGuyOsgRootNode &root)
bool m_flash
Definition: DtDiGuyOsgGraphicsLink.h:68
void remove_shape(DtDiGuyOsgGraphicsShape *shape)
cleans up geodes and shapes
std::vector< std::vector< diguyOsgGraphicsShapeSwitchPair > > m_switch_nodes
Definition: DtDiGuyOsgGraphicsLink.h:159
Per link approximation for collision.
Definition: DtDiGuyOsgGraphicsLink.h:73
unsigned int myLastTraversal
Definition: DtDiGuyOsgGraphicsLink.h:163
diguyGraphicsShape * m_shape
Definition: DtDiGuyOsgGraphicsLink.h:66
DtOctree class.
osg::Quat myQuat
Definition: DtDiGuyOsgGraphicsLink.h:171
virtual void setOctreeNode(DtOctreeNode< float64 > *node)
set octree node associated with this character
virtual void setIsOccupant(bool occ)
is this a non-moving character in a vehicle
Definition: DtDiGuyOsgGraphicsLink.h:138
bool myOccupant
Definition: DtDiGuyOsgGraphicsLink.h:165
virtual ~DtDiGuyOsgRootNode()
DTOR.
Override of diguyGraphicsShape to create OSG geometry for DI-Guy shapes.
Definition: DtDiGuyOsgGraphicsShape.h:43
osg::Geode * m_geode
Definition: DtDiGuyOsgGraphicsLink.h:56
Class declaration. DtDiGuyOsgGraphicsShaderInstance publicly inherits diguyGraphicsShaderInstance. Virtual functions are declared for some of the virtual functions in the base class.
Definition: DtDiGuyOsgGraphicsShaderInstance.h:28
std::vector< std::vector< diguyOsgGraphicsShapeGeodePair > > m_lod_drawables
Definition: DtDiGuyOsgGraphicsLink.h:160
virtual osg::BoundingSphere computeBound(const osg::Node &node) const
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
struct for associating a shape with a switch node for fast updates
Definition: DtDiGuyOsgGraphicsLink.h:61
virtual void traverse(osg::NodeVisitor &nv)
override of base osg code
osg::Switch * m_switch
Definition: DtDiGuyOsgGraphicsLink.h:67
Contains makVrv::DtUniqueID type.
Class that renders all the diguy instance objects in one osg drawable, major performance improvement...
Definition: DtDiGuyInstanceDrawable.h:27
DtVector myWorldPosition
Definition: DtDiGuyOsgGraphicsLink.h:169
diguyCharacter * character()
gets diguy character
DtOctreeNode< float64 > * myOctreeNode
Definition: DtDiGuyOsgGraphicsLink.h:166
Custom root node bbox callback to avoid traversing down the model. 10x faster then trusting osg which...
Definition: DtDiGuyOsgGraphicsLink.h:91
DtDiGuyOsgRootNode(DtDiGuyOsgGraphicsLink *link)
CTOR.
diguyOsgGraphicsShapeSwitchPair(diguyGraphicsShape *shape, osg::Switch *switch_node)
CTOR.
bool isOccupant()
is this a fake person in a vehicle
Definition: DtDiGuyOsgGraphicsLink.h:150
virtual void traverse(osg::NodeVisitor &nv)
traverse function
diguyOsgGraphicsShapeGeodePair(diguyGraphicsShape *shape, osg::Geode *geode)
CTOR.
Owns a DiGuy scenario for the application.
Definition: DtDiGuyScenario.h:87
void add_switch_for_fast_draw(diguyGraphicsShape *shape, osg::Switch *switch_node, int lod)
adding a switch for fast drawing

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)