Archived

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

Positions

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Since no one understood my collision detection problem I have made a site with pictures, etc. The pictures are big and might take long to load. Plz check it out and if you can help me. The url is - http://home.iprimus.com.au/laser1/help.htm

Share this post


Link to post
Share on other sites
Did you really have to upload all those images as .bmps instead of .gifs or .jpgs or something? That page took AGES to load.

Now I''d like to help, but I still don''t really understand your problem. I haven''t used D3D before so I don''t really know what all those D3DX functions do.

I can tell you however that this piece of code you posted on that site (which I couldn''t find in your .zip file btw) is utterly useless. Why it is useless? Well all statements do exactly the same. See the comments I added:

  
if (point.x < 0)
{
if (pos.x < 0)
{
if (pos.x > point.x)
{
posold.x = point.x + (point.x-pos.x); // = 2*point.x - pos.x

}
else
{
posold.x = point.x - (pos.x-point.x); // = 2*point.x - pos.x

}
}
else
{
posold.x = point.x - (pos.x-point.x); // = 2*point.x - pos.x

}
}
else
{
if (pos.x > 0)
{
if (pos.x > point.x)
{
posold.x = point.x - (pos.x-point.x); // = 2*point.x - pos.x

}
else
{
posold.x = point.x + (point.x-pos.x); // = 2*point.x - pos.x

}
}
else
{
posold.x = point.x + (point.x-pos.x); // = 2*point.x - pos.x

}
}

// Conclusion, this whole block of code is identical to:

// posold.x = 2*point.x - pos.x;





I''m sorry I can''t help you on your method. But I would seriously suggest you look into creating your own collision function which uses a real bounding box. Just checking the vertices of a bounding box is not enough. (Imagine a long car colliding with a narrow building. All the bounding box vertices could be outside the building while the building still penetrates the car.)

If you want some help with that, just ask.

Share this post


Link to post
Share on other sites
This is a classic problem that has been responded to several times on this forum. Your object''s velocity is such that in the interval between collision test the object may have passed through the boundary. The solution is to determine when the object will collide (using the velocity vector and the surface in the direction - intersection of a line and a plane) and calculate where the object should be at the next interval (frame, for example). Hope that made sense to you.

Share this post


Link to post
Share on other sites
Well you have only two different statements:
posold.x = point.x + (point.x-pos.x);
and
posold.x = point.x - (pos.x-point.x)

You should know from simple math that:
posold.x = point.x - (pos.x-point.x)
posold.x = point.x - pos.x - -point.x
posold.x = point.x - pos.x + point.x
posold.x = point.x + point.x - pos.x
posold.x = 2*point.x - pos.x

And also that:
posold.x = point.x + (point.x-pos.x)
posold.x = point.x + point.x + -pos.x
posold.x = point.x + point.x - pos.x
posold.x = 2*point.x - pos.x

Thus, both statements are equal. I hope you understood that, I'm not terribly good at explaining things.

I wouldn't know how to fix it up though, since I'm not quite sure what that block of code is supposed to do.

EDIT: typo's

Edited by - Scarab0 on October 19, 2001 7:24:14 PM

Share this post


Link to post
Share on other sites