OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Transform.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_TRANSFORM
15 #define OSG_TRANSFORM 1
16 
17 #include <osg/Group>
18 #include <osg/Matrix>
19 
20 #ifndef GL_RESCALE_NORMAL
21 #define GL_RESCALE_NORMAL 0x803A
22 #endif
23 
24 #ifndef GL_NORMALIZE
25 #define GL_NORMALIZE 0x0BA1
26 #endif
27 
28 namespace osg {
29 
30 
31 
35 extern OSG_EXPORT Matrix computeLocalToWorld(const NodePath& nodePath, bool ignoreCameras = true);
36 
40 extern OSG_EXPORT Matrix computeWorldToLocal(const NodePath& nodePath, bool ignoreCameras = true);
41 
46 extern OSG_EXPORT Matrix computeLocalToEye(const Matrix& modelview, const NodePath& nodePath, bool ignoreCameras = true);
47 
52 extern OSG_EXPORT Matrix computeEyeToLocal(const Matrix& modelview, const NodePath& nodePath, bool ignoreCameras = true);
53 
54 
74 class OSG_EXPORT Transform : public Group
75 {
76  public :
77 
78  Transform();
79 
81  Transform(const Transform&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
82 
84 
85  virtual Transform* asTransform() { return this; }
86  virtual const Transform* asTransform() const { return this; }
87 
88  virtual MatrixTransform* asMatrixTransform() { return 0; }
89  virtual const MatrixTransform* asMatrixTransform() const { return 0; }
90 
92  virtual const PositionAttitudeTransform* asPositionAttitudeTransform() const { return 0; }
93 
95  {
98  ABSOLUTE_RF_INHERIT_VIEWPOINT
99  };
100 
119  void setReferenceFrame(ReferenceFrame rf);
120 
121  ReferenceFrame getReferenceFrame() const { return _referenceFrame; }
122 
123  virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
124  {
125  if (_referenceFrame==RELATIVE_RF)
126  {
127  return false;
128  }
129  else // absolute
130  {
131  matrix.makeIdentity();
132  return true;
133  }
134  }
135 
136  virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const
137  {
138  if (_referenceFrame==RELATIVE_RF)
139  {
140  return false;
141  }
142  else // absolute
143  {
144  matrix.makeIdentity();
145  return true;
146  }
147  }
148 
154  virtual BoundingSphere computeBound() const;
155 
156  protected :
157 
158  virtual ~Transform();
159 
160 
162 
163 };
164 
165 }
166 
167 #endif
#define OSG_EXPORT
Definition: Export.h:43
virtual Transform * asTransform()
Definition: Transform.h:85
OSG_EXPORT Matrix computeWorldToLocal(const NodePath &nodePath, bool ignoreCameras=true)
#define META_Node(library, name)
Definition: Node.h:59
virtual PositionAttitudeTransform * asPositionAttitudeTransform()
Definition: Transform.h:91
virtual bool computeWorldToLocalMatrix(Matrix &matrix, NodeVisitor *) const
Definition: Transform.h:136
virtual const PositionAttitudeTransform * asPositionAttitudeTransform() const
Definition: Transform.h:92
virtual bool computeLocalToWorldMatrix(Matrix &matrix, NodeVisitor *) const
Definition: Transform.h:123
ReferenceFrame _referenceFrame
Definition: Transform.h:161
virtual MatrixTransform * asMatrixTransform()
Definition: Transform.h:88
OSG_EXPORT Matrix computeLocalToWorld(const NodePath &nodePath, bool ignoreCameras=true)
OSG_EXPORT Matrix computeLocalToEye(const Matrix &modelview, const NodePath &nodePath, bool ignoreCameras=true)
void makeIdentity()
Definition: AlphaFunc.h:19
OSG_EXPORT Matrix computeEyeToLocal(const Matrix &modelview, const NodePath &nodePath, bool ignoreCameras=true)
virtual const MatrixTransform * asMatrixTransform() const
Definition: Transform.h:89
virtual const Transform * asTransform() const
Definition: Transform.h:86
std::vector< Node * > NodePath
Definition: Node.h:44
ReferenceFrame getReferenceFrame() const
Definition: Transform.h:121
Matrixd Matrix
Definition: Matrix.h:27