PDA

View Full Version : Collision Detection can't work


chingching
04-18-2006, 06:38 PM
Hi all, I got some problems here...
In my code,when I perform these few lines -->

tVector3 Poly1[3];
for(int i = 0; i < worldModel.GetObjectNum(); i++)
{
t3DObject *pObject = &worldModel.pObject[i];

for(int j = 0; j < pObject->numOfFaces; j++)
{

Poly1[0]=pObject->pVerts[ pObject->pFaces[j].vertIndex[0] ];
Poly1[1]=pObject->pVerts[ pObject->pFaces[j].vertIndex[1] ];
Poly1[2]=pObject->pVerts[ pObject->pFaces[j].vertIndex[2] ];

SphereTriangleCollision(Poly1);

}
}

Then, no error while compiling and debuging....but later it will pop out a msg box said "The xxxx.exe has encountered a problem and need to close"...then I click the debug button on the msg box, then it said "The instruction at '0x004120 a1' referenced memory at '0x4128d421'. The memory could not be 'read'."

But when I comment those few lines...won't have such msg and I could see my model...can anyone pls help me with my collision detection?A lot of thanks!!:worthy:

monjardin
04-18-2006, 07:17 PM
Have you tried using a debugger to see exactly where it is breaking? Make sure you are getting valid pointers and array indices.

EDIT: You might also want to check whether GetObjectNum() does what you think.