74 for (std::list<ModelNode_NWN2 *>::iterator n = nodes.begin(); n != nodes.end(); ++n)
98 for (NodeList::iterator n = (*s)->nodeList.begin(); n != (*s)->nodeList.end(); ++n)
99 dynamic_cast<ModelNode_NWN2 &>(**n).setTint(tint);
106 for (NodeList::iterator n = (*s)->nodeList.begin(); n != (*s)->nodeList.end(); ++n)
107 if ((*n)->getName().beginsWith(
"TL_"))
108 if ((*n)->getName().endsWith(
"_F"))
109 dynamic_cast<ModelNode_NWN2 &>(**n).setTint(tint);
118 for (NodeList::iterator n = (*s)->nodeList.begin(); n != (*s)->nodeList.end(); ++n)
119 if ((*n)->getName().beginsWith(
"TL_"))
120 if (!(*n)->getName().endsWith(
"_F") && !(*n)->getName().endsWith(
"_R") &&
121 !(*n)->getName().endsWith(
"_W") && !(*n)->getName().endsWith(
"_C3"))
122 dynamic_cast<ModelNode_NWN2 &>(**n).setTint(tint);
135 std::vector<PacketKey> packetKeys;
136 packetKeys.resize(packetCount);
137 for (std::vector<PacketKey>::iterator packetKey = packetKeys.begin();
138 packetKey != packetKeys.end(); ++packetKey) {
146 for (std::vector<PacketKey>::const_iterator packetKey = packetKeys.begin();
147 packetKey != packetKeys.end(); ++packetKey) {
149 ctx.
mdb->
seek(packetKey->offset);
152 bool success =
false;
154 if (packetKey->signature ==
kRigidID)
156 else if (packetKey->signature ==
kSkinID)
160 ctx.
nodes.push_back(newNode);
180 for (std::list<ModelNode_NWN2 *>::iterator n = ctx.
nodes.begin();
181 n != ctx.
nodes.end(); ++n) {
184 ctx.
state->
nodeMap.insert(std::make_pair((*n)->getName(), *n));
186 if (!(*n)->getParent())
242 if ((vertexCount == 0) || (facesCount == 0))
249 std::vector<Common::UString> textures;
250 textures.push_back(diffuseMap);
268 for (
uint32 i = 0; i < vertexCount; i++) {
302 for (
uint32 i = 0; i < facesCount * 3; i++)
307 if (ctx.
state->name.size() != 0) {
308 meshName += ctx.
state->name;
310 meshName +=
"xoreos.default";
317 warning(
"Warning: probable mesh duplication of: %s, attempting to correct", meshName.
c_str());
367 if ((vertexCount == 0) || (facesCount == 0))
374 std::vector<Common::UString> textures;
375 textures.push_back(diffuseMap);
393 for (
uint32 i = 0; i < vertexCount; i++) {
430 for (
uint32 i = 0; i < facesCount * 3; i++)
437 if (ctx.
state->name.size() != 0) {
438 meshName += ctx.
state->name;
440 meshName +=
"xoreos.default";
447 warning(
"Warning: probable mesh duplication of: %s, attempting to correct", meshName.
c_str());
465 memcpy(
_tint, tint, 3 * 4 *
sizeof(
float));
510 for (
int n = 0; n < tintImg.
width * tintImg.
height; n++) {
511 float srcColor[4], dstColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
512 tintImg.
getPixel(n, srcColor[0], srcColor[1], srcColor[2], srcColor[3]);
514 if (srcColor[3] != 0.0f) {
517 for (
int i = 0; i < 3; i++) {
518 for (
int j = 0; j < 3; j++)
523 for (
int i = 0; i < 3; i++)
526 tintedImg.
setPixel(n, dstColor[0], dstColor[1], dstColor[2], dstColor[3]);
#define ResMan
Shortcut for accessing the sound manager.
GLvoid * getData()
Access buffer data.
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like 'DATA', to ensure portability.
uint16 readUint16LE()
Read an unsigned 16-bit word stored in little endian (LSB first) order from the stream and return it...
Generic image decoder interface.
void lockFrameIfVisible()
NodeMap nodeMap
The nodes within the state, indexed by name.
Vertex texture coordinates, VTCOORDi = VTCOORD + i.
uint32 readUint32LE()
Read an unsigned 32-bit word stored in little endian (LSB first) order from the stream and return it...
void getPixel(int x, int y, float &r, float &g, float &b, float &a) const
Get the color values of the pixel at this position.
A class holding an UTF-8 string.
#define TextureMan
Shortcut for accessing the texture manager.
virtual size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)=0
Sets the stream position indicator for the stream.
VertexBuffer * getVertexBuffer()
void loadTextures(const std::vector< Common::UString > &textures)
static Texture * create(const Common::UString &name, bool deswizzle=false)
Create a texture from this image resource.
void init()
General mesh initialisation, queuing the mesh for GL resource creation.
The Aurora texture manager.
bool render
Render this mesh?
Common::UString name
The state's name.
void setTintFloor(const float tint[3][4])
Tint all floor nodes of the model with these tint colors.
NodeList rootNodes
The nodes in the state without a parent.
void setVertexDeclInterleave(uint32 vertCount, VertexDecl &decl)
Set the interleaved vertex declaration for this buffer.
State * _currentState
The current state.
bool endsWith(const UString &with) const
bool _render
Render the node?
Common::UString _fileName
The model's file name.
std::vector< VertexAttrib > VertexDecl
Vertex data layout.
#define IGNORE_UNUSED_VARIABLES
Utility templates and functions for working with strings and streams.
int height
The mip map's height.
void decompress()
Manually decompress the texture image data.
Model_NWN2(const Common::UString &name, ModelType type=kModelTypeObject)
Basic exceptions to throw.
friend class ModelNode_NWN2
const char * c_str() const
Return the (utf8 encoded) string data.
ModelNode_NWN2(Model &model)
ModelType
The display type of a model.
static ImageDecoder * loadImage(const Common::UString &name, bool deswizzle=false)
Load an image in any of the common texture formats.
void unlockFrameIfVisible()
void newState(ParserContext &ctx)
void setPixel(int x, int y, float r, float g, float b, float a)
Set the color values of the pixel at this position.
virtual size_t skip(ptrdiff_t offset)
Skip the specified number of bytes, adding that offset to the current position in the stream...
const MipMap & getMipMap(size_t mipMap, size_t layer=0) const
Return a mip map.
Utility functions for working with differing string encodings.
bool loadSkin(Model_NWN2::ParserContext &ctx)
bool empty() const
Is the string empty?
float specular[3]
Specular color.
NodeList nodeList
The nodes within the state.
void setTintWalls(const float tint[3][4])
Tint all wall nodes of the model with these tint colors.
void warning(const char *s,...)
StateMap _stateMap
All states within this model, index by name.
std::vector< TextureHandle > textures
Textures.
Basic reading stream interfaces.
static IGNORE_UNUSED_VARIABLES const uint32 kMDBID
void setTint(const float tint[3][4])
bool loadRigid(Model_NWN2::ParserContext &ctx)
uint32 readUint32BE()
Read an unsigned 32-bit word stored in big endian (MSB first) order from the stream and return it...
const MipMap & getMipMap(size_t mipMap) const
Return a mip map.
FORCEINLINE float readIEEEFloatLE()
Read a 32-bit IEEE float stored in little endian (LSB first) order from the stream and return it...
void setTint(const float tint[3][4])
Tint the whole model with these tint colors.
#define MeshMan
Shortcut for accessing the shader manager.
Basic type definitions to handle files used in BioWare's Aurora engine.
Plain, unextended ASCII (7bit clean).
int width
The mip map's width.
An image surface, in BGRA format.
Graphics::Mesh::Mesh * rawMesh
Node raw mesh data.
Common::UString _name
The node's name.
std::list< ModelNode_NWN2 * > nodes
ParserContext(const Common::UString &name)
A texture as used in the Aurora engines.
UString debugTag(uint32 tag, bool trim)
Create an elaborate string from an integer tag, for debugging purposes.
GLvoid * getData()
Access buffer data.
float diffuse[3]
Diffuse color.
Common::SeekableReadStream * mdb
A generic interface for image decoders.
void finalize()
Finalize the loading procedure.
UString readStringFixed(SeekableReadStream &stream, Encoding encoding, size_t length)
Read length bytes as a string with the given encoding out of a stream.
void setName(const Common::UString &name)
Loading MDB files found in Neverwinter Nights 2.
void load(ParserContext &ctx)
StateList _stateList
All states within this model.
static const uint32 kRigidID
Generic vertex attribute data.
IndexBuffer * getIndexBuffer()
bool isCompressed() const
Is the image data compressed?
void setSize(uint32 indexCount, uint32 indexSize, GLenum indexType)
Change buffer size.
The global resource manager for Aurora resources.
void addState(ParserContext &ctx)
static const uint32 kSkinID