D3DXIntersect with Jim Adams' cObject classes

Started by
4 comments, last by alwayslaughhard 21 years, 2 months ago
Ok, so I''m using Jim Adams''s code for cMesh, cObject, etc. and I want to check for a collision between one object (the character) and another (the scene). My call is: D3DXIntersect(m_pSceneMesh->GetParentMesh()->m_Mesh, &vecPos, &vecDir, $Hit, NULL, NULL, NULL, &Dist, NULL, NULL); where: m_pSceneMesh is a cObject pointer for the scene, vecPos is the vector position of the cObject that is the character (initialized with GexXPos(), GetYPos(), and GetZPos()), vecDir is a vector direction (using keyboard input, I move the character in the X, Y, and Z directions), Hit is just a BOOL for hit detection, Dist is a float to check that the intersection actually hits the mesh. Ok, for some reason or another, it doesn''t seem to work really at all. I can still walk through walls, fall through floors, etc. However, every once in a while, I will run into something (when there is an intersection the character won''t move), but where the game detects an intersection is not where there should be one! Anyone have any thoughts or suggestions. Please keep your laughing and obscene insults to a minimum.
Advertisement
Is this too difficult a problem for everyone? or perhaps I didn''t explain my situation clearly?
Someone at least post, saying whether or not they have a clue what I''m talking about.
Please!
Are you doing something like the tower game (like the 3D in 2D chapter)? Are you sure that your scene mesh is properly aligned with the camera?

pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code

//--------------------------------------------
// Join the Anti "War Thread" Coalition!!
//--------------------------------------------
Minister of Propaganda : leighstringer.com : Nobody likes the man who brings bad news - Sophocles (496 BC - 406 BC), Antigone
hi,

you might be not using the function properly, did you remember to transform the ray into the object''s model space? did you calculate your vector direction well?

you can get more informatino here,

improved raypicking

http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
Yes, my game is like the tower game (3D in 2D demo).
I create the scene mesh and scene object but I don''t rotate it or move it in any way. When the user hits one of the keyboard direction keys, I use the cObject.MoveRel(x, y, z) function to move the character object and camera object simutaneously. So I don''t understand how my scene could be misaligned.
As to the ray transformation, I tried doing this, but it didn''t help. However, it could be that I didn''t do it correctly. I used something like the following:
D3DXMatrixInverse(&newLocal, NULL, m_pWorldPos->GetMatrix(m_pGraphics))
D3DXVec3TransformCoord (&vecPos, &vecPos, &newLocal);
D3DXVec3TransformNormal(&vecDir, &vecDir, &newLocal);

where newLocal is just a temporary D3DXMatrix,
and m_pWorldPos is the cWorldPosition object.

I''m not sure that I''m properly using the cWorldPosition object, though. Maybe this is my problem. Is this object supposed to be keeping track of my world coordinate system?
hi,

the link i gave you is to teach you how to pick meshes on the screen using your mouse, ie picking,

when using ray collision from your mesh to mesh, that''s quite different, try to look for ray->plane->polygon collsiion detection at gametutorials.com under opengl section,

and yeah, cWorldPosition keeps track of your objects position in world space/coords,


anyway, i''m sorry i can''t say much coz i''m also having some quite similar problems with you,
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,

This topic is closed to new replies.

Advertisement