| Support Forum Library Source SourceForge Page G3D Web Page |
Quake II model class primarily used for low-polygon keyframe animated characters. More...
Inherits G3D::Model.
Classes | |
| class | MD2AnimInfo |
| class | Part |
| class | Pose |
| class | Specification |
Public Types | |
| enum | Animation { JUMP_UP = -6, CROUCH_WALK_BACKWARD = -13, RUN_BACKWARD = -1, STAND = 0, RUN = 1, ATTACK = 2, PAIN_A = 3, PAIN_B = 4, PAIN_C = 5, JUMP_DOWN = 6, FLIP = 7, SALUTE = 8, FALLBACK = 9, WAVE = 10, POINT = 11, CROUCH_STAND = 12, CROUCH_WALK = 13, CROUCH_ATTACK = 14, CROUCH_PAIN = 15, CROUCH_DEATH = 16, DEATH_FALLBACK = 17, DEATH_FALLFORWARD = 18, DEATH_FALLBACKSLOW = 19, JUMP = 20, MAX_ANIMATIONS = 21 } |
| These names are (mostly) from Quake II. More... | |
| typedef shared_ptr< MD2Model > | Ref |
Public Member Functions | |
| const std::string & | name () const |
| int | numParts () const |
| Either 1 or 2, depending on whether a weapon is present. | |
| int | numTriangles () const |
| Total number of triangles in the mesh. | |
| void | pose (Array< shared_ptr< Surface > > &surfaceArray, const CoordinateFrame &rootFrame, const CoordinateFrame &prevRootFrame, const Pose &pose=Pose()) |
| void | pose (Array< shared_ptr< Surface > > &surfaceArray, const CoordinateFrame &rootFrame=CoordinateFrame(), const Pose ¤tPose=Pose()) |
Static Public Member Functions | |
| static bool | animationAttack (Animation a) |
| static bool | animationCrouch (Animation a) |
| Returns true for the crouching set of animations. | |
| static bool | animationDeath (Animation a) |
| Returns true for the death animations. | |
| static bool | animationInterruptible (Animation a) |
| True for actions that can be interrupted, like running or saluting. | |
| static bool | animationJump (Animation a) |
| static GameTime | animationLength (Animation a) |
| Returns the total time of the animation. | |
| static bool | animationLoops (Animation a) |
| Returns true for standing, running, crouching, and crouch walking animations. | |
| static bool | animationPain (Animation A) |
| static bool | animationRun (Animation a) |
| running, forward or backward, standing or crouching | |
| static bool | animationRunBackward (Animation a) |
| static bool | animationRunForward (Animation a) |
| static bool | animationStand (Animation a) |
| STAND or CROUCH_STAND. | |
| static void | computeFrameNumbers (const Pose &pose, int &kf0, int &kf1, float &alpha) |
| Computes the previous and next frame indices and how far we are between them. | |
| static Ref | create (const Specification &s, const std::string &name="") |
| Create a new MD2Model. | |
| static int | getFrameNumber (const Pose &pose) |
| Returns a value for MD2Model::Pose::preFrameNumber that will smoothly blend from this animation to the next one. | |
| static void | setNormalTable () |
| Loads data into the normalTable. | |
Static Public Attributes | |
| static const MD2AnimInfo | animationTable [MAX_ANIMATIONS] |
| Information relating Animations to keyFrames. | |
| static const float | hangTimePct |
| How long we hold in the air as a fraction of jump time. | |
| static Vector3 | normalTable [162] |
| Quake uses a set of canonical normal vectors. | |
| static const GameTime | PRE_BLEND_TIME |
| Amount of time to blend between two animations. | |
Protected Attributes | |
| std::string | m_name |
| int | m_numTriangles |
| Array< Part::Ref > | m_part |
| bool | negateNormals |
| If true, negate the normal direction on this object when rendering. | |
Quake II model class primarily used for low-polygon keyframe animated characters.
Quake II models contain up to two parts, where the second part is typically a weapon. Each part is a single mesh that is keyframe animated. Because the vertex positions and normals are highly quantized, these models tend to distort a bit under animation.
Models are centered about their waist. To figure out where the feet are you might want to look at the bounding box for the stand/walk animations.
This class is not threadsafe; you cannot even call methods on two different instances on different threads.
When getting geometry from the posed model, the normalArray values are interpolated and often have slightly less than unit length.
When available, this class uses SSE instructions for fast vertex blending. This cuts the time for getGeometry by a factor of 2 on most processors.
Sample posing code:
You can specify multiple fields of the Action and the onSimulation method will resolve the best underlying animation.
| typedef shared_ptr<MD2Model> G3D::MD2Model::Ref |
These names are (mostly) from Quake II.
FLIP, SALUTE, FALLBACK, WAVE, and POINT are all taunts. A negative number means to run the specified animation backwards. The JUMP animation is Quake's jump animation backwards followed by the same animation forwards.
|
static |
|
static |
Returns true for the crouching set of animations.
|
static |
Returns true for the death animations.
|
static |
True for actions that can be interrupted, like running or saluting.
Jumping (which is really more of a falling animation) is considered interruptible.
|
static |
Returns the total time of the animation.
If the animation loops (e.g. walking) this is the time from the first frame until that frame repeats. If the animation does not loop (e.g. death) this is the time from the first frame until the last frame.
|
static |
Returns true for standing, running, crouching, and crouch walking animations.
|
static |
|
static |
running, forward or backward, standing or crouching
|
static |
|
static |
|
static |
STAND or CROUCH_STAND.
|
static |
Computes the previous and next frame indices and how far we are between them.
|
static |
Create a new MD2Model.
Note that this can also be invoked with the path name of a single tris.md2 file as an std::string, which will automatically cast to a MD2Model::Specification.
Returns a value for MD2Model::Pose::preFrameNumber that will smoothly blend from this animation to the next one.
|
inline |
|
inline |
Either 1 or 2, depending on whether a weapon is present.
|
inline |
Total number of triangles in the mesh.
| void G3D::MD2Model::pose | ( | Array< shared_ptr< Surface > > & | surfaceArray, |
| const CoordinateFrame & | rootFrame, | ||
| const CoordinateFrame & | prevRootFrame, | ||
| const Pose & | pose = Pose() |
||
| ) |
Referenced by pose().
|
inline |
|
static |
Loads data into the normalTable.
|
static |
Information relating Animations to keyFrames.
Used by computeFrameNumbers().
|
static |
How long we hold in the air as a fraction of jump time.
|
protected |
Referenced by name().
|
protected |
Referenced by numTriangles().
Referenced by numParts().
|
protected |
If true, negate the normal direction on this object when rendering.
|
static |
Quake uses a set of canonical normal vectors.
|
static |
Amount of time to blend between two animations.
1.8.2