xoreos
0.0.5
|
A 3D model in the NWN binary MDL format. More...
#include <model_kotor.h>
Classes | |
struct | ParserContext |
Public Member Functions | |
Model_KotOR (const Common::UString &name, bool kotor2, bool xbox, ModelType type=kModelTypeObject, const Common::UString &texture="", ModelCache *modelCache=0) | |
~Model_KotOR () | |
Public Member Functions inherited from Graphics::Aurora::Model | |
Model (ModelType type=kModelTypeObject) | |
~Model () | |
void | show () |
Show the object. More... | |
void | hide () |
Hide the object. More... | |
ModelType | getType () const |
Return the model's type. More... | |
const Common::UString & | getName () const |
Get the model's name. More... | |
float | getWidth () const |
Get the width of the model's bounding box. More... | |
float | getHeight () const |
Get the height of the model's bounding box. More... | |
float | getDepth () const |
Get the depth of the model's bounding box. More... | |
void | drawBound (bool enabled) |
Should a bounding box be drawn around this model? More... | |
void | drawSkeleton (bool enabled, bool showInvisible) |
Should a skeleton showing the nodes and their relation be drawn inside the model? More... | |
void | setEnvironmentMap (const Common::UString &environmentMap="") |
Change the environment map on this model. More... | |
void | setSkinned (bool skinned) |
Set the flag if the model has skinned animations. More... | |
bool | isIn (float x, float y) const |
Is that point within the model's bounding box? More... | |
bool | isIn (float x, float y, float z) const |
Is that point within the model's bounding box? More... | |
bool | isIn (float x1, float y1, float z1, float x2, float y2, float z2) const |
Does the line from x1.y1.z1 to x2.y2.z2 intersect with model's bounding box? More... | |
void | getScale (float &x, float &y, float &z) const |
Get the current scale of the model. More... | |
void | getOrientation (float &x, float &y, float &z, float &angle) const |
Get the current orientation of the model. More... | |
void | getPosition (float &x, float &y, float &z) const |
Get the current position of the model. More... | |
void | getAbsolutePosition (float &x, float &y, float &z) const |
Get the position of the node after translate/rotate. More... | |
void | setScale (float x, float y, float z) |
Set the current scale of the model. More... | |
void | setOrientation (float x, float y, float z, float angle) |
Set the current orientation of the model. More... | |
void | setPosition (float x, float y, float z) |
Set the current position of the model. More... | |
void | scale (float x, float y, float z) |
Scale the model, relative to its current scale. More... | |
void | rotate (float x, float y, float z, float angle) |
Rotate the model, relative to its current orientation. More... | |
void | move (float x, float y, float z) |
Move the model, relative to its current position. More... | |
void | getTooltipAnchor (float &x, float &y, float &z) const |
Get the point where the feedback tooltip is anchored. More... | |
const std::list< Common::UString > & | getStates () const |
Return a list of all animation state names. More... | |
void | setState (const Common::UString &name="") |
Set the current animation state. More... | |
const Common::UString & | getState () const |
Return the name of the current state. More... | |
bool | hasNode (const Common::UString &node) const |
Does the specified node exist in the current state? More... | |
ModelNode * | getNode (const Common::UString &node) |
Get the specified node, from the current state. More... | |
const ModelNode * | getNode (const Common::UString &node) const |
Get the specified node, from the current state. More... | |
ModelNode * | getNode (const Common::UString &stateName, const Common::UString &node) |
Get the specified node, from the named state, if it exists. More... | |
const ModelNode * | getNode (const Common::UString &stateName, const Common::UString &node) const |
Get the specified node, from the named state, if it exists. More... | |
ModelNode * | getNode (uint16 nodeNumber) |
Get node by node number. More... | |
const ModelNode * | getNode (uint16 nodeNumber) const |
Get node by node number. More... | |
const std::list< ModelNode * > & | getNodes () |
Get all nodes in the current state. More... | |
void | attachModel (const Common::UString &nodeName, Model *model) |
Add another model as a child to the named node. More... | |
bool | hasAnimation (const Common::UString &anim) const |
Does this model have this named animation? More... | |
float | getAnimationScale (const Common::UString &anim) |
Determine what animation scaling applies. More... | |
void | addAnimationChannel (AnimationChannelName name) |
AnimationChannel * | getAnimationChannel (AnimationChannelName name) |
void | clearDefaultAnimations () |
void | addDefaultAnimation (const Common::UString &anim, uint8 probability) |
void | playDefaultAnimation () |
void | playAnimation (const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f) |
void | calculateDistance () |
Calculate the object's distance. More... | |
void | render (RenderPass pass) |
Render the object. More... | |
void | renderImmediate (const glm::mat4 &parentTransform) |
For shader based systems, don't sort anything, render this right_now. More... | |
void | queueRender (const glm::mat4 &parentTransform) |
Queue the object for later rendering. More... | |
void | advanceTime (float dt) |
Advance time (used by renderables with animations). More... | |
void | flushNodeBuffers () |
Apply buffered changes to model nodes position and geometry. More... | |
Model * | getAttachedModel (const Common::UString &node) |
Public Member Functions inherited from Graphics::GLContainer | |
GLContainer () | |
~GLContainer () | |
void | rebuild () |
void | destroy () |
Public Member Functions inherited from Graphics::Queueable | |
Queueable () | |
virtual | ~Queueable () |
Public Member Functions inherited from Graphics::Renderable | |
Renderable (RenderableType type) | |
~Renderable () | |
bool | operator< (const Queueable &q) const |
double | getDistance () const |
Get the distance of the object from the viewer. More... | |
uint32 | getID () const |
Get the object's unique ID. More... | |
bool | isClickable () const |
Is the object clickable? More... | |
void | setClickable (bool clickable) |
Set the object's clickable state. More... | |
const Common::UString & | getTag () const |
Get the object's tag. More... | |
void | setTag (const Common::UString &tag) |
Set the object's tag. More... | |
bool | isVisible () const |
Is the object visible? More... | |
Private Member Functions | |
void | newState (ParserContext &ctx) |
void | addState (ParserContext &ctx) |
void | load (ParserContext &ctx) |
bool | readAnim (ParserContext &ctx, uint32 offset) |
void | loadSuperModel (ModelCache *modelCache, bool kotor2, bool xbox) |
void | readStrings (Common::SeekableReadStream &mdl, const std::vector< uint32 > &offsets, uint32 offset, std::vector< Common::UString > &strings) |
void | makeBoneNodeMap () |
Map bone indices to model node references for better peformance. More... | |
Friends | |
class | ModelNode_KotOR |
Additional Inherited Members | |
Static Public Member Functions inherited from Graphics::Aurora::Model | |
static void | readValue (Common::SeekableReadStream &stream, uint32 &value) |
static void | readValue (Common::SeekableReadStream &stream, float &value) |
static void | readArrayDef (Common::SeekableReadStream &stream, uint32 &offset, uint32 &count) |
template<typename T > | |
static void | readArray (Common::SeekableReadStream &stream, uint32 offset, uint32 count, std::vector< T > &values) |
Protected Types inherited from Graphics::Aurora::Model | |
typedef std::list< ModelNode * > | NodeList |
typedef std::map< Common::UString, ModelNode *, Common::UString::iless > | NodeMap |
typedef std::map< Common::UString, Animation *, Common::UString::iless > | AnimationMap |
typedef std::map< AnimationChannelName, AnimationChannel * > | AnimationChannelMap |
typedef std::list< State * > | StateList |
typedef std::map< Common::UString, State * > | StateMap |
Protected Member Functions inherited from Graphics::Aurora::Model | |
void | queueDrawBound () |
void | doDrawBound () |
void | doDrawSkeleton () |
Animation * | getAnimation (const Common::UString &anim) |
Get the animation from its name. More... | |
void | finalize () |
Finalize the loading procedure. More... | |
void | doRebuild () |
void | doDestroy () |
Protected Member Functions inherited from Graphics::Queueable | |
bool | isInQueue (QueueType queue) const |
void | addToQueue (QueueType queue) |
void | removeFromQueue (QueueType queue) |
void | lockQueue (QueueType queue) |
void | unlockQueue (QueueType queue) |
void | sortQueue (QueueType queue) |
Protected Member Functions inherited from Graphics::Renderable | |
void | resort () |
void | lockFrame () |
void | unlockFrame () |
void | lockFrameIfVisible () |
void | unlockFrameIfVisible () |
Protected Attributes inherited from Graphics::Aurora::Model | |
ModelType | _type |
The model's type. More... | |
Common::UString | _fileName |
The model's file name. More... | |
Common::UString | _name |
The model's name. More... | |
Common::UString | _superModelName |
Name of the super model. More... | |
Model * | _superModel |
The actual super model. More... | |
StateList | _stateList |
All states within this model. More... | |
StateMap | _stateMap |
All states within this model, index by name. More... | |
State * | _currentState |
The current state. More... | |
std::list< Common::UString > | _stateNames |
All state names. More... | |
AnimationMap | _animationMap |
Map of all animations in this model. More... | |
AnimationChannelMap | _animationChannels |
float | _animationScale |
The scale of the animation. More... | |
float | _scale [3] |
Model's scale. More... | |
float | _orientation [4] |
Model's orientation. More... | |
float | _position [3] |
Model's position. More... | |
float | _center [3] |
Model's center. More... | |
glm::mat4 | _absolutePosition |
Common::BoundingBox | _boundBox |
The model's bounding box. More... | |
Common::BoundingBox | _absoluteBoundBox |
The model's box after translate/rotate. More... | |
bool | _skinned |
bool | _positionRelative |
Shader::ShaderRenderable | _boundRenderable |
glm::mat4 | _boundTransform |
Protected Attributes inherited from Graphics::Renderable | |
QueueType | _queueExists |
QueueType | _queueVisible |
uint32 | _id |
bool | _clickable |
Common::UString | _tag |
double | _distance |
The distance of the object from the viewer. More... | |
A 3D model in the NWN binary MDL format.
Definition at line 42 of file model_kotor.h.
Graphics::Aurora::Model_KotOR::Model_KotOR | ( | const Common::UString & | name, |
bool | kotor2, | ||
bool | xbox, | ||
ModelType | type = kModelTypeObject , |
||
const Common::UString & | texture = "" , |
||
ModelCache * | modelCache = 0 |
||
) |
Definition at line 155 of file model_kotor.cpp.
References Graphics::Aurora::Model::_fileName, Graphics::Aurora::Model::_positionRelative, Graphics::Aurora::Model::_skinned, Graphics::Aurora::Model::finalize(), load(), loadSuperModel(), and makeBoneNodeMap().
Referenced by loadSuperModel().
Graphics::Aurora::Model_KotOR::~Model_KotOR | ( | ) |
Definition at line 174 of file model_kotor.cpp.
|
private |
Definition at line 368 of file model_kotor.cpp.
References Graphics::Aurora::Model::_currentState, Graphics::Aurora::Model::_stateList, Graphics::Aurora::Model::_stateMap, Graphics::Aurora::Model_KotOR::ParserContext::clear(), Graphics::Aurora::Model::State::name, Graphics::Aurora::Model::State::nodeList, Graphics::Aurora::Model::State::nodeMap, Graphics::Aurora::Model_KotOR::ParserContext::nodes, Graphics::Aurora::Model::State::rootNodes, and Graphics::Aurora::Model_KotOR::ParserContext::state.
Referenced by load().
|
private |
Definition at line 177 of file model_kotor.cpp.
References Graphics::Aurora::Model::_name, Graphics::Aurora::Model::_superModelName, addState(), Graphics::Aurora::Model_KotOR::ParserContext::clear(), Common::kEncodingASCII, Graphics::Aurora::ModelNode_KotOR::load(), Graphics::Aurora::Model_KotOR::ParserContext::mdl, Graphics::Aurora::Model_KotOR::ParserContext::mdlName, ModelNode_KotOR, Graphics::Aurora::Model_KotOR::ParserContext::names, newState(), Graphics::Aurora::Model_KotOR::ParserContext::nodes, Graphics::Aurora::Model_KotOR::ParserContext::offModelData, Graphics::Aurora::Model_KotOR::ParserContext::offRawData, readAnim(), Graphics::Aurora::Model::readArray(), Graphics::Aurora::Model::readArrayDef(), Common::ReadStream::readByte(), Common::ReadStream::readIEEEFloatLE(), Common::readStringFixed(), readStrings(), Common::ReadStream::readUint32LE(), Common::SeekableReadStream::seek(), and Common::SeekableReadStream::skip().
Referenced by Model_KotOR().
|
private |
Definition at line 325 of file model_kotor.cpp.
References Graphics::Aurora::Model::_superModel, Graphics::Aurora::Model::_superModelName, Graphics::Aurora::Model::_type, Common::UString::empty(), and Model_KotOR().
Referenced by Model_KotOR().
|
private |
Map bone indices to model node references for better peformance.
Definition at line 395 of file model_kotor.cpp.
References Graphics::Aurora::ModelNode::Skin::boneMapping, Graphics::Aurora::ModelNode::Skin::boneMappingCount, Graphics::Aurora::ModelNode::Skin::boneNodeMap, Graphics::Aurora::ModelNode::computeInverseBindPose(), Graphics::Aurora::ModelNode::getMesh(), Graphics::Aurora::Model::getNode(), Graphics::Aurora::Model::getNodes(), and Graphics::Aurora::ModelNode::Mesh::skin.
Referenced by Model_KotOR().
|
private |
Definition at line 362 of file model_kotor.cpp.
References Graphics::Aurora::Model_KotOR::ParserContext::clear(), and Graphics::Aurora::Model_KotOR::ParserContext::state.
Referenced by load().
|
private |
Definition at line 262 of file model_kotor.cpp.
References Graphics::Aurora::Model::_animationMap, Graphics::Aurora::Model::_name, Graphics::Aurora::Model::_stateMap, Graphics::Aurora::Animation::addAnimNode(), Graphics::Aurora::Model::Animation, Common::UString::c_str(), Common::kEncodingASCII, Graphics::Aurora::ModelNode_KotOR::load(), Graphics::Aurora::Model_KotOR::ParserContext::mdl, ModelNode_KotOR, Graphics::Aurora::Model::State::name, Graphics::Aurora::Model_KotOR::ParserContext::nodes, Graphics::Aurora::Model_KotOR::ParserContext::offModelData, Graphics::Aurora::Model::readArrayDef(), Common::ReadStream::readByte(), Common::ReadStream::readIEEEFloatLE(), Common::readStringFixed(), Common::ReadStream::readUint32LE(), Common::SeekableReadStream::seek(), Graphics::Aurora::Animation::setLength(), Graphics::Aurora::Animation::setName(), Graphics::Aurora::Animation::setTransTime(), Common::SeekableReadStream::skip(), Graphics::Aurora::Model_KotOR::ParserContext::state, and warning().
Referenced by load().
|
private |
Definition at line 346 of file model_kotor.cpp.
References Common::kEncodingASCII, Common::SeekableReadStream::pos(), Common::readString(), and Common::SeekableReadStream::seek().
Referenced by load().
|
friend |
Definition at line 95 of file model_kotor.h.
Referenced by load(), and readAnim().