Skip to content

Commit

Permalink
GRAPHICS: Add Model::getCenter() and Model::getAbsoluteCenter()
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Dec 25, 2012
1 parent 6656155 commit b8ec5d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/graphics/aurora/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,22 @@ void Model::setRotation(float x, float y, float z) {
GfxMan.unlockFrame();
}

void Model::getCenter(float &x, float &y, float &z) {
x = _center[0] * _modelScale[0];
y = _center[1] * _modelScale[1];
z = _center[2] * _modelScale[2];
}

void Model::getAbsoluteCenter(float &x, float &y, float &z) {
Common::TransformationMatrix center = _absolutePosition;

center.translate(_center[0], _center[1], _center[2]);

x = center.getX();
y = center.getY();
z = center.getZ();
}

void Model::move(float x, float y, float z) {
x /= _modelScale[0];
y /= _modelScale[1];
Expand Down
5 changes: 5 additions & 0 deletions src/graphics/aurora/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class Model : public GLContainer, public Renderable {
/** Set the current rotation of the model. */
void setRotation(float x, float y, float z);

/** Get the model's center position. */
void getCenter(float &x, float &y, float &z);
/** Get the model's center position after translate/rotate. */
void getAbsoluteCenter(float &x, float &y, float &z);

/** Move the model, relative to its current position. */
void move (float x, float y, float z);
/** Rotate the model, relative to its current rotation. */
Expand Down

0 comments on commit b8ec5d7

Please sign in to comment.