dont flame plz, i browsed the last 100 threads and only found issues insanely more complicated than mine...i just need some simple advice.
all i do is draw a rectangle then try to detect if my current location (xPos,yPos,zPos) is within that rectangle
here is the pseudo
set current position to temp x,y,z variables
recalculate x,y,z position
detect if new x,y,z is within rectangle
if so, set x,y,z to temp variables
its primitive but.....so is my program
the rectClass consists of 6 floats
x,y,z to act as an origin
then l,w,h to create the rectangle
so the first corner is coordinate (x,y,z)
and the far opposite corner is (x+l,y+w,z+h)
the other points can be calculated as combinations of these two sets
anywhoo
here is the function of the rectWall class
bool withinMe(float xVal, float yVal, float zVal)
{
if(((xPos >= x)&&(xPos<=x+l)) || ((xPos <= x)&&(xPos >=x+l)))
if(((yPos >= y)&&(yPos<=y+w)) || ((yPos <= y)&&(yPos >=y+w)))
if(((zPos >= z)&&(zPos<=z+h)) || ((zPos <= z)&&(zPos >=z+h)))
return true;
return false;
}
here is how i call the function
if(keyW)
{
int x = 0;
float tempX = xPos;
float tempY = yPos;
float tempZ = zPos;
vertRotRad = (vertRot / 180 * 3.141592654f);
horiRotRad = (horiRot / 180 * 3.141592654f);
xPos -= float(sin(horiRotRad));
zPos += float(cos(horiRotRad));
yPos += float(sin(vertRotRad));
for(x;x<walls.size();x++)
{
if(walls[x]->withinMe(xPos, yPos, zPos))
{
xPos = tempX;
yPos = tempY;
zPos = tempZ;
break;
}
}
}
my issue is that it withinMe doesnt return true...ever! lol!
so if anyone could shoot me some advice i'd be thankful.
ps-
oh yeah i forgot
walls[x] etc etc
walls is a vector of rectWall*