xoreos  0.0.5
geometryobject.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/util.h"
26 
29 
30 namespace Graphics {
31 
32 namespace Aurora {
33 
35  Renderable(kRenderableTypeObject), _vertexBuffer(vBuf), _indexBuffer(iBuf) {
36 
37  _position[0] = 0.0f;
38  _position[1] = 0.0f;
39  _position[2] = 0.0f;
40  _rotation[0] = 0.0f;
41  _rotation[1] = 0.0f;
42  _rotation[2] = 0.0f;
43 }
44 
46 }
47 
48 void GeometryObject::getPosition(float &x, float &y, float &z) const {
49  x = _position[0];
50  y = _position[1];
51  z = _position[2];
52 }
53 
54 void GeometryObject::getRotation(float &x, float &y, float &z) const {
55  x = _rotation[0];
56  y = _rotation[1];
57  z = _rotation[2];
58 }
59 
60 void GeometryObject::setPosition(float x, float y, float z) {
62 
63  _position[0] = x;
64  _position[1] = y;
65  _position[2] = z;
66 
68 
69  resort();
70 
72 }
73 
74 void GeometryObject::setRotation(float x, float y, float z) {
76 
77  _rotation[0] = x;
78  _rotation[1] = y;
79  _rotation[2] = z;
80 
82 
83  resort();
84 
86 }
87 
88 void GeometryObject::move(float x, float y, float z) {
89  setPosition(_position[0] + x, _position[1] + y, _position[2] + z);
90 }
91 
92 void GeometryObject::rotate(float x, float y, float z) {
93  setRotation(_rotation[0] + x, _rotation[1] + y, _rotation[2] + z);
94 }
95 
97  _distance = 0;
98 }
99 
102  return;
103 
104  glTranslatef(_position[0], _position[1], _position[2]);
105 
106  glRotatef(_rotation[0], 1.0f, 0.0f, 0.0f);
107  glRotatef(_rotation[1], 0.0f, 1.0f, 0.0f);
108  glRotatef(_rotation[2], 0.0f, 0.0f, 1.0f);
109 
110  TextureMan.reset();
111 
112  _vertexBuffer.draw(GL_TRIANGLES, _indexBuffer);
113 }
114 
115 } // End of namespace Aurora
116 
117 } // End of namespace Graphics
GeometryObject(const VertexBuffer &vBuf, const IndexBuffer &iBuf)
Only render transparent parts.
Definition: types.h:99
void calculateDistance()
Calculate the object&#39;s distance.
#define TextureMan
Shortcut for accessing the texture manager.
Definition: textureman.h:127
double _distance
The distance of the object from the viewer.
Definition: renderable.h:101
The Aurora texture manager.
void setPosition(float x, float y, float z)
Set the current position of the model.
void getPosition(float &x, float &y, float &z) const
Get the current position of the model.
RenderPass
Definition: types.h:97
void rotate(float x, float y, float z)
Rotate the model, relative to its current rotation.
Utility templates and functions.
void render(RenderPass pass)
Render the object.
Buffer containing vertex data.
Definition: vertexbuffer.h:68
void getRotation(float &x, float &y, float &z) const
Get the current rotation of the model.
An object that can be displayed by the graphics manager.
Definition: renderable.h:42
void draw(GLenum mode, const IndexBuffer &indexBuffer) const
Draw this IndexBuffer/VertexBuffer combination.
Buffer containing indices data.
Definition: indexbuffer.h:33
#define pass
Definition: fft.cpp:257
A simple 3D object.
void setRotation(float x, float y, float z)
Set the current rotation of the model.
void move(float x, float y, float z)
Move the model, relative to its current position.