transform.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "tango-gl/transform.h"
18 #include "tango-gl/util.h"
19 
20 #define nullptr 0
21 
22 namespace tango_gl {
23 
25  : parent_(nullptr),
26  position_(0.0f, 0.0f, 0.0f),
27  rotation_(1.0f, 0.0f, 0.0f, 0.0f),
28  scale_(1.0f, 1.0f, 1.0f) {
29 }
30 
32  // Objects are not responsible for deleting their parents.
33 }
34 
35 void Transform::SetPosition(const glm::vec3& position) {
36  position_ = position;
37 }
38 
40  return position_;
41 }
42 
45 }
46 
48  return rotation_;
49 }
50 
52  scale_ = scale;
53 }
54 
56  return scale_;
57 }
58 
59 void Transform::Translate(const glm::vec3& translation) {
60  position_ += translation;
61 }
62 
63 void Transform::SetTransformationMatrix(const glm::mat4& transform_mat) {
65 }
66 
69  trans_mat[3][0] = position_.x;
70  trans_mat[3][1] = position_.y;
71  trans_mat[3][2] = position_.z;
72  glm::mat4 parent_mat = glm::mat4(1.0f);
73  if (parent_ != NULL) {
74  parent_mat = parent_->GetTransformationMatrix();
75  trans_mat = parent_mat * trans_mat;
76  }
77  return trans_mat;
78 }
79 
80 void Transform::SetParent(Transform* transform) {
81  parent_ = transform;
82 }
83 
85  return parent_;
86 }
87 
89  return parent_;
90 }
91 
92 } // namespace tango_gl
glm::vec3 GetPosition() const
Definition: transform.cpp:39
#define NULL
glm::vec3 scale_
Definition: transform.h:56
Transform * parent_
Definition: transform.h:52
void SetRotation(const glm::quat &rotation)
Definition: transform.cpp:43
f
glm::mat4 GetTransformationMatrix() const
Definition: transform.cpp:67
GLM_FUNC_DECL detail::tmat4x4< T, P > scale(detail::tmat4x4< T, P > const &m, detail::tvec3< T, P > const &v)
glm::quat GetRotation() const
Definition: transform.cpp:47
const Transform * GetParent() const
Definition: transform.cpp:84
void Translate(const glm::vec3 &translation)
Definition: transform.cpp:59
#define nullptr
Definition: transform.cpp:20
GLM_FUNC_DECL detail::tmat4x4< T, P > mat4_cast(detail::tquat< T, P > const &x)
void SetParent(Transform *transform)
Definition: transform.cpp:80
virtual ~Transform()
Definition: transform.cpp:31
glm::vec3 position_
Definition: transform.h:54
GLM_FUNC_DECL detail::tquat< T, P > rotation(detail::tvec3< T, P > const &orig, detail::tvec3< T, P > const &dest)
void SetTransformationMatrix(const glm::mat4 &transform_mat)
Definition: transform.cpp:63
glm::vec3 GetScale() const
Definition: transform.cpp:55
mat4x4 mat4
Definition: type_mat.hpp:441
glm::quat rotation_
Definition: transform.h:55
void DecomposeMatrix(const glm::mat4 &transform_mat, glm::vec3 &translation, glm::quat &rotation, glm::vec3 &scale)
Definition: util.cpp:115
void SetPosition(const glm::vec3 &position)
Definition: transform.cpp:35
void SetScale(const glm::vec3 &scale)
Definition: transform.cpp:51


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:37:06