Skip to content

Commit

Permalink
GRAPHICS: Add initial stubs for animation and animnode classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jbowtie authored and DrMcCoy committed Apr 21, 2012
1 parent cf993fa commit 0cb55d7
Show file tree
Hide file tree
Showing 8 changed files with 344 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/graphics/aurora/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ noinst_HEADERS = types.h \
guiquad.h \
modelnode.h \
model.h \
animnode.h \
animation.h \
model_nwn.h \
model_nwn2.h \
model_kotor.h \
Expand All @@ -38,6 +40,8 @@ libaurora_la_SOURCES = texture.cpp \
guiquad.cpp \
modelnode.cpp \
model.cpp \
animnode.cpp \
animation.cpp \
model_nwn.cpp \
model_nwn2.cpp \
model_kotor.cpp \
Expand Down
58 changes: 58 additions & 0 deletions src/graphics/aurora/animation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names can be
* found in the AUTHORS file distributed with this source
* distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* The Infinity, Aurora, Odyssey and Eclipse engines, Copyright (c) BioWare corp.
* The Electron engine, Copyright (c) Obsidian Entertainment and BioWare corp.
*/

/** @file graphics/aurora/animation.cpp
* An animation to be applied to a model.
*/

#include "common/stream.h"

#include "graphics/graphics.h"
#include "graphics/camera.h"

#include "graphics/aurora/model.h"
#include "graphics/aurora/modelnode.h"
#include "graphics/aurora/animation.h"
#include "graphics/aurora/animnode.h"

namespace Graphics {

namespace Aurora {

Animation::Animation()
{

}

Animation::~Animation() {
}

const Common::UString &Model::getName() const {
return _name;
}

} // End of namespace Aurora

} // End of namespace Graphics
102 changes: 102 additions & 0 deletions src/graphics/aurora/animation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names can be
* found in the AUTHORS file distributed with this source
* distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* The Infinity, Aurora, Odyssey and Eclipse engines, Copyright (c) BioWare corp.
* The Electron engine, Copyright (c) Obsidian Entertainment and BioWare corp.
*/

/** @file graphics/aurora/animation.h
* An animation to be applied to a model.
*/

#ifndef GRAPHICS_AURORA_ANIMATION_H
#define GRAPHICS_AURORA_ANIMATION_H

#include <vector>
#include <list>
#include <map>

#include "common/ustring.h"
#include "common/transmatrix.h"
#include "common/boundingbox.h"

#include "graphics/types.h"
#include "graphics/glcontainer.h"
#include "graphics/renderable.h"

#include "graphics/aurora/types.h"

namespace Common {
class SeekableReadStream;
}

namespace Graphics {

namespace Aurora {

class AnimNode;

class Animation {
public:
Animation();
~Animation();

/** Get the animation's name. */
const Common::UString &getName() const;

// Nodes

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

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

protected:
typedef std::list<AnimNode *> NodeList;
typedef std::map<Common::UString, AnimNode *, Common::UString::iless> NodeMap;

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

/*
public:
// General loading helpers
static void readValue(Common::SeekableReadStream &stream, uint32 &value);
static void readValue(Common::SeekableReadStream &stream, float &value);
static void readArrayDef(Common::SeekableReadStream &stream,
uint32 &offset, uint32 &count);
template<typename T>
static void readArray(Common::SeekableReadStream &stream,
uint32 offset, uint32 count, std::vector<T> &values);
friend class AnimNode;*/
};

} // End of namespace Aurora

} // End of namespace Graphics

#endif // GRAPHICS_AURORA_ANIMATION_H
69 changes: 69 additions & 0 deletions src/graphics/aurora/animnode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names can be
* found in the AUTHORS file distributed with this source
* distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* The Infinity, Aurora, Odyssey and Eclipse engines, Copyright (c) BioWare corp.
* The Electron engine, Copyright (c) Obsidian Entertainment and BioWare corp.
*/

/** @file graphics/aurora/modelnode.cpp
* A node within a 3D model.
*/

#include "common/util.h"
#include "common/maths.h"

#include "graphics/aurora/modelnode.h"
#include "graphics/aurora/animnode.h"
#include "graphics/aurora/animation.h"
#include "graphics/aurora/model.h"

namespace Graphics {

namespace Aurora {


AnimNode::AnimNode(Animation &animation) :
_animation(&animation), _parent(0)
{
}

AnimNode::~AnimNode() {
}

AnimNode *AnimNode::getParent() {
return _parent;
}

const AnimNode *AnimNode::getParent() const {
return _parent;
}

void AnimNode::setParent(AnimNode *parent) {
_parent = parent;
}

const Common::UString &AnimNode::getName() const {
return _name;
}

} // End of namespace Aurora

} // End of namespace Graphics
87 changes: 87 additions & 0 deletions src/graphics/aurora/animnode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names can be
* found in the AUTHORS file distributed with this source
* distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* The Infinity, Aurora, Odyssey and Eclipse engines, Copyright (c) BioWare corp.
* The Electron engine, Copyright (c) Obsidian Entertainment and BioWare corp.
*/

/** @file graphics/aurora/animnode.h
* A node within an animation.
*/

#ifndef GRAPHICS_AURORA_ANIMNODE_H
#define GRAPHICS_AURORA_ANIMNODE_H

#include <list>
#include <vector>

#include "common/ustring.h"
#include "common/transmatrix.h"
#include "common/boundingbox.h"

#include "graphics/types.h"

#include "graphics/aurora/types.h"
#include "graphics/aurora/textureman.h"

namespace Graphics {

namespace Aurora {

class Animation;

class AnimNode {
public:
AnimNode(Animation &anim);
~AnimNode();

/** Get the node's name. */
const Common::UString &getName() const;

protected:
Animation *_animation; ///< The animation this node belongs to.

AnimNode *_parent; ///< The node's parent.
std::list<AnimNode *> _children; ///< The node's children.

Common::UString _name; ///< The node's name.

//void render(RenderPass pass);

public:
// General helpers

AnimNode *getParent(); ///< Get the node's parent.
const AnimNode *getParent() const; ///< Get the node's parent.

void setParent(AnimNode *parent); ///< Set the node's parent.

//void reparent(AnimNode &parent);


friend class Animation;
};

} // End of namespace Aurora

} // End of namespace Graphics

#endif // GRAPHICS_AURORA_ANIMNODE_H
1 change: 1 addition & 0 deletions src/graphics/aurora/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "graphics/camera.h"

#include "graphics/aurora/model.h"
#include "graphics/aurora/animation.h"
#include "graphics/aurora/modelnode.h"

namespace Graphics {
Expand Down
2 changes: 2 additions & 0 deletions src/graphics/aurora/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace Graphics {
namespace Aurora {

class ModelNode;
class Animation;

class Model : public GLContainer, public Renderable {
public:
Expand Down Expand Up @@ -132,6 +133,7 @@ class Model : public GLContainer, public Renderable {
protected:
typedef std::list<ModelNode *> NodeList;
typedef std::map<Common::UString, ModelNode *, Common::UString::iless> NodeMap;
typedef std::map<Common::UString, Animation *, Common::UString::iless> AnimationMap;

/** A model state. */
struct State {
Expand Down
21 changes: 21 additions & 0 deletions src/graphics/aurora/model_nwn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,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
}

void Model_NWN::addState(ParserContext &ctx) {
Expand Down

0 comments on commit 0cb55d7

Please sign in to comment.