Renamed AttributeUsage and AttributeType
... to VertexComponent and ComponentType. -Renderer: Renamed IsVertexAttributeSupported static method to IsComponentTypeSupported -VertexDeclaration: Added IsTypeSupported static method Renamed [Disable|Enable|Get]Attribute to [Disable|Enable|Get]Component Removed GetAttributeSize static method -VertexMapper: Renamed GetAttributePtr method to GetComponentPtr Former-commit-id: 7115856e1d389610c35b26f63af5d93a5ad5c690
This commit is contained in:
@@ -1854,47 +1854,6 @@ GLenum NzOpenGL::Attachment[] =
|
||||
|
||||
static_assert(nzAttachmentPoint_Max+1 == 4, "Attachment array is incomplete");
|
||||
|
||||
nzUInt8 NzOpenGL::AttributeIndex[] =
|
||||
{
|
||||
10, // nzAttributeUsage_InstanceData0
|
||||
11, // nzAttributeUsage_InstanceData1
|
||||
12, // nzAttributeUsage_InstanceData2
|
||||
13, // nzAttributeUsage_InstanceData3
|
||||
14, // nzAttributeUsage_InstanceData4
|
||||
15, // nzAttributeUsage_InstanceData5
|
||||
2, // nzAttributeUsage_Normal
|
||||
0, // nzAttributeUsage_Position
|
||||
3, // nzAttributeUsage_Tangent
|
||||
1, // nzAttributeUsage_TexCoord
|
||||
4, // nzAttributeUsage_Userdata0
|
||||
5, // nzAttributeUsage_Userdata1
|
||||
6, // nzAttributeUsage_Userdata2
|
||||
7, // nzAttributeUsage_Userdata3
|
||||
8, // nzAttributeUsage_Userdata4
|
||||
9 // nzAttributeUsage_Userdata5
|
||||
};
|
||||
|
||||
static_assert(nzAttributeUsage_Max+1 == 16, "Attribute index array is incomplete");
|
||||
|
||||
GLenum NzOpenGL::AttributeType[] =
|
||||
{
|
||||
GL_UNSIGNED_BYTE, // nzAttributeType_Color
|
||||
GL_DOUBLE, // nzAttributeType_Double1
|
||||
GL_DOUBLE, // nzAttributeType_Double2
|
||||
GL_DOUBLE, // nzAttributeType_Double3
|
||||
GL_DOUBLE, // nzAttributeType_Double4
|
||||
GL_FLOAT, // nzAttributeType_Float1
|
||||
GL_FLOAT, // nzAttributeType_Float2
|
||||
GL_FLOAT, // nzAttributeType_Float3
|
||||
GL_FLOAT, // nzAttributeType_Float4
|
||||
GL_INT, // nzAttributeType_Int1
|
||||
GL_INT, // nzAttributeType_Int2
|
||||
GL_INT, // nzAttributeType_Int3
|
||||
GL_INT // nzAttributeType_Int4
|
||||
};
|
||||
|
||||
static_assert(nzAttributeType_Max+1 == 13, "Attribute type array is incomplete");
|
||||
|
||||
GLenum NzOpenGL::BlendFunc[] =
|
||||
{
|
||||
GL_DST_ALPHA, // nzBlendFunc_DestAlpha
|
||||
@@ -1958,6 +1917,25 @@ GLenum NzOpenGL::BufferUsage[] =
|
||||
|
||||
static_assert(nzBufferUsage_Max+1 == 2, "Buffer usage array is incomplete");
|
||||
|
||||
GLenum NzOpenGL::ComponentType[] =
|
||||
{
|
||||
GL_UNSIGNED_BYTE, // nzComponentType_Color
|
||||
GL_DOUBLE, // nzComponentType_Double1
|
||||
GL_DOUBLE, // nzComponentType_Double2
|
||||
GL_DOUBLE, // nzComponentType_Double3
|
||||
GL_DOUBLE, // nzComponentType_Double4
|
||||
GL_FLOAT, // nzComponentType_Float1
|
||||
GL_FLOAT, // nzComponentType_Float2
|
||||
GL_FLOAT, // nzComponentType_Float3
|
||||
GL_FLOAT, // nzComponentType_Float4
|
||||
GL_INT, // nzComponentType_Int1
|
||||
GL_INT, // nzComponentType_Int2
|
||||
GL_INT, // nzComponentType_Int3
|
||||
GL_INT // nzComponentType_Int4
|
||||
};
|
||||
|
||||
static_assert(nzComponentType_Max+1 == 13, "Attribute type array is incomplete");
|
||||
|
||||
GLenum NzOpenGL::CubemapFace[] =
|
||||
{
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X, // nzCubemapFace_PositiveX
|
||||
@@ -2117,6 +2095,28 @@ GLenum NzOpenGL::TextureTargetProxy[] =
|
||||
|
||||
static_assert(nzImageType_Max+1 == 6, "Texture target proxy array is incomplete");
|
||||
|
||||
nzUInt8 NzOpenGL::VertexComponentIndex[] =
|
||||
{
|
||||
10, // nzVertexComponent_InstanceData0
|
||||
11, // nzVertexComponent_InstanceData1
|
||||
12, // nzVertexComponent_InstanceData2
|
||||
13, // nzVertexComponent_InstanceData3
|
||||
14, // nzVertexComponent_InstanceData4
|
||||
15, // nzVertexComponent_InstanceData5
|
||||
2, // nzVertexComponent_Normal
|
||||
0, // nzVertexComponent_Position
|
||||
3, // nzVertexComponent_Tangent
|
||||
1, // nzVertexComponent_TexCoord
|
||||
4, // nzVertexComponent_Userdata0
|
||||
5, // nzVertexComponent_Userdata1
|
||||
6, // nzVertexComponent_Userdata2
|
||||
7, // nzVertexComponent_Userdata3
|
||||
8, // nzVertexComponent_Userdata4
|
||||
9 // nzVertexComponent_Userdata5
|
||||
};
|
||||
|
||||
static_assert(nzVertexComponent_Max+1 == 16, "Attribute index array is incomplete");
|
||||
|
||||
PFNGLACTIVETEXTUREPROC glActiveTexture = nullptr;
|
||||
PFNGLATTACHSHADERPROC glAttachShader = nullptr;
|
||||
PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender = nullptr;
|
||||
|
||||
@@ -897,6 +897,34 @@ bool NzRenderer::Initialize()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzRenderer::IsComponentTypeSupported(nzComponentType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case nzComponentType_Color:
|
||||
case nzComponentType_Float1:
|
||||
case nzComponentType_Float2:
|
||||
case nzComponentType_Float3:
|
||||
case nzComponentType_Float4:
|
||||
return true; // Supportés nativement
|
||||
|
||||
case nzComponentType_Double1:
|
||||
case nzComponentType_Double2:
|
||||
case nzComponentType_Double3:
|
||||
case nzComponentType_Double4:
|
||||
return glVertexAttribLPointer != nullptr; // Fonction requise pour envoyer des doubles
|
||||
|
||||
case nzComponentType_Int1:
|
||||
case nzComponentType_Int2:
|
||||
case nzComponentType_Int3:
|
||||
case nzComponentType_Int4:
|
||||
return glVertexAttribIPointer != nullptr; // Fonction requise pour envoyer des entiers
|
||||
}
|
||||
|
||||
NazaraError("Attribute type out of enum (0x" + NzString::Number(type, 16) + ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NzRenderer::IsEnabled(nzRendererParameter parameter)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
@@ -915,34 +943,6 @@ bool NzRenderer::IsInitialized()
|
||||
return s_moduleReferenceCounter != 0;
|
||||
}
|
||||
|
||||
bool NzRenderer::IsVertexAttributeSupported(nzAttributeType attributeType)
|
||||
{
|
||||
switch (attributeType)
|
||||
{
|
||||
case nzAttributeType_Color:
|
||||
case nzAttributeType_Float1:
|
||||
case nzAttributeType_Float2:
|
||||
case nzAttributeType_Float3:
|
||||
case nzAttributeType_Float4:
|
||||
return true; // Supportés nativement
|
||||
|
||||
case nzAttributeType_Double1:
|
||||
case nzAttributeType_Double2:
|
||||
case nzAttributeType_Double3:
|
||||
case nzAttributeType_Double4:
|
||||
return glVertexAttribLPointer != nullptr; // Fonction requise pour envoyer des doubles
|
||||
|
||||
case nzAttributeType_Int1:
|
||||
case nzAttributeType_Int2:
|
||||
case nzAttributeType_Int3:
|
||||
case nzAttributeType_Int4:
|
||||
return glVertexAttribIPointer != nullptr; // Fonction requise pour envoyer des entiers
|
||||
}
|
||||
|
||||
NazaraError("Attribute type out of enum");
|
||||
return false;
|
||||
}
|
||||
|
||||
void NzRenderer::SetBlendFunc(nzBlendFunc srcBlend, nzBlendFunc dstBlend)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
@@ -1766,51 +1766,51 @@ bool NzRenderer::EnsureStateUpdate()
|
||||
bufferOffset = s_vertexBuffer->GetStartOffset();
|
||||
vertexDeclaration = s_vertexBuffer->GetVertexDeclaration();
|
||||
stride = vertexDeclaration->GetStride();
|
||||
for (unsigned int i = nzAttributeUsage_FirstVertexData; i <= nzAttributeUsage_LastVertexData; ++i)
|
||||
for (unsigned int i = nzVertexComponent_FirstVertexData; i <= nzVertexComponent_LastVertexData; ++i)
|
||||
{
|
||||
nzAttributeType type;
|
||||
nzComponentType type;
|
||||
bool enabled;
|
||||
unsigned int offset;
|
||||
vertexDeclaration->GetAttribute(static_cast<nzAttributeUsage>(i), &enabled, &type, &offset);
|
||||
vertexDeclaration->GetComponent(static_cast<nzVertexComponent>(i), &enabled, &type, &offset);
|
||||
|
||||
if (!IsVertexAttributeSupported(type))
|
||||
if (!IsComponentTypeSupported(type))
|
||||
{
|
||||
NazaraError("Invalid declaration: Vertex attribute 0x" + NzString::Number(i, 16) + " (0x" + NzString::Number(type, 16) + ") is not supported");
|
||||
NazaraError("Invalid declaration: Vertex component 0x" + NzString::Number(i, 16) + " (type: 0x" + NzString::Number(type, 16) + ") is not supported");
|
||||
updateFailed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
glEnableVertexAttribArray(NzOpenGL::AttributeIndex[i]);
|
||||
if (type <= nzAttributeType_Double1 && type >= nzAttributeType_Double4)
|
||||
glEnableVertexAttribArray(NzOpenGL::VertexComponentIndex[i]);
|
||||
if (type <= nzComponentType_Double1 && type >= nzComponentType_Double4)
|
||||
{
|
||||
glVertexAttribLPointer(NzOpenGL::AttributeIndex[i],
|
||||
NzVertexDeclaration::GetAttributeSize(type),
|
||||
NzOpenGL::AttributeType[type],
|
||||
glVertexAttribLPointer(NzOpenGL::VertexComponentIndex[i],
|
||||
NzUtility::ComponentCount[type],
|
||||
NzOpenGL::ComponentType[type],
|
||||
stride,
|
||||
reinterpret_cast<void*>(bufferOffset + offset));
|
||||
}
|
||||
else if (type <= nzAttributeType_Int1 && type >= nzAttributeType_Int4)
|
||||
else if (type <= nzComponentType_Int1 && type >= nzComponentType_Int4)
|
||||
{
|
||||
glVertexAttribIPointer(NzOpenGL::AttributeIndex[i],
|
||||
NzVertexDeclaration::GetAttributeSize(type),
|
||||
NzOpenGL::AttributeType[type],
|
||||
glVertexAttribIPointer(NzOpenGL::VertexComponentIndex[i],
|
||||
NzUtility::ComponentCount[type],
|
||||
NzOpenGL::ComponentType[type],
|
||||
stride,
|
||||
reinterpret_cast<void*>(bufferOffset + offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
glVertexAttribPointer(NzOpenGL::AttributeIndex[i],
|
||||
NzVertexDeclaration::GetAttributeSize(type),
|
||||
NzOpenGL::AttributeType[type],
|
||||
(type == nzAttributeType_Color) ? GL_TRUE : GL_FALSE,
|
||||
glVertexAttribPointer(NzOpenGL::VertexComponentIndex[i],
|
||||
NzUtility::ComponentCount[type],
|
||||
NzOpenGL::ComponentType[type],
|
||||
(type == nzComponentType_Color) ? GL_TRUE : GL_FALSE,
|
||||
stride,
|
||||
reinterpret_cast<void*>(bufferOffset + offset));
|
||||
}
|
||||
}
|
||||
else
|
||||
glDisableVertexAttribArray(NzOpenGL::AttributeIndex[i]);
|
||||
glDisableVertexAttribArray(NzOpenGL::VertexComponentIndex[i]);
|
||||
}
|
||||
|
||||
if (!updateFailed)
|
||||
@@ -1823,59 +1823,59 @@ bool NzRenderer::EnsureStateUpdate()
|
||||
bufferOffset = s_instanceBuffer.GetStartOffset();
|
||||
vertexDeclaration = s_instanceBuffer.GetVertexDeclaration();
|
||||
stride = vertexDeclaration->GetStride();
|
||||
for (unsigned int i = nzAttributeUsage_FirstInstanceData; i <= nzAttributeUsage_LastInstanceData; ++i)
|
||||
for (unsigned int i = nzVertexComponent_FirstInstanceData; i <= nzVertexComponent_LastInstanceData; ++i)
|
||||
{
|
||||
nzAttributeType type;
|
||||
nzComponentType type;
|
||||
bool enabled;
|
||||
unsigned int offset;
|
||||
vertexDeclaration->GetAttribute(static_cast<nzAttributeUsage>(i), &enabled, &type, &offset);
|
||||
vertexDeclaration->GetComponent(static_cast<nzVertexComponent>(i), &enabled, &type, &offset);
|
||||
|
||||
if (!IsVertexAttributeSupported(type))
|
||||
if (!IsComponentTypeSupported(type))
|
||||
{
|
||||
NazaraError("Invalid declaration: Vertex attribute 0x" + NzString::Number(i, 16) + " (0x" + NzString::Number(type, 16) + ") is not supported");
|
||||
NazaraError("Invalid declaration: Vertex component 0x" + NzString::Number(i, 16) + " (type: 0x" + NzString::Number(type, 16) + ") is not supported");
|
||||
updateFailed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
glEnableVertexAttribArray(NzOpenGL::AttributeIndex[i]);
|
||||
if (type <= nzAttributeType_Double1 && type >= nzAttributeType_Double4)
|
||||
glEnableVertexAttribArray(NzOpenGL::VertexComponentIndex[i]);
|
||||
if (type <= nzComponentType_Double1 && type >= nzComponentType_Double4)
|
||||
{
|
||||
glVertexAttribLPointer(NzOpenGL::AttributeIndex[i],
|
||||
NzVertexDeclaration::GetAttributeSize(type),
|
||||
NzOpenGL::AttributeType[type],
|
||||
glVertexAttribLPointer(NzOpenGL::VertexComponentIndex[i],
|
||||
NzUtility::ComponentCount[type],
|
||||
NzOpenGL::ComponentType[type],
|
||||
stride,
|
||||
reinterpret_cast<void*>(bufferOffset + offset));
|
||||
}
|
||||
else if (type <= nzAttributeType_Int1 && type >= nzAttributeType_Int4)
|
||||
else if (type <= nzComponentType_Int1 && type >= nzComponentType_Int4)
|
||||
{
|
||||
glVertexAttribIPointer(NzOpenGL::AttributeIndex[i],
|
||||
NzVertexDeclaration::GetAttributeSize(type),
|
||||
NzOpenGL::AttributeType[type],
|
||||
glVertexAttribIPointer(NzOpenGL::VertexComponentIndex[i],
|
||||
NzUtility::ComponentCount[type],
|
||||
NzOpenGL::ComponentType[type],
|
||||
stride,
|
||||
reinterpret_cast<void*>(bufferOffset + offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
glVertexAttribPointer(NzOpenGL::AttributeIndex[i],
|
||||
NzVertexDeclaration::GetAttributeSize(type),
|
||||
NzOpenGL::AttributeType[type],
|
||||
(type == nzAttributeType_Color) ? GL_TRUE : GL_FALSE,
|
||||
glVertexAttribPointer(NzOpenGL::VertexComponentIndex[i],
|
||||
NzUtility::ComponentCount[type],
|
||||
NzOpenGL::ComponentType[type],
|
||||
(type == nzComponentType_Color) ? GL_TRUE : GL_FALSE,
|
||||
stride,
|
||||
reinterpret_cast<void*>(bufferOffset + offset));
|
||||
}
|
||||
|
||||
glVertexAttribDivisor(NzOpenGL::AttributeIndex[i], 1);
|
||||
glVertexAttribDivisor(NzOpenGL::VertexComponentIndex[i], 1);
|
||||
}
|
||||
else
|
||||
glDisableVertexAttribArray(NzOpenGL::AttributeIndex[i]);
|
||||
glDisableVertexAttribArray(NzOpenGL::VertexComponentIndex[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = nzAttributeUsage_FirstInstanceData; i <= nzAttributeUsage_LastInstanceData; ++i)
|
||||
glDisableVertexAttribArray(NzOpenGL::AttributeIndex[i]);
|
||||
for (unsigned int i = nzVertexComponent_FirstInstanceData; i <= nzVertexComponent_LastInstanceData; ++i)
|
||||
glDisableVertexAttribArray(NzOpenGL::VertexComponentIndex[i]);
|
||||
}
|
||||
|
||||
// Et on active l'index buffer (Un seul index buffer par VAO)
|
||||
|
||||
@@ -149,22 +149,22 @@ bool NzShader::Create()
|
||||
|
||||
m_linked = false;
|
||||
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_InstanceData0], "InstanceData0");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_InstanceData1], "InstanceData1");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_InstanceData2], "InstanceData2");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_InstanceData3], "InstanceData3");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_InstanceData4], "InstanceData4");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_InstanceData5], "InstanceData5");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_Normal], "VertexNormal");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_Position], "VertexPosition");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_Tangent], "VertexTangent");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_TexCoord], "VertexTexCoord");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_Userdata0], "VertexUserdata0");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_Userdata1], "VertexUserdata1");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_Userdata2], "VertexUserdata2");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_Userdata3], "VertexUserdata3");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_Userdata4], "VertexUserdata4");
|
||||
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzAttributeUsage_Userdata5], "VertexUserdata5");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData0], "InstanceData0");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData1], "InstanceData1");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData2], "InstanceData2");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData3], "InstanceData3");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData4], "InstanceData4");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData5], "InstanceData5");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Normal], "VertexNormal");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Position], "VertexPosition");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Tangent], "VertexTangent");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_TexCoord], "VertexTexCoord");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata0], "VertexUserdata0");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata1], "VertexUserdata1");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata2], "VertexUserdata2");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata3], "VertexUserdata3");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata4], "VertexUserdata4");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata5], "VertexUserdata5");
|
||||
|
||||
if (NzRenderer::HasCapability(nzRendererCap_MultipleRenderTargets))
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ void NzStaticMesh::Center()
|
||||
NzVector3f offset(m_aabb.x + m_aabb.width/2.f, m_aabb.y + m_aabb.height/2.f, m_aabb.z + m_aabb.depth/2.f);
|
||||
|
||||
NzVertexMapper mapper(this);
|
||||
NzSparsePtr<NzVector3f> position = mapper.GetAttributePtr<NzVector3f>(nzAttributeUsage_Position);
|
||||
NzSparsePtr<NzVector3f> position = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Position);
|
||||
|
||||
unsigned int vertexCount = mapper.GetVertexCount();
|
||||
for (unsigned int i = 0; i < vertexCount; ++i)
|
||||
|
||||
@@ -27,8 +27,8 @@ void NzSubMesh::GenerateNormals()
|
||||
NzVertexMapper mapper(this);
|
||||
unsigned int vertexCount = mapper.GetVertexCount();
|
||||
|
||||
NzSparsePtr<NzVector3f> normals = mapper.GetAttributePtr<NzVector3f>(nzAttributeUsage_Normal);
|
||||
NzSparsePtr<NzVector3f> positions = mapper.GetAttributePtr<NzVector3f>(nzAttributeUsage_Position);
|
||||
NzSparsePtr<NzVector3f> normals = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Normal);
|
||||
NzSparsePtr<NzVector3f> positions = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Position);
|
||||
|
||||
for (unsigned int i = 0; i < vertexCount; ++i)
|
||||
normals[i].MakeZero();
|
||||
@@ -58,10 +58,10 @@ void NzSubMesh::GenerateNormalsAndTangents()
|
||||
NzVertexMapper mapper(this);
|
||||
unsigned int vertexCount = mapper.GetVertexCount();
|
||||
|
||||
NzSparsePtr<NzVector3f> normals = mapper.GetAttributePtr<NzVector3f>(nzAttributeUsage_Normal);
|
||||
NzSparsePtr<NzVector3f> positions = mapper.GetAttributePtr<NzVector3f>(nzAttributeUsage_Position);
|
||||
NzSparsePtr<NzVector3f> tangents = mapper.GetAttributePtr<NzVector3f>(nzAttributeUsage_Tangent);
|
||||
NzSparsePtr<NzVector2f> texCoords = mapper.GetAttributePtr<NzVector2f>(nzAttributeUsage_TexCoord);
|
||||
NzSparsePtr<NzVector3f> normals = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Normal);
|
||||
NzSparsePtr<NzVector3f> positions = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Position);
|
||||
NzSparsePtr<NzVector3f> tangents = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Tangent);
|
||||
NzSparsePtr<NzVector2f> texCoords = mapper.GetComponentPtr<NzVector2f>(nzVertexComponent_TexCoord);
|
||||
|
||||
for (unsigned int i = 0; i < vertexCount; ++i)
|
||||
{
|
||||
@@ -113,10 +113,10 @@ void NzSubMesh::GenerateTangents()
|
||||
{
|
||||
NzVertexMapper mapper(this);
|
||||
|
||||
NzSparsePtr<NzVector3f> normals = mapper.GetAttributePtr<NzVector3f>(nzAttributeUsage_Normal);
|
||||
NzSparsePtr<NzVector3f> positions = mapper.GetAttributePtr<NzVector3f>(nzAttributeUsage_Position);
|
||||
NzSparsePtr<NzVector3f> tangents = mapper.GetAttributePtr<NzVector3f>(nzAttributeUsage_Tangent);
|
||||
NzSparsePtr<NzVector2f> texCoords = mapper.GetAttributePtr<NzVector2f>(nzAttributeUsage_TexCoord);
|
||||
NzSparsePtr<NzVector3f> normals = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Normal);
|
||||
NzSparsePtr<NzVector3f> positions = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Position);
|
||||
NzSparsePtr<NzVector3f> tangents = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Tangent);
|
||||
NzSparsePtr<NzVector2f> texCoords = mapper.GetComponentPtr<NzVector2f>(nzVertexComponent_TexCoord);
|
||||
|
||||
NzTriangleIterator iterator(this);
|
||||
do
|
||||
|
||||
@@ -126,4 +126,42 @@ void NzUtility::Uninitialize()
|
||||
NzCore::Uninitialize();
|
||||
}
|
||||
|
||||
unsigned int NzUtility::ComponentCount[nzComponentType_Max+1] =
|
||||
{
|
||||
4, // nzComponentType_Color
|
||||
1, // nzComponentType_Double1
|
||||
2, // nzComponentType_Double2
|
||||
3, // nzComponentType_Double3
|
||||
4, // nzComponentType_Double4
|
||||
1, // nzComponentType_Float1
|
||||
2, // nzComponentType_Float2
|
||||
3, // nzComponentType_Float3
|
||||
4, // nzComponentType_Float4
|
||||
1, // nzComponentType_Int1
|
||||
2, // nzComponentType_Int2
|
||||
3, // nzComponentType_Int3
|
||||
4 // nzComponentType_Int4
|
||||
};
|
||||
|
||||
static_assert(nzComponentType_Max+1 == 13, "Component count array is incomplete");
|
||||
|
||||
unsigned int NzUtility::ComponentStride[nzComponentType_Max+1] =
|
||||
{
|
||||
4*sizeof(nzUInt8), // nzComponentType_Color
|
||||
1*sizeof(double), // nzComponentType_Double1
|
||||
2*sizeof(double), // nzComponentType_Double2
|
||||
3*sizeof(double), // nzComponentType_Double3
|
||||
4*sizeof(double), // nzComponentType_Double4
|
||||
1*sizeof(float), // nzComponentType_Float1
|
||||
2*sizeof(float), // nzComponentType_Float2
|
||||
3*sizeof(float), // nzComponentType_Float3
|
||||
4*sizeof(float), // nzComponentType_Float4
|
||||
1*sizeof(nzUInt32), // nzComponentType_Int1
|
||||
2*sizeof(nzUInt32), // nzComponentType_Int2
|
||||
3*sizeof(nzUInt32), // nzComponentType_Int3
|
||||
4*sizeof(nzUInt32) // nzComponentType_Int4
|
||||
};
|
||||
|
||||
static_assert(nzComponentType_Max+1 == 13, "Component stride array is incomplete");
|
||||
|
||||
unsigned int NzUtility::s_moduleReferenceCounter = 0;
|
||||
|
||||
@@ -8,51 +8,11 @@
|
||||
#include <Nazara/Core/OffsetOf.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Utility.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
#include <cstring>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
unsigned int attributeSize[] =
|
||||
{
|
||||
4, // nzAttributeType_Color
|
||||
1, // nzAttributeType_Double1
|
||||
2, // nzAttributeType_Double2
|
||||
3, // nzAttributeType_Double3
|
||||
4, // nzAttributeType_Double4
|
||||
1, // nzAttributeType_Float1
|
||||
2, // nzAttributeType_Float2
|
||||
3, // nzAttributeType_Float3
|
||||
4, // nzAttributeType_Float4
|
||||
1, // nzAttributeType_Int1
|
||||
2, // nzAttributeType_Int2
|
||||
3, // nzAttributeType_Int3
|
||||
4 // nzAttributeType_Int4
|
||||
};
|
||||
|
||||
static_assert(sizeof(attributeSize)/sizeof(unsigned int) == nzAttributeType_Max+1, "Attribute size array is incomplete");
|
||||
|
||||
unsigned int attributeStride[] =
|
||||
{
|
||||
4*sizeof(nzUInt8), // nzAttributeType_Color
|
||||
1*sizeof(double), // nzAttributeType_Double1
|
||||
2*sizeof(double), // nzAttributeType_Double2
|
||||
3*sizeof(double), // nzAttributeType_Double3
|
||||
4*sizeof(double), // nzAttributeType_Double4
|
||||
1*sizeof(float), // nzAttributeType_Float1
|
||||
2*sizeof(float), // nzAttributeType_Float2
|
||||
3*sizeof(float), // nzAttributeType_Float3
|
||||
4*sizeof(float), // nzAttributeType_Float4
|
||||
1*sizeof(nzUInt32), // nzAttributeType_Int1
|
||||
2*sizeof(nzUInt32), // nzAttributeType_Int2
|
||||
3*sizeof(nzUInt32), // nzAttributeType_Int3
|
||||
4*sizeof(nzUInt32) // nzAttributeType_Int4
|
||||
};
|
||||
|
||||
static_assert(sizeof(attributeStride)/sizeof(unsigned int) == nzAttributeType_Max+1, "Attribute stride array is incomplete");
|
||||
}
|
||||
|
||||
NzVertexDeclaration::NzVertexDeclaration() :
|
||||
m_stride(0)
|
||||
{
|
||||
@@ -62,7 +22,7 @@ NzVertexDeclaration::NzVertexDeclaration(NzVertexDeclaration& declaration) :
|
||||
NzResource(),
|
||||
m_stride(declaration.m_stride)
|
||||
{
|
||||
std::memcpy(m_attributes, declaration.m_attributes, sizeof(Attribute)*(nzAttributeUsage_Max+1));
|
||||
std::memcpy(m_components, declaration.m_components, sizeof(Component)*(nzVertexComponent_Max+1));
|
||||
}
|
||||
|
||||
NzVertexDeclaration::~NzVertexDeclaration()
|
||||
@@ -70,85 +30,93 @@ NzVertexDeclaration::~NzVertexDeclaration()
|
||||
NotifyDestroy();
|
||||
}
|
||||
|
||||
void NzVertexDeclaration::DisableAttribute(nzAttributeUsage usage)
|
||||
void NzVertexDeclaration::DisableComponent(nzVertexComponent component)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (usage > nzAttributeUsage_Max)
|
||||
if (component > nzVertexComponent_Max)
|
||||
{
|
||||
NazaraError("Attribute usage out of enum");
|
||||
NazaraError("Vertex component out of enum");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (usage == nzAttributeUsage_Unused)
|
||||
if (component == nzVertexComponent_Unused)
|
||||
{
|
||||
NazaraError("Cannot disable \"unused\" attribute");
|
||||
NazaraError("Cannot disable \"unused\" component");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Attribute& attribute = m_attributes[usage];
|
||||
if (attribute.enabled)
|
||||
Component& vertexComponent = m_components[component];
|
||||
if (vertexComponent.enabled)
|
||||
{
|
||||
attribute.enabled = false;
|
||||
m_stride -= attributeStride[attribute.type];
|
||||
vertexComponent.enabled = false;
|
||||
m_stride -= NzUtility::ComponentStride[vertexComponent.type];
|
||||
}
|
||||
}
|
||||
|
||||
void NzVertexDeclaration::EnableAttribute(nzAttributeUsage usage, nzAttributeType type, unsigned int offset)
|
||||
void NzVertexDeclaration::EnableComponent(nzVertexComponent component, nzComponentType type, unsigned int offset)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (usage > nzAttributeUsage_Max)
|
||||
if (component > nzVertexComponent_Max)
|
||||
{
|
||||
NazaraError("Attribute usage out of enum");
|
||||
NazaraError("Vertex component out of enum");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (usage != nzAttributeUsage_Unused)
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsTypeSupported(type))
|
||||
{
|
||||
Attribute& attribute = m_attributes[usage];
|
||||
if (attribute.enabled)
|
||||
m_stride -= attributeStride[attribute.type];
|
||||
NazaraError("Component type 0x" + NzString::Number(type, 16) + " is not supported by vertex declarations");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (component != nzVertexComponent_Unused)
|
||||
{
|
||||
Component& vertexComponent = m_components[component];
|
||||
if (vertexComponent.enabled)
|
||||
m_stride -= NzUtility::ComponentStride[vertexComponent.type];
|
||||
else
|
||||
attribute.enabled = true;
|
||||
vertexComponent.enabled = true;
|
||||
|
||||
attribute.offset = offset;
|
||||
attribute.type = type;
|
||||
vertexComponent.offset = offset;
|
||||
vertexComponent.type = type;
|
||||
}
|
||||
|
||||
m_stride += attributeStride[type];
|
||||
m_stride += NzUtility::ComponentStride[type];
|
||||
}
|
||||
|
||||
void NzVertexDeclaration::GetAttribute(nzAttributeUsage usage, bool* enabled, nzAttributeType* type, unsigned int* offset) const
|
||||
void NzVertexDeclaration::GetComponent(nzVertexComponent component, bool* enabled, nzComponentType* type, unsigned int* offset) const
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (usage > nzAttributeUsage_Max)
|
||||
if (component > nzVertexComponent_Max)
|
||||
{
|
||||
NazaraError("Attribute usage out of enum");
|
||||
NazaraError("Vertex component out of enum");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (usage == nzAttributeUsage_Unused)
|
||||
if (component == nzVertexComponent_Unused)
|
||||
{
|
||||
NazaraError("Cannot get \"unused\" attribute");
|
||||
NazaraError("Cannot get \"unused\" component");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
const Attribute& attribute = m_attributes[usage];
|
||||
const Component& vertexComponent = m_components[component];
|
||||
|
||||
if (enabled)
|
||||
*enabled = attribute.enabled;
|
||||
*enabled = vertexComponent.enabled;
|
||||
|
||||
if (type)
|
||||
*type = attribute.type;
|
||||
*type = vertexComponent.type;
|
||||
|
||||
if (offset)
|
||||
*offset = attribute.offset;
|
||||
*offset = vertexComponent.offset;
|
||||
}
|
||||
|
||||
unsigned int NzVertexDeclaration::GetStride() const
|
||||
@@ -163,7 +131,7 @@ void NzVertexDeclaration::SetStride(unsigned int stride)
|
||||
|
||||
NzVertexDeclaration& NzVertexDeclaration::operator=(const NzVertexDeclaration& declaration)
|
||||
{
|
||||
std::memcpy(m_attributes, declaration.m_attributes, sizeof(Attribute)*(nzAttributeUsage_Max+1));
|
||||
std::memcpy(m_components, declaration.m_components, sizeof(Component)*(nzVertexComponent_Max+1));
|
||||
m_stride = declaration.m_stride;
|
||||
|
||||
return *this;
|
||||
@@ -182,17 +150,28 @@ NzVertexDeclaration* NzVertexDeclaration::Get(nzVertexLayout layout)
|
||||
return &s_declarations[layout];
|
||||
}
|
||||
|
||||
unsigned int NzVertexDeclaration::GetAttributeSize(nzAttributeType type)
|
||||
bool NzVertexDeclaration::IsTypeSupported(nzComponentType type)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (type > nzAttributeType_Max)
|
||||
switch (type)
|
||||
{
|
||||
NazaraError("Attribute type out of enum");
|
||||
return 0;
|
||||
case nzComponentType_Color:
|
||||
case nzComponentType_Double1:
|
||||
case nzComponentType_Double2:
|
||||
case nzComponentType_Double3:
|
||||
case nzComponentType_Double4:
|
||||
case nzComponentType_Float1:
|
||||
case nzComponentType_Float2:
|
||||
case nzComponentType_Float3:
|
||||
case nzComponentType_Float4:
|
||||
case nzComponentType_Int1:
|
||||
case nzComponentType_Int2:
|
||||
case nzComponentType_Int3:
|
||||
case nzComponentType_Int4:
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return attributeSize[type];
|
||||
NazaraError("Component type not handled (0x" + NzString::Number(type, 16) + ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NzVertexDeclaration::Initialize()
|
||||
@@ -206,72 +185,72 @@ bool NzVertexDeclaration::Initialize()
|
||||
|
||||
// nzVertexLayout_XY : NzVertexStruct_XY
|
||||
declaration = &s_declarations[nzVertexLayout_XY];
|
||||
declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float2, NzOffsetOf(NzVertexStruct_XY, position));
|
||||
declaration->EnableComponent(nzVertexComponent_Position, nzComponentType_Float2, NzOffsetOf(NzVertexStruct_XY, position));
|
||||
|
||||
NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XY), "Invalid stride for declaration NzVertexStruct_XY");
|
||||
|
||||
// nzVertexLayout_XY_UV : NzVertexStruct_XY_UV
|
||||
declaration = &s_declarations[nzVertexLayout_XY_UV];
|
||||
declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float2, NzOffsetOf(NzVertexStruct_XY_UV, position));
|
||||
declaration->EnableAttribute(nzAttributeUsage_TexCoord, nzAttributeType_Float2, NzOffsetOf(NzVertexStruct_XY_UV, uv));
|
||||
declaration->EnableComponent(nzVertexComponent_Position, nzComponentType_Float2, NzOffsetOf(NzVertexStruct_XY_UV, position));
|
||||
declaration->EnableComponent(nzVertexComponent_TexCoord, nzComponentType_Float2, NzOffsetOf(NzVertexStruct_XY_UV, uv));
|
||||
|
||||
NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XY_UV), "Invalid stride for declaration nzVertexLayout_XY_UV");
|
||||
|
||||
// nzVertexLayout_XYZ : NzVertexStruct_XYZ
|
||||
declaration = &s_declarations[nzVertexLayout_XYZ];
|
||||
declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ, position));
|
||||
declaration->EnableComponent(nzVertexComponent_Position, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ, position));
|
||||
|
||||
NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XYZ), "Invalid stride for declaration nzVertexLayout_XYZ");
|
||||
|
||||
// nzVertexLayout_XYZ_Normal : NzVertexStruct_XYZ_Normal
|
||||
declaration = &s_declarations[nzVertexLayout_XYZ_Normal];
|
||||
declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal, position));
|
||||
declaration->EnableAttribute(nzAttributeUsage_Normal, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal, normal));
|
||||
declaration->EnableComponent(nzVertexComponent_Position, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal, position));
|
||||
declaration->EnableComponent(nzVertexComponent_Normal, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal, normal));
|
||||
|
||||
NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XYZ_Normal), "Invalid stride for declaration nzVertexLayout_XYZ_Normal");
|
||||
|
||||
// nzVertexLayout_XYZ_Normal_UV : NzVertexStruct_XYZ_Normal_UV
|
||||
declaration = &s_declarations[nzVertexLayout_XYZ_Normal_UV];
|
||||
declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV, position));
|
||||
declaration->EnableAttribute(nzAttributeUsage_Normal, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV, normal));
|
||||
declaration->EnableAttribute(nzAttributeUsage_TexCoord, nzAttributeType_Float2, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV, uv));
|
||||
declaration->EnableComponent(nzVertexComponent_Position, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV, position));
|
||||
declaration->EnableComponent(nzVertexComponent_Normal, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV, normal));
|
||||
declaration->EnableComponent(nzVertexComponent_TexCoord, nzComponentType_Float2, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV, uv));
|
||||
|
||||
NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XYZ_Normal_UV), "Invalid stride for declaration nzVertexLayout_XYZ_Normal_UV");
|
||||
|
||||
// nzVertexLayout_XYZ_Normal_UV_Tangent : NzVertexStruct_XYZ_Normal_UV_Tangent
|
||||
declaration = &s_declarations[nzVertexLayout_XYZ_Normal_UV_Tangent];
|
||||
declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent, position));
|
||||
declaration->EnableAttribute(nzAttributeUsage_Normal, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent, normal));
|
||||
declaration->EnableAttribute(nzAttributeUsage_TexCoord, nzAttributeType_Float2, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent, uv));
|
||||
declaration->EnableAttribute(nzAttributeUsage_Tangent, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent, tangent));
|
||||
declaration->EnableComponent(nzVertexComponent_Position, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent, position));
|
||||
declaration->EnableComponent(nzVertexComponent_Normal, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent, normal));
|
||||
declaration->EnableComponent(nzVertexComponent_TexCoord, nzComponentType_Float2, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent, uv));
|
||||
declaration->EnableComponent(nzVertexComponent_Tangent, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent, tangent));
|
||||
|
||||
NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XYZ_Normal_UV_Tangent), "Invalid stride for declaration nzVertexLayout_XYZ_Normal_UV_Tangent");
|
||||
|
||||
// nzVertexLayout_XYZ_Normal_UV_Tangent_Skinning : NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning
|
||||
declaration = &s_declarations[nzVertexLayout_XYZ_Normal_UV_Tangent_Skinning];
|
||||
declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, position));
|
||||
declaration->EnableAttribute(nzAttributeUsage_Normal, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, normal));
|
||||
declaration->EnableAttribute(nzAttributeUsage_TexCoord, nzAttributeType_Float2, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, uv));
|
||||
declaration->EnableAttribute(nzAttributeUsage_Tangent, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, tangent));
|
||||
declaration->EnableAttribute(nzAttributeUsage_Unused, nzAttributeType_Int1, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, weightCount));
|
||||
declaration->EnableAttribute(nzAttributeUsage_Userdata0, nzAttributeType_Float4, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, weights));
|
||||
declaration->EnableAttribute(nzAttributeUsage_Userdata1, nzAttributeType_Int4, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, jointIndexes));
|
||||
declaration->EnableComponent(nzVertexComponent_Position, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, position));
|
||||
declaration->EnableComponent(nzVertexComponent_Normal, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, normal));
|
||||
declaration->EnableComponent(nzVertexComponent_TexCoord, nzComponentType_Float2, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, uv));
|
||||
declaration->EnableComponent(nzVertexComponent_Tangent, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, tangent));
|
||||
declaration->EnableComponent(nzVertexComponent_Unused, nzComponentType_Int1, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, weightCount));
|
||||
declaration->EnableComponent(nzVertexComponent_Userdata0, nzComponentType_Float4, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, weights));
|
||||
declaration->EnableComponent(nzVertexComponent_Userdata1, nzComponentType_Int4, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, jointIndexes));
|
||||
|
||||
NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning), "Invalid stride for declaration nzVertexLayout_XYZ_Normal_UV_Tangent_Skinning");
|
||||
|
||||
// nzVertexLayout_XYZ_UV : NzVertexStruct_XYZ_UV
|
||||
declaration = &s_declarations[nzVertexLayout_XYZ_UV];
|
||||
declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_UV, position));
|
||||
declaration->EnableAttribute(nzAttributeUsage_TexCoord, nzAttributeType_Float2, NzOffsetOf(NzVertexStruct_XYZ_UV, uv));
|
||||
declaration->EnableComponent(nzVertexComponent_Position, nzComponentType_Float3, NzOffsetOf(NzVertexStruct_XYZ_UV, position));
|
||||
declaration->EnableComponent(nzVertexComponent_TexCoord, nzComponentType_Float2, NzOffsetOf(NzVertexStruct_XYZ_UV, uv));
|
||||
|
||||
NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XYZ_UV), "Invalid stride for declaration nzVertexLayout_XYZ_UV");
|
||||
|
||||
// nzVertexLayout_Matrix4 : NzMatrix4f
|
||||
declaration = &s_declarations[nzVertexLayout_Matrix4];
|
||||
declaration->EnableAttribute(nzAttributeUsage_InstanceData0, nzAttributeType_Float4, NzOffsetOf(NzMatrix4f, m11));
|
||||
declaration->EnableAttribute(nzAttributeUsage_InstanceData1, nzAttributeType_Float4, NzOffsetOf(NzMatrix4f, m21));
|
||||
declaration->EnableAttribute(nzAttributeUsage_InstanceData2, nzAttributeType_Float4, NzOffsetOf(NzMatrix4f, m31));
|
||||
declaration->EnableAttribute(nzAttributeUsage_InstanceData3, nzAttributeType_Float4, NzOffsetOf(NzMatrix4f, m41));
|
||||
declaration->EnableComponent(nzVertexComponent_InstanceData0, nzComponentType_Float4, NzOffsetOf(NzMatrix4f, m11));
|
||||
declaration->EnableComponent(nzVertexComponent_InstanceData1, nzComponentType_Float4, NzOffsetOf(NzMatrix4f, m21));
|
||||
declaration->EnableComponent(nzVertexComponent_InstanceData2, nzComponentType_Float4, NzOffsetOf(NzMatrix4f, m31));
|
||||
declaration->EnableComponent(nzVertexComponent_InstanceData3, nzComponentType_Float4, NzOffsetOf(NzMatrix4f, m41));
|
||||
|
||||
NazaraAssert(declaration->GetStride() == sizeof(NzMatrix4f), "Invalid stride for declaration nzVertexLayout_Matrix4");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user