11#ifndef __MESH_H__
22#define __MESH_H__
33
4- #include < ppu-types.h>
54#include < vectormath/cpp/vectormath_aos.h>
65
7- #include < rsx/rsx.h>
8-
9- #include " irrarray.h"
10-
11- using namespace irr ;
126using namespace Vectormath ::Aos;
137
148template < class T >
@@ -29,100 +23,41 @@ inline const T clamp(const T& val,const T& low,const T& high)
2923 return min_ (max_ (val,low),high);
3024}
3125
32- class SColor
33- {
34- public:
35- SColor () : color(0 ) {};
36- SColor (u32 c) : color(c) {};
37- SColor (u8 a,u8 r,u8 g,u8 b) : R(r),G(g),B(b),A(a) {};
38- SColor (const SColor& other) : color(other.color) {};
39-
40- u8 getRed () const { return R; }
41- u8 getGreen () const { return G; }
42- u8 getBlue () const { return B; }
43- u8 getAlpha () const { return A; }
44-
45- union {
46- u32 color;
47- struct {
48- u8 R,G,B,A;
49- };
50- };
51- };
52-
5326struct S3DVertex
5427{
5528 S3DVertex () {};
56- S3DVertex (f32 x,f32 y,f32 z,f32 nx,f32 ny,f32 nz,SColor c,f32 tu,f32 tv)
57- : pos(x,y,z),nrm(nx,ny,nz),col(c),u(tu),v(tv) {};
58- S3DVertex (const Vector3& _pos,const Vector3& _nrm,const SColor& c,f32 tu,f32 tv)
59- : pos(_pos),nrm(_nrm),col(c),u(tu),v(tv) {};
29+ S3DVertex (f32 x,f32 y,f32 z,f32 nx,f32 ny,f32 nz,f32 tu,f32 tv, u32 c)
30+ : pos(x, y, z), nrm(nx, ny, nz), u(tu), v(tv), col(c) {};
6031
6132 inline S3DVertex& operator =(const S3DVertex& other)
6233 {
6334 pos = other.pos ;
6435 nrm = other.nrm ;
65- col = other.col ;
6636 u = other.u ;
6737 v = other.v ;
38+ col = other.col ;
6839 return *this ;
6940 }
7041
7142 Vector3 pos;
7243 Vector3 nrm;
73- SColor col;
74-
75- f32 u,v;
44+ f32 u, v;
45+ u32 col;
7646};
7747
78-
79- class SMeshBuffer
48+ template < class T >
49+ class CMeshBuffer
8050{
8151public:
82- SMeshBuffer () : pos_off(0 ),nrm_off(0 ),col_off(0 ),uv_off(0 ),ind_off(0 ) {};
83- virtual ~SMeshBuffer ()
84- {
85- }
52+ CMeshBuffer () : indices(NULL ),cnt_indices(0 ),vertices(NULL ),cnt_vertices(0 ) {};
8653
87- virtual const void * getVertices () const
88- {
89- return vertices.const_pointer ();
90- }
54+ u16 *indices;
55+ u32 cnt_indices;
9156
92- virtual void * getVertices ()
93- {
94- return vertices.pointer ();
95- }
96-
97- virtual u32 getVertexCount () const
98- {
99- return vertices.size ();
100- }
101-
102- virtual const u32 * getIndices () const
103- {
104- return indices.const_pointer ();
105- }
106-
107- virtual u32 * getIndices ()
108- {
109- return indices.pointer ();
110- }
111-
112- virtual u32 getIndexCount () const
113- {
114- return indices.size ();
115- }
116-
117- core::array< u32 , core::allocatorRSX< u32 > > indices;
118- core::array< S3DVertex, core::allocatorRSX< S3DVertex > > vertices;
119-
120- u32 pos_off;
121- u32 nrm_off;
122- u32 col_off;
123- u32 uv_off;
124-
125- u32 ind_off;
57+ S3DVertex *vertices;
58+ u32 cnt_vertices;
12659};
12760
61+ typedef CMeshBuffer<S3DVertex> SMeshBuffer;
62+
12863#endif
0 commit comments