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