Advertisement

Wall Class for Wall Avoidance

Started by April 04, 2010 06:48 AM
4 comments, last by Eddycharly 14 years, 7 months ago
So im doing Wall avoidance now. For the wall is a class with a point for the start and a point for the end of the wall enough? (i dont care about the y value of the wall, our characters cant jump). How then do i go about representing doors? I can get the normal for the wall from the start and end points.
Quote: For the wall is a class with a point for the start and a point for the end of the wall enough?
Yes, it should be. Any other info you need (generally speaking) can be derived from the start and end points (either on demand, or as a preprocessing step).
Quote: How then do i go about representing doors?
Just split the wall into two walls, one on each side of the door?
Advertisement
christ, i even said i wasnt using the y in my question but i was thinking the part of the wall over the door would cause a problem. Slow as a wet week today i am.
Anyone tell me if this is right for calculating the normal, taking note that the y doesnt matter

void calculateNormal()
{
Vector3D temp = end - start;
temp.normalize();

normal.x = -temp.z;
normal.y = temp.y;
normal.z = temp.x;
}
Yup, that looks fine. The only real variable is which direction you want the normal to point (if you want it to point the other way, just swap the signs of x and z).

[Edit: I don't know what the significance of the 'y' value is for your walls, but if it's not already zero, you'll need to zero it out, as shown in Eddycharly's post below.]

[Edited by - jyk on April 5, 2010 1:37:27 PM]
nop, i's not correct. in your very special case you could do :

void calculateNormal()
{
Vector3D temp = end - start;

// ignore y vector component
temp.y = 0;

temp.normalize();

normal.x = -temp.z;

// ignore y component, it will be 0 anyway as we setted it to 0 in the input
normal.y = 0;

normal.z = temp.x;
}

it is equivalent to the 2D case.
in 3D it is more complicated, you have to use a cross product from two vectors lying on the plane to find the normal.

This topic is closed to new replies.

Advertisement