mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 00:49:19 +02:00
Change Math3D::vector3 to glm::dvec3 in TCamera class
This commit is contained in:
@@ -378,7 +378,7 @@ openal_renderer::update( double const Deltatime ) {
|
|||||||
// orientation
|
// orientation
|
||||||
glm::dmat4 cameramatrix;
|
glm::dmat4 cameramatrix;
|
||||||
Global.pCamera.SetMatrix( cameramatrix );
|
Global.pCamera.SetMatrix( cameramatrix );
|
||||||
auto cameraposition = Global.pCamera.Pos + (Global.viewport_move * glm::mat3(cameramatrix));
|
auto cameraposition = Global.pCamera.Pos + glm::dvec3((Global.viewport_move * glm::mat3(cameramatrix)));
|
||||||
cameramatrix = glm::dmat4(glm::inverse(Global.viewport_rotate)) * cameramatrix;
|
cameramatrix = glm::dmat4(glm::inverse(Global.viewport_rotate)) * cameramatrix;
|
||||||
auto rotationmatrix { glm::mat3{ cameramatrix } };
|
auto rotationmatrix { glm::mat3{ cameramatrix } };
|
||||||
glm::vec3 const orientation[] = {
|
glm::vec3 const orientation[] = {
|
||||||
|
|||||||
@@ -2277,7 +2277,7 @@ opengl_renderer::Render( scene::shape_node const &Shape, bool const Ignorerange
|
|||||||
case rendermode::shadows:
|
case rendermode::shadows:
|
||||||
case rendermode::cabshadows: {
|
case rendermode::cabshadows: {
|
||||||
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
||||||
distancesquared = Math3D::SquareMagnitude( ( data.area.center - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor;
|
distancesquared = Math3D::SquareMagnitude( ( data.area.center - Global.pCamera.Pos ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case rendermode::reflections: {
|
case rendermode::reflections: {
|
||||||
@@ -3505,7 +3505,7 @@ opengl_renderer::Render_Alpha( TAnimModel *Instance ) {
|
|||||||
switch( m_renderpass.draw_mode ) {
|
switch( m_renderpass.draw_mode ) {
|
||||||
case rendermode::shadows: {
|
case rendermode::shadows: {
|
||||||
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
||||||
distancesquared = Math3D::SquareMagnitude( ( Instance->location() - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor;
|
distancesquared = Math3D::SquareMagnitude( ( Instance->location() - Global.pCamera.Pos ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ void vector3::RotateY(double angle)
|
|||||||
x = (cos(angle) * x + z * sin(angle));
|
x = (cos(angle) * x + z * sin(angle));
|
||||||
z = (z * cos(angle) - sin(angle) * tx);
|
z = (z * cos(angle) - sin(angle) * tx);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
glm::vec3 RotateY(glm::vec3 v, float angle)
|
||||||
|
{
|
||||||
|
float s = sin(angle);
|
||||||
|
float c = cos(angle);
|
||||||
|
|
||||||
|
return glm::vec3(c * v.x + s * v.z, v.y, c * v.z - s * v.x);
|
||||||
|
}
|
||||||
|
|
||||||
void vector3::RotateZ(double angle)
|
void vector3::RotateZ(double angle)
|
||||||
{
|
{
|
||||||
double ty = y;
|
double ty = y;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
namespace Math3D
|
namespace Math3D
|
||||||
{
|
{
|
||||||
|
|
||||||
|
glm::vec3 RotateY(glm::vec3 v, float angle);
|
||||||
|
|
||||||
// Define this to have Math3D.cp generate a main which tests these classes
|
// Define this to have Math3D.cp generate a main which tests these classes
|
||||||
//#define TEST_MATH3D
|
//#define TEST_MATH3D
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void TCamera::Init( Math3D::vector3 const &NPos, Math3D::vector3 const &NAngle/*, TCameraType const NType*/, TDynamicObject *Owner ) {
|
void TCamera::Init(glm::vec3 const &NPos, glm::vec3 const &NAngle /*, TCameraType const NType*/, TDynamicObject *Owner)
|
||||||
|
{
|
||||||
|
|
||||||
vUp = { 0, 1, 0 };
|
vUp = { 0, 1, 0 };
|
||||||
Velocity = { 0, 0, 0 };
|
Velocity = { 0, 0, 0 };
|
||||||
@@ -170,7 +171,7 @@ void TCamera::Update()
|
|||||||
|| ( true == DebugCameraFlag ) ) {
|
|| ( true == DebugCameraFlag ) ) {
|
||||||
// free movement position update
|
// free movement position update
|
||||||
auto movement { Velocity };
|
auto movement { Velocity };
|
||||||
movement.RotateY( Angle.y );
|
movement = Math3D::RotateY(movement, Angle.y);
|
||||||
Pos += movement * 5.0 * deltatime;
|
Pos += movement * 5.0 * deltatime;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -193,7 +194,7 @@ void TCamera::Update()
|
|||||||
movement.y = -movement.y;
|
movement.y = -movement.y;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
movement.RotateY( Angle.y );
|
movement = Math3D::RotateY(movement, Angle.y);
|
||||||
|
|
||||||
m_owneroffset += movement * deltatime;
|
m_owneroffset += movement * deltatime;
|
||||||
}
|
}
|
||||||
@@ -221,7 +222,7 @@ bool TCamera::SetMatrix( glm::dmat4 &Matrix ) {
|
|||||||
|
|
||||||
void TCamera::RaLook()
|
void TCamera::RaLook()
|
||||||
{ // zmiana kierunku patrzenia - przelicza Yaw
|
{ // zmiana kierunku patrzenia - przelicza Yaw
|
||||||
Math3D::vector3 where = LookAt - Pos /*+ Math3D::vector3(0, 3, 0)*/; // trochę w górę od szyn
|
Math3D::vector3 where = glm::dvec3(LookAt )- Pos /*+ Math3D::vector3(0, 3, 0)*/; // trochę w górę od szyn
|
||||||
if( ( where.x != 0.0 ) || ( where.z != 0.0 ) ) {
|
if( ( where.x != 0.0 ) || ( where.z != 0.0 ) ) {
|
||||||
Angle.y = atan2( -where.x, -where.z ); // kąt horyzontalny
|
Angle.y = atan2( -where.x, -where.z ); // kąt horyzontalny
|
||||||
m_rotationoffsets.y = 0.0;
|
m_rotationoffsets.y = 0.0;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "utilities/dumb3d.h"
|
|
||||||
#include "input/command.h"
|
#include "input/command.h"
|
||||||
#include "vehicle/DynObj.h"
|
#include "vehicle/DynObj.h"
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
class TCamera {
|
class TCamera {
|
||||||
|
|
||||||
public: // McZapkie: potrzebuje do kiwania na boki
|
public: // McZapkie: potrzebuje do kiwania na boki
|
||||||
void Init( Math3D::vector3 const &Location, Math3D::vector3 const &Angle, TDynamicObject *Owner );
|
void Init(glm::vec3 const &Location, glm::vec3 const &Angle, TDynamicObject *Owner);
|
||||||
void Reset();
|
void Reset();
|
||||||
void OnCursorMove(double const x, double const y);
|
void OnCursorMove(double const x, double const y);
|
||||||
bool OnCommand( command_data const &Command );
|
bool OnCommand( command_data const &Command );
|
||||||
@@ -26,14 +25,14 @@ class TCamera {
|
|||||||
bool SetMatrix(glm::dmat4 &Matrix);
|
bool SetMatrix(glm::dmat4 &Matrix);
|
||||||
void RaLook();
|
void RaLook();
|
||||||
|
|
||||||
Math3D::vector3 Angle; // pitch, yaw, roll
|
glm::dvec3 Angle; // pitch, yaw, roll
|
||||||
Math3D::vector3 Pos; // współrzędne obserwatora
|
glm::dvec3 Pos; // współrzędne obserwatora
|
||||||
Math3D::vector3 LookAt; // współrzędne punktu, na który ma patrzeć
|
glm::vec3 LookAt; // współrzędne punktu, na który ma patrzeć
|
||||||
Math3D::vector3 vUp;
|
glm::vec3 vUp;
|
||||||
Math3D::vector3 Velocity;
|
glm::dvec3 Velocity;
|
||||||
|
|
||||||
TDynamicObject *m_owner { nullptr }; // TODO: change to const when shake calculations are part of vehicles update
|
TDynamicObject *m_owner { nullptr }; // TODO: change to const when shake calculations are part of vehicles update
|
||||||
Math3D::vector3 m_owneroffset {};
|
glm::vec3 m_owneroffset{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
glm::dvec3 m_moverate;
|
glm::dvec3 m_moverate;
|
||||||
|
|||||||
Reference in New Issue
Block a user