Hey guys,
I've been making a little 3D pong clone using Direct3D 9 and C++. I've got my meshes created/textured/imported and the scene's all set up how I want it.
I'm just a little bit stumped on how to handle collisions between the ball and the paddle?
I've looked into AABB collision detection and I have a little bit set up:
<code>
BYTE* vertices;
HRESULT hr = paddle->theMesh->LockVertexBuffer(D3DLOCK_READONLY,(LPVOID *) &vertices);
if(FAILED(hr)) PostQuitMessage(0);
D3DXVECTOR3 minBounds, maxBounds;
D3DXComputeBoundingBox((D3DXVECTOR3 *)vertices,paddle->theMesh->GetNumVertices(),D3DXGetFVFVertexSize(paddle->theMesh->GetFVF()),&minBounds,&maxBounds);
paddle->theMesh->UnlockVertexBuffer();
</code>
All credit to http://www.toymaker.info/Games/html/collisions.html
But obviously this only gives me a bounding box for object space, how do I convert the minBounds and Maxbounds vectors into world space so I can test to see if the ball intersects with them?
As usual any help is appreciated.
Ollie.
Plane/Sphere Collision Detection
Does the paddle have a fixed orientation? If so, just add the paddle's position to the min and max vectors of the AABB to yield the world-space AABB.
Thanks for the swift reply.
I'm not entirely sure what fixed orientation means.. But if I understand correctly then yes it does, the paddle does not rotate and can only move in the XY plane.
Please excuse my ignorance if I got that completely wrong! =P
I'm not entirely sure what fixed orientation means.. But if I understand correctly then yes it does, the paddle does not rotate and can only move in the XY plane.
Please excuse my ignorance if I got that completely wrong! =P
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement