Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
Irrlicht
Include
IVertexDescriptor.h
1
// Copyright (C) 2012-2016 Patryk Nadrowski
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5
#ifndef __I_VERTEX_DESCRIPTOR_H_INCLUDED__
6
#define __I_VERTEX_DESCRIPTOR_H_INCLUDED__
7
8
#include "IReferenceCounted.h"
9
#include "irrArray.h"
10
#include "irrString.h"
11
12
namespace
irr
13
{
14
namespace
video
15
{
16
// Remember declare Semantic Name (CD3D11VertexDescriptor)
17
// getSemanticName
18
enum
E_VERTEX_ATTRIBUTE_SEMANTIC
19
{
20
EVAS_POSITION = 0,
21
EVAS_NORMAL,
22
EVAS_COLOR,
23
EVAS_TEXCOORD0,
24
EVAS_TEXCOORD1,
25
EVAS_TEXCOORD2,
26
EVAS_TEXCOORD3,
27
EVAS_TEXCOORD4,
28
EVAS_TEXCOORD5,
29
EVAS_TEXCOORD6,
30
EVAS_TEXCOORD7,
31
EVAS_TEXCOORD8,
32
EVAS_TEXCOORD9,
33
EVAS_TEXCOORD10,
34
EVAS_TEXCOORD11,
35
EVAS_TEXCOORD12,
36
EVAS_TEXCOORD13,
37
EVAS_TEXCOORD14,
38
EVAS_TEXCOORD15,
39
EVAS_TANGENT,
40
EVAS_BINORMAL,
41
EVAS_BLEND_WEIGHTS,
42
EVAS_BLEND_INDICES,
43
EVAS_LIGHTPROBE,
44
EVAS_VERTEXDATA,
45
EVAS_LIGHTMAP,
46
EVAS_CUSTOM,
47
48
EVAS_COUNT
49
};
50
51
enum
E_VERTEX_ATTRIBUTE_TYPE
52
{
53
EVAT_BYTE = 0,
54
EVAT_UBYTE,
55
EVAT_SHORT,
56
EVAT_USHORT,
57
EVAT_INT,
58
EVAT_UINT,
59
EVAT_FLOAT,
60
EVAT_DOUBLE
61
};
62
63
enum
E_INSTANCE_DATA_STEP_RATE
64
{
65
EIDSR_PER_VERTEX,
66
EIDSR_PER_INSTANCE
67
};
68
69
class
IVertexAttribute
70
{
71
public
:
72
IVertexAttribute(
const
core::stringc
& name,
u32
elementCount, E_VERTEX_ATTRIBUTE_SEMANTIC semantic, E_VERTEX_ATTRIBUTE_TYPE type,
u32
offset,
u32
bufferID) :
73
Name(name), ElementCount(elementCount), Semantic(semantic), Type(type), Offset(offset), BufferID(bufferID)
74
{
75
switch
(Type)
76
{
77
case
EVAT_BYTE:
78
case
EVAT_UBYTE:
79
TypeSize =
sizeof
(
u8
);
80
break
;
81
case
EVAT_SHORT:
82
case
EVAT_USHORT:
83
TypeSize =
sizeof
(
u16
);
84
break
;
85
case
EVAT_INT:
86
case
EVAT_UINT:
87
TypeSize =
sizeof
(
u32
);
88
break
;
89
case
EVAT_FLOAT:
90
TypeSize =
sizeof
(
f32
);
91
break
;
92
case
EVAT_DOUBLE:
93
TypeSize =
sizeof
(
f64
);
94
break
;
95
}
96
}
97
98
virtual
~IVertexAttribute()
99
{
100
}
101
102
const
core::stringc
& getName()
const
103
{
104
return
Name;
105
}
106
107
u32
getElementCount()
const
108
{
109
return
ElementCount;
110
}
111
112
E_VERTEX_ATTRIBUTE_SEMANTIC getSemantic()
const
113
{
114
return
Semantic;
115
}
116
117
E_VERTEX_ATTRIBUTE_TYPE getType()
const
118
{
119
return
Type;
120
}
121
122
u32
getTypeSize()
const
123
{
124
return
TypeSize;
125
}
126
127
u32
getOffset()
const
128
{
129
return
Offset;
130
}
131
132
u32
getBufferID()
const
133
{
134
return
BufferID;
135
}
136
137
protected
:
138
core::stringc
Name;
139
140
u32
ElementCount;
141
142
E_VERTEX_ATTRIBUTE_SEMANTIC Semantic;
143
144
E_VERTEX_ATTRIBUTE_TYPE Type;
145
146
u32
TypeSize;
147
148
u32
Offset;
149
150
u32
BufferID;
151
};
152
153
class
IVertexDescriptor :
public
virtual
IReferenceCounted
154
{
155
public
:
156
IVertexDescriptor(
const
core::stringc
& name,
u32
id
) : ID(
id
), Name(name)
157
{
158
#ifdef _DEBUG
159
setDebugName
(
"IVertexDescriptor"
);
160
#endif
161
162
for
(
u32
i = 0; i < EVAS_COUNT; ++i)
163
AttributeSemanticIndex[i] = -1;
164
}
165
166
virtual
~IVertexDescriptor()
167
{
168
}
169
170
u32
getID()
const
171
{
172
return
ID;
173
}
174
175
const
core::stringc
& getName()
const
176
{
177
return
Name;
178
}
179
180
u32
getVertexSize(
u32
bufferID)
const
181
{
182
_IRR_DEBUG_BREAK_IF(bufferID >= VertexSize.size())
183
184
return
VertexSize[bufferID];
185
}
186
187
E_INSTANCE_DATA_STEP_RATE getInstanceDataStepRate(
u32
bufferID)
const
188
{
189
_IRR_DEBUG_BREAK_IF(bufferID >= InstanceDataStepRate.size())
190
191
return
InstanceDataStepRate[bufferID];
192
}
193
194
void
setInstanceDataStepRate(E_INSTANCE_DATA_STEP_RATE rate,
u32
bufferID)
195
{
196
_IRR_DEBUG_BREAK_IF(bufferID >= InstanceDataStepRate.size())
197
198
InstanceDataStepRate[bufferID] = rate;
199
}
200
201
virtual
IVertexAttribute
* addAttribute(
const
core::stringc
& name,
u32
elementCount, E_VERTEX_ATTRIBUTE_SEMANTIC semantic, E_VERTEX_ATTRIBUTE_TYPE type,
u32
bufferID) = 0;
202
203
virtual
void
clearAttribute() = 0;
204
205
IVertexAttribute
* getAttribute(
u32
id
)
const
206
{
207
_IRR_DEBUG_BREAK_IF(
id
>= AttributePointer.size())
208
209
return
AttributePointer[id];
210
}
211
212
IVertexAttribute
* getAttributeByName(
const
core::stringc
& name)
const
213
{
214
for
(
u32
i = 0; i < AttributePointer.size(); ++i)
215
if
(name == AttributePointer[i]->getName())
216
return
AttributePointer[i];
217
218
return
0;
219
}
220
221
IVertexAttribute
* getAttributeBySemantic(E_VERTEX_ATTRIBUTE_SEMANTIC semantic)
const
222
{
223
IVertexAttribute
* attribute = 0;
224
225
s32
ID = AttributeSemanticIndex[(
u32
)semantic];
226
227
if
(ID >= 0)
228
attribute = AttributePointer[ID];
229
230
return
attribute;
231
}
232
233
u32
getAttributeCount()
const
234
{
235
return
AttributePointer.size();
236
}
237
238
protected
:
239
u32
ID;
240
241
core::stringc
Name;
242
243
core::array<u32>
VertexSize;
244
core::array<E_INSTANCE_DATA_STEP_RATE>
InstanceDataStepRate;
245
246
s32
AttributeSemanticIndex[(
u32
)EVAS_COUNT];
247
248
core::array<IVertexAttribute*>
AttributePointer;
249
};
250
}
251
}
252
253
#endif
irr::IReferenceCounted::setDebugName
void setDebugName(const c8 *newName)
Sets the debug name of the object.
Definition
IReferenceCounted.h:163
irr::IReferenceCounted::IReferenceCounted
IReferenceCounted()
Constructor.
Definition
IReferenceCounted.h:50
irr::core::array
Self reallocating template array (like stl vector) with additional features.
Definition
irrArray.h:23
irr::video::IVertexAttribute
Definition
IVertexDescriptor.h:70
irr::core::stringc
string< c8 > stringc
Typedef for character strings.
Definition
irrString.h:1373
irr::video
The video namespace contains classes for accessing the video driver. All 2d and 3d rendering is done ...
Definition
EDriverFeatures.h:11
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition
Skylicht.h:33
irr::f32
float f32
32 bit floating point variable.
Definition
irrTypes.h:104
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition
irrTypes.h:58
irr::f64
double f64
64 bit floating point variable.
Definition
irrTypes.h:108
irr::u8
unsigned char u8
8 bit unsigned variable.
Definition
irrTypes.h:18
irr::s32
signed int s32
32 bit signed variable.
Definition
irrTypes.h:66
irr::u16
unsigned short u16
16 bit unsigned variable.
Definition
irrTypes.h:40
Generated by
1.17.0