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


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

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


在下文中一共展示了GeometryPtr::LoadToBuffers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: exception


//.........这里部分代码省略.........
			void** raw = d.data.at(f);
			PlyDataArray<int>* idxs = reinterpret_cast<PlyDataArray<int>*>(raw[0]);
			
			if( -1 == faceSize)
				faceSize = idxs->length;
			else if(faceSize != idxs->length)
				throw new std::exception("Expected each face to have the same number of indexes");
		}

		if(withAdjacency)
		{
			MeshPtr->SetPrimitiveType( (D3D11_PRIMITIVE_TOPOLOGY)(D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + ((2*faceSize) - 1)) );

			// Grab all of the faces so we can search for adjacency
			int* pRaw = new int[d.elementCount * faceSize];

			int pRawIdx = 0;

			for(int f = 0; f < d.elementCount; ++f)
			{
				void** raw = d.data.at(f);
				PlyDataArray<int>* idxs = reinterpret_cast<PlyDataArray<int>*>(raw[0]);

				for(unsigned int fi = 0; fi < idxs->length; ++fi)
					pRaw[pRawIdx++] = idxs->data[fi];
			}

			// We can now go and add the actual indices
			for(int f = 0; f < (d.elementCount * faceSize); f+=3)
			{
				MeshPtr->AddIndex( pRaw[f + 0] );
				MeshPtr->AddIndex( pRaw[f + 1] );
				MeshPtr->AddIndex( pRaw[f + 2] );

				// We now need to find an adjacency for each
				// edge where possible
				int a0 = FindAdjacentIndex( pRaw[f + 0], pRaw[f + 1], pRaw[f + 2], pRaw, d.elementCount * faceSize );
				int a1 = FindAdjacentIndex( pRaw[f + 1], pRaw[f + 2], pRaw[f + 0], pRaw, d.elementCount * faceSize );
				int a2 = FindAdjacentIndex( pRaw[f + 2], pRaw[f + 0], pRaw[f + 1], pRaw, d.elementCount * faceSize );

				std::wstringstream out;
				out << "Actual indices <" << pRaw[f+0] << ", " << pRaw[f+1] << ", " << pRaw[f+2] << "> have adjacency <" << a0 << ", " << a1 << ", " << a2 << ">.";
				OutputDebugString( out.str().c_str() );
				OutputDebugString( L"\n" );

				MeshPtr->AddIndex( a0 );
				MeshPtr->AddIndex( a1 );
				MeshPtr->AddIndex( a2 );
			}

			delete[] pRaw;
		}
		else
		{
			// Thirdly, can now set the appropriate topology
			MeshPtr->SetPrimitiveType( (D3D11_PRIMITIVE_TOPOLOGY)(D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + (faceSize - 1)) );

			// Finally, extract this data
			for(int f = 0; f < d.elementCount; ++f)
			{
				void** raw = d.data.at(f);
				PlyDataArray<int>* idxs = reinterpret_cast<PlyDataArray<int>*>(raw[0]);

				for(unsigned int fi = 0; fi < idxs->length; ++fi)
					MeshPtr->AddIndex( idxs->data[fi] );
			}
		}
	}
	else
	{
		throw new std::exception("Expected a 'face' element, but not found");
	}

	// Push into renderable resource
	MeshPtr->LoadToBuffers( );

	// Release all intermediary memory
	for( std::vector< PlyElementDesc >::iterator it = elements.begin(); it != elements.end(); ++it)
	{
		PlyElementDesc d = *it;
		for(int e = 0; e < d.elementCount; ++e)
		{
			void** raw = d.data.at(e);

			if(d.dataFormat.at(0).isList)
			{
				PlyDataArray<void*>* rawArray = reinterpret_cast<PlyDataArray<void*>*>(raw[0]);
				SAFE_DELETE_ARRAY( rawArray->data );
				SAFE_DELETE(raw[0]);
			}
			else
			{
				SAFE_DELETE(raw[0]);
			}
		}
	}

	// Return to caller
	return MeshPtr;
}
开发者ID:CaptainJH,项目名称:hieroglyph3-90072,代码行数:101,代码来源:GeometryLoaderDX11.cpp

示例3: sizeof


//.........这里部分代码省略.........
			AnimationStream<Vector3f>* pPosFrames = new AnimationStream<Vector3f>();

			for ( int j = 0; j < pMS3DJoints[i].numKeyFramesTrans; j++ )
			{
				Vector3f p = Vector3f( pMS3DJoints[i].keyFramesTrans[j].position[0],
					pMS3DJoints[i].keyFramesTrans[j].position[1],
					pMS3DJoints[i].keyFramesTrans[j].position[2] );

				pPosFrames->AddState( AnimationState<Vector3f>( pMS3DJoints[i].keyFramesTrans[j].time, p ) ); 
			}

			AnimationStream<Vector3f>* pRotFrames = new AnimationStream<Vector3f>();
			
			Vector3f BindRotation = Vector3f( pMS3DJoints[i].rotation[0] + 6.28f, pMS3DJoints[i].rotation[1] + 6.28f, pMS3DJoints[i].rotation[2] + 6.28f );

			for ( int j = 0; j < pMS3DJoints[i].numKeyFramesRot; j++ )
			{
				Vector3f p = Vector3f( pMS3DJoints[i].keyFramesRot[j].rotation[0] + 6.28f,
					pMS3DJoints[i].keyFramesRot[j].rotation[1] + 6.28f,
					pMS3DJoints[i].keyFramesRot[j].rotation[2] + 6.28f );

				pRotFrames->AddState( AnimationState<Vector3f>( pMS3DJoints[i].keyFramesRot[j].time, p ) ); 
			}

			pActor->AddBoneNode( pBone, BindPosition, BindRotation, pPosFrames, pRotFrames );

			JointNodes[std::string(pMS3DJoints[i].name)] = pBone;
		}

		// Connect up the bones to form the skeleton.
		for ( int i = 0; i < nNumJoints; i++ )
		{
			Node3D* pParent = JointNodes[std::string(pMS3DJoints[i].parentName)];
			Node3D* pChild = JointNodes[std::string(pMS3DJoints[i].name)];

			// If the node has a parent, link them
			if ( pParent && pChild )
				pParent->AttachChild( pChild );

			// If the node has no parent, link it to the root of the skinned actor (for connection
			// to the scene graph).
			if ( !pParent && pChild )
				pActor->GetNode()->AttachChild( pChild );
		}
	}


	// Delete temporary joint information
	if ( pMS3DJoints )
	{
		for ( int i = 0; i < nNumJoints; i++ )
		{
			delete[] pMS3DJoints[i].keyFramesRot;
			delete[] pMS3DJoints[i].keyFramesTrans;
		}
		delete[] pMS3DJoints;
	}


	// Delete temporary materials
	if (pMS3DMaterials != NULL)
	{
		delete[] pMS3DMaterials;
		pMS3DMaterials = NULL;
	}

	// Delete temporary groups and their indices
	if (pMS3DGroups != NULL)
	{
		for (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

示例4: Initialize

//--------------------------------------------------------------------------------
void App::Initialize()
{
	// Create the light parameters for use with this effect

	Vector4f LightParams = Vector4f( 0.2f, 0.7f, 0.2f, 0.7f );
	m_pLightColor = m_pRenderer11->m_pParamMgr->GetVectorParameterRef( std::wstring( L"LightColor" ) );
	m_pLightColor->InitializeParameterData( &LightParams );

	Vector4f LightPosition = Vector4f( -1000.0f, 200.0f, 0.0f, 0.0f );
	m_pLightPosition = m_pRenderer11->m_pParamMgr->GetVectorParameterRef( std::wstring( L"LightPositionWS" ) );
	m_pLightPosition->InitializeParameterData( &LightPosition );


	// Create the camera, and the render view that will produce an image of the 
	// from the camera's point of view of the scene.

	m_pCamera->Spatial().SetRotation( Vector3f( 0.7f, 0.0f, 0.0f ) );
	m_pCamera->Spatial().SetTranslation( Vector3f( 0.0f, 50.0f, -20.0f ) );
	m_pRenderView->SetBackColor( Vector4f( 0.1f, 0.1f, 0.3f, 0.0f ) );



	// Create the displaced skinned actor

	m_pDisplacedActor = new SkinnedActor();
	GeometryPtr pGeometry = GeometryPtr( new GeometryDX11() );
	GeometryGeneratorDX11::GenerateWeightedSkinnedCone( pGeometry, 16, 20, 2.0f, 40.0f, 6, m_pDisplacedActor );
	pGeometry->SetPrimitiveType( D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST );
	m_pDisplacedActor->GetBody()->Visual.SetMaterial( MaterialGeneratorDX11::GenerateSkinnedSolid( *m_pRenderer11 ) );

	RotationController<Node3D>* pRotController1 = new RotationController<Node3D>();
	m_pDisplacedActor->GetNode()->Controllers.Attach( pRotController1 );

	
	// Create the skinned actor without displacement

	m_pSkinnedActor = new SkinnedActor();
	GeometryPtr pSkinnedGeometry = GeometryPtr( new GeometryDX11() );
	GeometryGeneratorDX11::GenerateWeightedSkinnedCone( pSkinnedGeometry, 16, 20, 2.0f, 40.0f, 6, m_pSkinnedActor );
	pSkinnedGeometry->SetPrimitiveType( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
	m_pSkinnedActor->GetBody()->Visual.SetMaterial( MaterialGeneratorDX11::GenerateSkinnedTextured( *m_pRenderer11 ) );

	RotationController<Node3D>* pRotController2 = new RotationController<Node3D>();
	m_pSkinnedActor->GetNode()->Controllers.Attach( pRotController2 );

	
	// Generate the static mesh, and attach a texture to its entity

	m_pStaticActor = new Actor();
	GeometryPtr pStaticGeometry = GeometryLoaderDX11::loadMS3DFile2( std::wstring( L"box.ms3d" ) );
	pStaticGeometry->LoadToBuffers();
	MaterialPtr pStaticMaterial = MaterialGeneratorDX11::GenerateStaticTextured( *m_pRenderer11 );
	m_pStaticActor->GetBody()->Visual.SetGeometry( pStaticGeometry );
	m_pStaticActor->GetBody()->Visual.SetMaterial( pStaticMaterial );

	RotationController<Entity3D>* pRotController3 = new RotationController<Entity3D>();
	m_pStaticActor->GetBody()->Controllers.Attach( pRotController3);

	
	ResourcePtr ColorTexture = RendererDX11::Get()->LoadTexture( L"Tiles.png" );
	ShaderResourceParameterWriterDX11* pTextureParameter = new ShaderResourceParameterWriterDX11();
	m_pStaticActor->GetBody()->Parameters.SetShaderResourceParameter( L"ColorTexture", ColorTexture );
	

	// Attach the actors to the scene, so that they will be rendered all together.

	m_pScene->AddActor( m_pDisplacedActor );
	m_pScene->AddActor( m_pSkinnedActor );
	m_pScene->AddActor( m_pStaticActor );


	// Setup the skinned actors' bind poses and start their animations.

	m_pDisplacedActor->SetBindPose();
	m_pDisplacedActor->SetSkinningMatrices( *m_pRenderer11 );
	m_pDisplacedActor->PlayAllAnimations();

	m_pSkinnedActor->SetBindPose();
	m_pSkinnedActor->SetSkinningMatrices( *m_pRenderer11 );
	m_pSkinnedActor->PlayAllAnimations();

	m_pStaticActor->GetBody()->Transform.Position() = Vector3f( -20.0f, 10.0f, 15.0f );
	m_pSkinnedActor->GetNode()->Transform.Position() = Vector3f( 0.0f, 0.0f, 20.0f );
	m_pDisplacedActor->GetNode()->Transform.Position() = Vector3f( 20.0f, 0.0f, 20.0f );
}
开发者ID:CaptainJH,项目名称:hieroglyph3-90072,代码行数:86,代码来源:App.cpp


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