当前位置: 首页>>代码示例>>C++>>正文


C++ GeometryPtr::AddFace方法代码示例

本文整理汇总了C++中GeometryPtr::AddFace方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryPtr::AddFace方法的具体用法?C++ GeometryPtr::AddFace怎么用?C++ GeometryPtr::AddFace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeometryPtr的用法示例。


在下文中一共展示了GeometryPtr::AddFace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
开发者ID:CaptainJH,项目名称:forward,代码行数:42,代码来源:source.cpp

示例2: 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 );
}
开发者ID:CaptainJH,项目名称:hieroglyph3-90072,代码行数:101,代码来源:GeometryLoaderDX11.cpp


注:本文中的GeometryPtr::AddFace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。