G3D::MD2Model Class ReferenceQuake II model class.
More...
#include <MD2Model.h>
Inherits G3D::ReferenceCountedObject.
List of all members.
|
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
} |
Public Member Functions |
| void | debugRenderWireframe (RenderDevice *renderDevice, const Pose &pose) |
| const Array< MeshAlg::Edge > & | edges () const |
| const Array< MeshAlg::Face > & | faces () const |
| virtual size_t | mainMemorySize () const |
| std::string | name () const |
| const Box & | objectSpaceBoundingBox () const |
| const Sphere & | objectSpaceBoundingSphere () const |
| PosedModel::Ref | pose (const CoordinateFrame &cframe, const Pose &pose, const GMaterial &mat) |
| PosedModel::Ref | pose (const CoordinateFrame &cframe, const Pose &pose) |
| void | ReferenceCountedObject_zeroWeakPointers () |
| virtual void | setName (const std::string &n) |
| const Array< Vector2 > & | texCoordArray () const |
| const Array< std::string > & | textureFilenames () const |
| const Array< MeshAlg::Vertex > & | vertices () const |
| const Array< MeshAlg::Edge > & | weldedEdges () const |
| const Array< MeshAlg::Face > & | weldedFaces () const |
| const Array< MeshAlg::Vertex > & | weldedVertices () const |
| virtual | ~MD2Model () |
Static Public Member Functions |
| static bool | animationAttack (Animation a) |
| static bool | animationCrouch (Animation a) |
| static bool | animationDeath (Animation a) |
| static bool | animationInterruptible (Animation a) |
| static bool | animationJump (Animation a) |
| static GameTime | animationLength (Animation a) |
| static bool | animationLoops (Animation a) |
| static bool | animationPain (Animation A) |
| static bool | animationRun (Animation a) |
| static bool | animationRunBackward (Animation a) |
| static bool | animationRunForward (Animation a) |
| static bool | animationStand (Animation a) |
| static MD2ModelRef G3D_DEPRECATED | create (const std::string &filename, float scale=1.0f) |
| static MD2ModelRef | fromFile (const std::string &filename, float scale=1.0f) |
| static int | getFrameNumber (const Pose &pose) |
| static Texture::Ref | textureFromFile (const std::string &filename) |
Public Attributes |
| AtomicInt32 | ReferenceCountedObject_refCount |
| _WeakPtrLinkedList * | ReferenceCountedObject_weakPointer |
Static Public Attributes |
| static const GameTime | PRE_BLEND_TIME |
Protected Types |
| enum | { NUM_VAR_AREAS = 10,
NONE_ALLOCATED = -1
} |
Protected Member Functions |
| void | allocateVertexArrays (RenderDevice *renderDevice) |
| void | computeTexCoords (const Array< Vector2int16 > &inCoords) |
| void | getGeometry (const Pose &pose, MeshAlg::Geometry &geometry) const |
| void | load (const std::string &filename, float scale) |
| void | loadTextureFilenames (BinaryInput &b, int num, int offset) |
| | MD2Model () |
| void | render (RenderDevice *renderDevice, const Pose &pose) |
| virtual void | reset () |
| void | sendGeometry (RenderDevice *rd, const Pose &pose) const |
Static Protected Member Functions |
| static void | computeFrameNumbers (const MD2Model::Pose &pose, int &kf0, int &kf1, double &alpha) |
| static void | setNormalTable () |
Protected Attributes |
| std::string | _name |
| Array< Vector2 > | _texCoordArray |
| Array< std::string > | _textureFilenames |
| Box | animationBoundingBox [MAX_ANIMATIONS] |
| Sphere | animationBoundingSphere [MAX_ANIMATIONS] |
| Box | boundingBox |
| Sphere | boundingSphere |
| Array< MeshAlg::Edge > | edgeArray |
| Array< MeshAlg::Face > | faceArray |
| Array< Vector3 > | faceNormalArray |
| Array< int > | indexArray |
| Array< PackedGeometry > | keyFrame |
| int | numBoundaryEdges |
| int | numWeldedBoundaryEdges |
| Array< Primitive > | primitiveArray |
| Vector2 | texCoordScale |
| Array< MeshAlg::Vertex > | vertexArray |
| Array< MeshAlg::Edge > | weldedEdgeArray |
| Array< MeshAlg::Face > | weldedFaceArray |
| Array< MeshAlg::Vertex > | weldedVertexArray |
Static Protected Attributes |
| static const MD2AnimInfo | animationTable [MAX_ANIMATIONS] |
| static const double | hangTimePct |
| static MeshAlg::Geometry | interpolatedFrame |
| static MD2Model * | interpolatedModel |
| static Pose | interpolatedPose |
| static int | nextVarArea |
| static Vector3 | normalTable [162] |
| static VARAreaRef | varArea [NUM_VAR_AREAS] |
Friends |
| class | PosedMD2Model |
Classes |
| class | MD2AnimInfo |
| class | PackedGeometry |
| class | Pose |
| class | PosedMD2Model |
| class | Primitive |
| | One RenderDevice primitive. More...
|
Detailed Description
Quake II model class.
See demos/MD2Model for an example of how to use this class.
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.
When available, this class uses SSE instructions for fast vertex blending. This cuts the time for getGeometry by a factor of 2.
This class is not threadsafe; you cannot even call methods on two different instances on different threads.
The posed model supplies texture coordinates and normals when rendering but the caller must bind a texture, set the object to world matrix, and set up lighting.
If VAR has been initialized for the renderDevice, the first time this is called (for any Model) a 512k VAR area is allocated. This memory is shared between all MD2 models.
Really huge MD2 models will not fit into this small VAR area and will revert to non-VAR rendering.
When getting geometry from the posed model, the normalArray values are interpolated and may have slightly less than unit length.
Member Enumeration Documentation
anonymous enum [protected] |
- Enumerator:
-
| NUM_VAR_AREAS |
|
| NONE_ALLOCATED |
|
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 |
|
Constructor & Destructor Documentation
| G3D::MD2Model::MD2Model |
( |
|
) |
[inline, protected] |
| virtual G3D::MD2Model::~MD2Model |
( |
|
) |
[inline, virtual] |
Member Function Documentation
| void G3D::MD2Model::allocateVertexArrays |
( |
RenderDevice * |
renderDevice |
) |
[protected] |
Called from render() to create the vertex arrays.
Assumes VAR is available and the arrays are not initialized.
| 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] |
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] |
| static void G3D::MD2Model::computeFrameNumbers |
( |
const MD2Model::Pose & |
pose, |
|
|
int & |
kf0, |
|
|
int & |
kf1, |
|
|
double & |
alpha | |
|
) |
| | [static, protected] |
Computes the previous and next frame indices and how far we are between them.
| void G3D::MD2Model::computeTexCoords |
( |
const Array< Vector2int16 > & |
inCoords |
) |
[protected] |
MD2 Models are stored with separate indices into texture coordinate and vertex arrays.
This means that some vertices must be duplicated in order to render with a single OpenGL-style vertex array.
Creates a texCoordArray to parallel the vertex and normal arrays, duplicating vertices in the keyframes as needed. Called from load(). - Parameters:
-
| inCoords | Texture coords corresponding to the index array |
| static MD2ModelRef G3D_DEPRECATED G3D::MD2Model::create |
( |
const std::string & |
filename, |
|
|
float |
scale = 1.0f | |
|
) |
| | [inline, static] |
| void G3D::MD2Model::debugRenderWireframe |
( |
RenderDevice * |
renderDevice, |
|
|
const Pose & |
pose | |
|
) |
| | |
Render the wireframe mesh.
| static MD2ModelRef G3D::MD2Model::fromFile |
( |
const std::string & |
filename, |
|
|
float |
scale = 1.0f | |
|
) |
| | [static] |
The tris.md2 file.
Note that most MD2 files are stored in two files, tris.md2 and weapon.md2. You will have to load both as separate models.
- Parameters:
-
| scale | Optional scale factor to apply while loading. |
| static int G3D::MD2Model::getFrameNumber |
( |
const Pose & |
pose |
) |
[static] |
Fills the geometry out from the pose.
Called from PosedMD2Model::getGeometry
| void G3D::MD2Model::load |
( |
const std::string & |
filename, |
|
|
float |
scale | |
|
) |
| | [protected] |
| void G3D::MD2Model::loadTextureFilenames |
( |
BinaryInput & |
b, |
|
|
int |
num, |
|
|
int |
offset | |
|
) |
| | [protected] |
| virtual size_t G3D::MD2Model::mainMemorySize |
( |
|
) |
const [virtual] |
Returns the approximate amount of main memory, not counting the texture, occupied by this data structure.
| std::string G3D::MD2Model::name |
( |
|
) |
const [inline] |
| const Box& G3D::MD2Model::objectSpaceBoundingBox |
( |
|
) |
const [inline] |
An oriented bounding box on the model.
Covers all vertices in all animations.
| const Sphere& G3D::MD2Model::objectSpaceBoundingSphere |
( |
|
) |
const [inline] |
A bounding sphere on the model.
Covers all vertices in all animations.
You can also pose a model without a material.
A good example of why this is useful is the MD2Model_Demo, in which shadows are rendered by flattening a pose of the model. The shadow should not be textured!
| void G3D::ReferenceCountedObject::ReferenceCountedObject_zeroWeakPointers |
( |
|
) |
[inline, inherited] |
Automatically called immediately before the object is deleted.
This is not called from the destructor because it needs to be invoked before the subclass destructor.
| void G3D::MD2Model::render |
( |
RenderDevice * |
renderDevice, |
|
|
const Pose & |
pose | |
|
) |
| | [protected] |
| virtual void G3D::MD2Model::reset |
( |
|
) |
[protected, virtual] |
Wipe all data structures.
Called from load.
| void G3D::MD2Model::sendGeometry |
( |
RenderDevice * |
rd, |
|
|
const Pose & |
pose | |
|
) |
| | const [protected] |
| virtual void G3D::MD2Model::setName |
( |
const std::string & |
n |
) |
[inline, virtual] |
| static void G3D::MD2Model::setNormalTable |
( |
|
) |
[static, protected] |
Loads data into the normalTable.
| const Array<Vector2>& G3D::MD2Model::texCoordArray |
( |
|
) |
const [inline] |
| const Array<std::string>& G3D::MD2Model::textureFilenames |
( |
|
) |
const [inline] |
Filenames of textures this model can use.
| static Texture::Ref G3D::MD2Model::textureFromFile |
( |
const std::string & |
filename |
) |
[static] |
Loads a Quake2 character texture.
Same as:
Texture::Settings settings;
settings.wrapMode = Texture::CLAMP;
Texture::PreProcess preprocess;
preprocess.brighten = 2.0f;
Texture::fromFile(filename, TextureFormat::AUTO, Texture::DIM_2D, settings, preprocess)
You must get the geometry for the vertex positions-- this only specifies adjacency.
Friends And Related Function Documentation
Member Data Documentation
Texture array that parallels vertex and normal arrays.
Set up by computeTexCoords
How long we hold in the air as a fraction of jump time.
Triangle list array useful for generating all of the triangles, e.g.
for collision detection. Not used for rendering.
The pose currently stored in interpolatedFrame.
When the animation is MAX_ANIMATIONS interpolatedFrame is not yet initialized.
When NONE_ALLOCATED, the vertex arrays have not been allocated.
Quake uses a set of canonical normal vectors.
Amount of time to blend between two animations.
The long name is to keep this from accidentally conflicting with a subclass's variable name.
Do not use or explicitly manipulate this value--its type may change in the future and is not part of the supported API.
Linked list of all weak pointers that reference this (some may be on the stack!).
Do not use or explicitly manipulate this value.
1/header.skinWidth, 1/header.skinHeight, used by computeTextureCoords
Shared dynamic vertex arrays.
Allocated by allocateVertexArrays. We cycle through multiple VARAreas because the models are so small that we can send data to the card faster than it can be rendered and we end up spending all of our time waiting on the GPU.
The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:46 2007 for G3D by
1.5.2
Hosted by
|