Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Transform.cpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #include <vlCore/Transform.hpp>
35 #include <vlCore/Log.hpp>
36 #include <algorithm>
37 #include <set>
38 
39 using namespace vl;
40 
41 //-----------------------------------------------------------------------------
42 // Transform
43 //-----------------------------------------------------------------------------
45 {
46 #if 0
47  if (!mChildren.empty())
48  Log::warning("Transform::~Transform(): a Transform with children is being destroyed! One or more Transforms will be orphaned.\n");
49 #endif
50 
51  for(size_t i=0; i<mChildren.size(); ++i)
52  {
53  mChildren[i]->mParent = NULL;
54  mChildren[i]->setLocalMatrix( mChildren[i]->worldMatrix() );
55  }
56 }
57 //-----------------------------------------------------------------------------
58 void Transform::translate(real x, real y, real z)
59 {
61 }
62 //-----------------------------------------------------------------------------
63 void Transform::translate(const vec3& t)
64 {
66 }
67 //-----------------------------------------------------------------------------
68 void Transform::scale(real x, real y, real z)
69 {
71 }
72 //-----------------------------------------------------------------------------
73 void Transform::rotate(real degrees, real x, real y, real z)
74 {
75  setLocalMatrix( mat4::getRotation(degrees,x,y,z)*localMatrix() );
76 }
77 //-----------------------------------------------------------------------------
78 void Transform::rotate(const vec3& from, const vec3& to)
79 {
81 }
82 //-----------------------------------------------------------------------------
84 {
86 }
87 //-----------------------------------------------------------------------------
89 {
91 }
92 //-----------------------------------------------------------------------------
void rotate(real degrees, real x, real y, real z)
Utility function equivalent to setLocalMatrix( mat4::getRotation(degrees,x,y,z)*localMatrix() )...
Definition: Transform.cpp:73
std::vector< ref< Transform > > mChildren
Definition: Transform.hpp:435
static void warning(const String &message)
Use this function to provide information about situations that might lead to errors or loss of data...
Definition: Log.cpp:155
void setLocalMatrix(const mat4 &m)
The matrix representing the transform&#39;s local space.
Definition: Transform.hpp:139
T degrees(T radians)
Definition: glsl_math.hpp:173
void translate(real x, real y, real z)
Utility function equivalent to setLocalMatrix( mat4::getTranslation(x,y,z)*localMatrix() )...
Definition: Transform.cpp:58
const mat4 & localMatrix() const
The matrix representing the transform&#39;s local space.
Definition: Transform.hpp:145
~Transform()
Destructor.
Definition: Transform.cpp:44
Visualization Library main namespace.
void preMultiply(const mat4 &m)
Utility function equivalent to setLocalMatrix( m*localMatrix() ).
Definition: Transform.cpp:83
void postMultiply(const mat4 &m)
Utility function equivalent to setLocalMatrix( localMatrix()*m ).
Definition: Transform.cpp:88
#define NULL
Definition: OpenGLDefs.hpp:81
const mat4 & worldMatrix() const
Returns the world matrix used for rendering.
Definition: Transform.hpp:168
static Matrix4 & getRotation(Matrix4 &out, float degrees, float x, float y, float z)
Definition: Matrix4.hpp:904
static Matrix4 & getTranslation(Matrix4 &out, const Vector3< float > &v)
Definition: Matrix4.hpp:548
static Matrix4 & getScaling(Matrix4 &out, const Vector3< float > &v)
Definition: Matrix4.hpp:584
void scale(real x, real y, real z)
Utility function equivalent to setLocalMatrix( mat4::getScaling(x,y,z)*localMatrix() )...
Definition: Transform.cpp:68