35 #ifndef MESH_TYPEDEFS_H
36 #define MESH_TYPEDEFS_H
42 # define MESHASSERT LBASSERT
43 # define MESHERROR LBERROR
44 # define MESHWARN LBWARN
45 # define MESHINFO LBINFO
47 # include <vmmlib/vmmlib.hpp>
49 # include <Winsock2.h>
53 # include <OpenGL/gl.h>
58 # define MESHASSERT assert
59 # define MESHERROR std::cerr
60 # define MESHWARN std::cout
61 # define MESHINFO std::cout
71 typedef vmml::vector< 3, float > Vertex;
72 typedef vmml::vector< 3, uint8_t > Color;
73 typedef vmml::vector< 3, float > Normal;
74 typedef vmml::matrix< 4, 4, float >
Matrix4f;
75 typedef vmml::vector< 4, float >
Vector4f;
77 typedef GLushort ShortIndex;
82 explicit MeshException(
const std::string& msg ) : _message( msg ) {}
84 virtual const char* what()
const throw() {
return _message.c_str(); }
94 int overflow(
int c ) {
return traits_type::not_eof( c ); }
97 NullOStream() : std::ios( &_nullBuf ), std::ostream( &_nullBuf ) {}
101 template<
class T,
size_t d >
105 ArrayWrapper(
const T* from ) { memcpy( data, from,
sizeof( data )); }
106 T& operator[](
const size_t i )
112 const T& operator[](
const size_t i )
const
124 typedef vmml::vector< 3, Index > Triangle;
126 typedef vmml::vector< 4, float > BoundingSphere;
132 const Index LEAF_SIZE( 21845 );
135 const unsigned short FILE_VERSION ( 0x0118 );
144 inline std::ostream& operator << ( std::ostream& os,
const Axis axis )
146 os << ( axis == AXIS_X ?
"x axis" : axis == AXIS_Y ?
"y axis" :
147 axis == AXIS_Z ?
"z axis" :
"ERROR" );
163 RENDER_MODE_IMMEDIATE = 0,
164 RENDER_MODE_DISPLAY_LIST,
165 RENDER_MODE_BUFFER_OBJECT,
168 inline std::ostream& operator << ( std::ostream& os,
const RenderMode mode )
170 os << ( mode == RENDER_MODE_IMMEDIATE ?
"immediate mode" :
171 mode == RENDER_MODE_DISPLAY_LIST ?
"display list mode" :
172 mode == RENDER_MODE_BUFFER_OBJECT ?
"VBO mode" :
"ERROR" );
186 inline void memRead(
char* destination,
char** source,
size_t length )
188 memcpy( destination, *source, length );
200 template<>
inline void byteswap( mesh::RenderMode& value )
201 { byteswap( reinterpret_cast< uint32_t& >( value )); }
203 template<>
inline void byteswap(
mesh::Range& value )
205 byteswap( value[ 0 ]);
206 byteswap( value[ 1 ]);
210 #endif // MESH_TYPEDEFS_H
vmml::matrix< 4, 4, float > Matrix4f
A 4x4 float matrix.
vmml::vector< 4, float > Vector4f
A four-component float vector.
NodeType
Node types to identify connecting nodes.