Skip to content

Commit

Permalink
FORMATTING: Run astyle to correct tab usage and bracket placement
Browse files Browse the repository at this point in the history
  • Loading branch information
jbowtie authored and DrMcCoy committed Apr 21, 2012
1 parent 7eb9f56 commit b9ad1e9
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 79 deletions.
8 changes: 3 additions & 5 deletions src/graphics/aurora/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ namespace Graphics {

namespace Aurora {

Animation::Animation()
{
Animation::Animation() {

}

Expand All @@ -56,16 +55,15 @@ const Common::UString &Animation::getName() const {
return _name;
}

void Animation::update(Model *model, float lastFrame, float nextFrame)
{
void Animation::update(Model *model, float lastFrame, float nextFrame) {
//TODO: loop through animnodes and have them update modelnodes
debugC(4, kDebugGraphics, "Playing animation in model \"%s\" @ time %f", model->getName().c_str(), lastFrame);
//also need to fire off associated events
//for event in _events event->fire()
//for animnode in nodes
//animnode.update(model, lastframe, nextframe)
for (NodeList::iterator n = nodeList.begin();
n != nodeList.end(); ++n) {
n != nodeList.end(); ++n) {
(*n)->update(model, lastFrame, nextFrame);
}
}
Expand Down
41 changes: 25 additions & 16 deletions src/graphics/aurora/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,41 @@ class Animation {
// Nodes

/** Does the specified node exist in the current state? */
// bool hasNode(const Common::UString &node) const;
// bool hasNode(const Common::UString &node) const;

/** Get the specified node, from the current state. */
// AnimNode *getNode(const Common::UString &node);
// AnimNode *getNode(const Common::UString &node);
/** Get the specified node, from the current state. */
// const AnimNode *getNode(const Common::UString &node) const;
// const AnimNode *getNode(const Common::UString &node) const;

typedef std::list<AnimNode *> NodeList;
typedef std::map<Common::UString, AnimNode *, Common::UString::iless> NodeMap;
NodeList nodeList; ///< The nodes within the state.
NodeMap nodeMap; ///< The nodes within the state, indexed by name.
NodeList nodeList; ///< The nodes within the state.
NodeMap nodeMap; ///< The nodes within the state, indexed by name.

NodeList rootNodes; ///< The nodes in the state without a parent.
NodeList rootNodes; ///< The nodes in the state without a parent.
protected:

Common::UString _name; ///< The model's name.
float _length;
float _transtime;
float _length;
float _transtime;

public:
void setLength(float length) {_length=length;}
float getLength() {return _length;}
void setTransTime(float transtime) {_transtime=transtime;}
void setName(Common::UString& name) {_name=name;}

void update(Model *model, float lastFrame, float nextFrame);
/*
void setLength(float length) {
_length=length;
}
float getLength() {
return _length;
}
void setTransTime(float transtime) {
_transtime=transtime;
}
void setName(Common::UString& name) {
_name=name;
}

void update(Model *model, float lastFrame, float nextFrame);
/*
// General loading helpers
static void readValue(Common::SeekableReadStream &stream, uint32 &value);
Expand All @@ -104,7 +112,8 @@ class Animation {
static void readArray(Common::SeekableReadStream &stream,
uint32 offset, uint32 count, std::vector<T> &values);
friend class AnimNode;*/
friend class AnimNode;
*/
};

} // End of namespace Aurora
Expand Down
3 changes: 1 addition & 2 deletions src/graphics/aurora/animnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ const Common::UString &AnimNode::getName() const {
return _name;
}

void AnimNode::update(Model *model, float lastFrame, float nextFrame)
{
void AnimNode::update(Model *model, float lastFrame, float nextFrame) {
if(!_nodedata)
return;
//determine the corresponding keyframes
Expand Down
13 changes: 5 additions & 8 deletions src/graphics/aurora/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ namespace Aurora {

Model::Model(ModelType type) : Renderable((RenderableType) type),
_type(type), _supermodel(0), _currentState(0),
_currentAnimation(0), _nextAnimation(0), _drawBound(false),
_lists(0) {
_currentAnimation(0), _nextAnimation(0), _drawBound(false),
_lists(0) {

for (int i = 0; i < kRenderPassAll; i++)
_needBuild[i] = true;
Expand Down Expand Up @@ -436,8 +436,7 @@ bool Model::buildList(RenderPass pass) {
return true;
}

void Model::advanceTime(float dt)
{
void Model::advanceTime(float dt) {
manageAnimations(dt);
}

Expand All @@ -447,8 +446,7 @@ void Model::manageAnimations(float dt) {
_elapsedTime = nextFrame;

// start a new animation if scheduled
if(_nextAnimation)
{
if(_nextAnimation) {
// note that this interrupts the current animation!
_currentAnimation = _nextAnimation;
_nextAnimation = 0;
Expand All @@ -464,8 +462,7 @@ void Model::manageAnimations(float dt) {

// if the current animation has finished,
// start a default animation
if(_currentAnimation && nextFrame >= _currentAnimation->getLength())
{
if(_currentAnimation && nextFrame >= _currentAnimation->getLength()) {
//debug output
selectDefaultAnimation();
_elapsedTime = 0.0f;
Expand Down
22 changes: 11 additions & 11 deletions src/graphics/aurora/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,16 @@ class Model : public GLContainer, public Renderable {
const ModelNode *getNode(const Common::UString &node) const;


// Animation
// Animation

/** Get the specified node, from the current state. */
Animation *getAnimation(const Common::UString &anim);
/** play a named animation */
void playAnimation(const Common::UString &anim);
/** create the list of default animations */
void populateDefaultAnimations();
/** select the default idle animation */
void selectDefaultAnimation();
/** play a named animation */
void playAnimation(const Common::UString &anim);
/** create the list of default animations */
void populateDefaultAnimations();
/** select the default idle animation */
void selectDefaultAnimation();

// Renderable
void calculateDistance();
Expand Down Expand Up @@ -176,10 +176,10 @@ class Model : public GLContainer, public Renderable {

std::list<Common::UString> _stateNames; ///< All state names.

AnimationMap _animationMap;
AnimationList _defaultAnimations;
Animation *_currentAnimation;
Animation *_nextAnimation;
AnimationMap _animationMap;
AnimationList _defaultAnimations;
Animation *_currentAnimation;
Animation *_nextAnimation;

float _modelScale[3]; ///< The model's scale.

Expand Down
54 changes: 27 additions & 27 deletions src/graphics/aurora/model_nwn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void Model_NWN::ParserContext::clear() {
}

bool Model_NWN::ParserContext::findNode(const Common::UString &name,
ModelNode *&node) const {
ModelNode *&node) const {

node = 0;

Expand Down Expand Up @@ -374,27 +374,27 @@ void Model_NWN::skipAnimASCII(ParserContext &ctx) {

void Model_NWN::readAnimASCII(ParserContext &ctx) {
// TODO: Model_NWN_ASCII::readAnimASCII
// read in the animation name
// there should be a list of animations
// each with a bunch of animnodes
// each animnode targets a model node
// and has a list of position, orientation keyframes
// (at time t, position, orientation = x)
//
// at render time/playAnimation
// -- if there's a default animation we should always be playing that?
// determine time t
// for each animnode look up surrounding keyframes
// interpolate to get real position, orientation
// when rendering the node, apply the position, orientation
//
// models have a current and next animation
// next animation is set by playanimation
// when current animation expires, we schedule next one
// if next is null either loop or select a random
// default animation for the current
// when there is an active animation
// track time t and apply animnodes
// read in the animation name
// there should be a list of animations
// each with a bunch of animnodes
// each animnode targets a model node
// and has a list of position, orientation keyframes
// (at time t, position, orientation = x)
//
// at render time/playAnimation
// -- if there's a default animation we should always be playing that?
// determine time t
// for each animnode look up surrounding keyframes
// interpolate to get real position, orientation
// when rendering the node, apply the position, orientation
//
// models have a current and next animation
// next animation is set by playanimation
// when current animation expires, we schedule next one
// if next is null either loop or select a random
// default animation for the current
// when there is an active animation
// track time t and apply animnodes
}

void Model_NWN::addState(ParserContext &ctx) {
Expand Down Expand Up @@ -476,10 +476,10 @@ void Model_NWN::readAnimBinary(ParserContext &ctx, uint32 offset) {
debugC(4, kDebugGraphics, "Loaded animation \"%s\" in model \"%s\"", ctx.state->name.c_str(), _name.c_str());

for (std::list<ModelNode *>::iterator n = ctx.nodes.begin();
n != ctx.nodes.end(); ++n) {
AnimNode* animnode = new AnimNode(*n);
anim->nodeList.push_back(animnode);
anim->nodeMap.insert(std::make_pair(animnode->getName(), animnode));
n != ctx.nodes.end(); ++n) {
AnimNode* animnode = new AnimNode(*n);
anim->nodeList.push_back(animnode);
anim->nodeMap.insert(std::make_pair(animnode->getName(), animnode));
}

}
Expand Down Expand Up @@ -816,7 +816,7 @@ void ModelNode_NWN_Binary::readAnim(Model_NWN::ParserContext &ctx) {
}

void ModelNode_NWN_Binary::readNodeControllers(Model_NWN::ParserContext &ctx,
uint32 offset, uint32 count, std::vector<float> &data) {
uint32 offset, uint32 count, std::vector<float> &data) {

uint32 pos = ctx.mdl->seekTo(offset);

Expand Down
10 changes: 4 additions & 6 deletions src/graphics/aurora/modelnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ void ModelNode::renderGeometry() {

glBegin(GL_TRIANGLES);
for (uint32 f = 0; f < _faceCount; f++, vX += 3, vY += 3, vZ += 3,
tX += 3 * textureCount, tY += 3 * textureCount) {
tX += 3 * textureCount, tY += 3 * textureCount) {

// Texture vertex A
for (uint32 t = 0; t < textureCount; t++)
Expand Down Expand Up @@ -487,7 +487,7 @@ void ModelNode::render(RenderPass pass) {

bool shouldRender = _render && (_faceCount > 0);
if (((pass == kRenderPassOpaque) && _isTransparent) ||
((pass == kRenderPassTransparent) && !_isTransparent))
((pass == kRenderPassTransparent) && !_isTransparent))
shouldRender = false;

if (shouldRender)
Expand All @@ -511,8 +511,7 @@ void ModelNode::interpolatePosition(float time, float &x, float &y, float &z) co
}

int lastFrame = 0;
for(uint32 i = 0; i < _positionFrames.size(); i++)
{
for(uint32 i = 0; i < _positionFrames.size(); i++) {
PositionKeyFrame pos = _positionFrames[i];
if(pos.time < time)
lastFrame = i;
Expand All @@ -535,8 +534,7 @@ void ModelNode::interpolateOrientation(float time, float &x, float &y, float &z,
}

int lastFrame = 0;
for(uint32 i = 0; i < _orientationFrames.size(); i++)
{
for(uint32 i = 0; i < _orientationFrames.size(); i++) {
QuaternionKeyFrame pos = _orientationFrames[i];
if(pos.time < time)
lastFrame = i;
Expand Down
6 changes: 2 additions & 4 deletions src/graphics/aurora/modelnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,14 @@ namespace Aurora {

class Model;

struct PositionKeyFrame
{
struct PositionKeyFrame {
float time;
float x;
float y;
float z;
};

struct QuaternionKeyFrame
{
struct QuaternionKeyFrame {
float time;
float x;
float y;
Expand Down

0 comments on commit b9ad1e9

Please sign in to comment.