Jump to content


Collision Detection can't work


1 reply to this topic

#1 chingching

    Member

  • Members
  • PipPip
  • 38 posts

Posted 19 April 2006 - 01:38 AM

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:

#2 monjardin

    Senior Member

  • Members
  • PipPipPipPip
  • 1033 posts

Posted 19 April 2006 - 02:17 AM

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.
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users