openscenegraph
Transform
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
28namespace osg {
29
30
31
35extern OSG_EXPORT Matrix computeLocalToWorld(const NodePath& nodePath, bool ignoreCameras = true);
36
40extern OSG_EXPORT Matrix computeWorldToLocal(const NodePath& nodePath, bool ignoreCameras = true);
41
46extern OSG_EXPORT Matrix computeLocalToEye(const Matrix& modelview, const NodePath& nodePath, bool ignoreCameras = true);
47
52extern OSG_EXPORT Matrix computeEyeToLocal(const Matrix& modelview, const NodePath& nodePath, bool ignoreCameras = true);
53
54
75{
76 public :
77
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
94 virtual AutoTransform* asAutoTransform() { return 0; }
95 virtual const AutoTransform* asAutoTransform() const { return 0; }
96
98 {
101 ABSOLUTE_RF_INHERIT_VIEWPOINT
102 };
103
123
124 ReferenceFrame getReferenceFrame() const { return _referenceFrame; }
125
126 virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
127 {
128 if (_referenceFrame==RELATIVE_RF)
129 {
130 return false;
131 }
132 else // absolute
133 {
134 matrix.makeIdentity();
135 return true;
136 }
137 }
138
139 virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const
140 {
141 if (_referenceFrame==RELATIVE_RF)
142 {
143 return false;
144 }
145 else // absolute
146 {
147 matrix.makeIdentity();
148 return true;
149 }
150 }
151
158
159 protected :
160
161 virtual ~Transform();
162
163
165
166};
167
168}
169
170#endif
Definition AutoTransform:28
Definition BoundingSphere:35
Definition CopyOp:41
Definition Group:29
Definition MatrixTransform:26
Definition Matrixd:27
void makeIdentity()
Definition NodeVisitor:82
Definition PositionAttitudeTransform:29
Definition Transform:75
ReferenceFrame _referenceFrame
Definition Transform:164
META_Node(osg, Transform)
Transform(const Transform &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
virtual bool computeWorldToLocalMatrix(Matrix &matrix, NodeVisitor *) const
Definition Transform:139
virtual const AutoTransform * asAutoTransform() const
Definition Transform:95
virtual AutoTransform * asAutoTransform()
Definition Transform:94
virtual ~Transform()
virtual const MatrixTransform * asMatrixTransform() const
Definition Transform:89
virtual const Transform * asTransform() const
Definition Transform:86
virtual Transform * asTransform()
Definition Transform:85
virtual PositionAttitudeTransform * asPositionAttitudeTransform()
Definition Transform:91
virtual BoundingSphere computeBound() const
virtual MatrixTransform * asMatrixTransform()
Definition Transform:88
ReferenceFrame getReferenceFrame() const
Definition Transform:124
virtual bool computeLocalToWorldMatrix(Matrix &matrix, NodeVisitor *) const
Definition Transform:126
virtual const PositionAttitudeTransform * asPositionAttitudeTransform() const
Definition Transform:92
ReferenceFrame
Definition Transform:98
@ RELATIVE_RF
Definition Transform:99
@ ABSOLUTE_RF
Definition Transform:100
void setReferenceFrame(ReferenceFrame rf)
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
OSG_EXPORT Matrix computeEyeToLocal(const Matrix &modelview, const NodePath &nodePath, bool ignoreCameras=true)
std::vector< Node * > NodePath
Definition Node:47
OSG_EXPORT Matrix computeLocalToEye(const Matrix &modelview, const NodePath &nodePath, bool ignoreCameras=true)
OSG_EXPORT Matrix computeLocalToWorld(const NodePath &nodePath, bool ignoreCameras=true)
OSG_EXPORT Matrix computeWorldToLocal(const NodePath &nodePath, bool ignoreCameras=true)
#define OSG_EXPORT
Definition osg/Export:39