Working with sky boxes

This commit is contained in:
Vladislav Khorev 2024-06-09 01:09:40 +03:00
parent 79cfbeada3
commit 737b30e8ec
2 changed files with 46 additions and 26 deletions

View File

@ -60,12 +60,12 @@ public:
void SetGLCamAngleView(); void SetGLCamAngleView();
void SetGLCamView(); void SetGLCamView();
void SetGlIdentityView(); void SetGlIdentityView();
void SetGlPosXView(bool renderToFrame = false); void SetGlPosXView(bool translate = true, bool renderToFrame = false);
void SetGlNegXView(bool renderToFrame = false); void SetGlNegXView(bool translate = true, bool renderToFrame = false);
void SetGlPosYView(bool renderToFrame = false); void SetGlPosYView(bool translate = true, bool renderToFrame = false);
void SetGlNegYView(bool renderToFrame = false); void SetGlNegYView(bool translate = true, bool renderToFrame = false);
void SetGlPosZView(bool renderToFrame = false); void SetGlPosZView(bool translate = true, bool renderToFrame = false);
void SetGlNegZView(bool renderToFrame = false); void SetGlNegZView(bool translate = true, bool renderToFrame = false);
void MoveAlpha(float dAlpha); void MoveAlpha(float dAlpha);

View File

@ -5,6 +5,7 @@
namespace SE namespace SE
{ {
const float speed_coef = 0.1;
TSalmonRendererInterface::TSalmonRendererInterface() TSalmonRendererInterface::TSalmonRendererInterface()
@ -198,6 +199,7 @@ void TSalmonRendererInterface::SetGLCamAngleView()
TranslateMatrix(CamPos); TranslateMatrix(CamPos);
CamModelViewMatrix = ModelviewMatrixStack.top(); CamModelViewMatrix = ModelviewMatrixStack.top();
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);
@ -251,7 +253,7 @@ void TSalmonRendererInterface::SetGlIdentityView()
SetUniforms(); SetUniforms();
} }
void TSalmonRendererInterface::SetGlPosXView(bool renderToFrame) void TSalmonRendererInterface::SetGlPosXView(bool translate, bool renderToFrame)
{ {
/* /*
glLoadIdentity(); glLoadIdentity();
@ -273,7 +275,10 @@ void TSalmonRendererInterface::SetGlPosXView(bool renderToFrame)
{ {
RotateMatrix(vec4(0.f, 1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f))); RotateMatrix(vec4(0.f, 1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f)));
} }
TranslateMatrix(-CamPos); if (translate)
{
TranslateMatrix(-CamPos);
}
CamModelViewMatrix = ModelviewMatrixStack.top(); CamModelViewMatrix = ModelviewMatrixStack.top();
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);
@ -282,7 +287,7 @@ void TSalmonRendererInterface::SetGlPosXView(bool renderToFrame)
} }
void TSalmonRendererInterface::SetGlNegXView(bool renderToFrame) void TSalmonRendererInterface::SetGlNegXView(bool translate, bool renderToFrame)
{ {
/* /*
glLoadIdentity(); glLoadIdentity();
@ -304,7 +309,10 @@ void TSalmonRendererInterface::SetGlNegXView(bool renderToFrame)
{ {
RotateMatrix(vec4(0.f, 1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f))); RotateMatrix(vec4(0.f, 1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f)));
} }
TranslateMatrix(-CamPos); if (translate)
{
TranslateMatrix(-CamPos);
}
CamModelViewMatrix = ModelviewMatrixStack.top(); CamModelViewMatrix = ModelviewMatrixStack.top();
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);
@ -312,7 +320,7 @@ void TSalmonRendererInterface::SetGlNegXView(bool renderToFrame)
SetUniforms(); SetUniforms();
} }
void TSalmonRendererInterface::SetGlPosYView(bool renderToFrame) void TSalmonRendererInterface::SetGlPosYView(bool translate, bool renderToFrame)
{ {
/* /*
glLoadIdentity(); glLoadIdentity();
@ -326,7 +334,10 @@ void TSalmonRendererInterface::SetGlPosYView(bool renderToFrame)
LoadIdentity(); LoadIdentity();
RotateMatrix(vec4(-1.f * sin(pi / 4.f), 0.0f, 0.f, 1.f * cos(pi / 4.f))); RotateMatrix(vec4(-1.f * sin(pi / 4.f), 0.0f, 0.f, 1.f * cos(pi / 4.f)));
TranslateMatrix(-CamPos); if (translate)
{
TranslateMatrix(-CamPos);
}
CamModelViewMatrix = ModelviewMatrixStack.top(); CamModelViewMatrix = ModelviewMatrixStack.top();
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);
@ -335,7 +346,7 @@ void TSalmonRendererInterface::SetGlPosYView(bool renderToFrame)
} }
void TSalmonRendererInterface::SetGlNegYView(bool renderToFrame) void TSalmonRendererInterface::SetGlNegYView(bool translate, bool renderToFrame)
{ {
/* /*
glLoadIdentity(); glLoadIdentity();
@ -348,7 +359,10 @@ void TSalmonRendererInterface::SetGlNegYView(bool renderToFrame)
LoadIdentity(); LoadIdentity();
RotateMatrix(vec4(1.f * sin(pi / 4.f), 0.0f, 0.f, 1.f * cos(pi / 4.f))); RotateMatrix(vec4(1.f * sin(pi / 4.f), 0.0f, 0.f, 1.f * cos(pi / 4.f)));
TranslateMatrix(-CamPos); if (translate)
{
TranslateMatrix(-CamPos);
}
CamModelViewMatrix = ModelviewMatrixStack.top(); CamModelViewMatrix = ModelviewMatrixStack.top();
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);
@ -356,7 +370,7 @@ void TSalmonRendererInterface::SetGlNegYView(bool renderToFrame)
SetUniforms(); SetUniforms();
} }
void TSalmonRendererInterface::SetGlPosZView(bool renderToFrame) void TSalmonRendererInterface::SetGlPosZView(bool translate, bool renderToFrame)
{ {
/* /*
glLoadIdentity(); glLoadIdentity();
@ -376,7 +390,10 @@ void TSalmonRendererInterface::SetGlPosZView(bool renderToFrame)
{ {
RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f))); RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f)));
} }
TranslateMatrix(-CamPos); if (translate)
{
TranslateMatrix(-CamPos);
}
/*LoadIdentity(); /*LoadIdentity();
@ -391,7 +408,7 @@ void TSalmonRendererInterface::SetGlPosZView(bool renderToFrame)
SetUniforms(); SetUniforms();
} }
void TSalmonRendererInterface::SetGlNegZView(bool renderToFrame) void TSalmonRendererInterface::SetGlNegZView(bool translate, bool renderToFrame)
{ {
/* /*
glLoadIdentity(); glLoadIdentity();
@ -409,7 +426,10 @@ void TSalmonRendererInterface::SetGlNegZView(bool renderToFrame)
RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f))); RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f)));
} }
TranslateMatrix(-CamPos); if (translate)
{
TranslateMatrix(-CamPos);
}
CamModelViewMatrix = ModelviewMatrixStack.top(); CamModelViewMatrix = ModelviewMatrixStack.top();
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);
@ -605,9 +625,9 @@ void TSalmonRendererInterface::MoveForward()
float sina = sinf(CamAlpha); float sina = sinf(CamAlpha);
float cosa = cosf(CamAlpha); float cosa = cosf(CamAlpha);
mov.v[0] = sina; mov.v[0] = speed_coef * sina;
mov.v[1] = 0; mov.v[1] = 0;
mov.v[2] = - cosa; mov.v[2] = -speed_coef * cosa;
CamShift = CamShift + mov; CamShift = CamShift + mov;
@ -652,9 +672,9 @@ void TSalmonRendererInterface::MoveBackward()
float sina = sinf(CamAlpha); float sina = sinf(CamAlpha);
float cosa = cosf(CamAlpha); float cosa = cosf(CamAlpha);
mov.v[0] = - sina; mov.v[0] = -speed_coef*sina;
mov.v[1] = 0; mov.v[1] = 0;
mov.v[2] = cosa; mov.v[2] = speed_coef * cosa;
CamShift = CamShift + mov; CamShift = CamShift + mov;
//Possibly refactor??? //Possibly refactor???
@ -698,9 +718,9 @@ void TSalmonRendererInterface::MoveLeft()
float sina = sinf(CamAlpha); float sina = sinf(CamAlpha);
float cosa = cosf(CamAlpha); float cosa = cosf(CamAlpha);
mov.v[0] = - cosa; mov.v[0] = -speed_coef * cosa;
mov.v[1] = 0; mov.v[1] = 0;
mov.v[2] = - sina; mov.v[2] = -speed_coef * sina;
CamShift = CamShift + mov; CamShift = CamShift + mov;
@ -742,8 +762,8 @@ void TSalmonRendererInterface::MoveRight()
{ {
vec3 mov; vec3 mov;
float sina = sinf(CamAlpha); float sina = speed_coef * sinf(CamAlpha);
float cosa = cosf(CamAlpha); float cosa = speed_coef * cosf(CamAlpha);
mov.v[0] = cosa; mov.v[0] = cosa;
mov.v[1] = 0; mov.v[1] = 0;