xoreos  0.0.5
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Engines::NWN2::TRXFile Class Reference

Loader for TRX, baked terrain files, found in Neverwinter Nights 2. More...

#include <trxfile.h>

Collaboration diagram for Engines::NWN2::TRXFile:
Collaboration graph
[legend]

Classes

struct  Packet
 A packet within a TRX file. More...
 

Public Member Functions

 TRXFile (const Common::UString &resRef)
 
 ~TRXFile ()
 
void show ()
 
void hide ()
 

Private Types

typedef Common::PtrList< Graphics::Aurora::GeometryObjectObjectList
 

Private Member Functions

void load (Common::SeekableReadStream &trx)
 
void loadDirectory (Common::SeekableReadStream &trx, std::vector< Packet > &packets)
 Load the packets directory. More...
 
void loadPackets (Common::SeekableReadStream &trx, std::vector< Packet > &packets)
 Load the packets. More...
 
void loadPacket (Common::SeekableReadStream &trx, Packet &packet)
 Load one packets. More...
 
void loadTRWH (Common::SeekableReadStream &trx, Packet &packet)
 Load TRWH (size information) packets. More...
 
void loadTRRN (Common::SeekableReadStream &trx, Packet &packet)
 Load TRRN (terrain tile) packets. More...
 
void loadWATR (Common::SeekableReadStream &trx, Packet &packet)
 Load WATR (water tile) packets. More...
 
void loadASWM (Common::SeekableReadStream &trx, Packet &packet)
 Load ASWM (walk mesh) packets. More...
 

Private Attributes

bool _visible
 
uint32 _width
 
uint32 _height
 
ObjectList _terrain
 
ObjectList _water
 

Detailed Description

Loader for TRX, baked terrain files, found in Neverwinter Nights 2.

While indoor areas in Neverwinter Nights 2 use tiles similar to those found in the first Neverwinter Nights game, outdoor areas use a more free-form and dynamic terrain.

A TRX file consists of 4 "packet" types:

Usually, there should be exactly one TRWH packet, followed by an arbitrary number of TRRN, WATR and ASWM packets. TRRN packets are divided into tiles, rectangular areas for a piece of the ground, while WATR packets divide the bodies of water in more natural ways.

Definition at line 66 of file trxfile.h.

Member Typedef Documentation

◆ ObjectList

Definition at line 82 of file trxfile.h.

Constructor & Destructor Documentation

◆ TRXFile()

Engines::NWN2::TRXFile::TRXFile ( const Common::UString resRef)

Definition at line 46 of file trxfile.cpp.

References Common::StackException::add(), Common::UString::c_str(), Aurora::kFileTypeTRX, load(), and ResMan.

Here is the call graph for this function:

◆ ~TRXFile()

Engines::NWN2::TRXFile::~TRXFile ( )

Definition at line 60 of file trxfile.cpp.

References hide().

Here is the call graph for this function:

Member Function Documentation

◆ hide()

void Engines::NWN2::TRXFile::hide ( )

Definition at line 80 of file trxfile.cpp.

References _terrain, _visible, _water, and GfxMan.

Referenced by ~TRXFile().

Here is the caller graph for this function:

◆ load()

void Engines::NWN2::TRXFile::load ( Common::SeekableReadStream trx)
private

Definition at line 96 of file trxfile.cpp.

References Common::debugTag(), loadDirectory(), loadPackets(), MKTAG, Common::SeekableReadStream::pos(), Common::ReadStream::readUint16LE(), Common::ReadStream::readUint32BE(), Common::ReadStream::readUint32LE(), and Common::SeekableReadStream::size().

Referenced by TRXFile().

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

◆ loadASWM()

void Engines::NWN2::TRXFile::loadASWM ( Common::SeekableReadStream trx,
Packet packet 
)
private

Load ASWM (walk mesh) packets.

Definition at line 321 of file trxfile.cpp.

Referenced by loadPacket().

Here is the caller graph for this function:

◆ loadDirectory()

void Engines::NWN2::TRXFile::loadDirectory ( Common::SeekableReadStream trx,
std::vector< Packet > &  packets 
)
private

Load the packets directory.

Definition at line 117 of file trxfile.cpp.

References Common::ReadStream::readUint32BE(), Common::ReadStream::readUint32LE(), and Common::SeekableReadStream::size().

Referenced by load().

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

◆ loadPacket()

void Engines::NWN2::TRXFile::loadPacket ( Common::SeekableReadStream trx,
Packet packet 
)
private

Load one packets.

Definition at line 143 of file trxfile.cpp.

References Common::UString::c_str(), Common::debugTag(), loadASWM(), loadTRRN(), loadTRWH(), loadWATR(), MKTAG, and Engines::NWN2::TRXFile::Packet::type.

Referenced by loadPackets().

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

◆ loadPackets()

void Engines::NWN2::TRXFile::loadPackets ( Common::SeekableReadStream trx,
std::vector< Packet > &  packets 
)
private

Load the packets.

Definition at line 127 of file trxfile.cpp.

References loadPacket(), Common::SeekableReadStream::pos(), Common::ReadStream::readUint32BE(), Common::ReadStream::readUint32LE(), Common::SeekableReadStream::seek(), and Common::SeekableReadStream::size().

Referenced by load().

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

◆ loadTRRN()

void Engines::NWN2::TRXFile::loadTRRN ( Common::SeekableReadStream trx,
Packet packet 
)
private

◆ loadTRWH()

void Engines::NWN2::TRXFile::loadTRWH ( Common::SeekableReadStream trx,
Packet packet 
)
private

Load TRWH (size information) packets.

Definition at line 156 of file trxfile.cpp.

References _height, _width, Common::ReadStream::readUint32LE(), and Engines::NWN2::TRXFile::Packet::size.

Referenced by loadPacket().

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

◆ loadWATR()

void Engines::NWN2::TRXFile::loadWATR ( Common::SeekableReadStream trx,
Packet packet 
)
private

◆ show()

void Engines::NWN2::TRXFile::show ( )

Definition at line 64 of file trxfile.cpp.

References _terrain, _visible, _water, and GfxMan.

Member Data Documentation

◆ _height

uint32 Engines::NWN2::TRXFile::_height
private

Definition at line 88 of file trxfile.h.

Referenced by loadTRWH().

◆ _terrain

ObjectList Engines::NWN2::TRXFile::_terrain
private

Definition at line 90 of file trxfile.h.

Referenced by hide(), loadTRRN(), and show().

◆ _visible

bool Engines::NWN2::TRXFile::_visible
private

Definition at line 85 of file trxfile.h.

Referenced by hide(), and show().

◆ _water

ObjectList Engines::NWN2::TRXFile::_water
private

Definition at line 91 of file trxfile.h.

Referenced by hide(), loadWATR(), and show().

◆ _width

uint32 Engines::NWN2::TRXFile::_width
private

Definition at line 87 of file trxfile.h.

Referenced by loadTRWH().


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