Support Forum 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... | |
Public Member Functions | |
virtual const String & | className () const override |
Name of the G3D::Model subclass. More... | |
virtual bool | intersect (const Ray &ray, const CoordinateFrame &cframe, float &maxDistance, Model::HitInfo &info=Model::HitInfo::ignore, const Entity *entity=nullptr, const Model::Pose *pose=nullptr) const override |
Determines if the ray intersects the heightfield and fills the info with the proper information. More... | |
virtual const String & | name () const override |
Name of the instance (usually based on the filename it is loaded from) More... | |
int | numParts () const |
Either 1 or 2, depending on whether a weapon is present. More... | |
int | numTriangles () const |
Total number of triangles in the mesh. More... | |
void | pose (Array< shared_ptr< Surface > > &surfaceArray, const CFrame &rootFrame, const CFrame &prevFrame, const shared_ptr< Entity > &entity, const Model::Pose *pose, const Model::Pose *prevPose, const Surface::ExpressiveLightScatteringProperties &e) override |
The current implementation does not reflect character animation in GBuffer::SS_POSITION_CHANGE, only root motion. More... | |
Static Public Member Functions | |
static bool | animationAttack (Animation a) |
static bool | animationCrouch (Animation a) |
Returns true for the crouching set of animations. More... | |
static bool | animationDeath (Animation a) |
Returns true for the death animations More... | |
static bool | animationInterruptible (Animation a) |
True for actions that can be interrupted, like running or saluting. More... | |
static bool | animationJump (Animation a) |
static SimTime | animationLength (Animation a) |
Returns the total time of the animation. More... | |
static bool | animationLoops (Animation a) |
Returns true for standing, running, crouching, and crouch walking animations. More... | |
static bool | animationPain (Animation A) |
static bool | animationRun (Animation a) |
running, forward or backward, standing or crouching More... | |
static bool | animationRunBackward (Animation a) |
static bool | animationRunForward (Animation a) |
static bool | animationStand (Animation a) |
STAND or CROUCH_STAND. More... | |
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. More... | |
static shared_ptr< MD2Model > | create (const Specification &s, const String &name="") |
Create a new MD2Model. More... | |
static int | getFrameNumber (const Pose &pose) |
Returns a value for MD2Model::Pose::preFrameNumber that will smoothly blend from this animation to the next one. More... | |
static lazy_ptr< Model > | lazyCreate (const Specification &s, const String &name="") |
static lazy_ptr< Model > | lazyCreate (const String &name, const Any &any) |
static void | setNormalTable () |
Loads data into the normalTable. More... | |
static void | setUseOptimizedIntersect (bool b) |
If true, complex models should use TriTree to accelerate intersect() calls where possible. More... | |
static bool | useOptimizedIntersect () |
Static Public Attributes | |
static const MD2AnimInfo | animationTable [MAX_ANIMATIONS] |
Information relating Animations to keyFrames. More... | |
static const float | hangTimePct |
How long we hold in the air as a fraction of jump time. More... | |
static Vector3 | normalTable [162] |
Quake uses a set of canonical normal vectors. More... | |
static const SimTime | PRE_BLEND_TIME |
Amount of time to blend between two animations. More... | |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
static MD2Model::Animation | getAnimationCorrespondingToFrame (int frameNum) |
Returns the animation corresponding to the frame number (always the forward version of the animation) Used for computing conservative bounds. More... | |
Protected Attributes | |
String | m_name |
int | m_numTriangles |
Array< shared_ptr< Part > > | m_part |
bool | negateNormals |
If true, negate the normal direction on this object when rendering. More... | |
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.
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.
|
overridevirtual |
Name of the G3D::Model subclass.
Implements G3D::Model.
|
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 String, which will automatically cast to a MD2Model::Specification.
Referenced by lazyCreate().
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
staticprotected |
Returns the animation corresponding to the frame number (always the forward version of the animation) Used for computing conservative bounds.
|
static |
Returns a value for MD2Model::Pose::preFrameNumber that will smoothly blend from this animation to the next one.
|
overridevirtual |
Determines if the ray intersects the heightfield and fills the info with the proper information.
maxDistance | Max distance to trace to on input, hit distance written on output if hit |
Reimplemented from G3D::Model.
|
inlinestatic |
Referenced by lazyCreate().
|
inlineoverridevirtual |
Name of the instance (usually based on the filename it is loaded from)
Implements G3D::Model.
Referenced by lazyCreate().
|
inline |
Either 1 or 2, depending on whether a weapon is present.
|
inline |
Total number of triangles in the mesh.
|
overridevirtual |
The current implementation does not reflect character animation in GBuffer::SS_POSITION_CHANGE, only root motion.
Implements G3D::Model.
|
static |
Loads data into the normalTable.
|
inlinestaticinherited |
If true, complex models should use TriTree to accelerate intersect() calls where possible.
This can make the first intersect() call very slow for the tree build and can make loading slow. It may not affect performance of skinned or articulated models that animate.
This value should be set before the models are loaded. If it is changed after a model is loaded, the Model is not required to respond to it.
Default: false
|
inlinestaticinherited |
|
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 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.