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


C++ D3DXMatrixTranspose函数代码示例

本文整理汇总了C++中D3DXMatrixTranspose函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DXMatrixTranspose函数的具体用法?C++ D3DXMatrixTranspose怎么用?C++ D3DXMatrixTranspose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: D3DXMatrixTranspose

		bool ShadowMappingShader::SetShaderParameters(D3DXMATRIX worldMatrix, D3DXMATRIX viewMatrix,
			D3DXMATRIX projectionMatrix, D3DXMATRIX lightViewMatrix, D3DXMATRIX lightProjectionMatrix,
			ID3D11ShaderResourceView* texture, ID3D11ShaderResourceView* depthMapTexture, D3DXVECTOR3 lightPosition,
			D3DXVECTOR4 ambientColor, D3DXVECTOR4 diffuseColor)
		{
			HRESULT result;
			D3D11_MAPPED_SUBRESOURCE mappedResource;
			unsigned int bufferNumber;
			MatrixBufferType* dataPtr;
			LightBufferType* dataPtr2;
			LightBufferType2* dataPtr3;


			// Transpose the matrices to prepare them for the shader.
			D3DXMatrixTranspose(&worldMatrix, &worldMatrix);
			D3DXMatrixTranspose(&viewMatrix, &viewMatrix);
			D3DXMatrixTranspose(&projectionMatrix, &projectionMatrix);

			D3DXMatrixTranspose(&lightViewMatrix, &lightViewMatrix);
			D3DXMatrixTranspose(&lightProjectionMatrix, &lightProjectionMatrix);

			ID3D11DeviceContext* deviceContext = GraphicsDX::GetDeviceContext();

			// Lock the constant buffer so it can be written to.
			result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
			if (FAILED(result))
			{
				return false;
			}

			// Get a pointer to the data in the constant buffer.
			dataPtr = (MatrixBufferType*)mappedResource.pData;

			// Copy the matrices into the constant buffer.
			dataPtr->world = worldMatrix;
			dataPtr->view = viewMatrix;
			dataPtr->projection = projectionMatrix;

			dataPtr->lightView = lightViewMatrix;
			dataPtr->lightProjection = lightProjectionMatrix;

			// Unlock the constant buffer.
			deviceContext->Unmap(m_matrixBuffer, 0);

			// Set the position of the constant buffer in the vertex shader.
			bufferNumber = 0;

			// Now set the constant buffer in the vertex shader with the updated values.
			deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);

			// Set shader texture resource in the pixel shader.
			deviceContext->PSSetShaderResources(0, 1, &texture);

			deviceContext->PSSetShaderResources(1, 1, &depthMapTexture);

			// Lock the light constant buffer so it can be written to.
			result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
			if (FAILED(result))
			{
				return false;
			}

			// Get a pointer to the data in the constant buffer.
			dataPtr2 = (LightBufferType*)mappedResource.pData;

			// Copy the lighting variables into the constant buffer.
			dataPtr2->ambientColor = ambientColor;
			dataPtr2->diffuseColor = diffuseColor;

			// Unlock the constant buffer.
			deviceContext->Unmap(m_lightBuffer, 0);

			// Set the position of the light constant buffer in the pixel shader.
			bufferNumber = 0;

			// Finally set the light constant buffer in the pixel shader with the updated values.
			deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);

			// Lock the second light constant buffer so it can be written to.
			result = deviceContext->Map(m_lightBuffer2, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
			if (FAILED(result))
			{
				return false;
			}

			// Get a pointer to the data in the constant buffer.
			dataPtr3 = (LightBufferType2*)mappedResource.pData;

			// Copy the lighting variables into the constant buffer.
			dataPtr3->lightPosition = lightPosition;
			dataPtr3->padding = 0.0f;

			// Unlock the constant buffer.
			deviceContext->Unmap(m_lightBuffer2, 0);

			// Set the position of the light constant buffer in the vertex shader.
			bufferNumber = 1;

			// Finally set the light constant buffer in the pixel shader with the updated values.
			deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer2);
//.........这里部分代码省略.........
开发者ID:singingsingh,项目名称:Indra,代码行数:101,代码来源:ShadowMappingShader.cpp

示例2: vecLightDirUnnormalized

void CLcXSkinIns::Render()
{
	HRESULT hr=-1;

	LPDIRECT3DDEVICE9 pDev = (LPDIRECT3DDEVICE9)LcDev_GetD3Device();


	CLcXSkinSrc*	pOrg = (CLcXSkinSrc*)m_pOrg;

	ID3DXEffect*	pEft	= pOrg->GetEffect();

	// Setup the projection matrix
	D3DXMATRIX matProj;
	pDev->GetTransform(D3DTS_PROJECTION, &matProj);




	D3DLIGHT9 light;
	D3DXVECTOR3 vecLightDirUnnormalized(0.0f, -1.0f, 1.0f);
	ZeroMemory( &light, sizeof(D3DLIGHT9) );
	light.Type        = D3DLIGHT_DIRECTIONAL;
	light.Diffuse.r   = 1.0f;
	light.Diffuse.g   = 1.0f;
	light.Diffuse.b   = 1.0f;
	D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecLightDirUnnormalized );
	light.Position.x   = 0.0f;
	light.Position.y   = -1.0f;
	light.Position.z   = 1.0f;
	light.Range        = 1000.0f;

	pDev->SetLight(0, &light );
	pDev->LightEnable(0, TRUE );
	
	
	// Set Light for vertex shader
	D3DXVECTOR4 vLightDir( 0.0f, 1.0f, -1.0f, 0.0f );
	D3DXVec4Normalize( &vLightDir, &vLightDir );
	
	
	// for HLSL
	{
		pEft->SetMatrix( "mViewProj", &matProj);
		pEft->SetVector( "lhtDir", &vLightDir);
	}
	
	
	
	// for shader
	{
		// set the projection matrix for the vertex shader based skinning method
		D3DXMatrixTranspose(&matProj, &matProj);
		pDev->SetVertexShaderConstantF(2, (float*)&matProj, 4);
		pDev->SetVertexShaderConstantF(1, (float*)&vLightDir, 1);
	}

	if(m_pAC)
		m_pAC->AdvanceTime(m_fElapse, NULL);

	pOrg->UpdateFrameMatrices(m_pFrameOrg, &m_mtWld);	
	pOrg->DrawFrame(m_pFrameOrg);

	static	D3DXMATRIX	mtI(1,0,0,0,  0,1,0,0,  0,0,1,0,  0,0,0,1);
	pDev->SetTransform(D3DTS_WORLD, &mtI);
}
开发者ID:GALICSOFT,项目名称:glc220_src,代码行数:65,代码来源:LnXSkinIns.cpp

示例3: D3DXMatrixTranspose

bool TerrainShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, D3DXMATRIX worldMatrix, D3DXMATRIX viewMatrix, 
											 D3DXMATRIX projectionMatrix, D3DXVECTOR4 ambientColor, D3DXVECTOR4 diffuseColor, D3DXVECTOR3 lightDirection)
{
	HRESULT result;
    D3D11_MAPPED_SUBRESOURCE mappedResource;
	unsigned int bufferNumber;
	MatrixBufferType* dataPtr;
	LightBufferType* dataPtr2;


	// Transpose the matrices to prepare them for the shader.
	D3DXMatrixTranspose(&worldMatrix, &worldMatrix);
	D3DXMatrixTranspose(&viewMatrix, &viewMatrix);
	D3DXMatrixTranspose(&projectionMatrix, &projectionMatrix);

	// Lock the constant buffer so it can be written to.
	result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr = (MatrixBufferType*)mappedResource.pData;

	// Copy the matrices into the constant buffer.
	dataPtr->world = worldMatrix;
	dataPtr->view = viewMatrix;
	dataPtr->projection = projectionMatrix;

	// Unlock the constant buffer.
    deviceContext->Unmap(m_matrixBuffer, 0);

	// Set the position of the constant buffer in the vertex shader.
	bufferNumber = 0;

	// Now set the constant buffer in the vertex shader with the updated values.
    deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);

	// Lock the light constant buffer so it can be written to.
	result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr2 = (LightBufferType*)mappedResource.pData;

	// Copy the lighting variables into the constant buffer.
	dataPtr2->ambientColor = ambientColor;
	dataPtr2->diffuseColor = diffuseColor;
	dataPtr2->lightDirection = lightDirection;
	dataPtr2->padding = 0.0f;

	// Unlock the constant buffer.
	deviceContext->Unmap(m_lightBuffer, 0);

	// Set the position of the light constant buffer in the pixel shader.
	bufferNumber = 0;

	// Finally set the light constant buffer in the pixel shader with the updated values.
	deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);

	return true;
}
开发者ID:richa-sachdeva,项目名称:CGTPortfolio,代码行数:66,代码来源:terrainshaderclass.cpp

示例4: transpose

Matrix Matrix::transpose(const Matrix& matrix)
{
	return *D3DXMatrixTranspose(&tmp, &matrix);
}
开发者ID:steinbergerbernd,项目名称:Lucky-Leprechauns,代码行数:4,代码来源:Matrix.cpp

示例5: D3DXMatrixTranspose

/** Draws the visual for the given vob */
void GSkeletalMeshVisual::DrawVisual(const RenderInfo& info)
{
	GVisual::DrawVisual(info);

	// Draw the mesh using immediate states
	int n=0;
	for(auto it = VisualInfo.SkeletalMeshes.begin();it != VisualInfo.SkeletalMeshes.end(); it++)
	{
		D3DXMATRIX world; D3DXMatrixTranspose(&world, info.WorldMatrix);

		std::vector<SkeletalMeshInfo*>& meshes = (*it).second;
		for(int i=0;i<meshes.size();i++)
		{
			if(ImmediatePipelineStates[n]->BaseState.TextureIDs[0] == 0xFFFF)
			{
				// Only draw if the texture is loaded
				if((*it).first->GetTexture() && (*it).first->GetTexture()->CacheIn(0.6f) != zRES_CACHED_IN)
				{
					n++;
					continue;
				}

				// Get texture ID if everything is allright
				if((*it).first &&
					(*it).first->GetTexture() &&
					(*it).first->GetTexture()->GetSurface() &&
					(*it).first->GetTexture()->GetSurface()->GetEngineTexture())
				{
					ImmediatePipelineStates[n]->BaseState.TextureIDs[0] = (*it).first->GetTexture()->GetSurface()->GetEngineTexture()->GetID();

					// Get Alphatest
					if((*it).first->GetAlphaFunc() > 1 || (*it).first->GetTexture()->HasAlphaChannel())
						ImmediatePipelineStates[n]->BaseState.TranspacenyMode = PipelineState::ETransparencyMode::TM_MASKED;

					Engine::GraphicsEngine->SetupPipelineForStage(STAGE_DRAW_SKELETAL, ImmediatePipelineStates[n]);
				}
			}

			// Clone the state for this mesh
			PipelineState* transientState = Engine::GraphicsEngine->CreatePipelineState(ImmediatePipelineStates[n]);
			transientState->TransientState = true;

			// Input instanceCB and our bones
			transientState->BaseState.ConstantBuffersVS[1] = info.InstanceCB;
			transientState->BaseState.ConstantBuffersVS[2] = BoneConstantBuffer;

			Engine::GraphicsEngine->FillPipelineStateObject(transientState);

			// Push to renderlist
			Engine::GraphicsEngine->PushPipelineState(transientState);

			n++;
		}
	}

	return;
#ifndef DEBUG_DRAW_VISUALS
	return;
#endif

	std::vector<D3DXMATRIX> trans = *BoneTransforms;
	for(int i=0;i<trans.size();i++)
		D3DXMatrixTranspose(&trans[i], &trans[i]);

	// Debug draw the mesh as line-wireframe
	for(auto it = VisualInfo.SkeletalMeshes.begin();it != VisualInfo.SkeletalMeshes.end(); it++)
	{
		D3DXMATRIX world; D3DXMatrixTranspose(&world, info.WorldMatrix);

		std::vector<SkeletalMeshInfo*>& meshes = (*it).second;
		for(int i=0;i<meshes.size();i++)
		{
			std::vector<VERTEX_INDEX>& indices = meshes[i]->Indices;
			std::vector<ExSkelVertexStruct>& vertices = meshes[i]->Vertices;

			for(int i=0;i<indices.size();i+=3)
			{
				D3DXVECTOR3 vx[3];
				for(int v=0;v<3;v++)
				{
					D3DXVECTOR3 position = D3DXVECTOR3(0,0,0);
					ExSkelVertexStruct& input = vertices[indices[i + v]];
					for(int i=0;i<4;i++)
					{
						D3DXVECTOR3 bp; D3DXVec3TransformCoord(&bp, input.Position[i].toD3DXVECTOR3(), &trans[input.boneIndices[i]]);

						position += input.weights[i] * bp;
					}

					D3DXVec3TransformCoord(&position, &position, &world);

					vx[v] = position;				
				}

				// Don't draw too far
				if(D3DXVec3Length(&(vx[0] - Engine::GAPI->GetCameraPosition())) > 2400)
					continue;

				Engine::GraphicsEngine->GetLineRenderer()->AddTriangle(vx[0], vx[1], vx[2], D3DXVECTOR4(1,0,0,1));
//.........这里部分代码省略.........
开发者ID:parav,项目名称:GD3D11,代码行数:101,代码来源:GSkeletalMeshVisual.cpp

示例6: HR

void RobotArmDemo::drawScene()
{
	// Clear the backbuffer and depth buffer.
	HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0));

	HR(gd3dDevice->BeginScene());

	HR(mFX->SetValue(mhLight, &mLight, sizeof(DirLight)));
	
	HR(mFX->SetTechnique(mhTech));
	UINT numPasses = 0;
	HR(mFX->Begin(&numPasses, 0));
	HR(mFX->BeginPass(0));

	// Build the world transforms for each bone, then render them.
	buildBoneWorldTransforms();
	D3DXMATRIX T;
	D3DXMatrixTranslation(&T, -NUM_BONES, 0.0f, 0.0f);
	for(int i = 0; i < NUM_BONES; ++i)
	{
		// Append the transformation with a slight translation to better
		// center the skeleton at the center of the scene.
		mWorld = mBones[i].toWorldXForm * T;
		HR(mFX->SetMatrix(mhWVP, &(mWorld*mView*mProj)));
		D3DXMATRIX worldInvTrans;
		D3DXMatrixInverse(&worldInvTrans, 0, &mWorld);
		D3DXMatrixTranspose(&worldInvTrans, &worldInvTrans);
		HR(mFX->SetMatrix(mhWorldInvTrans, &worldInvTrans));
		HR(mFX->SetMatrix(mhWorld, &mWorld));
		for(int j = 0; j < mMtrl.size(); ++j)
		{
			HR(mFX->SetValue(mhMtrl, &mMtrl[j], sizeof(Mtrl)));
		
			// If there is a texture, then use.
			if(mTex[j] != 0)
			{
				HR(mFX->SetTexture(mhTex, mTex[j]));
			}

			// But if not, then set a pure white texture.  When the texture color
			// is multiplied by the color from lighting, it is like multiplying by
			// 1 and won't change the color from lighting.
			else
			{
				HR(mFX->SetTexture(mhTex, mWhiteTex));
			}
		
			HR(mFX->CommitChanges());
			HR(mBoneMesh->DrawSubset(j));
		}
	}

	HR(mFX->EndPass());
	HR(mFX->End());
	
	mGfxStats->display();

	HR(gd3dDevice->EndScene());

	// Present the backbuffer.
	HR(gd3dDevice->Present(0, 0, 0, 0));
}
开发者ID:nguyenkim495,项目名称:KidBuu,代码行数:62,代码来源:RobotArmDemo.cpp

示例7: D3DXMatrixTranspose

bool SpecularMapShader::SetShaderParameters(ID3D11DeviceContext* deviceContext, D3DXMATRIX worldMatrix, 
					     D3DXMATRIX viewMatrix, D3DXMATRIX projectionMatrix, 
					     ID3D11ShaderResourceView** textureArray, D3DXVECTOR3 lightDirection, 
					     D3DXVECTOR4 diffuseColor, D3DXVECTOR3 cameraPosition, D3DXVECTOR4 specularColor,
					     float specularPower)
{
	HRESULT result;
	D3D11_MAPPED_SUBRESOURCE mappedResource;
	MatrixBufferType* dataPtr;
	unsigned int bufferNumber;
	LightBufferType* dataPtr2;
	CameraBufferType* dataPtr3;

	// Transpose the matrices to prepare them for the shader.
	D3DXMatrixTranspose(&worldMatrix, &worldMatrix);
	D3DXMatrixTranspose(&viewMatrix, &viewMatrix);
	D3DXMatrixTranspose(&projectionMatrix, &projectionMatrix);

	// Lock the matrix constant buffer so it can be written to.
	result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr = (MatrixBufferType*)mappedResource.pData;

	// Copy the matrices into the constant buffer.
	dataPtr->world = worldMatrix;
	dataPtr->view = viewMatrix;
	dataPtr->projection = projectionMatrix;

	// Unlock the matrix constant buffer.
	deviceContext->Unmap(m_matrixBuffer, 0);

	// Set the position of the matrix constant buffer in the vertex shader.
	bufferNumber = 0;

	// Now set the matrix constant buffer in the vertex shader with the updated values.
	deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);

	// Set shader texture array resource in the pixel shader.
	deviceContext->PSSetShaderResources(0, 3, textureArray);

	// Lock the light constant buffer so it can be written to.
	result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr2 = (LightBufferType*)mappedResource.pData;

	// Copy the lighting variables into the constant buffer.
	dataPtr2->diffuseColor = diffuseColor;
	dataPtr2->lightDirection = lightDirection;
	dataPtr2->specularColor = specularColor;
	dataPtr2->specularPower = specularPower;

	// Unlock the constant buffer.
	deviceContext->Unmap(m_lightBuffer, 0);

	// Set the position of the light constant buffer in the pixel shader.
	bufferNumber = 0;

	// Finally set the light constant buffer in the pixel shader with the updated values.
	deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);

	// Lock the camera constant buffer so it can be written to.
	result = deviceContext->Map(m_cameraBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr3 = (CameraBufferType*)mappedResource.pData;

	// Copy the camera position into the constant buffer.
	dataPtr3->cameraPosition = cameraPosition;

	// Unlock the matrix constant buffer.
	deviceContext->Unmap(m_cameraBuffer, 0);

	// Set the position of the camera constant buffer in the vertex shader as the second buffer.
	bufferNumber = 1;

	// Now set the matrix constant buffer in the vertex shader with the updated values.
	deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_cameraBuffer);

	return true;
}
开发者ID:AidanTemple,项目名称:Direct3D_11_Sample,代码行数:94,代码来源:SpecularMapShader.cpp

示例8: HR

void EngineMain::drawScene()
{
	// Clear the backbuffer and depth buffer.
	HR(g_d3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0));
	
	HR(g_d3dDevice->BeginScene());

	D3DXMATRIX wVPM = camera.GetView()*camera.GetProjection();



	// Setup the rendering FX
	Shaders::BasicFX->SetDirectionalLight(&m_DirLight);
	Shaders::BasicFX->m_FX->SetTechnique(Shaders::BasicFX->m_hTech);
	// Begin passes.
	UINT numPasses = 0;


	Shaders::BasicFX->m_FX->Begin(&numPasses, 0);
	Shaders::BasicFX->m_FX->BeginPass(0);
	skull->DrawModel(wVPM);
	dwarf->DrawModel(wVPM);
	tiny->DrawModel(wVPM);

	Shaders::BasicFX->m_FX->EndPass();
	Shaders::BasicFX->m_FX->End();

	// Animation Passes //
	Shaders::VBlendFX->SetDirectionalLight(&m_DirLight);
	//HR(Shaders::VBlendFX->m_FX->SetValue(Shaders::VBlendFX->m_hLight, &m_DirLight, sizeof(DirectionalLight))); 
	Shaders::VBlendFX->m_FX->SetTechnique(Shaders::VBlendFX->m_hTech);
	numPasses = 0;
	Shaders::VBlendFX->m_FX->Begin(&numPasses, 0);
	Shaders::VBlendFX->m_FX->BeginPass(0);


	//tiny->draw(wVPM);

	Shaders::VBlendFX->m_FX->EndPass();
	Shaders::VBlendFX->m_FX->End();
	// End //

	#pragma region Draw Grid
	HR(mFX->SetTechnique(mhTech));

	HR(mFX->SetMatrix(mhWVP, &wVPM));
	D3DXMATRIX worldInvTrans;
	D3DXMatrixInverse(&worldInvTrans, 0, &m_World);
	D3DXMatrixTranspose(&worldInvTrans, &worldInvTrans);
	HR(mFX->SetMatrix(mhWorldInvTrans, &worldInvTrans));
	HR(mFX->SetValue(mhLightVecW, &mLightVecW, sizeof(D3DXVECTOR3)));
	HR(mFX->SetValue(mhDiffuseMtrl, &mDiffuseMtrl, sizeof(D3DXCOLOR)));
	HR(mFX->SetValue(mhDiffuseLight, &mDiffuseLight, sizeof(D3DXCOLOR)));
	HR(mFX->SetValue(mhAmbientMtrl, &mAmbientMtrl, sizeof(D3DXCOLOR)));
	HR(mFX->SetValue(mhAmbientLight, &mAmbientLight, sizeof(D3DXCOLOR)));
	HR(mFX->SetValue(mhSpecularLight, &mSpecularLight, sizeof(D3DXCOLOR)));
	HR(mFX->SetValue(mhSpecularMtrl, &mSpecularMtrl, sizeof(D3DXCOLOR)));
	HR(mFX->SetFloat(mhSpecularPower, mSpecularPower));
	HR(mFX->SetMatrix(mhWorld, &m_World));
	HR(mFX->SetTexture(mhTex, mGroundTex));

	HR(g_d3dDevice->SetVertexDeclaration(VertexPNT::Decl));
	HR(g_d3dDevice->SetStreamSource(0, mGridVB, 0, sizeof(VertexPNT)));
	HR(g_d3dDevice->SetIndices(mGridIB));

	// Begin passes.
	numPasses = 0;
	HR(mFX->Begin(&numPasses, 0));
	for(UINT i = 0; i < numPasses; ++i)
	{
		HR(mFX->BeginPass(i));
		HR(g_d3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, mNumGridVertices, 0, mNumGridTriangles));
		HR(mFX->EndPass());
	}
	HR(mFX->End());

#pragma endregion

	m_GfxStats->display();

	HR(g_d3dDevice->EndScene());

	// Present the backbuffer.
	HR(g_d3dDevice->Present(0, 0, 0, 0));
}
开发者ID:aSaul2006,项目名称:GameEngineProject,代码行数:85,代码来源:EngineMain.cpp

示例9: D3DXMatrixTranspose

void Matrix::setTranspose( const Matrix& mat ){
	D3DXMATRIX a;
	D3DXMatrixTranspose( &a, &D3DXMATRIX((float*)&mat.m ) );
	m.set( a );
}
开发者ID:KirisameMarisa,项目名称:Yoserusu,代码行数:5,代码来源:Matrix.cpp

示例10: D3DXMatrixTranspose

bool ReflectionShader::SetShaderParameters(ID3D11DeviceContext* deviceContext, D3DXMATRIX worldMatrix, D3DXMATRIX viewMatrix, 
						D3DXMATRIX projectionMatrix, ID3D11ShaderResourceView* colorTexture, 
						ID3D11ShaderResourceView* normalTexture, D3DXVECTOR4 lightDiffuseColor, D3DXVECTOR3 lightDirection, 
						float colorTextureBrightness, D3DXVECTOR4 clipPlane)
{
	HRESULT result;
	D3D11_MAPPED_SUBRESOURCE mappedResource;
	unsigned int bufferNumber;
	MatrixBufferType* dataPtr;
	ClipPlaneBufferType* dataPtr1;
	LightBufferType* dataPtr2;


	// Transpose the matrices to prepare them for the shader.
	D3DXMatrixTranspose(&worldMatrix, &worldMatrix);
	D3DXMatrixTranspose(&viewMatrix, &viewMatrix);
	D3DXMatrixTranspose(&projectionMatrix, &projectionMatrix);

	// Lock the constant buffer so it can be written to.
	result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr = (MatrixBufferType*)mappedResource.pData;

	// Copy the matrices into the constant buffer.
	dataPtr->world = worldMatrix;
	dataPtr->view = viewMatrix;
	dataPtr->projection = projectionMatrix;

	// Unlock the constant buffer.
	deviceContext->Unmap(m_matrixBuffer, 0);

	// Set the position of the constant buffer in the vertex shader.
	bufferNumber = 0;

	// Now set the constant buffer in the vertex shader with the updated values.
	deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
	
	// Lock the clip plane constant buffer so it can be written to.
	result = deviceContext->Map(m_clipPlaneBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the clip plane constant buffer.
	dataPtr1 = (ClipPlaneBufferType*)mappedResource.pData;

	// Copy the clip plane into the clip plane constant buffer.
	dataPtr1->clipPlane = clipPlane;

	// Unlock the buffer.
	deviceContext->Unmap(m_clipPlaneBuffer, 0);

	// Set the position of the clip plane constant buffer in the vertex shader.
	bufferNumber = 1;

	// Now set the clip plane constant buffer in the vertex shader with the updated values.
	deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_clipPlaneBuffer);
	
	// Lock the light constant buffer so it can be written to.
	result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr2 = (LightBufferType*)mappedResource.pData;

	// Copy the lighting variables into the constant buffer.
	dataPtr2->lightDiffuseColor = lightDiffuseColor;
	dataPtr2->lightDirection = lightDirection;
	dataPtr2->colorTextureBrightness = colorTextureBrightness;

	// Unlock the constant buffer.
	deviceContext->Unmap(m_lightBuffer, 0);

	// Set the position of the light constant buffer in the pixel shader.
	bufferNumber = 0;

	// Finally set the light constant buffer in the pixel shader with the updated values.
	deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);

	// Set the texture resources in the pixel shader.
	deviceContext->PSSetShaderResources(0, 1, &colorTexture);
	deviceContext->PSSetShaderResources(1, 1, &normalTexture);

	return true;
}
开发者ID:makehimanoffer,项目名称:3rdYearProjectStorage,代码行数:94,代码来源:ReflectionShader.cpp

示例11: GetDevice

	void Ground::Render() {
		GetDevice()->SetFVF(D3DFVF_GROUNDCUSTOMVERTEX);

		// TODO: 행렬 계산
		D3DXMATRIXA16	MatWorld;
		D3DXMATRIXA16	MatTrans;
		D3DXMATRIXA16	MatScale;
		D3DXMATRIXA16	MatRotate;
		D3DXVECTOR3		LookPt = mPosition + mFrontVector;

		D3DXMatrixIdentity(&MatWorld);

		//프론트 백터의 값에 따라 회전
		D3DXMatrixLookAtLH(&MatRotate, &mPosition, &LookPt, &mUpVec);
		//뷰행렬을 가져왔기 때문에 로테이션한 것처럼 행렬을 변환할 필요가 있다.
		//뷰행렬은 자신이 움직이는 것이 아닌 자신을 제외한 모든 좌표들이 움직이도록 되어있는 행렬이다.
		//(카메라의 좌표계에 맞춰져있다)
		//뷰행렬의 역행렬은 transpose해준 형태와 동일하다.
		MatRotate._41 = MatRotate._42 = MatRotate._43 = 0.f;
		D3DXMatrixTranspose(&MatRotate, &MatRotate);

		D3DXMatrixTranslation(&MatTrans, mPosition.x, mPosition.y, mPosition.z);
		D3DXMatrixScaling(&MatScale, mScaleVec.x, mScaleVec.y, mScaleVec.z);

		MatWorld = MatScale*MatRotate*MatTrans;

		//mDevice->SetTransform(D3DTS_WORLD, &MatWorld);

		D3DXMATRIXA16 g_matProj;
		D3DXMATRIXA16 matView;

		mDevice->GetTransform(D3DTS_VIEW, &matView);
		mDevice->GetTransform(D3DTS_PROJECTION, &g_matProj);
		D3DXMatrixMultiply(&matView, &matView, &g_matProj);

		mEffect->SetTechnique("t1");
		mEffect->SetMatrix("mWorld", &MatWorld);
		mEffect->SetMatrix("mViewProj", &matView);

		mEffect->SetTexture("mTexture", mGroundTexture);
		mEffect->SetTexture("mAlphaMap", mAlphaMap);
		mEffect->SetTexture("mTexture2", mSandTexture);

		//디바이스에 버텍스버퍼를 전달
		GetDevice()->SetStreamSource(0, mVertexBuffer, 0, sizeof(GROUND_CUSTOM_VERTEX));

		//인덱스 설정
		GetDevice()->SetIndices(mIndexBuffer);	
		//GetDevice()->SetTexture(0, mGroundTexture);

		UINT cPasses;
		mEffect->Begin(&cPasses, 0);
		for (UINT p = 0; p < cPasses; ++p) {
			mEffect->BeginPass(p);
			GetDevice()->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, mVertexCount, 0, mIndexCount);
			mEffect->EndPass();
		}
		mEffect->End();

		
	}
开发者ID:NHNNEXT,项目名称:2014-01-HUDIGAME-PoopTube,代码行数:61,代码来源:Ground.cpp

示例12: D3DXMatrixTranspose

bool PureLightShader::SetShaderParameters(ID3D11DeviceContext* deviceContext, D3DXMATRIX worldMatrix, D3DXMATRIX viewMatrix, 
										   D3DXMATRIX projectionMatrix, D3DXVECTOR3 lightDirection, D3DXVECTOR4 ambientColor, D3DXVECTOR4 diffuseColor, D3DXVECTOR3 cameraPosition, D3DXVECTOR4 specularColor, 
					   float specularPower, float deltavalue)
{
	HRESULT result;
    D3D11_MAPPED_SUBRESOURCE mappedResource;
	unsigned int bufferNumber;
	MatrixBufferType* dataPtr;
	LightBufferType* dataPtr2;
	VariableBufferType* dataPtr3;
	CameraBufferType* dataPtr4;


	// Transpose the matrices to prepare them for the shader.
	D3DXMatrixTranspose(&worldMatrix, &worldMatrix);
	D3DXMatrixTranspose(&viewMatrix, &viewMatrix);
	D3DXMatrixTranspose(&projectionMatrix, &projectionMatrix);

	// Lock the constant buffer so it can be written to.
	result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr = (MatrixBufferType*)mappedResource.pData;

	// Copy the matrices into the constant buffer.
	dataPtr->world = worldMatrix;
	dataPtr->view = viewMatrix;
	dataPtr->projection = projectionMatrix;

	// Unlock the constant buffer.
    deviceContext->Unmap(m_matrixBuffer, 0);

	// Set the position of the constant buffer in the vertex shader.
	bufferNumber = 0;

	// Now set the constant buffer in the vertex shader with the updated values.
    deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);

	//VARIABLE BUFFER
	result = deviceContext->Map(m_variableBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr3 = (VariableBufferType*)mappedResource.pData;

	// Copy the variablethe constant buffer.
	dataPtr3->delta = deltavalue;
	dataPtr3->padding =lightDirection; //this is just padding so this data isnt used.

	// Unlock the variable constant buffer.
	deviceContext->Unmap(m_variableBuffer, 0);

	// Set the position of the variable constant buffer in the vertex shader.
	bufferNumber = 1;

	// Now set the variable constant buffer in the vertex shader with the updated values.
	deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_variableBuffer);

	//END VARIABLE BUFFER

	// Lock the camera constant buffer so it can be written to.
	result = deviceContext->Map(m_cameraBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr4 = (CameraBufferType*)mappedResource.pData;

	// Copy the camera position into the constant buffer.
	dataPtr4->cameraPosition = cameraPosition;
	dataPtr4->padding1 = 0.0f;

	// Unlock the camera constant buffer.
	deviceContext->Unmap(m_cameraBuffer, 0);

	// Set the position of the camera constant buffer in the vertex shader.
	bufferNumber = 1;

	// Now set the camera constant buffer in the vertex shader with the updated values.
	deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_cameraBuffer);

	// Lock the light constant buffer so it can be written to.
	result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
	if(FAILED(result))
	{
		return false;
	}

	// Get a pointer to the data in the constant buffer.
	dataPtr2 = (LightBufferType*)mappedResource.pData;

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

示例13: CBBFont

void CNameTags::Draw()
{
	if(!bbfont) 
	{ 
		bbfont = new CBBFont(m_pD3DDevice, "vcpfnt");
		bbfont->Initialise(); 
	} 

	if(!BarOldStateBlock) 
	{ 
		m_pD3DDevice->BeginStateBlock(); 
		m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); 
		m_pD3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); 
		m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_FILLMODE, 3); 
		m_pD3DDevice->SetRenderState(D3DRS_CULLMODE, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_WRAP0, 0); 
		m_pD3DDevice->SetRenderState(D3DRS_CLIPPING, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_VERTEXBLEND, 0); 
		m_pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, 0); 
		m_pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 15); 
		m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, 5); 
		m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, 6); 
		m_pD3DDevice->SetRenderState(D3DRS_BLENDOP, 1); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 4); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0); 
		m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1); 
		m_pD3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); 
		m_pD3DDevice->SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE); 
		m_pD3DDevice->SetStreamSource(0, NULL, 0); 
		m_pD3DDevice->EndStateBlock(&BarOldStateBlock); 
	} 

	if(!BarNewStateBlock) 
	{ 
		m_pD3DDevice->BeginStateBlock(); 
		m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); 
		m_pD3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); 
		m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_FILLMODE, 3); 
		m_pD3DDevice->SetRenderState(D3DRS_CULLMODE, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_WRAP0, 0); 
		m_pD3DDevice->SetRenderState(D3DRS_CLIPPING, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_VERTEXBLEND, 0); 
		m_pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, 0); 
		m_pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 15); 
		m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, 5); 
		m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, 6); 
		m_pD3DDevice->SetRenderState(D3DRS_BLENDOP, 1); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 1); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); 
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0); 
		m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1); 
		m_pD3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, 1); 
		m_pD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); 
		m_pD3DDevice->SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE); 
		m_pD3DDevice->EndStateBlock(&BarNewStateBlock); 
	} 

	m_pD3DDevice->CaptureStateBlock(BarOldStateBlock); 
	m_pD3DDevice->ApplyStateBlock(BarNewStateBlock); 

	D3DXMATRIX matTransposed; 
	D3DXMatrixTranspose(&matTransposed, (D3DXMATRIX*)&matView); 
	matTransposed._14 = matTransposed._24 = matTransposed._34 = 0.0f; 

	if(pNetowkManager) 
	{ 
		CPlayerManager* pPlayerManager = pNetowkManager->GetPlayerManager(); 
		for(int x = 0; x < MAX_PLAYERS; x++)
		{ 
			if(pPlayerManager->GetSlotState(x) == TRUE)
			{ // Player is in use
				CRemotePlayer* Player = pPlayerManager->GetAt(x); 

				if(Player->IsActive() && (Player->GetDistanceFromLocalPlayer() <= 80.0f))
				{ // Active and within reasonable distance 
					CPlayerPed* PlayerPed = Player->GetPlayerPed(); 

					if(PlayerPed->IsOnScreen()) { // They're onscreen 
						// Get their position
						Vector3 vPos;
						PlayerPed->GetPosition(&vPos);

//.........这里部分代码省略.........
开发者ID:Tonyx97,项目名称:vice-players,代码行数:101,代码来源:CNameTags.cpp

示例14: assert

//----[  buildAnimatedBones  ]-------------------------------------------------
void AnimatedMeshRenderer::buildAnimatedBones(
    const D3DXMATRIX* root_transform,
    AnimatedMeshIndex animated_mesh,
    AnimatedMeshAnimationTrack* animation_track,
    D3DXMATRIX* bone_matrices) const {
  assert(animated_mesh < animated_meshes_.size());
  assert(animation_track);
  assert(bone_matrices);

  const RenderableAnimatedMesh& renderable_animated_mesh
    = animated_meshes_.at(animated_mesh);
  AnimatedMeshAnimationTrackElement* internal_animation_track =
    reinterpret_cast<AnimatedMeshAnimationTrackElement*>(animation_track);
  RenderableAnimatedMesh::Frame* frames = renderable_animated_mesh.frames;
  size_t number_of_frames = renderable_animated_mesh.number_of_frames;
  RenderableAnimatedMesh::Bone* bones = renderable_animated_mesh.bones;
  size_t number_of_bones = renderable_animated_mesh.number_of_bones;

  // Build the frames using the data in the animation track
  D3DXMATRIXA16 matrix;
  for (size_t frame_index = 0; frame_index < number_of_frames; ++frame_index) {
    RenderableAnimatedMesh::Frame* frame = &frames[frame_index];
    AnimatedMeshAnimationTrackElement* track_element
      = &internal_animation_track[frame_index];
    AnimatedMeshAnimationTrackElement::FrameTransform* frame_transform
      = &track_element->frame_transform;

    // Build the transform matrix from the scale/rotate/translate settings
    //D3DXMatrixTransformation(&matrix,
    //                         NULL,
    //                         NULL,
    //                         frame_transform->scaling(),
    //                         NULL,
    //                         frame_transform->rotation(),
    //                         frame_transform->translation());

    // This method of constructing the transform matrices is necessary because
    // it allows us to transpose the quaternion's matrix during the build.
    D3DXMATRIXA16 cumulative, builder;
    D3DXMatrixScaling(&cumulative,
                      frame_transform->s[0],
                      frame_transform->s[1],
                      frame_transform->s[2]);

    D3DXQUATERNION quat;
    D3DXQuaternionNormalize(&quat, frame_transform->rotation());
    D3DXMatrixRotationQuaternion(&builder, &quat);
    D3DXMatrixTranspose(&builder, &builder);

    D3DXMatrixMultiply(&cumulative, &cumulative, &builder);
    D3DXMatrixTranslation(&builder,
                          frame_transform->t[0],
                          frame_transform->t[1],
                          frame_transform->t[2]);
    D3DXMatrixMultiply(&matrix, &cumulative, &builder);



    // Use the frame hierarchy to construct this frame's final transformation
    size_t parent_frame_index = frame->parent_frame_index;
    assert(!frame_index || (parent_frame_index < frame_index));
    const D3DXMATRIX* parent_frame_matrix
      = frame_index == 0 ? root_transform
                         : internal_animation_track[parent_frame_index]
                             .frameMatrix();
    D3DXMatrixMultiply(track_element->frameMatrix(),
                       &matrix,
                       parent_frame_matrix);
  }

  // Construct the bone transformations for this framte state
  for (size_t bone_index = 0; bone_index < number_of_bones; ++bone_index) {
    D3DXMATRIX* bone_matrix = bone_matrices + bone_index;
    const RenderableAnimatedMesh::Bone* bone = bones + bone_index;
    const D3DXMATRIXA16* frame_matrix
      = (internal_animation_track + bone->frame_index)->frameMatrix();
    D3DXMatrixMultiply(bone_matrix,
                       &bone->inverse_offset,
                       frame_matrix);
  }
}
开发者ID:karlgluck,项目名称:Evidyon,代码行数:82,代码来源:animatedmeshrenderer.cpp

示例15: RenderSSAOEffect


//.........这里部分代码省略.........
				:
			( detailEnable ? SSAO_ALT_DETAIL_NUM_RAYS : SSAO_ALT_NUM_RAYS );

	if( !g_PrevSSAO_Valid )
	{
		D3DXMatrixIdentity( &g_PrevSSAO_View ) ;
	}

	float aspect = 1.0f ;

	D3DXVECTOR4 pconsts[ RAYS_START + SSAO_ALT_DETAIL_NUM_RAYS ];

	// float4      g_vZScale0_ColorControl     : register ( c0 );
	pconsts[ 0 ] = D3DXVECTOR4( sts.DepthRange / sts.Radius, 128.0f / sts.Radius, sts.Contrast, sts.Brightness * sts.Contrast - 1.5f * sts.Contrast + 0.5f );
	// float4      g_vProjScaleTrans           : register ( c1 );
	pconsts[ 1 ] = D3DXVECTOR4( 0.5f*r3dRenderer->ProjMatrix._11, -0.5f*r3dRenderer->ProjMatrix._22, 0.5f, 0.5f );
	// float4      g_vInvProjScaleTrans        : register ( c2 );
	pconsts[ 2 ] = D3DXVECTOR4( 2.0f / r3dRenderer->ProjMatrix._11, -2.0f / r3dRenderer->ProjMatrix._22, -1.0f / r3dRenderer->ProjMatrix._11, 1.0f / r3dRenderer->ProjMatrix._22 );
	// float4      g_vInvRes_DepthFadeRange    : register ( c3 );
	pconsts[ 3 ] = D3DXVECTOR4( 1.0f / r3dRenderer->ScreenW, 1.0f / r3dRenderer->ScreenH, 0.985f * fFar, 0.99f * fFar );
	// float4      g_vExpandRanges             : register ( c4 );
	pconsts[ 4 ] = D3DXVECTOR4( sts.RadiusExpandStart, sts.DetailRadiusExpandStart, sts.RadiusExpandCoef, sts.DetailRadiusExpandCoef );
	// float4      g_vDetail_Fade_ZScale1      : register ( c5 );
	pconsts[ 5 ] = D3DXVECTOR4( sts.DetailStrength, sts.DetailFadeOut * sts.DetailRadius, sts.DetailDepthRange / sts.DetailRadius, 128.0f / sts.DetailRadius );
	// float4      g_vTempoCtrl                : register ( c6 );
	pconsts[ 6 ] = D3DXVECTOR4( 0.00125f * sts.TemporalTolerance, 1.f / 512.f, aspect / 512.f, 0.f );

	if( doSSAOTemporalOptimize )
	{
		pconsts[ 6 ].w = r_half_scale_ssao->GetInt() ? 0.5f : 1.0f ;
	}

	// float4x3    g_mViewMtx                  : register ( c7 );
	D3DXMatrixTranspose( (D3DXMATRIX*)&pconsts[7], &r3dRenderer->ViewMatrix );
	// ^^^^
	// NOTE : last row is overwritten below

	D3DXMATRIX toPrevViewMtx = r3dRenderer->InvViewMatrix * g_PrevSSAO_View ;

	// float4x3    g_mToPrevViewMtx    : register ( c10 );
	D3DXMatrixTranspose( (D3DXMATRIX*)&pconsts[10], &toPrevViewMtx );
	// ^^^^
	// NOTE : last row is overwritten below

	// float4x3    g_mFromPrevViewMtx  : register ( c13 );
	D3DXMATRIX fromPrevViewMtx ;
	D3DXMatrixInverse( &fromPrevViewMtx, NULL, &toPrevViewMtx ) ;
	D3DXMatrixTranspose( (D3DXMATRIX*)&pconsts[13], &fromPrevViewMtx );
	// ^^^^
	// NOTE : last row is overwritten below

	int r = 0;

	if( !lightWeight )
	{
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4(-0.18486f, 0.32808f, 0.00708f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4( 0.22890f, 0.93380f,-0.09171f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4(-0.36097f, 0.18230f,-0.38227f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4( 0.06232f, 0.32664f, 0.21049f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4( 0.68342f, 0.25225f,-0.06311f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4(-0.05478f, 0.09994f, 0.34463f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4( 0.01732f, 0.36483f,-0.49192f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4(-0.72131f, 0.22451f,-0.09716f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4( 0.32283f, 0.33296f, 0.11536f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4(-0.27977f, 0.18833f, 0.16797f, 0 );
		pconsts[ RAYS_START + r++ ] = D3DXVECTOR4(-0.50663f, 0.08494f, 0.63250f, 0 );
开发者ID:Mateuus,项目名称:warbrasil,代码行数:67,代码来源:DrawWorld.hpp


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