3 Replies - 175 Views - Last Post: 01 June 2013 - 09:08 AM Rate Topic: -----

#1 Jigokuchi1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-February 13

Can't Implement a shadow in the right spot

Posted 31 May 2013 - 06:44 PM

Heres my function to implement a shadow form a teapot. but for some reason it just doens't work.

void Lab2::drawTeapotShadow()
{
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILENABLE,    true));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILFUNC,      D3DCMP_EQUAL));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILREF,       0x0));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILMASK,      0xffffffff));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILWRITEMASK, 0xffffffff));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILZFAIL,     D3DSTENCILOP_KEEP));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILFAIL,      D3DSTENCILOP_KEEP));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILPASS,      D3DSTENCILOP_INCR)); 

	D3DXVECTOR4 shadowVec = D3DXVECTOR4(0.577f, -0.577f, 0.577f, 0);
	D3DXPLANE plane = D3DXPLANE(0, -1, 0, 0);

	D3DXMATRIX shadow, T, sWorldMatrix;
	D3DXMatrixShadow(&shadow, &shadowVec, &plane);
	D3DXMatrixTranslation(&T, 0, 0.001, 0);

	sWorldMatrix = mTeapotWorld * shadow * T;
	HR(mFX->SetMatrix(mhWorld, &sWorldMatrix));
	HR(gd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA));
	HR(gd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA));

	drawTeapot();
	
	HR(mFX->SetMatrix(mhWorld, &mTeapotWorld));
	HR(gd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILENABLE,    false));
}


Is This A Good Question/Topic? 0
  • +

Replies To: Can't Implement a shadow in the right spot

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: -4
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Can't Implement a shadow in the right spot

Posted 01 June 2013 - 06:46 AM

Questions:

1. Is this your code?
2. What exactly is wrong?
3. What do YOU think it could be?
Was This Post Helpful? 0
  • +
  • -

#3 Jigokuchi1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-February 13

Re: Can't Implement a shadow in the right spot

Posted 01 June 2013 - 08:27 AM

View PostButchDean, on 01 June 2013 - 06:46 AM, said:

Questions:

1. Is this your code?
2. What exactly is wrong?
3. What do YOU think it could be?


sorry this is my lab + my code, i believe that there's something wrong with the matrices because the shadow is positioned with the original
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: -4
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Can't Implement a shadow in the right spot

Posted 01 June 2013 - 09:08 AM

You're just not giving enough to go on. You need to know the precise nature of your problem.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1