Support Forum       Library Source       SourceForge Page       G3D Web Page     
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
G3D::MD2Model Class Reference

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< MD2ModelRef
 

Public Member Functions

const std::stringname () 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 &currentPose=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::Refm_part
 
bool negateNormals
 If true, negate the normal direction on this object when rendering.
 

Detailed Description

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:

MD2Model::Pose::Action a;
a.movingForward = true;
pose.onSimulation(dt, a);

You can specify multiple fields of the Action and the onSimulation method will resolve the best underlying animation.

See Also
G3D::MD3Model, G3D::ArticulatedModel, G3D::IFSModel, G3D::Entity

Member Typedef Documentation

typedef shared_ptr<MD2Model> G3D::MD2Model::Ref

Member Enumeration Documentation

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.

Enumerator:
JUMP_UP 
CROUCH_WALK_BACKWARD 
RUN_BACKWARD 
STAND 
RUN 
ATTACK 
PAIN_A 
PAIN_B 
PAIN_C 
JUMP_DOWN 
FLIP 
SALUTE 
FALLBACK 
WAVE 
POINT 
CROUCH_STAND 
CROUCH_WALK 
CROUCH_ATTACK 
CROUCH_PAIN 
CROUCH_DEATH 
DEATH_FALLBACK 
DEATH_FALLFORWARD 
DEATH_FALLBACKSLOW 
JUMP 
MAX_ANIMATIONS 

Member Function Documentation

static bool G3D::MD2Model::animationAttack ( Animation  a)
static
static bool G3D::MD2Model::animationCrouch ( Animation  a)
static

Returns true for the crouching set of animations.

static bool G3D::MD2Model::animationDeath ( Animation  a)
static

Returns true for the death animations.

static bool G3D::MD2Model::animationInterruptible ( Animation  a)
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 bool G3D::MD2Model::animationJump ( Animation  a)
static
static GameTime G3D::MD2Model::animationLength ( Animation  a)
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 bool G3D::MD2Model::animationLoops ( Animation  a)
static

Returns true for standing, running, crouching, and crouch walking animations.

static bool G3D::MD2Model::animationPain ( Animation  A)
static
static bool G3D::MD2Model::animationRun ( Animation  a)
static

running, forward or backward, standing or crouching

static bool G3D::MD2Model::animationRunBackward ( Animation  a)
static
static bool G3D::MD2Model::animationRunForward ( Animation  a)
static
static bool G3D::MD2Model::animationStand ( Animation  a)
static

STAND or CROUCH_STAND.

static void G3D::MD2Model::computeFrameNumbers ( const Pose pose,
int kf0,
int kf1,
float &  alpha 
)
static

Computes the previous and next frame indices and how far we are between them.

static Ref G3D::MD2Model::create ( const Specification s,
const std::string name = "" 
)
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.

static int G3D::MD2Model::getFrameNumber ( const Pose pose)
static

Returns a value for MD2Model::Pose::preFrameNumber that will smoothly blend from this animation to the next one.

const std::string& G3D::MD2Model::name ( ) const
inline
int G3D::MD2Model::numParts ( ) const
inline

Either 1 or 2, depending on whether a weapon is present.

int G3D::MD2Model::numTriangles ( ) const
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().

void G3D::MD2Model::pose ( Array< shared_ptr< Surface > > &  surfaceArray,
const CoordinateFrame rootFrame = CoordinateFrame(),
const Pose currentPose = Pose() 
)
inline
static void G3D::MD2Model::setNormalTable ( )
static

Loads data into the normalTable.

Member Data Documentation

const MD2AnimInfo G3D::MD2Model::animationTable[MAX_ANIMATIONS]
static

Information relating Animations to keyFrames.

Used by computeFrameNumbers().

const float G3D::MD2Model::hangTimePct
static

How long we hold in the air as a fraction of jump time.

std::string G3D::MD2Model::m_name
protected

Referenced by name().

int G3D::MD2Model::m_numTriangles
protected

Referenced by numTriangles().

Array<Part::Ref > G3D::MD2Model::m_part
protected

Referenced by numParts().

bool G3D::MD2Model::negateNormals
protected

If true, negate the normal direction on this object when rendering.

Vector3 G3D::MD2Model::normalTable[162]
static

Quake uses a set of canonical normal vectors.

const GameTime G3D::MD2Model::PRE_BLEND_TIME
static

Amount of time to blend between two animations.


documentation generated on Sat Jan 12 2013 22:49:56 using doxygen 1.8.2