1
1
#ifndef __MESH_H__
2
2
#define __MESH_H__
3
3
4
- #include < ppu-types.h>
5
4
#include < vectormath/cpp/vectormath_aos.h>
6
5
7
- #include < rsx/rsx.h>
8
-
9
- #include " irrarray.h"
10
-
11
- using namespace irr ;
12
6
using namespace Vectormath ::Aos;
13
7
14
8
template < class T >
@@ -29,100 +23,41 @@ inline const T clamp(const T& val,const T& low,const T& high)
29
23
return min_ (max_ (val,low),high);
30
24
}
31
25
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
-
53
26
struct S3DVertex
54
27
{
55
28
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) {};
60
31
61
32
inline S3DVertex& operator =(const S3DVertex& other)
62
33
{
63
34
pos = other.pos ;
64
35
nrm = other.nrm ;
65
- col = other.col ;
66
36
u = other.u ;
67
37
v = other.v ;
38
+ col = other.col ;
68
39
return *this ;
69
40
}
70
41
71
42
Vector3 pos;
72
43
Vector3 nrm;
73
- SColor col;
74
-
75
- f32 u,v;
44
+ f32 u, v;
45
+ u32 col;
76
46
};
77
47
78
-
79
- class SMeshBuffer
48
+ template < class T >
49
+ class CMeshBuffer
80
50
{
81
51
public:
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 ) {};
86
53
87
- virtual const void * getVertices () const
88
- {
89
- return vertices.const_pointer ();
90
- }
54
+ u16 *indices;
55
+ u32 cnt_indices;
91
56
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;
126
59
};
127
60
61
+ typedef CMeshBuffer<S3DVertex> SMeshBuffer;
62
+
128
63
#endif
0 commit comments