VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgUtils.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2021 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <osg/Quat>
13 #include <osg/Texture2DArray>
14 #include <osg/Depth>
15 #include <osg/Camera>
16 #include <osg/MatrixTransform>
17 #include <osg/Geometry>
18 
21 
22 class DtTaitBryan;
23 
24 namespace makVrv
25 {
26  class DtGlSimpleTexture;
27 
30  class DtOsgDebugFrustum : public osg::Referenced
31  {
32  public:
33  DtOsgDebugFrustum(const osg::Vec4 & color);
34  void updateDebugFrustum(osg::Vec3d * frustumVertices);
35 
38  };
39 
43  {
44  public:
46  static void makeRotate(osg::Quat& q, const double& angle, const double& x, const double& y, const double& z);
47 
49  static osg::Matrixf toOsgRotation(const DtTaitBryan& orientation);
50 
54  static void quatMult(osg::Quat& lhs, const osg::Quat& rhs);
55 
57  static osg::Camera * CreateTextureQuadOverlay(DtGlSimpleTexture * texture,
58  float x, float y, float w, float h);
59 
61  static osg::Camera * CreateTextureQuadOverlay(osg::Texture * texture,
62  float x, float y, float w, float h);
63 
65  static osg::Camera * CreateTextureQuadOverlay(const std::string& shader_root, osg::Texture2DArray * textureArray,
66  float x, float y, float w, float h);
67 
69  static osg::MatrixTransform * create_axis_primitive();
70 
73 
76  static osg::Matrix getOrthoMatrix(bool useReverseZ, double left, double right,
77  double bottom, double top, double zNear, double zFar);
78 
81  static osg::Matrix getProjMatrix(bool useReverseZ, double left, double right,
82  double bottom, double top, double zNear, double zFar);
83 
85  static osg::Matrixd getRevZOrthoMatrix(double left, double right, double bottom,
86  double top, double zNear, double zFar);
87 
90  static bool getRevZPerspectiveMatrixAsFrustum(const osg::Matrix& mat, double& left,
91  double& right, double& bottom, double& top, double& zNear, double& zFar);
92 
95  static bool getRevZOrthoMatrixAsFrustum(const osg::Matrix& orthoMat, double& left,
96  double& right, double& bottom, double& top, double& zNear, double& zFar);
97 
100  static bool getRevZPerspective(const osg::Matrix& mat, double& fovy,
101  double& aspectRatio, double& zNear, double& zFar);
102 
105  static osg::Matrix makeRevZPerspective(double fovy, double aspectRatio,
106  double zNear, double zFar);
107 
109  static void getYPR(const osg::Matrix& m, double& yaw, double& pitch, double& roll);
110 
112  static void osgPolytopeToFrustum(Frustum_64& frustum, const osg::Polytope& polytope, bool hasNearFar);
113 
117  static void computeOsgCameraFrustumPlanes(std::vector<osg::Vec4d>& planes, const osg::Camera* camera);
118 
120  static void debugDumpShaderState(osg::State* state);
121 
123  static void debugDumpUniformState(const osg::Node* node);
124 
126 
127  static osg::Vec2 rotateVec2( const osg::Vec2& v, double rad );
129 
131  static osg::Vec2 translateVec2( const osg::Vec2& v, const osg::Vec2& translation );
132 
134  static osg::Vec2 scaleVec2( const osg::Vec2& v, double s );
135 
137  static osg::Vec2 scaleVec2( const osg::Vec2& v, double xScale, double yScale );
139 
141  static bool clipLine( double xMin, double xMax, double yMin, double yMax,
142  double x0src, double y0src, double x1src, double y1src,
143  double &x0clip, double &y0clip, double &x1clip, double &y1clip );
144 
146  static void clipPolygon( double xMin, double xMax, double yMin, double yMax,
147  std::vector<osg::Vec2>& vertices );
148 
149  // Adapted from VR-Link DtModPerLo [matrix/modper.cxx]
150  template <class VecType> static VecType DtModPerLoVec3( const VecType& in, double min, double max )
151  {
152  VecType result;
153  double per = max - min;
154 
155  for( int i = 0; i < 3; ++i )
156  {
157  if( min <= in[i] && in[i] < max )
158  {
159  result[i] = in[i];
160  }
161  else
162  {
163  result[i] = fmod( in[i] - min, per );
164 
165  if( result[i] < 0.0 )
166  {
167  result[i] += per;
168  }
169 
170  result[i] += min;
171  }
172  }
173  return result;
174  }
175 
182  static bool insideTriangulate( const std::vector<osg::Vec2>& contour, std::vector<int>& results );
183  protected:
185  static bool snipTriangle( const std::vector<osg::Vec2>& contour, int u, int v, int w, int n, int *V );
187  static bool insideTriangle( float Ax, float Ay, float Bx, float By, float Cx, float Cy, float Px, float Py );
189  static float triangulateAreaSize( const std::vector<osg::Vec2> &contour );
190 
191 
192  };
193 }
194 
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
static VecType DtModPerLoVec3(const VecType &in, double min, double max)
Definition: DtOsgUtils.h:150
void updateDebugFrustum(osg::Vec3d *frustumVertices)
Contains makVrv::DtOsgShaderUtils class.
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Wrapper for OpenGL Texture.
Definition: DtGlSimpleTexture.h:35
osg::ref_ptr< osg::MatrixTransform > myTransform
Definition: DtOsgUtils.h:36
Camera forward declarations.
DT_DLL_vrfutil double angle(double vec1[3], double vec2[3])
helper class, random osg debug helpers and math
Definition: DtOsgUtils.h:42
osg::ref_ptr< osg::Geometry > myGeometry
Definition: DtOsgUtils.h:37
DtOsgDebugFrustum(const osg::Vec4 &color)
helper for visualizing debug frustra
Definition: DtOsgUtils.h:30

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)