本文整理汇总了C++中GeometryPtr::AddElement方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryPtr::AddElement方法的具体用法?C++ GeometryPtr::AddElement怎么用?C++ GeometryPtr::AddElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryPtr
的用法示例。
在下文中一共展示了GeometryPtr::AddElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildQuad
void SDFShadowDemo::BuildQuad()
{
// create a screen quad
m_pQuad = GeometryPtr(new GeometryDX11());
const i32 NumVertexOfQuad = 4;
// create the vertex element streams
VertexElementDX11* pPositions = new VertexElementDX11(3, NumVertexOfQuad);
pPositions->m_SemanticName = VertexElementDX11::PositionSemantic;
pPositions->m_uiSemanticIndex = 0;
pPositions->m_Format = DXGI_FORMAT_R32G32B32_FLOAT;
pPositions->m_uiInputSlot = 0;
pPositions->m_uiAlignedByteOffset = 0;
pPositions->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
pPositions->m_uiInstanceDataStepRate = 0;
VertexElementDX11* pColors = new VertexElementDX11(4, NumVertexOfQuad);
pColors->m_SemanticName = VertexElementDX11::ColorSemantic;
pColors->m_uiSemanticIndex = 0;
pColors->m_Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
pColors->m_uiInputSlot = 0;
pColors->m_uiAlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
pColors->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
pColors->m_uiInstanceDataStepRate = 0;
m_pQuad->AddElement(pPositions);
m_pQuad->AddElement(pColors);
*pPositions->Get3f(0) = Vector3f(-1.0f, +1.0f, 0.0f);
*pPositions->Get3f(1) = Vector3f(+1.0f, +1.0f, 0.0f);
*pPositions->Get3f(2) = Vector3f(-1.0f, -1.0f, 0.0f);
*pPositions->Get3f(3) = Vector3f(+1.0f, -1.0f, 0.0f);
*pColors->Get4f(0) = Colors::White;
*pColors->Get4f(1) = Colors::White;
*pColors->Get4f(2) = Colors::White;
*pColors->Get4f(3) = Colors::White;
m_pQuad->AddFace(TriangleIndices(0, 1, 2));
m_pQuad->AddFace(TriangleIndices(1, 3, 2));
m_pQuad->LoadToBuffers();
}
示例2: exception
//.........这里部分代码省略.........
if(-1 < (elemIdx = FindPlyElementIndex(elements, "vertex")))
{
PlyElementDesc d = elements.at( elemIdx );
// Has positions?
int xIdx = FindPlyElementPropertyIndex( d.dataFormat, "x" );
int yIdx = FindPlyElementPropertyIndex( d.dataFormat, "y" );
int zIdx = FindPlyElementPropertyIndex( d.dataFormat, "z" );
if ((-1 != xIdx) && (-1 != yIdx) && (-1 != zIdx))
{
VertexElementDX11 *pPositions = new VertexElementDX11( 3, d.elementCount );
pPositions->m_SemanticName = VertexElementDX11::PositionSemantic;
pPositions->m_uiSemanticIndex = 0;
pPositions->m_Format = DXGI_FORMAT_R32G32B32_FLOAT;
pPositions->m_uiInputSlot = 0;
pPositions->m_uiAlignedByteOffset = 0;
pPositions->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
pPositions->m_uiInstanceDataStepRate = 0;
Vector3f* pRawPos = pPositions->Get3f( 0 );
for(int v = 0; v < d.elementCount; ++v)
{
void** raw = d.data.at(v);
float x = *reinterpret_cast<float*>(raw[xIdx]);
float y = *reinterpret_cast<float*>(raw[yIdx]);
float z = *reinterpret_cast<float*>(raw[zIdx]);
pRawPos[v] = Vector3f( x, y, z );
}
MeshPtr->AddElement( pPositions );
}
// Has normals?
int nxIdx = FindPlyElementPropertyIndex( d.dataFormat, "nx" );
int nyIdx = FindPlyElementPropertyIndex( d.dataFormat, "ny" );
int nzIdx = FindPlyElementPropertyIndex( d.dataFormat, "nz" );
if ((-1 != nxIdx) && (-1 != nyIdx) && (-1 != nzIdx))
{
VertexElementDX11 *pNormals = new VertexElementDX11( 3, d.elementCount );
pNormals->m_SemanticName = VertexElementDX11::NormalSemantic;
pNormals->m_uiSemanticIndex = 0;
pNormals->m_Format = DXGI_FORMAT_R32G32B32_FLOAT;
pNormals->m_uiInputSlot = 0;
pNormals->m_uiAlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
pNormals->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
pNormals->m_uiInstanceDataStepRate = 0;
Vector3f* pRawNorms = pNormals->Get3f( 0 );
for(int v = 0; v < d.elementCount; ++v)
{
void** raw = d.data.at(v);
float x = *reinterpret_cast<float*>(raw[nxIdx]);
float y = *reinterpret_cast<float*>(raw[nyIdx]);
float z = *reinterpret_cast<float*>(raw[nzIdx]);
pRawNorms[v] = Vector3f( x, y, z );
}
MeshPtr->AddElement( pNormals );
示例3: sizeof
//.........这里部分代码省略.........
GeometryPtr MeshPtr = GeometryPtr( new GeometryDX11() );
//for ( int i = 0; i < usVertexCount; i++ )
//{
// pPos[i].x() = pMS3DVertices[i].vertex[0];
// pPos[i].y() = pMS3DVertices[i].vertex[1];
// pPos[i].z() = -pMS3DVertices[i].vertex[2];
// pNrm[i].MakeZero();
//}
TriangleIndices face;
for ( int i = 0; i < usTriangleCount; i++ )
{
face.P1() = 3*i+0;
face.P2() = 3*i+2;
face.P3() = 3*i+1;
pPos[3*i+0].x = pMS3DVertices[pMS3DTriangles[i].vertexIndices[0]].vertex[0];
pPos[3*i+0].y = pMS3DVertices[pMS3DTriangles[i].vertexIndices[0]].vertex[1];
pPos[3*i+0].z = -pMS3DVertices[pMS3DTriangles[i].vertexIndices[0]].vertex[2];
pPos[3*i+1].x = pMS3DVertices[pMS3DTriangles[i].vertexIndices[1]].vertex[0];
pPos[3*i+1].y = pMS3DVertices[pMS3DTriangles[i].vertexIndices[1]].vertex[1];
pPos[3*i+1].z = -pMS3DVertices[pMS3DTriangles[i].vertexIndices[1]].vertex[2];
pPos[3*i+2].x = pMS3DVertices[pMS3DTriangles[i].vertexIndices[2]].vertex[0];
pPos[3*i+2].y = pMS3DVertices[pMS3DTriangles[i].vertexIndices[2]].vertex[1];
pPos[3*i+2].z = -pMS3DVertices[pMS3DTriangles[i].vertexIndices[2]].vertex[2];
pNrm[3*i+0].x = pMS3DTriangles[i].vertexNormals[0][0];
pNrm[3*i+0].y = pMS3DTriangles[i].vertexNormals[0][1];
pNrm[3*i+0].z = -pMS3DTriangles[i].vertexNormals[0][2];
pNrm[3*i+1].x = pMS3DTriangles[i].vertexNormals[1][0];
pNrm[3*i+1].y = pMS3DTriangles[i].vertexNormals[1][1];
pNrm[3*i+1].z = -pMS3DTriangles[i].vertexNormals[1][2];
pNrm[3*i+2].x = pMS3DTriangles[i].vertexNormals[2][0];
pNrm[3*i+2].y = pMS3DTriangles[i].vertexNormals[2][1];
pNrm[3*i+2].z = -pMS3DTriangles[i].vertexNormals[2][2];
pTex[3*i+0].x = pMS3DTriangles[i].s[0];
pTex[3*i+0].y = pMS3DTriangles[i].t[0];
pTex[3*i+1].x = pMS3DTriangles[i].s[1];
pTex[3*i+1].y = pMS3DTriangles[i].t[1];
pTex[3*i+2].x = pMS3DTriangles[i].s[2];
pTex[3*i+2].y = pMS3DTriangles[i].t[2];
MeshPtr->AddFace( face );
}
for ( int i = 0; i < usVertexCount; i++ )
{
pNrm[i].Normalize();
}
MeshPtr->AddElement( pPositions );
MeshPtr->AddElement( pTexcoords );
MeshPtr->AddElement( pNormals );
// Delete temporary materials
if (pMS3DMaterials != NULL)
{
delete[] pMS3DMaterials;
pMS3DMaterials = NULL;
}
// Delete temporary groups and their indices
if (pMS3DGroups != NULL)
{
for (int i = 0; i < usGroupCount; i++)
{
if (pMS3DGroups[i].triangleIndices != NULL)
{
delete[] pMS3DGroups[i].triangleIndices;
pMS3DGroups[i].triangleIndices = NULL;
}
}
delete[] pMS3DGroups;
pMS3DGroups = NULL;
}
// Delete temporary triangles
if (pMS3DTriangles != NULL)
{
delete[] pMS3DTriangles;
pMS3DTriangles = NULL;
}
// Delete temporary vertices
if (pMS3DVertices != NULL)
{
delete[] pMS3DVertices;
pMS3DVertices = NULL;
}
//MeshPtr->GenerateVertexDeclaration();
//MeshPtr->LoadToBuffers();
return( MeshPtr );
}