scg3  0.6
Transformation.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2014-2019 Volker Ahlers
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24 
25 #ifndef TRANSFORMATION_H_
26 #define TRANSFORMATION_H_
27 
28 #include "scg_glew.h"
29 #include "Composite.h"
30 #include "scg_glm.h"
31 #include "scg_internals.h"
32 
33 namespace scg {
34 
35 
36 class Traverser;
37 
38 
42 class Transformation: public Composite {
43 
44 public:
45 
50 
54  virtual ~Transformation();
55 
59  static TransformationSP create();
60 
64  const glm::mat4& getMatrix() const;
65 
70  virtual Transformation* setMatrix(const glm::mat4& matrix);
71 
77  virtual Transformation* translate(glm::vec3 translation);
78 
85  virtual Transformation* rotateRad(GLfloat angleRad, glm::vec3 axis);
86 
93  virtual Transformation* rotate(GLfloat angleDeg, glm::vec3 axis) {
94  return rotateRad(glm::radians(angleDeg), axis);
95  }
96 
102  virtual Transformation* scale(glm::vec3 scaling);
103 
107  virtual void accept(Traverser* traverser);
108 
112  virtual void acceptPost(Traverser* traverser);
113 
118  virtual void render(RenderState* renderState);
119 
123  virtual void renderPost(RenderState* renderState);
124 
125 protected:
126 
127  glm::mat4 matrix_;
128 
129 };
130 
131 
132 } /* namespace scg */
133 
134 
135 #endif /* TRANSFORMATION_H_ */
virtual Transformation * rotateRad(GLfloat angleRad, glm::vec3 axis)
virtual Transformation * scale(glm::vec3 scaling)
Base class for all composite nodes, i.e., nodes with children (composite pattern, abstract).
Local header file for GLM OpenGL Mathematics library.
Base class for all composite nodes, i.e., nodes with children (composite pattern, abstract).
Definition: Composite.h:37
static TransformationSP create()
virtual ~Transformation()
virtual void render(RenderState *renderState)
Base class for all traversers (visitor pattern, abstract).
Definition: Traverser.h:36
const glm::mat4 & getMatrix() const
Local header file for GLEW library.
virtual void renderPost(RenderState *renderState)
virtual void accept(Traverser *traverser)
virtual void acceptPost(Traverser *traverser)
The central render state that collects information about the current shader, transformations,...
Definition: RenderState.h:107
virtual Transformation * rotate(GLfloat angleDeg, glm::vec3 axis)
A transformation node to be used to appy a transformation to the sub-tree (composite node).
virtual Transformation * translate(glm::vec3 translation)
Definition: Animation.h:28
Internal definitions required by most classes.
virtual Transformation * setMatrix(const glm::mat4 &matrix)