Public Group

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

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

## 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 on other sites
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 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 );

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

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633669
• Total Posts
3013259
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!