18 VertexElementArray::VertexElementArray(
int maximum_vertex_elements) {
20 _maximum_vertex_elements = maximum_vertex_elements;
22 _vertex_element_array =
new D3DVERTEXELEMENT9[maximum_vertex_elements];
23 memset(_vertex_element_array, 0,
sizeof(D3DVERTEXELEMENT9) * maximum_vertex_elements);
26 VertexElementArray::~VertexElementArray() {
27 delete _vertex_element_array;
30 void VertexElementArray::add_position_xyz_vertex_element(
int stream_index,
int offset) {
31 if (_total_elements >= _maximum_vertex_elements) {
35 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
37 vertex_element->Stream = stream_index;
38 vertex_element->Offset = offset;
39 vertex_element->Type = D3DDECLTYPE_FLOAT3;
40 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
42 vertex_element->Usage = D3DDECLUSAGE_POSITION;
43 vertex_element->UsageIndex = 0;
48 void VertexElementArray::add_position_xyzw_vertex_element(
int stream_index,
int offset) {
49 if (_total_elements >= _maximum_vertex_elements) {
53 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
55 vertex_element->Stream = stream_index;
56 vertex_element->Offset = offset;
57 vertex_element->Type = D3DDECLTYPE_FLOAT4;
58 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
60 vertex_element->Usage = D3DDECLUSAGE_POSITION;
61 vertex_element->UsageIndex = 0;
66 void VertexElementArray::add_normal_vertex_element(
int stream_index,
int offset) {
67 if (_total_elements >= _maximum_vertex_elements) {
71 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
73 vertex_element->Stream = stream_index;
74 vertex_element->Offset = offset;
75 vertex_element->Type = D3DDECLTYPE_FLOAT3;
76 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
78 vertex_element->Usage = D3DDECLUSAGE_NORMAL;
79 vertex_element->UsageIndex = 0;
84 void VertexElementArray::add_binormal_vertex_element(
int stream_index,
int offset) {
85 if (_total_elements >= _maximum_vertex_elements) {
89 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
91 vertex_element->Stream = stream_index;
92 vertex_element->Offset = offset;
93 vertex_element->Type = D3DDECLTYPE_FLOAT3;
94 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
96 vertex_element->Usage = D3DDECLUSAGE_BINORMAL;
97 vertex_element->UsageIndex = 0;
102 void VertexElementArray::add_tangent_vertex_element(
int stream_index,
int offset) {
103 if (_total_elements >= _maximum_vertex_elements) {
107 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
109 vertex_element->Stream = stream_index;
110 vertex_element->Offset = offset;
111 vertex_element->Type = D3DDECLTYPE_FLOAT3;
112 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
114 vertex_element->Usage = D3DDECLUSAGE_TANGENT;
115 vertex_element->UsageIndex = 0;
120 void VertexElementArray::add_diffuse_color_vertex_element(
int stream_index,
int offset) {
121 if (_total_elements >= _maximum_vertex_elements) {
125 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
127 vertex_element->Stream = stream_index;
128 vertex_element->Offset = offset;
129 vertex_element->Type = D3DDECLTYPE_D3DCOLOR;
130 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
132 vertex_element->Usage = D3DDECLUSAGE_COLOR;
133 vertex_element->UsageIndex = 0;
138 void VertexElementArray::add_specular_color_vertex_element(
int stream_index,
int offset) {
139 if (_total_elements >= _maximum_vertex_elements) {
143 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
145 vertex_element->Stream = stream_index;
146 vertex_element->Offset = offset;
147 vertex_element->Type = D3DDECLTYPE_D3DCOLOR;
148 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
150 vertex_element->Usage = D3DDECLUSAGE_COLOR;
151 vertex_element->UsageIndex = 1;
156 void VertexElementArray::add_u_vertex_element(
int stream_index,
int offset,
int texture_stage) {
157 if (_total_elements >= _maximum_vertex_elements) {
161 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
163 vertex_element->Stream = stream_index;
164 vertex_element->Offset = offset;
165 vertex_element->Type = D3DDECLTYPE_FLOAT1;
166 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
168 vertex_element->Usage = D3DDECLUSAGE_TEXCOORD;
169 vertex_element->UsageIndex = texture_stage;
174 void VertexElementArray::add_uv_vertex_element(
int stream_index,
int offset,
int texture_stage) {
175 if (_total_elements >= _maximum_vertex_elements) {
179 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
181 vertex_element->Stream = stream_index;
182 vertex_element->Offset = offset;
183 vertex_element->Type = D3DDECLTYPE_FLOAT2;
184 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
186 vertex_element->Usage = D3DDECLUSAGE_TEXCOORD;
187 vertex_element->UsageIndex = texture_stage;
192 void VertexElementArray::add_uvw_vertex_element(
int stream_index,
int offset,
int texture_stage) {
193 if (_total_elements >= _maximum_vertex_elements) {
197 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
199 vertex_element->Stream = stream_index;
200 vertex_element->Offset = offset;
201 vertex_element->Type = D3DDECLTYPE_FLOAT3;
202 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
204 vertex_element->Usage = D3DDECLUSAGE_TEXCOORD;
205 vertex_element->UsageIndex = texture_stage;
210 void VertexElementArray::add_xyzw_vertex_element(
int stream_index,
int offset,
int texture_stage) {
211 if (_total_elements >= _maximum_vertex_elements) {
215 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
217 vertex_element->Stream = stream_index;
218 vertex_element->Offset = offset;
219 vertex_element->Type = D3DDECLTYPE_FLOAT4;
220 vertex_element->Method = D3DDECLMETHOD_DEFAULT;
222 vertex_element->Usage = D3DDECLUSAGE_TEXCOORD;
223 vertex_element->UsageIndex = texture_stage;
228 bool VertexElementArray::add_end_vertex_element(
void) {
229 if (_total_elements >= _maximum_vertex_elements) {
233 LPD3DVERTEXELEMENT9 vertex_element = &_vertex_element_array[_total_elements];
235 vertex_element->Stream = 0xFF;
236 vertex_element->Offset = 0;
237 vertex_element->Type = D3DDECLTYPE_UNUSED;
238 vertex_element->Method = 0;
240 vertex_element->Usage = 0;
241 vertex_element->UsageIndex = 0;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.