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 <atomic>
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();
142 
147  inline const DtVector& position() { return myWorldPosition; }
148 
152  inline const DtTaitBryan& orientation() { return myWorldOrientation; }
153 
155  inline const osg::Quat& quat() { return myQuat; }
156 
158  inline bool isOccupant() { return myOccupant; }
159 
161  inline void setLastTraversal(unsigned int lastTrav) { myLastTraversal = lastTrav; }
163  inline unsigned int lastTraversal() { return myLastTraversal; }
164 
165 
166  protected:
167  std::vector<std::vector<diguyOsgGraphicsShapeSwitchPair> > m_switch_nodes;
168  std::vector<std::vector<diguyOsgGraphicsShapeGeodePair> > m_lod_drawables;
170 
171  unsigned int myLastTraversal;
176 
177  DtVector myWorldPosition;
178  DtTaitBryan myWorldOrientation;
179  osg::Quat myQuat;
180 
181  };
182 
186  {
187  public:
188 
190  DtDiGuyOsgGraphicsLink( void* internal_data );
191 
193  virtual ~DtDiGuyOsgGraphicsLink();
194 
197  virtual void build() override;
198 
201  virtual void unbuild() override;
202 
205  virtual void update() override;
206 
207  virtual void update_position();
208 
210  virtual void patch_tbo_data( const osg::Vec3d& camera_pos );
211 
214  virtual void attach_to_scene() override;
215 
218  virtual void detach_from_scene() override;
219 
221  virtual void attach_to_link( diguyGraphicsLink* link );
222 
224  virtual void detach_from_link();
225 
228  virtual void set_shader_instance( diguyGraphicsShaderInstance* shader_instance ) override;
229 
231  virtual void instancing_state_changed( int is_instanced ) override;
232 
234  virtual void fill_out_tbo_additional_data( diguyGraphicsShape* current_shape, float* tbo_data ) override;
235 
237  osg::MatrixTransform* getDofNode();
238 
241 
243  virtual void set_allow_motion_offsets(bool allow);
245  virtual bool get_allow_motion_offsets() const;
246 
248  virtual void setPositionAndOrientation( const DtVector& pos, const DtTaitBryan& ori );
249 
251  virtual void setCollisionUniqueId( DtUniqueID id );
252 
254  virtual osg::Uniform* getOrCreateLinkMatrixUniform();
255 
257  osg::Geode* boundingSphereVisual();
258 
260  virtual void setHasLight( bool value );
261 
262  public:
263 
265  static void setDiGuySharedNodes(DtDiGuyScenario* scenario, osg::Group* diguy_attach_pt, osg::MatrixTransform* diguy_instancing_attach_pt,
267 
269  static osg::Group* getDiGuyAttachGroup();
270 
272  static osg::MatrixTransform* get_instancing_attach_node();
273 
276 
277  protected:
278 
280  osg::Geode* makeBoundingSphereVisual(osg::Vec3& center, float radius);
281 
282  protected:
283 
285  //osg::ref_ptr<osg::Texture2D> defaultVariationTexture();
286 
289 
291 
294 
296 
299 
301 
302  protected:
303 
304  static osg::Group* the_diguy_attach_group;
305  static osg::MatrixTransform* the_diguy_instancing_attach_pt;
307 
308  };
309 
310 
314 
315 }
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 This returns the last-set world orientation of the character. If the character is emb...
Definition: DtDiGuyOsgGraphicsLink.h:152
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:161
virtual void unbuild()
called by link::unbuild()
DtDiGuyOsgGraphicsLink * m_link
Definition: DtDiGuyOsgGraphicsLink.h:169
DtDiGuyScenario * myScenario
Definition: DtDiGuyOsgGraphicsLink.h:175
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:178
void add_geode_for_fast_draw(diguyGraphicsShape *shape, osg::Geode *geode, int lod)
caches a drawable for drawing quickly
float myMinDrawDistance
Definition: DtDiGuyOsgGraphicsLink.h:172
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 This returns the last-set world position of the character...
Definition: DtDiGuyOsgGraphicsLink.h:147
const osg::Quat & quat()
cached osg style orientation
Definition: DtDiGuyOsgGraphicsLink.h:155
Contains DLL export macros.
unsigned int lastTraversal()
used to figure out if the character has been visited yet this frame.
Definition: DtDiGuyOsgGraphicsLink.h:163
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:167
Per link approximation for collision.
Definition: DtDiGuyOsgGraphicsLink.h:73
unsigned int myLastTraversal
Definition: DtDiGuyOsgGraphicsLink.h:171
diguyGraphicsShape * m_shape
Definition: DtDiGuyOsgGraphicsLink.h:66
DtOctree class.
osg::Quat myQuat
Definition: DtDiGuyOsgGraphicsLink.h:179
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:173
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:168
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:177
diguyCharacter * character()
gets diguy character
DtOctreeNode< float64 > * myOctreeNode
Definition: DtDiGuyOsgGraphicsLink.h:174
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:158
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 Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)