Jump to content

  • Log In with Google      Sign In   
  • Create Account


Help! With Positions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 flashlaser   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 October 2001 - 08:37 PM

My GTA2 style game was coming along nicely until I got to collision detection. For collision detection I put my car in a bounding box and checked every vertice in the box against my city mesh and if no collision are detected then the car is moved to the destination. Now what I have relized is that my cars position is defined from its center so I would have to add the the box vertice I want to check with my cars position to get a accurate result. Here''s a picture - v1|-0--0-|v4 | p | * view from top, v1-v4 are the boxes v3|-0--0-|v5 vetices and p is the car''s position. so to check v1 for example I would have to minus v1 from p,(both are vectors) then check if it collides with the mesh. What I would like to know is if this is necessary, and if so how sould I go about doing it, since if v1 was smaller then pos I would have to minus v2 from pos, but if v1 was bigger than pos then I would have to minus pos from v1. I have tried every thing I could think of but my car still stops after the building is halfway though it. I am using DirectX8 with VisualC++ 6.0. I load the map and car from X. files into seperate vertice buffers. I lock the vertice buffers and index buffers when I need access to the vertices.

Sponsor:

#2 v71   Banned   -  Reputation: 100

Like
Likes
Like

Posted 11 October 2001 - 05:44 AM

You need velocity based collision detection function, try at gamasutra or look around the explanation with formulas is a little too big for this forum.



#3 flashlaser   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 October 2001 - 12:03 AM

I'll try to explain more about what I'm trying to do.

I have a car mesh, I worked out the bounding box for it, So now I have eight points. My collision detection method works by checking each the eight points of the box against my city mesh. If none of the points collide then the car is moved to its destination. My problem is this, I input the 8 points into the collision detection function with the cars destination one at a time. When no collision occurs the car is moved to the destination. The destination is worked out using the cars position (p) and speed. Since p is the center of the car the car goes a little into the building. What I want to do is somehow add the points to p so this will stop.

|--------------------|
| building |
| +-------+ |
| | | |
-----|-------|--------
| p |
| |
| car |
+-------+

I have tried some code already but it does't work. Here it is so you can see.

D3DXVECTOR3 Car::point(D3DXVECTOR3 point) {
D3DXVECTOR3 posold;
if (point.x <= 0) {
if (pos.x < 0) {
if (point.x < pos.x) {
posold.x = point.x + pos.x;
}
else {
posold.x = point.x - pos.x;
}
}
else {
posold.x = point.x-pos.x;
}
}
else {
if (pos.x >=0) {
if (point.x>pos.x) {
posold.x = point.x + pos.x;
}
else {
posold.x = point.x - pos.x;
}
}
else {
posold.x = point.x-pos.x;
}
}

if (point.y < 0) {
if (pos.y < 0) {
if (point.y < pos.y) {
posold.y = point.y + pos.y;
}
else {
posold.y = point.y - pos.y;
}
}
else {
posold.y = point.y-pos.y;
}
}
else {
if (pos.y>0) {
if (point.y>pos.y) {
posold.y = point.y + pos.y;
}
else {
posold.y = point.y - pos.y;
}
}
else {
posold.y = point.y-pos.y;
}
}

if (point.z < 0) {
if (pos.z < 0) {
if (point.z < pos.z) {
posold.z = point.z + pos.z;
}
else {
posold.z = point.z - pos.z;
}
}
else {
posold.z = point.z-pos.z;
}
}
else {
if (pos.z>0) {
if (point.z>pos.z) {
posold.z = point.z + pos.z;
}
else {
posold.z = point.z - pos.z;
}
}
else {
posold.z = point.z-pos.z;
}
}
return posold;
}



Edited by - flashlaser on October 15, 2001 7:05:11 AM

#4 flashlaser   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 October 2001 - 12:03 AM

bump

Edited by - flashlaser on October 15, 2001 7:04:21 AM




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS