Support Forum       G3D Web Page     
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
G3D::MD3Model Class Reference

Quake III MD3 model loader. More...

Inherits G3D::Model.

Classes

class  AnimType
 All standard animation types expected to have parameters in the animation.cfg file. More...
 
class  Pose
 Animation pose based on AnimType and animation time. More...
 
class  PoseSequence
 A sequence of animation poses that are loaded from the scene file. More...
 
class  Skin
 A set of materials for a MD3Model. More...
 
class  Specification
 

Public Types

enum  {
  NUM_PARTS = 3,
  NUM_ANIMATED_PARTS = 2
}
 
enum  PartType {
  PART_LOWER,
  PART_UPPER,
  PART_HEAD
}
 

Public Member Functions

virtual ~MD3Model ()
 
virtual const StringclassName () const override
 Name of the G3D::Model subclass. More...
 
void computeFrameNumbers (const Pose &pose, PartType partType, int &kf0, int &kf1, float &alpha) const
 determines which frame in the animation it is currently on and will return a negative frame number if it is in the process of blending between animations More...
 
const shared_ptr< Skin > & defaultSkin () const
 
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 Stringname () const override
 Name of the instance (usually based on the filename it is loaded from) More...
 
virtual 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
 This will be replaced soon with a version that takes a shared_ptr<Pose>. More...
 
void pose (Array< shared_ptr< class Surface > > &posedModelArray, const CFrame &cframe, const CFrame &previousFrame, const Pose &currentPose=Pose(), const shared_ptr< Entity > &entity=nullptr, const Surface::ExpressiveLightScatteringProperties &expressiveLightScatteringProperties=Surface::ExpressiveLightScatteringProperties())
 Poses then adds all available parts to posedModelArray. More...
 
void pose (Array< shared_ptr< class Surface > > &posedModelArray, const CFrame &cframe=CFrame(), const Pose &currentPose=Pose(), const shared_ptr< Entity > &entity=nullptr, const Surface::ExpressiveLightScatteringProperties &e=Surface::ExpressiveLightScatteringProperties())
 
void simulatePose (Pose &pose, SimTime dt) const
 Advances the pose based on this character's animations. More...
 
CoordinateFrame weaponFrame (const CoordinateFrame &cframe=CoordinateFrame(), const Pose &pose=Pose()) const
 Return the coordinate frame of the tag_weapon; this is where a simulator should place objects carried by the character. More...
 

Static Public Member Functions

static bool affectsLower (AnimType a)
 
static bool affectsUpper (AnimType a)
 
static shared_ptr< MD3Modelcreate (const Specification &spec, const String &name="")
 
static lazy_ptr< ModellazyCreate (const Specification &s, const String &name="")
 
static lazy_ptr< ModellazyCreate (const String &name, const Any &any)
 
static void setUseOptimizedIntersect (bool b)
 If true, complex models should use TriTree to accelerate intersect() calls where possible. More...
 
static bool useOptimizedIntersect ()
 

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

Detailed Description

Quake III MD3 model loader.

Quake 3 uses MD3 models for both characters and non-character objects.
Character objects contain three individual "models" inside of them with attachment points.

MD3Models are composed of up to four parts, which are named lower (legs), upper (torso), and head. The coordinate frame for each relative to its parent can be specified as part of the pose. Each part contains a set of triangle lists. The triangle lists may have different materials and are key-frame animated. A skin is a set of materials for the triangle lists. The model is created with a default skin, although an alternative skin may be provided as part of the pose. This allows sharing geometry over characters with different appearance.

It also contains a coordinate frame for a weapon's attachment location.

See http://bit.ly/acgNj9 for some models

Referenced Code: http://icculus.org/homepages/phaethon/q3a/formats/md3format.html
Referenced Code: http://www.misfitcode.com/misfitmodel3d/olh_quakemd3.html

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
NUM_PARTS 
NUM_ANIMATED_PARTS 

◆ PartType

Enumerator
PART_LOWER 
PART_UPPER 
PART_HEAD 

Heads are never animated.

Constructor & Destructor Documentation

◆ ~MD3Model()

virtual G3D::MD3Model::~MD3Model ( )
virtual

Member Function Documentation

◆ affectsLower()

static bool G3D::MD3Model::affectsLower ( AnimType  a)
inlinestatic

◆ affectsUpper()

static bool G3D::MD3Model::affectsUpper ( AnimType  a)
inlinestatic

◆ className()

virtual const String& G3D::MD3Model::className ( ) const
overridevirtual

Name of the G3D::Model subclass.

Implements G3D::Model.

◆ computeFrameNumbers()

void G3D::MD3Model::computeFrameNumbers ( const Pose pose,
PartType  partType,
int &  kf0,
int &  kf1,
float &  alpha 
) const

determines which frame in the animation it is currently on and will return a negative frame number if it is in the process of blending between animations

◆ create()

static shared_ptr<MD3Model> G3D::MD3Model::create ( const Specification spec,
const String name = "" 
)
static

Referenced by lazyCreate().

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ defaultSkin()

const shared_ptr<Skin>& G3D::MD3Model::defaultSkin ( ) const
inline

◆ intersect()

virtual bool G3D::MD3Model::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
overridevirtual

Determines if the ray intersects the heightfield and fills the info with the proper information.

Parameters
maxDistanceMax distance to trace to on input, hit distance written on output if hit

Reimplemented from G3D::Model.

◆ lazyCreate() [1/2]

static lazy_ptr<Model> G3D::MD3Model::lazyCreate ( const Specification s,
const String name = "" 
)
inlinestatic

Referenced by lazyCreate().

◆ lazyCreate() [2/2]

static lazy_ptr<Model> G3D::MD3Model::lazyCreate ( const String name,
const Any any 
)
inlinestatic

◆ name()

virtual const String& G3D::MD3Model::name ( ) const
inlineoverridevirtual

Name of the instance (usually based on the filename it is loaded from)

Implements G3D::Model.

Referenced by lazyCreate().

◆ pose() [1/3]

virtual void G3D::MD3Model::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 
)
overridevirtual

This will be replaced soon with a version that takes a shared_ptr<Pose>.

Parameters
poseMust have the subclass of Model::Pose appropriate to the Model subclass.

Implements G3D::Model.

Referenced by pose().

◆ pose() [2/3]

void G3D::MD3Model::pose ( Array< shared_ptr< class Surface > > &  posedModelArray,
const CFrame cframe,
const CFrame previousFrame,
const Pose currentPose = Pose(),
const shared_ptr< Entity > &  entity = nullptr,
const Surface::ExpressiveLightScatteringProperties expressiveLightScatteringProperties = Surface::ExpressiveLightScatteringProperties() 
)

Poses then adds all available parts to posedModelArray.

Each part is posed based on the animation parameters then positioned and rotated based on the appropriate tag according to Quake III model standards.

The lower.md3 part is the based. The upper.md3 part is attached to "tag_torso" in lower.md3. The head.md3 part is attached to "tag_head" in upper.md3.

The initial cframe transformation is applied to the base lower.md3 part before the whole model is posed.

◆ pose() [3/3]

void G3D::MD3Model::pose ( Array< shared_ptr< class Surface > > &  posedModelArray,
const CFrame cframe = CFrame(),
const Pose currentPose = Pose(),
const shared_ptr< Entity > &  entity = nullptr,
const Surface::ExpressiveLightScatteringProperties e = Surface::ExpressiveLightScatteringProperties() 
)
inline

◆ setUseOptimizedIntersect()

static void G3D::Model::setUseOptimizedIntersect ( bool  b)
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

◆ simulatePose()

void G3D::MD3Model::simulatePose ( Pose pose,
SimTime  dt 
) const

Advances the pose based on this character's animations.

◆ useOptimizedIntersect()

static bool G3D::Model::useOptimizedIntersect ( )
inlinestaticinherited

◆ weaponFrame()

CoordinateFrame G3D::MD3Model::weaponFrame ( const CoordinateFrame cframe = CoordinateFrame(),
const Pose pose = Pose() 
) const

Return the coordinate frame of the tag_weapon; this is where a simulator should place objects carried by the character.


documentation generated on Wed Nov 24 2021 08:01:58 using doxygen 1.8.15