• ### Popular Now

• 13
• 27
• 9
• 9
• 20

#### Archived

This topic is now archived and is closed to further replies.

# Collision Detection

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

## Recommended Posts

Can someone take a look at my figures and tell me what I am doing wrong? I have a background large mesh and a small player mesh both in world space. I can move the player around the screen and detect collision with the background; but it doesn''t seem to work perfectly. Here is my math mixed with the code:

//Level is the world space matrix for my background mesh:

Level =	1	0	0	0
0	1	0	0
0	0	0.25	0
0	-184.5	500	1

D3DXMatrixInverse(&invMat,NULL,(D3DXMATRIX*) m_LevelObject.GetMatrix());

// Convert World Space to Model or Local Space

// After the Inverse

Inv Level =	1	0	0	0
0	1	0	0
0	0	4	0
0	184.5	-2000	1

// Notice that Inv * Level = 1

Level * Inv Level =	1	0	0	0
0	1	0	0
0	0	1	0
0	0	0	1

// Vector of the players location

pvNear = 0
-173.5
470

// Needed to Convert World to Local Space

D3DXVec3TransformCoord(&vNear,pvNear,&invMat);

// Vector after the converstion

vNear = 0
311
-120

// Vector of the players movement

// Notice that the player moved up 5?

pvDir =	0
-168.5
470

D3DXVec3TransformNormal(&vDir,pvDir,&invMat);

// Normalize the players movement

// Needed to Convert world space to model space

// Why is this number so large?

vDir =	0
-168.5
1880

D3DXIntersect(m_LevelMesh.GetParentMesh()->m_Mesh, &vNear,&vDir,&bHit,&dwIndex,&u,&v,&dist,NULL,NULL)

Some of the numbers look a bit strange?