Ejemplo n.º 1
0
void Mesh_D3D11::Draw(void)
{
#if 0
  // Set vertex buffer
  unsigned int iOffset = 0;
  GetApp()->GetContext()->IASetVertexBuffers(0, 1, &m_pVertexBuffer, &m_iVertexSize, &iOffset);

  // Set index buffer
  GetApp()->GetContext()->IASetIndexBuffer(m_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);

  // Set primitive topology
  GetApp()->GetContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

  // Set the input layout
  GetApp()->GetContext()->IASetInputLayout(m_pVertexLayout);

  // Draw
  GetApp()->GetContext()->DrawIndexed(m_iNumTris * 3, 0, 0);
#endif

  noMat4 tm(worldTM_.rotate_ * worldTM_.scale_, worldTM_.trans_);
  tm.TransposeSelf();	

  GetApp()->drawModel(m_rd, ToMat4(tm), ViewMat(), ProjMat());

  g_iTrisPerFrame += m_iNumTris;
}
Ejemplo n.º 2
0
	void CloudLayer::Render(BaseCamera* c)
	{
		GetRenderer()->reset();
		GetRenderer()->setShader(mSkyX->mCloudShader);
		
		GetRenderer()->setVertexFormat(mSkyX->mCloudVF);
		GetRenderer()->setVertexBuffer(0, mSkyX->getMeshManager()->mVB);
		GetRenderer()->setIndexBuffer(mSkyX->getMeshManager()->mIB);

		GetRenderer()->setDepthState(mSkyX->getMeshManager()->mDepthWrite);
		GetRenderer()->setTexture("CloudTex", mSkyX->mDiffuseTex);
		GetRenderer()->setTexture("CloudNormal", mSkyX->mNormalTex);
		GetRenderer()->setTexture("CloudTileTex", mSkyX->mTileTex);

		GetRenderer()->setSamplerState("uClouds", mSkyX->linearWarp);		
		GetRenderer()->setSamplerState("uCloudsNormal", mSkyX->linearWarp);
		GetRenderer()->setSamplerState("uCloudsTile", mSkyX->linearWarp);		
		
		GetRenderer()->setBlendState(GetApp()->GetBlendMode(5));

		mat4 view =ViewMat();
		view.rows[3].x = view.rows[3].y = view.rows[3].z = 0.f;
		mat4 wvp =  view * ProjMat();
		GetRenderer()->setShaderConstant4x4f("uWorldViewProj", transpose(wvp));
		GetRenderer()->apply();
		GetRenderer()->drawElements(PRIM_TRIANGLES, 0, mSkyX->getMeshManager()->mNumIndices, 0, 0);	
	}
Ejemplo n.º 3
0
FMatrix FCanvas::CalcBaseTransform3D(uint32 ViewSizeX, uint32 ViewSizeY, float fFOV, float NearPlane)
{
	FMatrix ViewMat(CalcViewMatrix(ViewSizeX,ViewSizeY,fFOV));
	FMatrix ProjMat(CalcProjectionMatrix(ViewSizeX,ViewSizeY,fFOV,NearPlane));
	return ViewMat * ProjMat;
}
Ejemplo n.º 4
0
void M2EffectRender::RenderRibbons()
{

	//renderer->changeToMainFramebuffer();
	//loader->reset();

	ID3D11RenderTargetView* pRTV;
	ID3D11DepthStencilView* pDSV;

	D3D11Context()->OMGetRenderTargets(1, &pRTV, &pDSV);

	ID3D11DeviceContext* pd3dContext = GetApp()->GetContext();

	float ClearColor[4] =
	{
		0.0f, 0.0f, 0.0f, 1.0f
	};
	//pd3dContext->ClearRenderTargetView( pRTV, ClearColor);
	//pd3dContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0);

	D3DXVECTOR3 vEyePt;
	D3DXMATRIX mWorldViewProjection;	
	D3DXMATRIX mWorld;
	D3DXMATRIX mView;
	D3DXMATRIX mProj;	
	GetCamera()->getFrom(vEyePt);
	const unsigned int size16 = sizeof(float) * 16;


	memcpy(&mView, &ViewMat(), size16);	 
	memcpy(&mProj, &ProjMat(), size16);
	memcpy(&mWorld, &WorldMat(), size16);	

	RibbonData_.gpmWorld->SetMatrix( (float*)mWorld);	
	mWorldViewProjection = mWorld * mView * mProj;


	RibbonData_.gpmWorldViewProjection->SetMatrix( ( float* )&mWorldViewProjection );


	

	D3D11Context()->IASetInputLayout( RibbonData_.gpVertexLayout );
	for (size_t i=0; i < Owner_->header.nRibbonEmitters; ++i)
	{
		if (RibbonData_.gNumActiveParticles.at(i) == 0)
			continue;
			
		UINT Strides[1];
		UINT Offsets[1];
		ID3D11Buffer* pVB[1];
		pVB[0] = RibbonData_.ParticleBuffers.at(i);
		Strides[0] = sizeof( RibbonVertex );
		Offsets[0] = 0;
		pd3dContext->IASetVertexBuffers( 0, 1, pVB, Strides, Offsets );
		pd3dContext->IASetIndexBuffer( NULL, DXGI_FORMAT_R16_UINT, 0 );
		pd3dContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP );

		HRESULT hr = RibbonData_.gptxDiffuse->SetResource( RibbonData_.ParticleTextureSRVMaps.find(Owner_->ribbons[i].texture)->second );

		//Render
		D3DX11_TECHNIQUE_DESC techDesc;
		RibbonData_.gpRenderParticles->GetDesc( &techDesc );

		for( UINT p = 0; p < techDesc.Passes; ++p )
		{
			RibbonData_.gpRenderParticles->GetPassByIndex( p )->Apply( 0, pd3dContext );
			pd3dContext->Draw( RibbonData_.gNumActiveParticles.at(i) * 4, 0 );
		}		
	}
}