G3D::PosedModel Class ReferenceBase class for posed models.
More...
#include <PosedModel.h>
Inherits G3D::ReferenceCountedObject.
Inherited by G3D::IFSModel::PosedIFSModel, and G3D::MD2Model::PosedMD2Model.
List of all members.
|
Public Types |
typedef ReferenceCountedPointer<
class PosedModel > | Ref |
Public Member Functions |
| virtual CoordinateFrame | coordinateFrame () const |
| virtual const Array< MeshAlg::Edge > & | edges () const=0 |
| virtual const Array< MeshAlg::Face > & | faces () const=0 |
| virtual void | getCoordinateFrame (CoordinateFrame &c) const =0 |
| virtual void | getObjectSpaceBoundingBox (Box &) const =0 |
| virtual void | getObjectSpaceBoundingSphere (Sphere &) const=0 |
| virtual void | getObjectSpaceFaceNormals (Array< Vector3 > &faceNormals, bool normalize=true) const |
| virtual void | getWorldSpaceBoundingBox (Box &box) const |
| virtual void | getWorldSpaceBoundingSphere (Sphere &s) const |
| virtual void | getWorldSpaceFaceNormals (Array< Vector3 > &faceNormals, bool normalize=true) const |
| virtual void | getWorldSpaceGeometry (MeshAlg::Geometry &geometry) const |
| virtual bool | hasTexCoords () const |
| virtual bool | hasTransparency () const |
| virtual std::string | name () const=0 |
| virtual int | numBoundaryEdges () const=0 |
| int | numBrokenEdges () const |
| virtual int | numWeldedBoundaryEdges () const=0 |
| virtual Box | objectSpaceBoundingBox () const |
| virtual Sphere | objectSpaceBoundingSphere () const |
| virtual const Array< Vector3 > & | objectSpaceFaceNormals (bool normalize=true) const =0 |
| virtual const MeshAlg::Geometry & | objectSpaceGeometry () const=0 |
| void | ReferenceCountedObject_zeroWeakPointers () |
| virtual void | render (class RenderDevice *renderDevice) const |
| virtual void | renderNonShadowed (RenderDevice *rd, const LightingRef &lighting) const |
| virtual void | renderShadowedLightPass (RenderDevice *rd, const GLight &light) const |
| virtual void | renderShadowMappedLightPass (RenderDevice *rd, const GLight &light, const Matrix4 &lightMVP, const Texture::Ref &shadowMap) const |
| virtual void | sendGeometry (RenderDevice *rd) const |
| virtual const Array< Vector2 > & | texCoords () const |
| virtual const Array< int > & | triangleIndices () const=0 |
| virtual const Array< MeshAlg::Vertex > & | vertices () const=0 |
| virtual const Array< MeshAlg::Edge > & | weldedEdges () const=0 |
| virtual const Array< MeshAlg::Face > & | weldedFaces () const=0 |
| virtual const Array< MeshAlg::Vertex > & | weldedVertices () const=0 |
| virtual Box | worldSpaceBoundingBox () const |
| virtual Sphere | worldSpaceBoundingSphere () const |
| virtual | ~PosedModel () |
Static Public Member Functions |
| static void | sort (const Array< PosedModel::Ref > &inModels, const Vector3 &wsLookVector, Array< PosedModel::Ref > &opaque) |
| static void | sort (const Array< PosedModel::Ref > &inModels, const Vector3 &wsLookVector, Array< PosedModel::Ref > &opaque, Array< PosedModel::Ref > &transparent) |
Public Attributes |
| AtomicInt32 | ReferenceCountedObject_refCount |
| _WeakPtrLinkedList * | ReferenceCountedObject_weakPointer |
Protected Member Functions |
| virtual void | defaultRender (RenderDevice *rd) const |
| | PosedModel () |
Detailed Description
Base class for posed models.
A posed model is a snapshot of geometry and other rendering information, frozen in time, of a potentially animated or deformable "Model". G3D has no API (but some conventions) for how you get a PosedModel from a model class.
G3D does not provide a scene graph structure (e.g. there is no Model base class) because the visible surface determination, rendering, and caching behavior of a scene graph are different for each application. There is currently no one-size-fits-all scene graph design pattern.
G3D does provide some basic infrastructure for making your own scene graph, however. Model classes (e.g. G3D::IFSModel, G3D::MD2Model), which have no common base class, should all implement a pose method. The arguments to this method are all of the parameters (e.g. animation frame, limb position) needed for reducing the general purpose, poseable model to a specific world space mesh for rendering. This instance specific mesh is a G3D::PosedModel. Because all PosedModels have the same interface, they can be used interchangably.
Use G3D::PosedModelWrapper to encapsulate an existing posed model with your own.
A common strategy when implementing PosedModel is to not compute "derived" values like the object space face normals until they are needed. That is, the first call to a method might be very expensive because it goes off and computes some value that will be cached for future calls.
Rendering The easiest way to render is PosedModel::render(). More sophisticated rendering, e.g., in the presence of shadows, can be accomplished with the separate renderShadowMappedLightPass etc. routines.
PosedModel also allows you to directly extract and operate on its geometry. This is useful for adding effects like outlines in cartoon rendering, physics hit boxes, and shadow volume rendering. You can directly render from the geometry using the following rendering code (it is much faster if you can avoid re-creating the VARs and VARArea every frame!)
VARAreaRef area = VARArea::create(sizeof(Vector3) * posed->objectSpaceGeometry().vertexArray.size() * 2 + sizeof(Vector2) * posed->texCoords().size());
VAR vertex(posed->objectSpaceGeometry().vertexArray, area);
VAR normal(posed->objectSpaceGeometry().normalArray, area);
VAR texCoord(posed->texCoords(), area);
rd->setObjectToWorldMatrix(posed->coordinateFrame());
rd->setShadeMode(RenderDevice::SHADE_SMOOTH);
rd->beginIndexedPrimitives();
rd->setVertexArray(vertex);
rd->setNormalArray(normal);
rd->setTexCoordArray(0, texCoord);
rd->sendIndices(RenderDevice::TRIANGLES, posed->triangleIndices());
rd->endIndexedPrimitives();
Member Typedef Documentation
Constructor & Destructor Documentation
| G3D::PosedModel::PosedModel |
( |
|
) |
[inline, protected] |
| virtual G3D::PosedModel::~PosedModel |
( |
|
) |
[inline, virtual] |
Member Function Documentation
| virtual CoordinateFrame G3D::PosedModel::coordinateFrame |
( |
|
) |
const [virtual] |
| virtual void G3D::PosedModel::defaultRender |
( |
RenderDevice * |
rd |
) |
const [protected, virtual] |
Implementation must obey the current stencil, depth write, color write, and depth test modes.
Implementation may freely set the blending, and alpha test modes.
Default implementation renders the triangles returned by getIndices and getGeometry.
Adjacency information respecting the underlying connectivity of the mesh-- colocated vertices are treated as distinct.
Implemented in G3D::MD2Model::PosedMD2Model.
| virtual void G3D::PosedModel::getCoordinateFrame |
( |
CoordinateFrame & |
c |
) |
const [pure virtual] |
| virtual void G3D::PosedModel::getObjectSpaceBoundingBox |
( |
Box & |
|
) |
const [pure virtual] |
| virtual void G3D::PosedModel::getObjectSpaceBoundingSphere |
( |
Sphere & |
|
) |
const [pure virtual] |
| virtual void G3D::PosedModel::getObjectSpaceFaceNormals |
( |
Array< Vector3 > & |
faceNormals, |
|
|
bool |
normalize = true | |
|
) |
| | const [virtual] |
| virtual void G3D::PosedModel::getWorldSpaceBoundingBox |
( |
Box & |
box |
) |
const [virtual] |
| virtual void G3D::PosedModel::getWorldSpaceBoundingSphere |
( |
Sphere & |
s |
) |
const [virtual] |
| virtual void G3D::PosedModel::getWorldSpaceFaceNormals |
( |
Array< Vector3 > & |
faceNormals, |
|
|
bool |
normalize = true | |
|
) |
| | const [virtual] |
| virtual void G3D::PosedModel::getWorldSpaceGeometry |
( |
MeshAlg::Geometry & |
geometry |
) |
const [virtual] |
Get the world space geometry.
| virtual bool G3D::PosedModel::hasTexCoords |
( |
|
) |
const [inline, virtual] |
| virtual bool G3D::PosedModel::hasTransparency |
( |
|
) |
const [inline, virtual] |
If true, this object depends on back-to-front rendering order and should be rendered in sorted order.
Default is false.
| virtual std::string G3D::PosedModel::name |
( |
|
) |
const [pure virtual] |
| virtual int G3D::PosedModel::numBoundaryEdges |
( |
|
) |
const [pure virtual] |
| int G3D::PosedModel::numBrokenEdges |
( |
|
) |
const [inline] |
| virtual int G3D::PosedModel::numWeldedBoundaryEdges |
( |
|
) |
const [pure virtual] |
| virtual Box G3D::PosedModel::objectSpaceBoundingBox |
( |
|
) |
const [virtual] |
| virtual Sphere G3D::PosedModel::objectSpaceBoundingSphere |
( |
|
) |
const [virtual] |
| virtual const Array<Vector3>& G3D::PosedModel::objectSpaceFaceNormals |
( |
bool |
normalize = true |
) |
const [pure virtual] |
| virtual const MeshAlg::Geometry& G3D::PosedModel::objectSpaceGeometry |
( |
|
) |
const [pure virtual] |
| 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.
| virtual void G3D::PosedModel::render |
( |
class RenderDevice * |
renderDevice |
) |
const [virtual] |
Render using current fixed function lighting environment.
Do not change the steBehavior with regard to stencil, shadowing, etc. is intentionally undefinded.
Default implementation calls defaultRender.
Reimplemented in G3D::MD2Model::PosedMD2Model.
| virtual void G3D::PosedModel::renderNonShadowed |
( |
RenderDevice * |
rd, |
|
|
const LightingRef & |
lighting | |
|
) |
| | const [virtual] |
Render all terms that are independent of shadowing (e.g., transparency, reflection, ambient illumination, emissive illumination, nonShadowCastingLights).
Transparent objects are assumed to render additively (but should set the blend mode themselves). Restore all state to the original form on exit. Default implementation invokes render.
Implementation must obey the current stencil, depth write, color write, and depth test modes. Implementation may freely set the blending, and alpha test modes.
The caller should invoke this in depth sorted back to front order for transparent objects.
The default implementation configures the non-shadow casting lights and calls render.
Implementation advice:
-
If color write is disabled, don't bother performing any shading on this object.
-
It may be convenient to support multiple lights by invoking renderShadowedLightPass multiple times.
| virtual void G3D::PosedModel::renderShadowedLightPass |
( |
RenderDevice * |
rd, |
|
|
const GLight & |
light | |
|
) |
| | const [virtual] |
Render illumination from this light source additively.
Implementation must set the alpha blending mode to additive. Must obey the current stencil, depth write, and depth test modes. Default implementation enables a single light and calls render.
Render illumination from this source additively, held out by the shadow map (which the caller must have computed, probably using renderNonShadowed).
Default implementation configures the shadow map in texture unit 1 and calls render.
| virtual void G3D::PosedModel::sendGeometry |
( |
RenderDevice * |
rd |
) |
const [virtual] |
Sends all geometry including texture coordinates (uploading it first if necessary) but does not set any render device state or use any textures.
This is useful when applying your own G3D::Shader to an existing PosedModel.
Reimplemented in G3D::MD2Model::PosedMD2Model.
Sorts the array in place along the look vector from front-to-back.
Divides the inModels into a front-to-back sorted array of opaque models and a back-to-front sorted array of potentially transparent models.
Any data originally in the output arrays is cleared.
- Parameters:
-
| wsLookVector | Sort axis; usually the -Z axis of the camera. |
| virtual const Array<Vector2>& G3D::PosedModel::texCoords |
( |
|
) |
const [inline, virtual] |
If this model has texture coordinates, returns per-vertex texture coordinates in an array indexed the same as vertices() and geometry.vertexArray, otherwise returns an array of size zero.
Default implementation returns an array of size zero.
Reimplemented in G3D::MD2Model::PosedMD2Model.
| virtual const Array<int>& G3D::PosedModel::triangleIndices |
( |
|
) |
const [pure virtual] |
| virtual Box G3D::PosedModel::worldSpaceBoundingBox |
( |
|
) |
const [virtual] |
| virtual Sphere G3D::PosedModel::worldSpaceBoundingSphere |
( |
|
) |
const [virtual] |
Member Data Documentation
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.
The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:47 2007 for G3D by
1.5.2
Hosted by
|