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

Inherits G3D::ReferenceCountedObject.

Classes

class  PackedGeometry
 
class  Primitive
 
One RenderDevice primitive More...
 
class  Specification
 

Public Member Functions

virtual ~Part ()
 
void debugRenderWireframe (RenderDevice *renderDevice, const Pose &pose, bool negateNormals=false)
 
Render the wireframe mesh. More...
 
const Array< MeshAlg::Edge > & edges () const
 
const Array< MeshAlg::Face > & faces () const
 
virtual size_t mainMemorySize () const
 
Returns the approximate amount of main memory, not counting the texture, occupied by this data structure. More...
 
shared_ptr< UniversalMaterialmaterial () const
 
String name () const
 
const AABoxobjectSpaceBoundingBox () const
 
An oriented bounding box on the model. More...
 
const SphereobjectSpaceBoundingSphere () const
 
A bounding sphere on the model. More...
 
void pose (Array< shared_ptr< Surface > > &surfaceArray, const CoordinateFrame &cframe, const CFrame &prevFrame, const Pose &pose, bool negateNormals=false, const shared_ptr< class Entity > &entity=nullptr, const Surface::ExpressiveLightScatteringProperties &expressiveLightScatteringProperties=Surface::ExpressiveLightScatteringProperties())
 
virtual void setName (const String &n)
 
const Array< Vector2 > & texCoordArray () const
 
const Array< String > & textureFilenames () const
 Filenames of textures this model can use. More...
 
const Array< MeshAlg::Vertex > & vertices () const
 You must get the geometry for the vertex positions– this only specifies adjacency. More...
 
const Array< MeshAlg::Edge > & weldedEdges () const
 
const Array< MeshAlg::Face > & weldedFaces () const
 
const Array< MeshAlg::Vertex > & weldedVertices () const
 

Static Public Member Functions

static shared_ptr< class Partcreate (const Specification &specification)
 
static shared_ptr< class PartfromFile (const String &filename, const String &diffuseFilename, float scale=1.0f)
 
More...
 
static shared_ptr< TexturetextureFromFile (const String &filename)
 
Loads a Quake2 character texture. More...
 

Protected Types

enum  {
  NUM_VAR_AREAS = 10,
  NONE_ALLOCATED = -1
}
 

Protected Member Functions

 Part ()
 Called from create. More...
 
void allocateVertexArrays (RenderDevice *renderDevice)
 Called from render() to create the vertex arrays. More...
 
void computeTexCoords (const Array< Vector2int16 > &inCoords)
 
MD2 Models are stored with separate indices into texture coordinate and vertex arrays. More...
 
void getGeometry (const Pose &pose, MeshAlg::Geometry &geometry, bool negateNormals=false) const
 
Fills the geometry out from the pose. More...
 
void load (const String &filename, float scale)
 Called from create. More...
 
void loadTextureFilenames (BinaryInput &b, int num, int offset)
 
void render (RenderDevice *renderDevice, const Pose &pose)
 
Called from PosedMD2Model::render. More...
 
virtual void reset ()
 
Wipe all data structures. More...
 
void setBoundsFromPose (const Pose &pose, AABox &boxBounds, Sphere &sphereBounds)
 Sets. 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...
 

Protected Attributes

String _name
 
Array< Vector2_texCoordArray
 
Texture array that parallels vertex and normal arrays. More...
 
Array< String_textureFilenames
 
AABox animationBoundingBox [MAX_ANIMATIONS]
 
Sphere animationBoundingSphere [MAX_ANIMATIONS]
 
AABox boundingBox
 
Sphere boundingSphere
 
Array< MeshAlg::EdgeedgeArray
 
Array< MeshAlg::FacefaceArray
 
Array< Vector3faceNormalArray
 
Array< int > indexArray
 
Triangle list array useful for generating all of the triangles, e.g. More...
 
IndexStream indexVAR
 
Array< PackedGeometrykeyFrame
 
shared_ptr< UniversalMaterialm_material
 
int numBoundaryEdges
 
int numWeldedBoundaryEdges
 
Array< PrimitiveprimitiveArray
 
Vector2 texCoordScale
 1/header.skinWidth, 1/header.skinHeight, used by computeTextureCoords More...
 
Array< MeshAlg::VertexvertexArray
 
Array< MeshAlg::EdgeweldedEdgeArray
 
Array< MeshAlg::FaceweldedFaceArray
 
Array< MeshAlg::VertexweldedVertexArray
 

Static Protected Attributes

static MeshAlg::Geometry interpolatedFrame
 
static MD2Model::PartinterpolatedModel
 The pose currently stored in interpolatedFrame. More...
 
static Pose interpolatedPose
 
static int nextVarArea
 
When NONE_ALLOCATED, the vertex arrays have not been allocated. More...
 
static shared_ptr< VertexBuffervarArea [NUM_VAR_AREAS]
 Shared dynamic vertex arrays. More...
 

Friends

class MD2Model
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
NUM_VAR_AREAS 
NONE_ALLOCATED 

Constructor & Destructor Documentation

◆ Part()

G3D::MD2Model::Part::Part ( )
inlineprotected

Called from create.

◆ ~Part()

virtual G3D::MD2Model::Part::~Part ( )
inlinevirtual

Member Function Documentation

◆ allocateVertexArrays()

void G3D::MD2Model::Part::allocateVertexArrays ( RenderDevice renderDevice)
protected

Called from render() to create the vertex arrays.

Assumes AttributeArray is available and the arrays are not initialized.

◆ computeTexCoords()

void G3D::MD2Model::Part::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
inCoordsTexture coords corresponding to the index array

◆ create()

static shared_ptr<class Part> G3D::MD2Model::Part::create ( const Specification specification)
static

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

◆ debugRenderWireframe()

void G3D::MD2Model::Part::debugRenderWireframe ( RenderDevice renderDevice,
const Pose pose,
bool  negateNormals = false 
)


Render the wireframe mesh.

◆ edges()

const Array<MeshAlg::Edge>& G3D::MD2Model::Part::edges ( ) const

◆ faces()

const Array<MeshAlg::Face>& G3D::MD2Model::Part::faces ( ) const

◆ fromFile()

static shared_ptr<class Part> G3D::MD2Model::Part::fromFile ( const String filename,
const String diffuseFilename,
float  scale = 1.0f 
)
static


Parameters
filenameThe 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.
scaleOptional scale factor to apply while loading. The scale of 1.0 is chosen so that a typical character is 2 meters tall (1/2 the default quake unit scaling)

◆ getGeometry()

void G3D::MD2Model::Part::getGeometry ( const Pose pose,
MeshAlg::Geometry geometry,
bool  negateNormals = false 
) const
protected


Fills the geometry out from the pose.

Called from PosedMD2Model::getGeometry

◆ load()

void G3D::MD2Model::Part::load ( const String filename,
float  scale 
)
protected

Called from create.

◆ loadTextureFilenames()

void G3D::MD2Model::Part::loadTextureFilenames ( BinaryInput b,
int  num,
int  offset 
)
protected

◆ mainMemorySize()

virtual size_t G3D::MD2Model::Part::mainMemorySize ( ) const
virtual


Returns the approximate amount of main memory, not counting the texture, occupied by this data structure.

◆ material()

shared_ptr<UniversalMaterial> G3D::MD2Model::Part::material ( ) const
inline

◆ name()

String G3D::MD2Model::Part::name ( ) const
inline

◆ objectSpaceBoundingBox()

const AABox& G3D::MD2Model::Part::objectSpaceBoundingBox ( ) const
inline


An oriented bounding box on the model.

Covers all vertices in all animations.

◆ objectSpaceBoundingSphere()

const Sphere& G3D::MD2Model::Part::objectSpaceBoundingSphere ( ) const
inline


A bounding sphere on the model.

Covers all vertices in all animations.

◆ pose()

void G3D::MD2Model::Part::pose ( Array< shared_ptr< Surface > > &  surfaceArray,
const CoordinateFrame cframe,
const CFrame prevFrame,
const Pose pose,
bool  negateNormals = false,
const shared_ptr< class Entity > &  entity = nullptr,
const Surface::ExpressiveLightScatteringProperties expressiveLightScatteringProperties = Surface::ExpressiveLightScatteringProperties() 
)

◆ render()

void G3D::MD2Model::Part::render ( RenderDevice renderDevice,
const Pose pose 
)
protected


Called from PosedMD2Model::render.

◆ reset()

virtual void G3D::MD2Model::Part::reset ( )
protectedvirtual


Wipe all data structures.

Called from load.

◆ setBoundsFromPose()

void G3D::MD2Model::Part::setBoundsFromPose ( const Pose pose,
AABox boxBounds,
Sphere sphereBounds 
)
protected

Sets.

Parameters
boxBoundsand
sphereBoundsto conservative bounds for the pose, which includes combining bounds for two animations if the pose is during an animation blend

◆ setName()

virtual void G3D::MD2Model::Part::setName ( const String n)
inlinevirtual

◆ texCoordArray()

const Array<Vector2>& G3D::MD2Model::Part::texCoordArray ( ) const
inline

◆ textureFilenames()

const Array<String>& G3D::MD2Model::Part::textureFilenames ( ) const
inline

Filenames of textures this model can use.

◆ textureFromFile()

static shared_ptr<Texture> G3D::MD2Model::Part::textureFromFile ( const String filename)
static


Loads a Quake2 character texture.

Note that you may want to apply gamma correction as well if you are using tone mapping.

Same as:

Texture::Settings settings;
settings.wrapMode = WrapMode::CLAMP;
Texture::Preprocess preprocess;
preprocess.brighten = 2.0f;
Texture::fromFile(filename, ImageFormat::AUTO, Texture::DIM_2D, settings, preprocess)

◆ vertices()

const Array<MeshAlg::Vertex>& G3D::MD2Model::Part::vertices ( ) const

You must get the geometry for the vertex positions– this only specifies adjacency.

◆ weldedEdges()

const Array<MeshAlg::Edge>& G3D::MD2Model::Part::weldedEdges ( ) const

◆ weldedFaces()

const Array<MeshAlg::Face>& G3D::MD2Model::Part::weldedFaces ( ) const

◆ weldedVertices()

const Array<MeshAlg::Vertex>& G3D::MD2Model::Part::weldedVertices ( ) const

Friends And Related Function Documentation

◆ MD2Model

friend class MD2Model
friend

Member Data Documentation

◆ _name

String G3D::MD2Model::Part::_name
protected

Referenced by name(), and setName().

◆ _texCoordArray

Array<Vector2> G3D::MD2Model::Part::_texCoordArray
protected


Texture array that parallels vertex and normal arrays.

Set up by computeTexCoords

Referenced by texCoordArray().

◆ _textureFilenames

Array<String> G3D::MD2Model::Part::_textureFilenames
protected

Referenced by textureFilenames().

◆ animationBoundingBox

AABox G3D::MD2Model::Part::animationBoundingBox[MAX_ANIMATIONS]
protected

◆ animationBoundingSphere

Sphere G3D::MD2Model::Part::animationBoundingSphere[MAX_ANIMATIONS]
protected

◆ boundingBox

AABox G3D::MD2Model::Part::boundingBox
protected

Referenced by objectSpaceBoundingBox().

◆ boundingSphere

Sphere G3D::MD2Model::Part::boundingSphere
protected

◆ edgeArray

Array<MeshAlg::Edge> G3D::MD2Model::Part::edgeArray
protected

◆ faceArray

Array<MeshAlg::Face> G3D::MD2Model::Part::faceArray
protected

◆ faceNormalArray

Array<Vector3> G3D::MD2Model::Part::faceNormalArray
protected

◆ indexArray

Array<int> G3D::MD2Model::Part::indexArray
protected


Triangle list array useful for generating all of the triangles, e.g.

for collision detection. Not used for rendering.

◆ indexVAR

IndexStream G3D::MD2Model::Part::indexVAR
protected

◆ interpolatedFrame

MeshAlg::Geometry G3D::MD2Model::Part::interpolatedFrame
staticprotected

◆ interpolatedModel

MD2Model::Part* G3D::MD2Model::Part::interpolatedModel
staticprotected

The pose currently stored in interpolatedFrame.

When the animation is MAX_ANIMATIONS interpolatedFrame is not yet initialized.

◆ interpolatedPose

Pose G3D::MD2Model::Part::interpolatedPose
staticprotected

◆ keyFrame

Array<PackedGeometry> G3D::MD2Model::Part::keyFrame
protected

◆ m_material

shared_ptr<UniversalMaterial> G3D::MD2Model::Part::m_material
protected

Referenced by material().

◆ nextVarArea

int G3D::MD2Model::Part::nextVarArea
staticprotected


When NONE_ALLOCATED, the vertex arrays have not been allocated.

◆ numBoundaryEdges

int G3D::MD2Model::Part::numBoundaryEdges
protected

◆ numWeldedBoundaryEdges

int G3D::MD2Model::Part::numWeldedBoundaryEdges
protected

◆ primitiveArray

Array<Primitive> G3D::MD2Model::Part::primitiveArray
protected

◆ texCoordScale

Vector2 G3D::MD2Model::Part::texCoordScale
protected

1/header.skinWidth, 1/header.skinHeight, used by computeTextureCoords

◆ varArea

shared_ptr<VertexBuffer> G3D::MD2Model::Part::varArea[NUM_VAR_AREAS]
staticprotected

Shared dynamic vertex arrays.

Allocated by allocateVertexArrays. We cycle through multiple VertexBuffers 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.

◆ vertexArray

Array<MeshAlg::Vertex> G3D::MD2Model::Part::vertexArray
protected

◆ weldedEdgeArray

Array<MeshAlg::Edge> G3D::MD2Model::Part::weldedEdgeArray
protected

◆ weldedFaceArray

Array<MeshAlg::Face> G3D::MD2Model::Part::weldedFaceArray
protected

◆ weldedVertexArray

Array<MeshAlg::Vertex> G3D::MD2Model::Part::weldedVertexArray
protected

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