VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgGizmoRenderer.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
14 #include <osg/Vec3>
15 #include <osg/MatrixTransform>
16 #include <osg/Drawable>
17 
19 
20 namespace osg
21 {
22  class RenderInfo;
23 }
24 
25 
26 namespace makVrv
27 {
28  class DtOsgGizmoRenderer;
32  {
33  public:
35  DtDebugDrawCallbackInterface(DtDe& de) : myDe(de) { ; }
36 
38  virtual void drawDebugLines(osg::RenderInfo& renderInfo, const osg::Vec3d& eyePoint, DtOsgGizmoRenderer* renderer) = 0;
39 
41  virtual void systemShutDown() { ; }
42 
43  protected:
45 
46  };
47 
50  class DT_DLL_VRVOSG DtOsgGizmoTransform : public osg::MatrixTransform
51  {
52  public:
55 
58 
60  virtual osg::Object* clone(const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) const;
61 
66  virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const;
67 
69  virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const;
70 
71  private:
73  DtOsgGizmoTransform(const DtOsgGizmoTransform& ob, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
74 
75  };
76 
80  {
81  public:
87  void releaseGLObjects(osg::State* state) const;
88 
90  void init();
92  void setName(const char* name);
94  void update(const std::vector<osg::Vec3f>& verts,
95  const std::vector<osg::Vec4f>* colors, const std::vector<osg::Vec3f>* normals, const std::vector<osg::Vec2f>* uvs,
96  const osg::UShortArray* index_buffer);
98  void updateBuffer(GLuint& id, const char* suffix, int size, void* data);
99 
101  void draw(const osg::Matrixf& model_matrix, const osg::Vec4& default_color = osg::Vec4(1, 1, 1, 1));
102 
103  public:
104  std::string m_name;
105 
106  mutable unsigned int m_verts_object;
107  mutable unsigned int m_colors_object;
108  mutable unsigned int m_normals_object;
109  mutable unsigned int m_index_buffer;
110  mutable unsigned int m_model_matrix_buffer;
111  mutable unsigned int m_color_array_buffer;
116  };
117 
125  class DT_DLL_VRVOSG DtOsgGizmoRenderer : public osg::Drawable
126  {
127  public:
132 
134  void releaseGLObjects(osg::State* state);
135 
137  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
138 
140  virtual void addDebugDrawerCallback(DtDebugDrawCallbackInterface* drawer);
141 
143  void addWsLine(const osg::Vec3d& p1, const osg::Vec3d& p2, const osg::Vec4f& color1, const osg::Vec4f& color2);
144 
146  // virtual void drawAxis(const osg::Matrixf& model_matrix, const osg::Vec3& pos);
147 
149  virtual void renderWsBoxIntoVbo(const osg::Vec3d& p1, const osg::Vec3d& p2,
150  const osg::Vec4f& color);
151 
153  virtual void renderBoxFromPointsIntoVbo(const osg::Matrixf& model_matrix,
154  const osg::Vec3f& pMin, const osg::Vec3f& pMax, const osg::Vec4f& color);
155 
157  virtual void renderSphereIntoVbo(const osg::Vec3f& localCenter, const osg::Vec3f& radii, const osg::Matrixf& xform,
158  const osg::Vec4f& force_color);
159 
161  virtual void renderCircleIntoVbo(const osg::Vec3f& localCenter, const float radii, const osg::Matrixf& xform,
162  const osg::Vec4f& force_color);
163 
165  virtual void renderHemisphereIntoVbo(const osg::Vec3f& localCenter, const osg::Vec3f& radii, const osg::Matrixf& xform,
166  const osg::Vec4f& force_color);
167 
169  virtual void renderEllipseIntoVbo(const osg::Vec3f& localCenter, const osg::Vec2f& radii, const osg::Matrixf& xform,
170  const osg::Vec4f& force_color);
171 
173  virtual void renderBoxIntoVbo(const osg::Vec3f& localCenter, const osg::Vec3f& localMin, const osg::Vec3f& localMax, const osg::Matrixf& xform,
174  const osg::Vec4f& force_color);
175 
177  void drawStreamedData(osg::RenderInfo& renderInfo, int primitive_type,
178  const std::vector<osg::Vec3f>& verts, const std::vector<osg::Vec4f>* colors, const std::vector<osg::Vec3f>* normals,
179  const std::vector<unsigned short>* index_buffer,
180  const osg::Vec4f& default_color = osg::Vec4f(1, 1, 1, 1));
181 
182  protected:
184  void setCameraPos(const osg::Vec3& pos);
185 
187  virtual void drawImplementationNonConst(osg::RenderInfo& renderInfo);
188 
189  protected:
193 
194  // used for drawing boxes
195  std::vector<osg::Vec3f> m_line_strip_verts;
196  std::vector<osg::Vec4f> m_line_strip_colors;
197  std::vector<unsigned short> m_line_strip_indexes;
198 
200 
201  osg::Vec3d m_camera_pos;
202  std::vector<osg::Vec3f> m_scratch_verts;
203  std::vector<osg::Vec4f> m_scratch_colors;
204  std::vector<DtDebugDrawCallbackInterface*> myExtraDebugDrawObjects;
205  };
206 
207 
211  {
212  public:
213 
217  virtual ~DtOsgGizmoRendererManager();
218 
221  static DtOsgGizmoRendererManager& instance(DtDe& de);
222 
223  static void registerInstance(DtDe& de, DtOsgGizmoRendererManager *manager);
224  static const std::string& theClassName();
225 
227  virtual DtOsgGizmoRenderer* gizmoRenderer();
228 
229  protected:
232  };
233 
234 }
a helper struct to send basic primitives to video card
Definition: DtOsgGizmoRenderer.h:79
std::vector< osg::Vec3f > m_scratch_verts
Definition: DtOsgGizmoRenderer.h:202
DtDebugDrawCallbackInterface(DtDe &de)
CTOR.
Definition: DtOsgGizmoRenderer.h:35
Virtual base class.
Definition: DtVirtualBaseClass.h:22
unsigned int m_normals_object
Definition: DtOsgGizmoRenderer.h:108
std::vector< osg::Vec4f > m_scratch_colors
Definition: DtOsgGizmoRenderer.h:203
unsigned int m_model_matrix_buffer
Definition: DtOsgGizmoRenderer.h:110
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
unsigned int m_verts_object
Definition: DtOsgGizmoRenderer.h:106
int m_index_count
Definition: DtOsgGizmoRenderer.h:113
DtStreamedVboData m_dynamic_vbo
Definition: DtOsgGizmoRenderer.h:191
voidpf void uLong size
Definition: ioapi.h:39
std::vector< unsigned short > m_line_strip_indexes
Definition: DtOsgGizmoRenderer.h:197
DtStreamedVboData m_axis_vbo
Definition: DtOsgGizmoRenderer.h:192
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
A simple interface for allowing the various systems to draw lines at the right time.
Definition: DtOsgGizmoRenderer.h:31
int m_intialized
Definition: DtOsgGizmoRenderer.h:114
a class to quickly render a bunch of basic primitives as debugging aids basic overview, create an adapter that inherits from DtDebugDrawCallbackInterface then call DtOsgGizmoRenderer::addDebugDrawerCallback() to register it with the system.
Definition: DtOsgGizmoRenderer.h:125
int m_primitive_size
Definition: DtOsgGizmoRenderer.h:112
DtDe & myDe
Definition: DtOsgGizmoRenderer.h:190
int m_primitive_type
Definition: DtOsgGizmoRenderer.h:115
DtDe & myDe
Definition: DtOsgGizmoRenderer.h:44
Contains makVrv::DtVirtualBaseClass class.
virtual void systemShutDown()
Gizmo Renderer manager is getting shut down.
Definition: DtOsgGizmoRenderer.h:41
std::vector< osg::Vec3f > m_line_strip_verts
Definition: DtOsgGizmoRenderer.h:195
DtGizmoRendererManager.
Definition: DtOsgGizmoRenderer.h:210
osg::Vec3d m_camera_pos
Definition: DtOsgGizmoRenderer.h:201
std::string m_name
Definition: DtOsgGizmoRenderer.h:104
unsigned int m_color_array_buffer
Definition: DtOsgGizmoRenderer.h:111
std::vector< osg::Vec4f > m_line_strip_colors
Definition: DtOsgGizmoRenderer.h:196
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
unsigned int m_colors_object
Definition: DtOsgGizmoRenderer.h:107
unsigned int m_index_buffer
Definition: DtOsgGizmoRenderer.h:109
DtDe & myDe
Definition: DtOsgGizmoRenderer.h:230
std::vector< DtDebugDrawCallbackInterface * > myExtraDebugDrawObjects
Definition: DtOsgGizmoRenderer.h:204
GLuint m_vertex_array_object
Definition: DtOsgGizmoRenderer.h:199
Helps attach the drawable to the scene graph.
Definition: DtOsgGizmoRenderer.h:50
DtOsgGizmoRenderer * myRenderer
Definition: DtOsgGizmoRenderer.h:231

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)