3 Replies - 426 Views - Last Post: 09 June 2013 - 01:58 AM Rate Topic: -----

#1 Jigokuchi1  Icon User is offline

  • New D.I.C Head

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

Camera Class graphics problem

Posted 07 June 2013 - 12:46 PM

I Changed the code for my lab so that i can have a camera class that can be used all throughout the code, but I think i didn't quite update the all the world view proj right. I have looked through the code and everything looks good to me but I cannot be sure. When i initialize the camera at a position it doesn't allow anything to show up. I have attached the Main.cpp file and Camera.h and .cpp.

camera code in main file
//initialized in WinMain function
	Camera camera;
	gCamera = &camera;

//in lab2 constructor function
Lab2::Lab2
	gCamera->pos() = D3DXVECTOR3(55.0f, 50.0f, 25.0f);
	gCamera->setSpeed(40.0f);

//ON device reset
	float w = (float)md3dPP.BackBufferWidth;
	float h = (float)md3dPP.BackBufferHeight;
	gCamera->setLens(D3DX_PI * 0.25f, w/h, 0.01f, 5000.0f);

//update function
	gCamera->update(dt);

//when drawing each object

D3DXMATRIX worldViewProj;
	worldViewProj = mRoomWorld * gCamera->viewProj();
	HR(mFX->SetMatrix(mhWVP, &worldViewProj));

	D3DXMATRIX worldInvTrans;
	D3DXMatrixInverse(&worldInvTrans, 0, &mRoomWorld);
	D3DXMatrixTranspose(&worldInvTrans, &worldInvTrans);

	HR(mFX->SetMatrix(mhWorldInvTrans, &worldInvTrans));
	HR(mFX->SetMatrix(mhWorld, &mRoomWorld));





and if anyone can figure out my shadow wouldn't show up away from the actual location of the teapot heres the code for that.... i gave up on it but anyone is welcome to give me hints on what i did wrong

	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();


Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Camera Class graphics problem

#2 anonymous26  Icon User is offline

  • D.I.C Lover

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

Re: Camera Class graphics problem

Posted 08 June 2013 - 09:30 AM

Often, particularly with game code, you cannot eyeball the code to see what the problem is, you need to be able to debug the code to see what values are being stored in the variable in your game. This is your job as part of your lab.
Was This Post Helpful? 1
  • +
  • -

#3 Jigokuchi1  Icon User is offline

  • New D.I.C Head

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

Re: Camera Class graphics problem

Posted 08 June 2013 - 09:36 AM

This part actually wasn't part of my lab, I just got tired of not having a flexible camera to work with. I figured it out fortuately. I had the camera in the wrong place and everything was beeing culled due to CCW culling
Was This Post Helpful? 0
  • +
  • -

#4 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 567
  • View blog
  • Posts: 1,263
  • Joined: 24-April 12

Re: Camera Class graphics problem

Posted 09 June 2013 - 01:58 AM

Backface culling will sure bite you in the posterior end. It's obviously a performance enhancer, but the first thing to do in a situation like that is turn backface culling off and see if things start appearing. I have that problem a lot.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1