Recent Developments

11 April 2009 | Uncategorized

So it has been a while since my last post. Ok so I have helped many people with this and I still have a hard time understanding what is so hard about it. This that I am talking about is screen picking bring mouse coordinates to world coordinates. For our game we use the mouse to aim the turret of the tank. To do this as a prototype we use project and unproject methods

 
//note I use project and unproject here as an example of how to use each and what you can do with them there are other alternative ways to do this.
//X and Y are normalized screen cords of the mouse we bring them back in to screen cords to 
WindowRectangle rec = ()->GetWindowRect();
	x *= rec.width;
	y *= rec.height;
 
	D3DXMATRIX ident;
	D3DXMATRIXIdentity(&ident);
 
	D3DXVECTOR3 out;
	D3DXVec3Project(&out, tankPosition,gameViewPort,projectionMatrix,viewMatrix,&ident);
 
//screen x and y
//z is the depth between the near clip plane and far clip plane
	D3DXVECTOR3 mouseVecTank = D3DXVECTOR3(x, y, out.z);
	D3DXVECTOR3 mouseVecTankOut;
 
 
	D3DXVec3Unproject(&mouseVecTankOut, &mouseVecTank, gameViewPort, projectionMatrix, viewMatrix, &ident);
 
 
	//if im not mistaken this can be replaced by taking the dot product of the tank forward vector and the direction to the mouse and using the angle returned from that. That may be faster than doing atan2f
 
	D3DXVECTOR3 dir = mouseVecTankOut – tankWorldTranslation
	D3DXVec3Normalize(&dir,&dir);
	Float angleFromUnitToMouse = atan2f(dir.x,dir.z);

If you have any questions please feel free to leave a comment I will respond as soon as I notice them.

Capstone: Terain

Capstone: Terain


Another thing I worked on this week was adding support for multi-texturing into our model format. I export the texture and updated the UV to include a W that is the index of the texture to use in the texture array. I will post screen shots of this when we have models that take advantage of it. The final thing I worked on this week was adding an influence map to the game and getting it to render. The dots you see in the picture are the influence of various units placed around the map. The red dots are one team and the blue dots are the other team.

Oh I almost forgot, I made some updates to the input system to be optimized for fast input during game play, and to use windows settings for chatting and console settings. I am using a combination of direct input and windows messages to achieve this.


2 Responses to “Recent Developments”

Leave a Reply