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


C++ Object3D::GetVertBuff方法代码示例

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


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

示例1: RenderCascadedShadowMap

void DxManager::RenderCascadedShadowMap()
{
	if(this->useSun)
	{
		D3DXMATRIX wvp;
		D3DXMatrixIdentity(&wvp);

		for (int l = 0; l < this->csm->GetNrOfCascadeLevels(); l++)
		{
			this->Dx_DeviceContext->OMSetRenderTargets(0, 0, this->csm->GetShadowMapDSV(l));
			D3D11_VIEWPORT wp = this->csm->GetShadowMapViewPort(l);
			this->Dx_DeviceContext->RSSetViewports(1, &wp);
			this->Dx_DeviceContext->ClearDepthStencilView(this->csm->GetShadowMapDSV(l), D3D11_CLEAR_DEPTH, 1.0f, 0);
		
			//Terrain
			for(int i = 0; i < this->terrains.size(); i++)
			{
				//Matrices
				wvp = this->terrains[i]->GetWorldMatrix() * this->csm->GetViewProjMatrix(l);
				this->Shader_ShadowMap->SetMatrix("LightWVP", wvp);
			
				//Input Assembler
				this->Dx_DeviceContext->IASetPrimitiveTopology(this->terrains[i]->GetTopology());

				//Vertex data
				Buffer* verts = this->terrains[i]->GetVertexBufferPointer();
				Buffer* inds = this->terrains[i]->GetIndexBufferPointer();
				if(verts)
				{
					inds->Apply();
				}
				if(inds)
				{
					verts->Apply();
				}

				//Apply Shader
				this->Shader_ShadowMap->Apply(0);

				//Draw
				if(inds)
				{
					this->Dx_DeviceContext->DrawIndexed(inds->GetElementCount(), 0, 0);
				}
				else
				{
					this->Dx_DeviceContext->Draw(verts->GetElementCount(), 0);
				}
			}

			//Static meshes
			for(int i = 0; i < this->objects.size(); i++)
			{
				if(!this->objects[i]->IsUsingInvisibility())
				{
					MaloW::Array<MeshStrip*>* strips = this->objects[i]->GetStrips();
					wvp = this->objects[i]->GetWorldMatrix() * this->csm->GetViewProjMatrix(l);
					this->Shader_ShadowMap->SetMatrix("LightWVP", wvp);

					for(int u = 0; u < strips->size(); u++)
					{
						Object3D* obj = strips->get(u)->GetRenderObject();
						Dx_DeviceContext->IASetPrimitiveTopology(obj->GetTopology());
						Buffer* verts = obj->GetVertBuff();
						if(verts)
							verts->Apply();

						Buffer* inds = obj->GetIndsBuff();
						if(inds)
							inds->Apply();

						Shader_ShadowMap->Apply(0);


						// draw
						if(inds)
							Dx_DeviceContext->DrawIndexed(inds->GetElementCount(), 0, 0);
						else
							Dx_DeviceContext->Draw(verts->GetElementCount(), 0);
					}
				}
			}
		
			D3DXMATRIX lvp = this->csm->GetViewProjMatrix(l);

			// For deferred:
			this->Shader_DeferredLightning->SetResourceAtIndex(l, "CascadedShadowMap", this->csm->GetShadowMapSRV(l));
			this->Shader_DeferredLightning->SetStructMemberAtIndexAsMatrix(l, "cascades", "viewProj", lvp);
		}
	

		float PCF_SIZE = (float)this->params.ShadowMapSettings + 1;
		float PCF_SQUARED = 1 / (PCF_SIZE * PCF_SIZE);

		this->Shader_DeferredLightning->SetFloat("SMAP_DX", 1.0f / (256.0f * pow(2.0f, this->params.ShadowMapSettings / 2.0f)));
		this->Shader_DeferredLightning->SetFloat("PCF_SIZE", PCF_SIZE);
		this->Shader_DeferredLightning->SetFloat("PCF_SIZE_SQUARED", PCF_SQUARED);
		this->Shader_DeferredLightning->SetFloat("NrOfCascades", (float)this->csm->GetNrOfCascadeLevels());

		this->Shader_DeferredLightning->SetFloat4("CascadeLevels", D3DXVECTOR4(this->csm->GetSplitDepth(0),
//.........这里部分代码省略.........
开发者ID:Edaenge,项目名称:NDYGFX,代码行数:101,代码来源:DxManagerRender.cpp

示例2: RenderShadowMap

void DxManager::RenderShadowMap()
{
	// Set sun-settings
	this->Shader_DeferredLightning->SetBool("UseSun", this->useSun);
	if(this->useSun)
	{
		this->Shader_DeferredLightning->SetStructMemberAsFloat4("sun", "Direction", D3DXVECTOR4(this->sun.direction, 0.0f));
		this->Shader_DeferredLightning->SetStructMemberAsFloat4("sun", "LightColor", D3DXVECTOR4(this->sun.lightColor, 0.0f));
		this->Shader_DeferredLightning->SetStructMemberAsFloat("sun", "LightIntensity", this->sun.intensity);
		//Shader_ShadowMap->Apply(0);		// Dont know why the fuck this has to be here, but it does, otherwise textures wont be sent when rendering objects. **Texture error**
	}
	// If special circle is used
	if(this->specialCircleParams.x) //if inner radius > 0, then send/set data
	{
		this->Shader_DeferredLightning->SetFloat4("dataPPHA", this->specialCircleParams);
	}

	// Generate and send shadowmaps to the main-shader
	if(!this->lights.size())
	{
		for (int l = 0; l < this->lights.size(); l++)
		{
			Dx_DeviceContext->OMSetRenderTargets(0, 0, this->lights[l]->GetShadowMapDSV());
			D3D11_VIEWPORT wp = this->lights[l]->GetShadowMapViewPort();
			Dx_DeviceContext->RSSetViewports(1, &wp);
			Dx_DeviceContext->ClearDepthStencilView(this->lights[l]->GetShadowMapDSV(), D3D11_CLEAR_DEPTH, 1.0f, 0);

			//Static meshes
			for(int i = 0; i < this->objects.size(); i++)
			{
				if(!this->objects[i]->IsUsingInvisibility())
				{
					MaloW::Array<MeshStrip*>* strips = this->objects[i]->GetStrips();
					D3DXMATRIX wvp = this->objects[i]->GetWorldMatrix() * this->lights[l]->GetViewProjMatrix();
					this->Shader_ShadowMap->SetMatrix("LightWVP", wvp);
				
					for(int u = 0; u < strips->size(); u++)
					{
						Object3D* obj = strips->get(u)->GetRenderObject();
						Dx_DeviceContext->IASetPrimitiveTopology(obj->GetTopology());
						Buffer* verts = obj->GetVertBuff();
						if(verts)
							verts->Apply();
						Shader_ShadowMap->SetBool("textured", false);

						Buffer* inds = obj->GetIndsBuff();
						if(inds)
							inds->Apply();

						Shader_ShadowMap->Apply(0);

					
						//Draw
						if(inds)
							Dx_DeviceContext->DrawIndexed(inds->GetElementCount(), 0, 0);
						else
							Dx_DeviceContext->Draw(verts->GetElementCount(), 0);
					}
				}
			}
		
			//Animated meshes
			for(int i = 0; i < this->animations.size(); i++)
			{
				if(!this->animations[i]->IsUsingInvisibility())
				{
					KeyFrame* one = NULL;
					KeyFrame* two = NULL;
					float t = 0.0f;
					this->animations[i]->SetCurrentTime(this->Timer);
					this->animations[i]->GetCurrentKeyFrames(&one, &two, t);
					MaloW::Array<MeshStrip*>* stripsOne = one->strips;
					MaloW::Array<MeshStrip*>* stripsTwo = two->strips;

					//set shader data (per object)
					D3DXMATRIX wvp = this->animations[i]->GetWorldMatrix() * this->lights[l]->GetViewProjMatrix();
					this->Shader_ShadowMapAnimated->SetMatrix("LightWVP", wvp);
					this->Shader_ShadowMapAnimated->SetFloat("t", t);

					for(int u = 0; u < stripsOne->size(); u++) 
					{
						Object3D* objOne = stripsOne->get(u)->GetRenderObject();
						Object3D* objTwo = stripsTwo->get(u)->GetRenderObject();

						this->Dx_DeviceContext->IASetPrimitiveTopology(objOne->GetTopology()); 

						Buffer* vertsOne = objOne->GetVertBuff();
						Buffer* vertsTwo = objTwo->GetVertBuff();

						ID3D11Buffer* vertexBuffers [] = {vertsOne->GetBufferPointer(), vertsTwo->GetBufferPointer()};
						UINT strides [] = {sizeof(Vertex), sizeof(Vertex)};
						UINT offsets [] = {0, 0};

						this->Dx_DeviceContext->IASetVertexBuffers(0, 2, vertexBuffers, strides, offsets);

						Shader_ShadowMapAnimated->Apply(0);
						this->Dx_DeviceContext->Draw(vertsOne->GetElementCount(), 0);
					}
				}
			}
//.........这里部分代码省略.........
开发者ID:Edaenge,项目名称:NDYGFX,代码行数:101,代码来源:DxManagerRender.cpp


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