xoreos  0.0.5
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Graphics::Aurora::ModelNode_Witcher Class Reference

#include <model_witcher.h>

Inheritance diagram for Graphics::Aurora::ModelNode_Witcher:
Inheritance graph
[legend]
Collaboration diagram for Graphics::Aurora::ModelNode_Witcher:
Collaboration graph
[legend]

Classes

struct  TexturePaintLayer
 

Public Member Functions

 ModelNode_Witcher (Model &model)
 
 ~ModelNode_Witcher ()
 
void load (Model_Witcher::ParserContext &ctx)
 
- Public Member Functions inherited from Graphics::Aurora::ModelNode
 ModelNode (Model &model)
 
virtual ~ModelNode ()
 
const Common::UStringgetName () const
 Get the node's name. More...
 
float getWidth () const
 Get the width of the node's bounding box. More...
 
float getHeight () const
 Get the height of the node's bounding box. More...
 
float getDepth () const
 Get the depth of the node's bounding box. More...
 
void setInvisible (bool invisible)
 Should the node never be rendered at all? More...
 
void setEnvironmentMap (const Common::UString &environmentMap="")
 Change the environment map on this model node. More...
 
void getPosition (float &x, float &y, float &z) const
 Get the position of the node. More...
 
void getRotation (float &x, float &y, float &z) const
 Get the rotation of the node. More...
 
void getOrientation (float &x, float &y, float &z, float &a) const
 Get the orientation of the node. More...
 
void getAbsolutePosition (float &x, float &y, float &z) const
 Get the position of the node after translate/rotate. More...
 
glm::mat4 getAbsolutePosition () const
 Get the position of the node after translate/rotate. More...
 
uint16 getNodeNumber () const
 
void setPosition (float x, float y, float z)
 Set the position of the node. More...
 
void setRotation (float x, float y, float z)
 Set the rotation of the node. More...
 
void setOrientation (float x, float y, float z, float a)
 Set the orientation of the node. More...
 
void move (float x, float y, float z)
 Move the node, relative to its current position. More...
 
void rotate (float x, float y, float z)
 Rotate the node, relative to its current rotation. More...
 
void setTextures (const std::vector< Common::UString > &textures)
 Set textures to the node. More...
 
void computeInverseBindPose ()
 
void computeAbsoluteTransform ()
 
float getAlpha ()
 Get the alpha (transparency) of the node. More...
 
void setAlpha (float alpha, bool isRecursive=true)
 Set the alpha (transparency) of the node. More...
 
float getScaleX ()
 
float getScaleY ()
 
float getScaleZ ()
 
ModelNodegetParent ()
 Get the node's parent. More...
 
const ModelNodegetParent () const
 Get the node's parent. More...
 
void setParent (ModelNode *parent)
 Set the node's parent. More...
 
std::list< ModelNode * > & getChildren ()
 Get the node's children. More...
 
MeshgetMesh () const
 
bool isInFrontOf (const ModelNode &node) const
 Is this node in front of that other node? More...
 
void inheritPosition (ModelNode &node) const
 
void inheritOrientation (ModelNode &node) const
 

Protected Member Functions

void buildMaterial ()
 
- Protected Member Functions inherited from Graphics::Aurora::ModelNode
void loadTextures (const std::vector< Common::UString > &textures)
 
void createBound ()
 
void createCenter ()
 
void createAbsoluteBound ()
 
void createAbsoluteBound (Common::BoundingBox parentPosition)
 
void render (RenderPass pass)
 
void drawSkeleton (const glm::mat4 &parent, bool showInvisible)
 
void calcRenderTransform (const glm::mat4 &parentTransform)
 Calculate the transform used for rendering. More...
 
void renderImmediate (const glm::mat4 &parentTransform)
 
void queueRender (const glm::mat4 &parentTransform)
 
void lockFrame ()
 
void unlockFrame ()
 
void lockFrameIfVisible ()
 
void unlockFrameIfVisible ()
 
void setBufferedPosition (float x, float y, float z)
 
void setBufferedOrientation (float x, float y, float z, float angle)
 
void flushBuffers ()
 
TextureHandlegetTextures (uint32 &count)
 
TextureHandlegetEnvironmentMap (EnvironmentMapMode &mode)
 
void setMaterial (Shader::ShaderMaterial *material)
 

Private Member Functions

void readMesh (Model_Witcher::ParserContext &ctx)
 
void readTexturePaint (Model_Witcher::ParserContext &ctx)
 
void readTextures (Model_Witcher::ParserContext &ctx, std::vector< Common::UString > &textures)
 
void readNodeControllers (Model_Witcher::ParserContext &ctx, uint32 offset, uint32 count, std::vector< float > &data)
 
void evaluateTextures (int n, std::vector< Common::UString > &textures, const Common::UString *staticTextures, const uint32 *tVertsCount, bool lightMapDayNight, const Common::UString &lightMapName)
 

Additional Inherited Members

- Public Types inherited from Graphics::Aurora::ModelNode
enum  EnvironmentMapMode { kModeEnvironmentBlendedUnder, kModeEnvironmentBlendedOver }
 The way the environment map is applied to a model node. More...
 
- Protected Attributes inherited from Graphics::Aurora::ModelNode
Model_model
 The model this node belongs to. More...
 
ModelNode_parent
 The node's parent. More...
 
std::list< ModelNode * > _children
 The node's children. More...
 
Model_attachedModel
 The model that is attached to this node. More...
 
uint32 _level
 
Common::UString _name
 The node's name. More...
 
std::vector< Shader::ShaderRenderable_renderableArray
 Damn you bioware. More...
 
float _center [3]
 The node's center. More...
 
float _position [3]
 Position of the node. More...
 
float _rotation [3]
 Node rotation. More...
 
float _orientation [4]
 Orientation of the node. More...
 
float _scale [3]
 Scale of the node. More...
 
float _alpha
 Alpha of the node, used if no _mesh is present in this node. More...
 
std::vector< PositionKeyFrame_positionFrames
 Keyframes for position animation. More...
 
std::vector< QuaternionKeyFrame_orientationFrames
 Keyframes for orientation animation. More...
 
glm::mat4 _absolutePosition
 Position of the node after translate/rotate. More...
 
glm::mat4 _renderTransform
 
bool _render
 Render the node? More...
 
bool _dirtyRender
 Rendering information needs updating. More...
 
bool _dirtyMesh
 Mesh data needs updating. More...
 
Mesh_mesh
 
ModelNode_rootStateNode
 
Common::BoundingBox _boundBox
 
Common::BoundingBox _absoluteBoundBox
 
uint16 _nodeNumber
 
glm::mat4 _invBindPose
 Inverse bind pose matrix used for animations. More...
 
glm::mat4 _absoluteTransform
 Absolute transformation matrix used for animations. More...
 
float _positionBuffer [3]
 
bool _positionBuffered
 
float _orientationBuffer [4]
 
bool _orientationBuffered
 
std::vector< float > _vertexCoordsBuffer
 
bool _vertexCoordsBuffered
 
Shader::ShaderMaterial_material
 
Shader::ShaderRenderable_shaderRenderable
 

Detailed Description

Definition at line 85 of file model_witcher.h.

Constructor & Destructor Documentation

◆ ModelNode_Witcher()

Graphics::Aurora::ModelNode_Witcher::ModelNode_Witcher ( Model model)

Definition at line 242 of file model_witcher.cpp.

Referenced by load().

Here is the caller graph for this function:

◆ ~ModelNode_Witcher()

Graphics::Aurora::ModelNode_Witcher::~ModelNode_Witcher ( )

Definition at line 245 of file model_witcher.cpp.

Member Function Documentation

◆ buildMaterial()

void Graphics::Aurora::ModelNode_Witcher::buildMaterial ( )
protectedvirtual

If there's no override of mesh, textures, or environment mapping, then don't bother to create any new renderables. Just make sure rootStateNode has some, and have the render queuing use the renderables from there instead. This isn't really a problem, as the per-modelnode data (modelview matrix in this case) is still supplied from _this object.

To get here, _mesh must exist and have some data. This is required to consider making a new renderable - otherwise, the renderable of the parent can be used directly. This may change depending what information the renderable is dependent on during creation. Important information in this case means texture or environment maps are overidden from any potential parent.

Seems that, regardless of _isTransparent, anything with shperical env mapping is opaque. This mostly comes from NWN, where it's seen that things marked as transparent actually shouldn't be. It's assumed this carries over to other game titles as well.

Sometimes the _textures handler array isn't matched up against what is properly loaded (missing files from disk). So do some brief sanity checks on this.

The Witcher will place diffuse texture as the second if there's more than one. In these cases, the first texture will be a lightmap. Because that makes sense.

Actually this looks like a case where someone has declared multiple textures, but only filled in one. So the second, which should be a lightmap, is actually the diffuse. Just to screw with everyone's head a bit. Just set the colour, which will default to white - a diffuse texture treated as a lightmap, multiplying white, will end up with the same RGB values.

Reimplemented from Graphics::Aurora::ModelNode.

Definition at line 980 of file model_witcher.cpp.

References Graphics::Aurora::ModelNode::_dirtyRender, Graphics::Aurora::ModelNode::_mesh, Graphics::Aurora::ModelNode::_model, Graphics::Aurora::ModelNode::_name, Graphics::Aurora::ModelNode::_render, Graphics::Aurora::ModelNode::_renderableArray, Graphics::Aurora::ModelNode::_rootStateNode, Graphics::Shader::ShaderDescriptor::addPass(), Graphics::Aurora::ModelNode::Mesh::alpha, Graphics::Shader::ShaderDescriptor::BLEND_DST_ALPHA, Graphics::Shader::ShaderDescriptor::BLEND_MULTIPLY, Graphics::Shader::ShaderDescriptor::BLEND_ONE, Graphics::Shader::ShaderDescriptor::BLEND_SRC_ALPHA, Graphics::Shader::ShaderDescriptor::build(), Graphics::Shader::ShaderDescriptor::COLOUR, Graphics::Shader::ShaderDescriptor::connect(), Graphics::Aurora::ModelNode::Mesh::data, Graphics::Shader::ShaderDescriptor::declareInput(), Graphics::Shader::ShaderDescriptor::declareSampler(), Graphics::Aurora::TextureHandle::empty(), Common::UString::empty(), Graphics::Shader::ShaderDescriptor::ENV_CUBE, Graphics::Shader::ShaderDescriptor::ENV_SPHERE, Graphics::Aurora::ModelNode::MeshData::envMap, Graphics::Shader::ShaderDescriptor::genName(), Graphics::Aurora::ModelNode::getEnvironmentMap(), Graphics::Aurora::Texture::getImage(), Graphics::Aurora::ModelNode::getMesh(), Graphics::Aurora::TextureHandle::getName(), Graphics::Aurora::Model::getNode(), Graphics::Aurora::Model::getState(), Graphics::Aurora::TextureHandle::getTexture(), Graphics::Aurora::ModelNode::getTextures(), Graphics::Shader::ShaderMaterial::getVariableData(), Graphics::Mesh::Mesh::getVertexBuffer(), Graphics::VertexBuffer::getVertexDecl(), GfxMan, Graphics::Shader::ShaderSampler::handle, Graphics::Shader::ShaderDescriptor::INPUT_NORMAL0, Graphics::Shader::ShaderDescriptor::INPUT_POSITION0, Graphics::Shader::ShaderDescriptor::INPUT_UV0, Graphics::Shader::ShaderDescriptor::INPUT_UV1, Graphics::Shader::ShaderDescriptor::INPUT_UV_CUBE, Graphics::Shader::ShaderDescriptor::INPUT_UV_SPHERE, Graphics::ImageDecoder::isCubeMap(), Graphics::Aurora::ModelNode::Mesh::isTransparent, Graphics::Aurora::ModelNode::kModeEnvironmentBlendedOver, Graphics::Aurora::ModelNode::kModeEnvironmentBlendedUnder, Graphics::Shader::ShaderMaterial::MATERIAL_DECAL, Graphics::Shader::ShaderMaterial::MATERIAL_OPAQUE, Graphics::Shader::ShaderMaterial::MATERIAL_SPECIAL_BLEND, Graphics::Shader::ShaderMaterial::MATERIAL_TRANSPARENT, MaterialMan, Graphics::Aurora::ModelNode::MeshData::rawMesh, Graphics::Shader::ShaderDescriptor::SAMPLER_2D, Graphics::Shader::ShaderDescriptor::SAMPLER_CUBE, Graphics::Shader::ShaderDescriptor::SAMPLER_TEXTURE_0, Graphics::Shader::ShaderDescriptor::SAMPLER_TEXTURE_1, Graphics::Shader::ShaderDescriptor::SAMPLER_TEXTURE_2, Graphics::Shader::ShaderDescriptor::SAMPLER_TEXTURE_3, Graphics::Shader::ShaderDescriptor::SAMPLER_TEXTURE_7, Graphics::Shader::ShaderMaterial::setFlags(), Graphics::Shader::SHADER_FRAGMENT, Graphics::Shader::SHADER_VERTEX, ShaderMan, SurfaceMan, Graphics::Shader::ShaderDescriptor::TEXTURE_DIFFUSE, Graphics::Shader::ShaderDescriptor::TEXTURE_LIGHTMAP, and Graphics::Aurora::ModelNode::MeshData::textures.

Referenced by readTexturePaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evaluateTextures()

void Graphics::Aurora::ModelNode_Witcher::evaluateTextures ( int  n,
std::vector< Common::UString > &  textures,
const Common::UString staticTextures,
const uint32 tVertsCount,
bool  lightMapDayNight,
const Common::UString lightMapName 
)
private

Definition at line 897 of file model_witcher.cpp.

References Aurora::kResourceImage, and ResMan.

Referenced by readMesh(), and readTexturePaint().

Here is the caller graph for this function:

◆ load()

void Graphics::Aurora::ModelNode_Witcher::load ( Model_Witcher::ParserContext ctx)

Dirty hack around an issue where sometimes a tile can have multiple meshes of exactly the same name. This dirty hack will double up on static objects without state, but hopefully they're relatively few and it won't impact performance too much. A future improvement will be to see if an entire model has already been loaded and to use that directly: that should prevent models with an empty state from being affected by this dirty hack. Screw you bioware.

Definition at line 248 of file model_witcher.cpp.

References Graphics::Aurora::ModelNode::_mesh, Graphics::Aurora::ModelNode::_model, Graphics::Aurora::ModelNode::_name, Graphics::Aurora::ModelNode::_render, Common::UString::c_str(), Graphics::Aurora::ModelNode::Mesh::data, Graphics::Mesh::Mesh::init(), Common::kEncodingASCII, Graphics::Aurora::kNodeTypeTexturePaint, Graphics::Aurora::kNodeTypeTrimesh, load(), Graphics::Aurora::Model_Witcher::ParserContext::mdb, Graphics::Aurora::Model_Witcher::ParserContext::mdlName, MeshMan, ModelNode_Witcher(), Graphics::Aurora::Model_Witcher::ParserContext::nodes, Graphics::Aurora::Model_Witcher::ParserContext::offModelData, Graphics::Aurora::ModelNode::MeshData::rawMesh, Graphics::Aurora::Model::readArray(), Graphics::Aurora::Model::readArrayDef(), readMesh(), readNodeControllers(), Common::readStringFixed(), readTexturePaint(), Common::ReadStream::readUint32LE(), Common::SeekableReadStream::seek(), Graphics::Mesh::Mesh::setName(), Graphics::Aurora::ModelNode::setParent(), Common::SeekableReadStream::skip(), Graphics::Aurora::Model_Witcher::ParserContext::state, and warning().

Referenced by Graphics::Aurora::Model_Witcher::load(), and load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readMesh()

void Graphics::Aurora::ModelNode_Witcher::readMesh ( Model_Witcher::ParserContext ctx)
private

Definition at line 360 of file model_witcher.cpp.

References Graphics::Aurora::ModelNode::_mesh, Graphics::Aurora::ModelNode::_render, Graphics::Aurora::ModelNode::Mesh::ambient, Graphics::Aurora::ModelNode::Mesh::beaming, Common::UString::clear(), Graphics::Aurora::ModelNode::createBound(), Graphics::Aurora::ModelNode::Mesh::data, Graphics::Aurora::ModelNode::Mesh::diffuse, evaluateTextures(), Graphics::Aurora::Model_Witcher::ParserContext::fileVersion, Graphics::IndexBuffer::getData(), Graphics::VertexBuffer::getData(), Graphics::Mesh::Mesh::getIndexBuffer(), Graphics::Mesh::Mesh::getVertexBuffer(), Graphics::Aurora::ModelNode::Mesh::hasTransparencyHint, Common::kEncodingASCII, Graphics::Aurora::ModelNode::loadTextures(), Graphics::Aurora::Model_Witcher::ParserContext::mdb, Graphics::Aurora::Model_Witcher::ParserContext::offRawData, Graphics::Aurora::Model_Witcher::ParserContext::offTexData, Graphics::Aurora::Model_Witcher::ParserContext::offTextureInfo, Graphics::Aurora::ModelNode::MeshData::rawMesh, Graphics::Aurora::Model::readArrayDef(), Common::ReadStream::readByte(), Common::ReadStream::readIEEEFloatLE(), Common::readStringFixed(), readTextures(), Common::ReadStream::readUint32BE(), Common::ReadStream::readUint32LE(), Graphics::Aurora::ModelNode::Mesh::render, Common::SeekableReadStream::seek(), Graphics::IndexBuffer::setSize(), Graphics::VertexBuffer::setVertexDeclLinear(), Graphics::Aurora::ModelNode::Mesh::shadow, Graphics::Aurora::ModelNode::Mesh::shininess, Common::SeekableReadStream::skip(), Graphics::Aurora::ModelNode::Mesh::transparencyHint, Graphics::VNORMAL, Graphics::VPOSITION, and Graphics::VTCOORD.

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readNodeControllers()

void Graphics::Aurora::ModelNode_Witcher::readNodeControllers ( Model_Witcher::ParserContext ctx,
uint32  offset,
uint32  count,
std::vector< float > &  data 
)
private

◆ readTexturePaint()

void Graphics::Aurora::ModelNode_Witcher::readTexturePaint ( Model_Witcher::ParserContext ctx)
private

◆ readTextures()

void Graphics::Aurora::ModelNode_Witcher::readTextures ( Model_Witcher::ParserContext ctx,
std::vector< Common::UString > &  textures 
)
private

The documentation for this class was generated from the following files: