예제 #1
0
//===============================================================================================================================
void RoomEnvironment::Render()
{
	if( Quickwire() )
	{
		mRoom->SetWireframe(true);
		ToggleSpawnedMeshItemsWireframe(true);
		ToggleLightMeshWireframe(true);
		
		m_D3DSystem->TurnOnWireframe();
	}
	else
	{
		if (!bWireframeMode)
		{
			m_D3DSystem->TurnOffCulling();
		}
	}
	
	ZShadeSandboxMesh::MeshRenderParameters mrp;
	mrp.camera = m_CameraSystem;
	mrp.light = mDirLight1;
	
	mRoom->Render(mrp);
	
	RenderSpawnedMeshItems(mrp);
	RenderLightMesh(mrp);
}
예제 #2
0
//===============================================================================================================================
void ModelEnvironment::RenderDeferred()
{
	if (!bWireframeMode)
	{
		mPlane->SetWireframe(true);
		
		ToggleSpawnedMeshItemsWireframe(true);
		
		mPickingSphere->SetWireframe(true);
		
		mSpaceCompound->SetWireframe(true);
		mHuman->SetWireframe(true);
		
		ToggleLightMeshWireframe(true);
		
		m_D3DSystem->TurnOnCulling();
	}

	ZShadeSandboxMesh::MeshRenderParameters mrp;
	mrp.camera = m_CameraSystem;
	mrp.renderDeferred = true;
	mrp.light = mDirLight1;
	
	mPlane->Render(mrp);

	RenderSpawnedMeshItems(mrp);

	mPickingSphere->Render(mrp);
	
	mSpaceCompound->Render(mrp);
	mHuman->Render(mrp);

	RenderLightMesh(mrp);
}
예제 #3
0
//===============================================================================================================================
void ModelEnvironment::RenderShadowMap()
{
	mDirLight1->Update();
	
	ZShadeSandboxMesh::MeshRenderParameters mrp;
	mrp.camera = m_CameraSystem;
	mrp.light = mDirLight1;
	mrp.shadowMap = true;
	
	mPlane->Render(mrp);
	
	RenderSpawnedMeshItems(mrp);
	
	mPickingSphere->Render(mrp);
	
	RenderLightMesh(mrp);
}
예제 #4
0
//===============================================================================================================================
void TerrainEnvironment::Render()
{
	//RenderTerrainShadowSSAO();

	//We now get the position of the camera and then get the height of the triangle that would
	//be directly underneath it. Once we get the height back we set the height of the camera two
	//units directly above the triangle's height. This way when the camera moves it automatically
	//follows the exact height of the terrain.
	if (bClipCameraToTerrain)
	{
		float height = 0.0f;
		XMFLOAT3 eye = m_CameraSystem->Position();

		// Apply simple gravity
		//m_CameraSystem->SetPositionY(eye.y - 1.0f);

		// Get the height of the triangle that is directly underneath the given camera position.
		if (m_pQuadTreeMesh->GetHeightAtPosition(eye, height))
		{
			// If there was a triangle under the camera then position the camera just above it by two units.
			m_CameraSystem->SetPositionY(height + 4.0f);
		}
	}

	// Mouse Picking Terrain Collision Test
	mPickingRay = m_CameraSystem->PickingRay(mLastMousePos.x, mLastMousePos.y, m_pQuadTreeRenderer->GetWorld());

	if (mPickingRay != NULL)
	{
		//if (bLeftMouseDown)
		{
			//bLeftMouseDown = false;
			bool hit = false;
			XMFLOAT3 hitPoint;
			ZShadeSandboxMath::Ray ray = *mPickingRay;
			m_pQuadTreeMesh->Intersects(ray, hit, hitPoint);
			if (hit)
			{
				// Create a sphere at the point of intersection
				mPickingSphere->Position() = hitPoint;
			}
		}
	}

	if (!bWireframeMode)
		m_D3DSystem->TurnOnCulling();

	//Quick wireframe mode
	if (Quickwire())
	{
		m_pQuadTreeRenderer->SetWireframe(true);

		vector<ZShadeSandboxMesh::CustomMesh*>::iterator it = m_SpawnedMeshContainer.begin();
		for (; it != m_SpawnedMeshContainer.end(); it++)
		{
			(*it)->SetWireframe(true);
		}

		mSky->SetWireframe(true);

		m_D3DSystem->TurnOnWireframe();
	}

	ZShadeSandboxMesh::MeshRenderParameters mrp;
	mrp.camera = m_CameraSystem;
	mrp.light = mDirLight1;

	vector<ZShadeSandboxMesh::CustomMesh*>::iterator it = m_SpawnedMeshContainer.begin();
	for (; it != m_SpawnedMeshContainer.end(); it++)
	{
		if ((*it)->MeshType() == ZShadeSandboxMesh::EMeshType::CYLINDER)
		{
			if (!bWireframeMode && !Quickwire())
				m_D3DSystem->TurnOffCulling();
		}

		(*it)->Render(mrp);

		if ((*it)->MeshType() == ZShadeSandboxMesh::EMeshType::CYLINDER)
		{
			if (!bWireframeMode && !Quickwire())
				m_D3DSystem->TurnOnCulling();
		}
	}

	mrp.tessellate = false;
	mrp.renderType = ZShadeSandboxMesh::ERenderType::eTriangleList;

	//
	//Render the terrain
	//

	float    fMinTessellation = 0.0f;
	float    fMaxTessellation = 64.0f;

	XMFLOAT4 fogColor;
	XMStoreFloat4(&fogColor, DXColors::Silver);

	ZShadeSandboxTerrain::TerrainShadingConst tsc;
	tsc.g_EyePosW = m_CameraSystem->Position();
	tsc.g_fogThinning = 1000;
	tsc.g_fogAltitude = 10;
	tsc.g_fogNear = 5.0f;
	tsc.g_fogFar = 1000.0f;
	tsc.g_fogColor = fogColor;
	tsc.g_TextureAmount = 1; // Amount of Layer textures (Not needed)
	tsc.g_seaLevel = fSeaLevel;
	tsc.g_waterBodyColor = XMFLOAT4(0.07f, 0.15f, 0.2f, 0.0f);
	tsc.g_useClippingPlane = 0;
	tsc.g_UseSobelFilter = 0;
	tsc.g_useNormalMap = (bToggleTerrainNormalMap == true) ? 1 : 0;
	tsc.g_useShadowMap = (bToggleTerrainShadow == true) ? 1 : 0;
	tsc.g_useSSAO = (bToggleTerrainSSAO == true) ? 1 : 0;
	tsc.g_MinDist = fMinDist;
	tsc.g_MaxDist = fMaxDist;
	tsc.g_MinTess = fMinTessellation;
	tsc.g_MaxTess = fMaxTessellation;
	tsc.g_FrustumCull = 0;
	tsc.g_HeightScale = fHeightScale;// gHeightScale;
	tsc.g_TerrSize = fTerrSize;// gTerrSize;
	tsc.g_TextureWidth = fMapSize;
	tsc.g_TextureHeight = fMapSize;
	tsc.g_TexelCellSpaceU = (1 / fMapSize);
	tsc.g_TexelCellSpaceV = (1 / fMapSize);
	tsc.g_ClipPlane = XMFLOAT4(0, 0, 0, 0);
	tsc.g_FarPlane = mEngineOptions->fFarPlane;
	tsc.g_MapSize = fMapSize;
	tsc.g_DetailBrightness = 1.8f;
	tsc.g_useReflection = false;

	m_pQuadTreeMesh->HeightScale() = fHeightScale;
	m_pQuadTreeMesh->TerrainZScale() = fTerrSize;

	m_pQuadTreeRenderer->Render(m_CameraSystem, mDirLight1, tsc);

	//
	// Render the picking sphere
	//

	if (mPickingSphere != NULL)
	{
		mPickingSphere->Render(mrp);
	}

	//
	// Render the sphere mesh for the lights in the scene
	//

	RenderLightMesh(mrp);
}
예제 #5
0
//===============================================================================================================================
void ModelEnvironment::Render()
{
	// Mouse Picking
	XMMATRIX world = XMMatrixIdentity();
	mPickingRay = m_CameraSystem->PickingRay(mLastMousePos.x, mLastMousePos.y, world);
	if (mPickingRay != NULL)
	{
		if (bLeftMouseDown)
		{
			bLeftMouseDown = false;
			bool hit = false;
			XMFLOAT3 hitPoint;
			ZShadeSandboxMath::Ray ray = *mPickingRay;
			// Picking Test goes here
			if (hit)
			{
				// Place the sphere at the point of intersection
				mPickingSphere->Position() = hitPoint;
			}
		}
	}
	
	if (!bWireframeMode)
	{
		m_D3DSystem->TurnOnCulling();
	}
	
	//Quick wire mode to view the objects underlying triangles quickly
	if( Quickwire() )
	{
		mPlane->SetWireframe(true);
		
		ToggleSpawnedMeshItemsWireframe(true);
		
		mPickingSphere->SetWireframe(true);
		
		mSpaceCompound->SetWireframe(true);
		mHuman->SetWireframe(true);
		
		ToggleLightMeshWireframe(true);
		
		m_D3DSystem->TurnOnWireframe();
	}
	
	ZShadeSandboxMesh::MeshRenderParameters mrp;
	mrp.camera = m_CameraSystem;
	mrp.light = mDirLight1;
	
	RenderSpawnedMeshItems(mrp);

	mrp.useInstancing = false;
	
	// Render the plane in tessellation mode
	//m_D3DSystem->TurnOnWireframe();
	//mPlane->SetWireframe(true);
	//mrp.fTessellationFactor = m_TessFactor;
	//mrp.bTessellate = true;
	//mrp.renderType = ZShadeSandboxMesh::ERenderType::e3ControlPointPatchList;
	mPlane->EnableShadowMap(bEnableShadows);
	mPlane->SetShadowMapSRV(mShadowTexture->SRView);
	mPlane->SetSSAOMapSRV(0);
	mPlane->Render(mrp);
	
	// Uncomment if using the picking sphere
	//mrp.bTessellate = false;
	//mrp.rt = RenderType::eTriangleList;
	//mPickingSphere->EnableShadowMap(bEnableShadows);
	//mPickingSphere->SetShadowMapSRV(mShadowTexture->SRView);
	//mPickingSphere->SetSSAOMapSRV(0);
	mPickingSphere->Render(mrp);
	
	//ZShadeSandboxMesh::OBJMeshRenderParameters omrp;
	//omrp.camera = m_CameraSystem.get();
	//omrp.renderType = ZShadeSandboxMesh::ERenderType::eTriangleList;
	//omrp.renderType = ZShadeSandboxMesh::ERenderType::e3ControlPointPatchList;
	//omrp.maxTess = 64.0f;
	//omrp.minTess = 0.0f;
	//omrp.maxTessDist = 500.0f;
	//omrp.minTessDist = 20.0f;
	//omrp.tessellate = true;
	mSpaceCompound->Render(mrp);
	mHuman->Render(mrp);
	
	RenderLightMesh(mrp);
	
	m_D3DSystem->TurnOffCulling();
}