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


C++ Appearance::SetTextureRV方法代码示例

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


在下文中一共展示了Appearance::SetTextureRV方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Initialise

HRESULT Application::Initialise(HINSTANCE hInstance, int nCmdShow)
{
    if (FAILED(InitWindow(hInstance, nCmdShow)))
	{
        return E_FAIL;
	}

    RECT rc;
    GetClientRect(_hWnd, &rc);
    _WindowWidth = rc.right - rc.left;
    _WindowHeight = rc.bottom - rc.top;

    if (FAILED(InitDevice()))
    {
        Cleanup();

        return E_FAIL;
    }

	CreateDDSTextureFromFile(_pd3dDevice, L"Resources\\stone.dds", nullptr, &_pTextureRV);
	CreateDDSTextureFromFile(_pd3dDevice, L"Resources\\floor.dds", nullptr, &_pGroundTextureRV);

	objMeshData = OBJLoader::Load("sphere.obj", _pd3dDevice);

    // Setup Camera
	XMFLOAT3 eye = XMFLOAT3(0.0f, 2.0f, -1.0f);
	XMFLOAT3 at = XMFLOAT3(0.0f, 2.0f, 0.0f);
	XMFLOAT3 up = XMFLOAT3(0.0f, 1.0f, 0.0f);

	_camera = new Camera(eye, at, up, (float)_renderWidth, (float)_renderHeight, 0.01f, 200.0f);

	// Setup the scene's light
	basicLight.AmbientLight = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
	basicLight.DiffuseLight = XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f);
	basicLight.SpecularLight = XMFLOAT4(0.8f, 0.8f, 0.8f, 1.0f);
	basicLight.SpecularPower = 20.0f;
	basicLight.LightVecW = XMFLOAT3(0.0f, 1.0f, -1.0f);

	Geometry cubeGeometry;
	cubeGeometry.indexBuffer = _pIndexBuffer;
	cubeGeometry.vertexBuffer = _pVertexBuffer;
	cubeGeometry.numberOfIndices = 36;
	cubeGeometry.vertexBufferOffset = 0;
	cubeGeometry.vertexBufferStride = sizeof(SimpleVertex);

	Geometry planeGeometry;
	planeGeometry.indexBuffer = _pPlaneIndexBuffer;
	planeGeometry.vertexBuffer = _pPlaneVertexBuffer;
	planeGeometry.numberOfIndices = 6;
	planeGeometry.vertexBufferOffset = 0;
	planeGeometry.vertexBufferStride = sizeof(SimpleVertex);

	Geometry sphereGeometry;
	sphereGeometry.indexBuffer = objMeshData.IndexBuffer;
	sphereGeometry.vertexBuffer = objMeshData.VertexBuffer;
	sphereGeometry.numberOfIndices = objMeshData.IndexCount;
	sphereGeometry.vertexBufferOffset = objMeshData.VBOffset;
	sphereGeometry.vertexBufferStride = objMeshData.VBStride;

	Material shinyMaterial;
	shinyMaterial.ambient = XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f);
	shinyMaterial.diffuse = XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f);
	shinyMaterial.specular = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
	shinyMaterial.specularPower = 10.0f;

	Material noSpecMaterial;
	noSpecMaterial.ambient = XMFLOAT4(0.1f, 0.1f, 0.1f, 1.0f);
	noSpecMaterial.diffuse = XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f);
	noSpecMaterial.specular = XMFLOAT4(0.0f, 0.0f, 0.0f, 0.0f);
	noSpecMaterial.specularPower = 0.0f;

	Appearance * floorAppearance = new Appearance(planeGeometry, noSpecMaterial);
	floorAppearance->SetTextureRV(_pGroundTextureRV);

	Appearance * crateAppearance = new Appearance(cubeGeometry, shinyMaterial);
	crateAppearance->SetTextureRV(_pTextureRV);

	Appearance * sphereAppearance = new Appearance(sphereGeometry, shinyMaterial);
	sphereAppearance->SetTextureRV(_pTextureRV);
	
	Transform * floorTransform = new Transform();
	floorTransform->SetPosition(0.0f, 0.0f, 0.0f);
	floorTransform->SetScale(15.0f, 15.0f, 15.0f);
	floorTransform->SetRotation(XMConvertToRadians(90.0f), 0.0f, 0.0f);

	Transform * sphereTransform = new Transform();
	sphereTransform->SetPosition(0.0f, 1.0f, 0.0f);

	ParticleModel * particleModel = new ParticleModel(floorTransform, false, XMFLOAT3(0.0f, 0.0f, 0.0f), XMFLOAT3(0.0f, 0.0f, 0.0f));

	GameObject * gameObject = new GameObject("Floor", floorAppearance, floorTransform, particleModel);

	_gameObjects.push_back(gameObject);

	for (auto i = 0; i < 5; i++)
	{
		Transform * cubeTransform = new Transform();
		cubeTransform->SetScale(0.5f, 0.5f, 0.5f);
		cubeTransform->SetPosition(-4.0f + (i * 2.0f), 0.5f, 10.0f);

//.........这里部分代码省略.........
开发者ID:ashpemb,项目名称:Physics,代码行数:101,代码来源:Application.cpp


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