顶点数据的生成
bool YfBuildWedgeVertices
(
Yreal width,
Yreal length,
Yreal height,
YeOriginPose originPose,
Yuint vertexStriding,
Yuint vertexPos,
void* pVerticesBuffer
)
{
if (!pVerticesBuffer)
{
return false;
} Yuint numVertices = ; // 顶点赋值
char* vertexPtr = (char*)pVerticesBuffer + vertexPos;
YsVector3* curVertexPtr = NULL;
Yuint nOffset = ; YsVector3 vOriginOffset(-width / , -height / , -length / );
if (originPose == YE_ORIGIN_POSE_TOP)
{
vOriginOffset.y = -height;
}
else if (originPose == YE_ORIGIN_POSE_BOTTOM)
{
vOriginOffset.y = 0.0f;
} // 底四个顶点
for (Yuint j = ; j < ; j++)
{
for (Yuint i = ; i < ; i++)
{
nOffset = (j* + i) * vertexStriding;
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = width*i + vOriginOffset.x;
curVertexPtr->y = vOriginOffset.y;
curVertexPtr->z = length*j + vOriginOffset.z;
}
} // 上顶点
nOffset = * vertexStriding;
if (vertexPtr)
{
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = vOriginOffset.x + width / ;
curVertexPtr->y = height + vOriginOffset.y;
curVertexPtr->z = vOriginOffset.z; curVertexPtr = (YsVector3*)(vertexPtr + nOffset + vertexStriding);
curVertexPtr->x = vOriginOffset.x + width / ;
curVertexPtr->y = height + vOriginOffset.y;
curVertexPtr->z = length + vOriginOffset.z;
} return true;
}
三角形索引数据的生成
bool YfBuildWedgeTriIndices
(
YeIndexType indexType,
Yuint indexStriding,
Yuint indexPos,
void* pTriIndicesBuffer
)
{
if (!pTriIndicesBuffer)
{
return false;
} char* indexPtr = (char*)pTriIndicesBuffer + indexPos;
if (indexType == YE_INDEX_16_BIT)
{
YsTriIndex16* triIndexPtr = NULL; // bottom
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ; // 4 face
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ; // 2 face
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
}
else
{
YsTriIndex32* triIndexPtr = NULL; // bottom
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ; // 4 face
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ; // 2 face
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
} return true;
}
线框索引数据的生成
bool YfBuildWedgeWireIndices
(
YeIndexType indexType,
Yuint indexStriding,
Yuint indexPos,
void* pWireIndicesBuffer
)
{
if (!pWireIndicesBuffer)
{
return false;
} Yuint numVertices = ;
Yuint numLines = ; // 索引赋值
char* indexPtr = (char*)pWireIndicesBuffer + indexPos;
Yuint nOffset = ;
if (indexType == YE_INDEX_16_BIT)
{
YsLineIndex16* lineIndexPtr = NULL; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ;
}
else
{
YsLineIndex32* lineIndexPtr = NULL; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ;
} return true;
}