changes to match latest matrix/vector3 api
This commit is contained in:
@@ -21,7 +21,7 @@ class CameraBase
|
||||
{
|
||||
|
||||
public:
|
||||
CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t_up);
|
||||
CameraBase(ScreenSettings *t_screen, Vector3 *t_position);
|
||||
virtual ~CameraBase(){};
|
||||
|
||||
/**
|
||||
@@ -56,9 +56,10 @@ protected:
|
||||
void updatePlanes(Vector3 t_target);
|
||||
|
||||
private:
|
||||
Vector3 *p_position, *p_up;
|
||||
Vector3 *p_position;
|
||||
float farPlaneDist, nearPlaneDist, nearHeight, nearWidth, farHeight, farWidth;
|
||||
Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr;
|
||||
Vector3 up; // always 0.0F, 1.0F, 0.0F
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -125,7 +125,7 @@ private:
|
||||
void flipBuffers();
|
||||
void beginFrameIfNeeded();
|
||||
u8 isFrameEmpty;
|
||||
Matrix perspective;
|
||||
Matrix perspective, camRotation;
|
||||
Light light;
|
||||
RenderData renderData;
|
||||
TextureRepository textureRepo;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// Constructors/Destructors
|
||||
// ----
|
||||
|
||||
CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t_up)
|
||||
CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position)
|
||||
: screen(t_screen)
|
||||
{
|
||||
PRINT_LOG("Initializing frustum");
|
||||
@@ -30,7 +30,7 @@ CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t
|
||||
farHeight = tang * farPlaneDist;
|
||||
farWidth = farHeight * screen->aspectRatio;
|
||||
p_position = t_position;
|
||||
p_up = t_up;
|
||||
up.set(0.0F, 1.0F, 0.0F);
|
||||
PRINT_LOG("CameraBase initialized!");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t
|
||||
void CameraBase::lookAt(Vector3 &t_target)
|
||||
{
|
||||
updatePlanes(t_target);
|
||||
worldView.lookAt(*p_up, *p_position, t_target);
|
||||
worldView.lookAt(*p_position, t_target);
|
||||
}
|
||||
|
||||
void CameraBase::updatePlanes(Vector3 t_target)
|
||||
@@ -51,7 +51,7 @@ void CameraBase::updatePlanes(Vector3 t_target)
|
||||
Z = *p_position - t_target;
|
||||
Z.normalize();
|
||||
// X axis of camera of given "up" vector and Z axis
|
||||
X = *p_up * Z;
|
||||
X = up * Z;
|
||||
X.normalize();
|
||||
// the real "up" vector is the cross product of Z and X
|
||||
Y = Z * X;
|
||||
|
||||
@@ -277,8 +277,8 @@ void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
if (!t_mesh.isDataLoaded())
|
||||
PRINT_ERR("Can't draw, because no mesh data was loaded!");
|
||||
|
||||
Vector3 rotatedCamera = Vector3(*renderData.cameraPosition);
|
||||
rotatedCamera.rotate(t_mesh.rotation, true);
|
||||
camRotation.rotation(-t_mesh.rotation);
|
||||
Vector3 rotatedCamera = Vector3(camRotation * *renderData.cameraPosition);
|
||||
|
||||
if (t_mesh.getCurrentAnimationFrame() != t_mesh.getNextAnimationFrame())
|
||||
t_mesh.animate();
|
||||
|
||||
@@ -14,12 +14,9 @@
|
||||
|
||||
const float CAMERA_Y = 15.0F;
|
||||
|
||||
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up)
|
||||
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
|
||||
{
|
||||
verticalLevel = 30.0F;
|
||||
up.x = 0.0F;
|
||||
up.y = 1.0F;
|
||||
up.z = 0.0F;
|
||||
}
|
||||
|
||||
Camera::~Camera() {}
|
||||
|
||||
@@ -22,7 +22,7 @@ class Camera : public CameraBase
|
||||
{
|
||||
|
||||
public:
|
||||
Vector3 position,up, unitCirclePosition;
|
||||
Vector3 position, up, unitCirclePosition;
|
||||
float horizontalLevel, verticalLevel;
|
||||
|
||||
Camera(ScreenSettings *t_screen);
|
||||
@@ -34,7 +34,6 @@ public:
|
||||
|
||||
protected:
|
||||
Vector3 *getPosition() { return &position; };
|
||||
Vector3 *getUp() { return &up; };
|
||||
ScreenSettings screen;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,13 +19,10 @@ const float CAMERA_Y = 30.0F;
|
||||
// Constructors/Destructors
|
||||
// ----
|
||||
|
||||
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up)
|
||||
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
|
||||
{
|
||||
PRINT_LOG("Initializing camera");
|
||||
verticalLevel = 80.0F;
|
||||
up.x = 0.0F;
|
||||
up.y = 1.0F;
|
||||
up.z = 0.0F;
|
||||
PRINT_LOG("Camera initialized!");
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ public:
|
||||
|
||||
protected:
|
||||
Vector3 *getPosition() { return &position; };
|
||||
Vector3 *getUp() { return &up; };
|
||||
ScreenSettings screen;
|
||||
};
|
||||
|
||||
|
||||
@@ -211,13 +211,13 @@ FloorsCheck *Player::checkFloors(const FloorManager &t_floorManager, const Vecto
|
||||
for (u32 i = 0; i < t_floorManager.floorAmount; i++)
|
||||
{
|
||||
Utils::getMinMax(t_floorManager.floors[i].mesh, min, max);
|
||||
if (result->currentFloor == NULL && this->mesh.position.isOnSquare(min, max))
|
||||
if (result->currentFloor == NULL && this->mesh.position.isOnBox(min, max))
|
||||
{
|
||||
result->currentFloor = &t_floorManager.floors[i];
|
||||
result->currFloorMin.set(min);
|
||||
result->currFloorMax.set(max);
|
||||
}
|
||||
if (result->willCollideFloor == NULL && t_nextPos.collidesSquare(min, max))
|
||||
if (result->willCollideFloor == NULL && t_nextPos.collidesBox(min, max))
|
||||
{
|
||||
result->willCollideFloor = &t_floorManager.floors[i];
|
||||
result->willCollideFloorMin.set(min);
|
||||
|
||||
Reference in New Issue
Block a user