Jump to content
  • Advertisement
Sign in to follow this  
Dun

[directx9]Centering backbuffer position and detecting out of scene objects

This topic is 2609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i am developing a simple 2d network game.My problem is: For example, i fire missile, which every few miliseconds moves in one direction. How can i simply compute that i can delete this missile, becouse it is far away out of screen. So the first real question, i define custom direct x vertex struct, but why when i put coordinates [0f,0f,0f], the object doesnt show in the middle of the screen, or in one corner. Why? How can i center the position [0,0,0] in the backbffer to center of the window. The second question. Why do i have to use float to custom vertex, everyone does this, as i saw in all tutorials. How can i then compute, that som float cooridnates are out of screen, when i have screen size defined as unsigned int in pixels? I am quite new in DX. Thx for answer.

struct Vertex
{
float fX,
fY,
fZ;
DWORD dwColor;
};

Share this post


Link to post
Share on other sites
Advertisement
Look up frustum culling - you'll typically see it used for 3D (perspective projection) but there's no reason why you can't use the same principles for 2D (and the calculations can be simpler too).

Share this post


Link to post
Share on other sites
Posted · Hidden
Hidden
but i really dont understand why my scene shows rectangle on pos 0,0,0 not in the center of the window but ,quite to the right. How can i fix this?


m_fFieldOfView = D3DX_PI / 4.0f;
m_fNearPlane = 1.0f;
m_fFarPlane = 1000.0f;
m_fAspectRatio = (float)m_dwWidth / (float)m_dwHeight;

D3DXVECTOR3 position( 0.0f, 0.0f, 0.0f );
// Calculate the new view matrix
D3DXVECTOR3 up = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXVECTOR3 lookAt = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
D3DXMatrixPerspectiveFovLH(&m_matProjection,m_fFieldOfView,m_fAspectRatio,m_fNearPlane,m_fFarPlane);
D3DXMatrixLookAtLH( &m_matView, &position, &lookAt, &up );

Share this post


Link to post
Posted · Hidden
Hidden
How can i create tight boundng sphere please? I googled it but, found nothing usefull.

Share this post


Link to post
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!