hey,
im developing a 3d racing game. Since the floor in the game can be
irregular, for example, it can have ramps, downhills, bumps etc...
I want to find the angle in which the floor is inclined so that i
can orient the car in the same angle (x). Im using dbObjectIntersect
() for collisions. Here is part of the code:
//calculate its next position
float NextXFloor = this->Position.x + (dbSin(this->AngleY) * dbObjectCollisionRadius(this->ObjectIndex));
float NextZFloor = this->Position.z + (dbCos(this->AngleY) * dbObjectCollisionRadius(this->ObjectIndex));
float NextXWall = this->Position.x + (dbSin(this->AngleY) * (this->Speed + dbObjectCollisionRadius(this->ObjectIndex)) );
float NextZWall = this->Position.z + (dbCos(this->AngleY) * (this->Speed + dbObjectCollisionRadius(this->ObjectIndex)) );
//////////////////////////////
//check for floor collision //
//////////////////////////////
float CollisionFloorFront = dbIntersectObject(LEVEL_INDEX, this->Position.x, this->Position.y, this->Position.z, this->Position.x, this->Position.y - dbObjectSizeY(this->ObjectIndex), this->Position.z);
float CollisionFloorBack = dbIntersectObject(LEVEL_INDEX, NextXFloor, this->Position.y, NextZFloor, NextXFloor, this->Position.y - dbObjectSizeY(this->ObjectIndex), NextZFloor);
float FloorAngle = 0.0f;
FloorAngle = (dbAtanFull(CollisionFloorFront, CollisionFloorBack) - 45.0f) * -1;
thanks for help!