Nebula
Loading...
Searching...
No Matches
CoreGraphics::Nvx3StreamReader Class Reference

#include <nvx3streamreader.h>

Inherits IO::StreamReader.

Public Member Functions

 Nvx3StreamReader ()
 contructor
 
virtual ~Nvx3StreamReader ()
 destructor
 
void SetRawMode (bool b)
 enable/disable raw mode (raw mode does not setup vertex/index buffers), default is false
 
bool IsRawMode () const
 get raw mode flag
 
void SetUsage (Base::ResourceBase::Usage usage)
 set the intended resource usage (default is UsageImmutable)
 
Base::ResourceBase::Usage GetUsage () const
 get resource usage
 
void SetAccess (Base::ResourceBase::Access access)
 set the intended resource access (default is AccessNone)
 
Base::ResourceBase::Access GetAccess () const
 get the resource access
 
virtual bool Open ()
 begin reading from the stream, read entire data
 
virtual void Close ()
 end reading from the stream, destroys loaded objects
 
const Ptr< Base::VertexBufferBase > & GetVertexBuffer () const
 get vertex buffer (not valid in raw mode)
 
const Ptr< Base::IndexBufferBase > & GetIndexBuffer () const
 get index buffer (not valid in raw mode)
 
const Util::Array< CoreGraphics::PrimitiveGroup > & GetPrimitiveGroups () const
 get primitive groups
 
float * GetVertexData () const
 get pointer to raw vertex data
 
ushortGetIndexData () const
 get pointer to raw index data
 
SizeT GetNumVertices () const
 get number of vertices
 
SizeT GetNumIndices () const
 get number of indices
 
SizeT GetVertexWidth () const
 get vertex width
 
const Util::Array< CoreGraphics::VertexComponent > & GetVertexComponents () const
 get vertex components
 
void SetVertexBuffer (const Ptr< Base::VertexBufferBase > &vBuf)
 set the specialized vertex buffer
 
void SetVertexBufferLoader (const Ptr< Base::MemoryVertexBufferLoaderBase > &vBufLoader)
 set the specialized vertex buffer reader
 
- Public Member Functions inherited from IO::StreamReader
 StreamReader ()
 constructor
 
virtual ~StreamReader ()
 destructor
 
void SetStream (const Ptr< Stream > &s)
 set stream to read from
 
const Ptr< Stream > & GetStream () const
 get currently set stream
 
bool HasStream () const
 return true if a stream is set
 
bool Eof () const
 return true if the stream has reached EOF
 
bool IsOpen () const
 return true if currently open
 
- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Static Public Member Functions

static void ConvertVertexBufferEndianess (void *vertexPtr, SizeT numVertices, const Util::Array< CoreGraphics::VertexComponent > &vertexComps)
 helper method to convert vertex buffer endianess
 
- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 

Private Types

enum  N3VertexComponent {
  N3Coord = (1<<0) , N3Normal = (1<<1) , N3NormalUB4N = (1<<2) , N3Uv0 = (1<<3) ,
  N3Uv0S2 = (1<<4) , N3Uv1 = (1<<5) , N3Uv1S2 = (1<<6) , N3Uv2 = (1<<7) ,
  N3Uv2S2 = (1<<8) , N3Uv3 = (1<<9) , N3Uv3S2 = (1<<10) , N3Color = (1<<11) ,
  N3ColorUB4N = (1<<12) , N3Tangent = (1<<13) , N3TangentUB4N = (1<<14) , N3Binormal = (1<<15) ,
  N3BinormalUB4N = (1<<16) , N3Weights = (1<<17) , N3WeightsUB4N = (1<<18) , N3JIndices = (1<<19) ,
  N3JIndicesUB4 = (1<<20) , N3NumVertexComponents = 21 , N3AllComponents = ((1<<N3NumVertexComponents) - 1)
}
 Nebula vertex components, see Nebula's class for details. More...
 

Private Member Functions

 __DeclareClass (Nvx3StreamReader)
 
void ReadHeaderData ()
 read header data from stream
 
void ReadPrimitiveGroups ()
 read primitive groups from stream
 
void SetupVertexComponents ()
 setup vertex components array
 
void UpdateGroupBoundingBoxes ()
 update primitive group bounding boxes
 
void SetupVertexBuffer ()
 setup the vertex buffer object (not called in raw mode)
 
void SetupIndexBuffer ()
 setup the index buffer object (not called in raw mode)
 

Private Attributes

Base::ResourceBase::Usage usage
 
Base::ResourceBase::Access access
 
bool rawMode
 
Ptr< Base::VertexBufferBase > vertexBuffer
 
Ptr< Base::IndexBufferBase > indexBuffer
 
Ptr< Base::MemoryVertexBufferLoaderBase > vertexBufferLoader
 
Ptr< Base::MemoryIndexBufferLoaderBase > indexBufferLoader
 
Util::Array< CoreGraphics::PrimitiveGroupprimGroups
 
void * mapPtr
 
void * groupDataPtr
 
void * vertexDataPtr
 
void * indexDataPtr
 
SizeT groupDataSize
 
SizeT vertexDataSize
 
SizeT indexDataSize
 
uint numGroups
 
uint numVertices
 
uint vertexWidth
 
uint numIndices
 
uint vertexComponentMask
 
Util::Array< CoreGraphics::VertexComponentvertexComponents
 

Additional Inherited Members

- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 
- Protected Attributes inherited from IO::StreamReader
Ptr< Streamstream
 
bool isOpen
 
bool streamWasOpen
 

Member Enumeration Documentation

◆ N3VertexComponent

Nebula vertex components, see Nebula's class for details.

Enumerator
N3Coord 
N3Normal 
N3NormalUB4N 
N3Uv0 
N3Uv0S2 
N3Uv1 
N3Uv1S2 
N3Uv2 
N3Uv2S2 
N3Uv3 
N3Uv3S2 
N3Color 
N3ColorUB4N 
N3Tangent 
N3TangentUB4N 
N3Binormal 
N3BinormalUB4N 
N3Weights 
N3WeightsUB4N 
N3JIndices 
N3JIndicesUB4 
N3NumVertexComponents 
N3AllComponents 

Constructor & Destructor Documentation

◆ Nvx3StreamReader()

CoreGraphics::Nvx3StreamReader::Nvx3StreamReader ( )

contructor

◆ ~Nvx3StreamReader()

CoreGraphics::Nvx3StreamReader::~Nvx3StreamReader ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

CoreGraphics::Nvx3StreamReader::__DeclareClass ( Nvx3StreamReader )
private

◆ Close()

void CoreGraphics::Nvx3StreamReader::Close ( )
virtual

end reading from the stream, destroys loaded objects

Reimplemented from IO::StreamReader.

◆ ConvertVertexBufferEndianess()

static void CoreGraphics::Nvx3StreamReader::ConvertVertexBufferEndianess ( void * vertexPtr,
SizeT numVertices,
const Util::Array< CoreGraphics::VertexComponent > & vertexComps )
static

helper method to convert vertex buffer endianess

◆ GetAccess()

Base::ResourceBase::Access CoreGraphics::Nvx3StreamReader::GetAccess ( ) const
inline

get the resource access

◆ GetIndexBuffer()

const Ptr< Base::IndexBufferBase > & CoreGraphics::Nvx3StreamReader::GetIndexBuffer ( ) const
inline

get index buffer (not valid in raw mode)

◆ GetIndexData()

ushort * CoreGraphics::Nvx3StreamReader::GetIndexData ( ) const
inline

get pointer to raw index data

◆ GetNumIndices()

SizeT CoreGraphics::Nvx3StreamReader::GetNumIndices ( ) const
inline

get number of indices

◆ GetNumVertices()

SizeT CoreGraphics::Nvx3StreamReader::GetNumVertices ( ) const
inline

get number of vertices

◆ GetPrimitiveGroups()

const Util::Array< CoreGraphics::PrimitiveGroup > & CoreGraphics::Nvx3StreamReader::GetPrimitiveGroups ( ) const
inline

get primitive groups

◆ GetUsage()

Base::ResourceBase::Usage CoreGraphics::Nvx3StreamReader::GetUsage ( ) const
inline

get resource usage

◆ GetVertexBuffer()

const Ptr< Base::VertexBufferBase > & CoreGraphics::Nvx3StreamReader::GetVertexBuffer ( ) const
inline

get vertex buffer (not valid in raw mode)

◆ GetVertexComponents()

const Util::Array< CoreGraphics::VertexComponent > & CoreGraphics::Nvx3StreamReader::GetVertexComponents ( ) const
inline

get vertex components

◆ GetVertexData()

float * CoreGraphics::Nvx3StreamReader::GetVertexData ( ) const
inline

get pointer to raw vertex data

◆ GetVertexWidth()

SizeT CoreGraphics::Nvx3StreamReader::GetVertexWidth ( ) const
inline

get vertex width

◆ IsRawMode()

bool CoreGraphics::Nvx3StreamReader::IsRawMode ( ) const
inline

get raw mode flag

◆ Open()

bool CoreGraphics::Nvx3StreamReader::Open ( )
virtual

begin reading from the stream, read entire data

Reimplemented from IO::StreamReader.

◆ ReadHeaderData()

void CoreGraphics::Nvx3StreamReader::ReadHeaderData ( )
private

read header data from stream

This reads the nvx3 header data and checks whether the file is actually an nvx3 file through the magic number.

All header data will be read into member variables, and pointers to the start of the group-, vertex- and index-data will be setup.

NOTE: we assume that the file is in the correct byte order!

◆ ReadPrimitiveGroups()

void CoreGraphics::Nvx3StreamReader::ReadPrimitiveGroups ( )
private

read primitive groups from stream

◆ SetAccess()

void CoreGraphics::Nvx3StreamReader::SetAccess ( Base::ResourceBase::Access access)
inline

set the intended resource access (default is AccessNone)

◆ SetRawMode()

void CoreGraphics::Nvx3StreamReader::SetRawMode ( bool b)
inline

enable/disable raw mode (raw mode does not setup vertex/index buffers), default is false

◆ SetupIndexBuffer()

void CoreGraphics::Nvx3StreamReader::SetupIndexBuffer ( )
private

setup the index buffer object (not called in raw mode)

◆ SetupVertexBuffer()

void CoreGraphics::Nvx3StreamReader::SetupVertexBuffer ( )
private

setup the vertex buffer object (not called in raw mode)

◆ SetupVertexComponents()

void CoreGraphics::Nvx3StreamReader::SetupVertexComponents ( )
private

setup vertex components array

◆ SetUsage()

void CoreGraphics::Nvx3StreamReader::SetUsage ( Base::ResourceBase::Usage usage)
inline

set the intended resource usage (default is UsageImmutable)

◆ SetVertexBuffer()

void CoreGraphics::Nvx3StreamReader::SetVertexBuffer ( const Ptr< Base::VertexBufferBase > & vBuf)
inline

set the specialized vertex buffer

◆ SetVertexBufferLoader()

void CoreGraphics::Nvx3StreamReader::SetVertexBufferLoader ( const Ptr< Base::MemoryVertexBufferLoaderBase > & vBufLoader)
inline

set the specialized vertex buffer reader

◆ UpdateGroupBoundingBoxes()

void CoreGraphics::Nvx3StreamReader::UpdateGroupBoundingBoxes ( )
private

update primitive group bounding boxes

Since nvx2 files don't contain any bounding box information we need to compute per-primitive-group bounding boxes manually by walking the triangle indices.

This may be inefficient with large meshes.

Member Data Documentation

◆ access

Base::ResourceBase::Access CoreGraphics::Nvx3StreamReader::access
private

◆ groupDataPtr

void* CoreGraphics::Nvx3StreamReader::groupDataPtr
private

◆ groupDataSize

SizeT CoreGraphics::Nvx3StreamReader::groupDataSize
private

◆ indexBuffer

Ptr<Base::IndexBufferBase> CoreGraphics::Nvx3StreamReader::indexBuffer
private

◆ indexBufferLoader

Ptr<Base::MemoryIndexBufferLoaderBase> CoreGraphics::Nvx3StreamReader::indexBufferLoader
private

◆ indexDataPtr

void* CoreGraphics::Nvx3StreamReader::indexDataPtr
private

◆ indexDataSize

SizeT CoreGraphics::Nvx3StreamReader::indexDataSize
private

◆ mapPtr

void* CoreGraphics::Nvx3StreamReader::mapPtr
private

◆ numGroups

uint CoreGraphics::Nvx3StreamReader::numGroups
private

◆ numIndices

uint CoreGraphics::Nvx3StreamReader::numIndices
private

◆ numVertices

uint CoreGraphics::Nvx3StreamReader::numVertices
private

◆ primGroups

Util::Array<CoreGraphics::PrimitiveGroup> CoreGraphics::Nvx3StreamReader::primGroups
private

◆ rawMode

bool CoreGraphics::Nvx3StreamReader::rawMode
private

◆ usage

Base::ResourceBase::Usage CoreGraphics::Nvx3StreamReader::usage
private

◆ vertexBuffer

Ptr<Base::VertexBufferBase> CoreGraphics::Nvx3StreamReader::vertexBuffer
private

◆ vertexBufferLoader

Ptr<Base::MemoryVertexBufferLoaderBase> CoreGraphics::Nvx3StreamReader::vertexBufferLoader
private

◆ vertexComponentMask

uint CoreGraphics::Nvx3StreamReader::vertexComponentMask
private

◆ vertexComponents

Util::Array<CoreGraphics::VertexComponent> CoreGraphics::Nvx3StreamReader::vertexComponents
private

◆ vertexDataPtr

void* CoreGraphics::Nvx3StreamReader::vertexDataPtr
private

◆ vertexDataSize

SizeT CoreGraphics::Nvx3StreamReader::vertexDataSize
private

◆ vertexWidth

uint CoreGraphics::Nvx3StreamReader::vertexWidth
private

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