55 e.
add(
"Failed to load TRX \"%s\"", resRef.
c_str());
72 for (ObjectList::iterator w =
_water.begin(); w !=
_water.end(); ++w)
88 for (ObjectList::iterator w =
_water.begin(); w !=
_water.end(); ++w)
98 if (magic !=
MKTAG(
'N',
'W',
'N',
'2'))
103 if ((versionMajor != 2) || (versionMinor != 3))
107 if ((trx.
size() - trx.
pos()) < (packetCount * 8))
110 std::vector<Packet> packets;
111 packets.resize(packetCount);
118 for (std::vector<Packet>::iterator p = packets.begin(); p != packets.end(); ++p) {
122 if (p->offset >= trx.
size())
123 throw Common::Exception(
"Offset of 0x%08X packet too big (%d)", p->type, p->offset);
128 for (std::vector<Packet>::iterator p = packets.begin(); p != packets.end(); ++p) {
133 throw Common::Exception(
"Packet type mismatch (0x%08X vs 0x%08X)", type, p->type);
136 if ((trx.
size() - trx.
pos()) < p->size)
144 if (packet.
type ==
MKTAG(
'T',
'R',
'W',
'H'))
146 else if (packet.
type ==
MKTAG(
'T',
'R',
'R',
'N'))
148 else if (packet.
type ==
MKTAG(
'W',
'A',
'T',
'R'))
150 else if (packet.
type ==
MKTAG(
'A',
'S',
'W',
'M'))
157 if (packet.
size != 12)
172 for (
int i = 0; i < 6; i++)
175 float textureColors[6][3];
176 for (
int i = 0; i < 6; i++)
177 for (
int j = 0; j < 3; j++)
178 textureColors[i][j] = ttrn.readIEEEFloatLE();
180 const uint32 vCount = ttrn.readUint32LE();
181 const uint32 fCount = ttrn.readUint32LE();
192 float *v =
reinterpret_cast<float *
>(vBuf.
getData());
193 for (
uint32 i = 0; i < vCount; i++) {
194 *v++ = ttrn.readIEEEFloatLE();
195 *v++ = ttrn.readIEEEFloatLE();
196 *v++ = ttrn.readIEEEFloatLE();
198 *v++ = ttrn.readIEEEFloatLE();
199 *v++ = ttrn.readIEEEFloatLE();
200 *v++ = ttrn.readIEEEFloatLE();
202 for (
int j = 0; j < 3; j++) {
204 float rgb = ttrn.readByte() / 255.0f;
206 for (
int k = 0; k < 6; k++) {
207 if (!textures[k].empty()) {
208 rgb += textureColors[k][j];
218 *v++ = ttrn.readByte() / 255.0f;
227 for (
uint32 i = 0; i < fCount; i++) {
228 *f++ = ttrn.readUint16LE();
229 *f++ = ttrn.readUint16LE();
230 *f++ = ttrn.readUint16LE();
251 color[0] = watr.readIEEEFloatLE();
252 color[1] = watr.readIEEEFloatLE();
253 color[2] = watr.readIEEEFloatLE();
264 for (
int i = 0; i < 3; i++) {
276 uint32 vCount = watr.readUint32LE();
277 uint32 fCount = watr.readUint32LE();
287 float *v =
reinterpret_cast<float *
>(vBuf.
getData());
288 for (
uint32 i = 0; i < vCount; i++) {
289 *v++ = watr.readIEEEFloatLE();
290 *v++ = watr.readIEEEFloatLE();
291 *v++ = watr.readIEEEFloatLE();
304 for (
uint32 i = 0; i < fCount; i++) {
305 *f++ = watr.readUint16LE();
306 *f++ = watr.readUint16LE();
307 *f++ = watr.readUint16LE();
#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...
uint32 type
Type of the packet (TRWH, TRRN, WATR, ASWM).
void add(const char *s,...) GCC_PRINTF(2
The global graphics manager.
uint32 readUint32LE()
Read an unsigned 32-bit word stored in little endian (LSB first) order from the stream and return it...
void loadPackets(Common::SeekableReadStream &trx, std::vector< Packet > &packets)
Load the packets.
A class holding an UTF-8 string.
virtual size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)=0
Sets the stream position indicator for the stream.
uint32 size
Size of the packet.
void setVertexDeclInterleave(uint32 vertCount, VertexDecl &decl)
Set the interleaved vertex declaration for this buffer.
std::vector< VertexAttrib > VertexDecl
Vertex data layout.
Utility templates and functions for working with strings and streams.
Exception that provides a stack of explanations.
A simple scoped smart pointer template.
Basic exceptions to throw.
void loadTRWH(Common::SeekableReadStream &trx, Packet &packet)
Load TRWH (size information) packets.
const char * c_str() const
Return the (utf8 encoded) string data.
void loadASWM(Common::SeekableReadStream &trx, Packet &packet)
Load ASWM (walk mesh) packets.
void loadTRRN(Common::SeekableReadStream &trx, Packet &packet)
Load TRRN (terrain tile) packets.
Utility functions for working with differing string encodings.
Buffer containing vertex data.
virtual size_t size() const =0
Obtains the total size of the stream, measured in bytes.
Basic reading stream interfaces.
virtual size_t pos() const =0
Obtains the current value of the stream position indicator of the stream.
A packet within a TRX file.
uint32 readUint32BE()
Read an unsigned 32-bit word stored in big endian (MSB first) order from the stream and return it...
void loadWATR(Common::SeekableReadStream &trx, Packet &packet)
Load WATR (water tile) packets.
TRXFile(const Common::UString &resRef)
Plain, unextended ASCII (7bit clean).
void loadPacket(Common::SeekableReadStream &trx, Packet &packet)
Load one packets.
UString debugTag(uint32 tag, bool trim)
Create an elaborate string from an integer tag, for debugging purposes.
GLvoid * getData()
Access buffer data.
void load(Common::SeekableReadStream &trx)
void loadDirectory(Common::SeekableReadStream &trx, std::vector< Packet > &packets)
Load the packets directory.
Buffer containing indices data.
UString readStringFixed(SeekableReadStream &stream, Encoding encoding, size_t length)
Read length bytes as a string with the given encoding out of a stream.
SeekableSubReadStream provides access to a SeekableReadStream restricted to the range [begin...
Loader for Neverwinter Nights 2 baked terrain files (TRX).
Generic vertex attribute data.
Interface for a seekable & readable data stream.
#define GfxMan
Shortcut for accessing the graphics manager.
void setSize(uint32 indexCount, uint32 indexSize, GLenum indexType)
Change buffer size.
The global resource manager for Aurora resources.