mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 12:39:56 +00:00
FREESCAPE: perspective correction in drawEclipse
This commit is contained in:
parent
b9e39e80e1
commit
a9026919d4
@ -1002,9 +1002,9 @@ void Renderer::drawBackground(uint8 color) {
|
||||
|
||||
void Renderer::drawEclipse(byte color1, byte color2, float progress) {
|
||||
Math::Vector3d sunPosition(-5000, 1200, 0);
|
||||
float radius = 500.0;
|
||||
float radius = 400.0;
|
||||
drawCelestialBody(sunPosition, radius, color1);
|
||||
Math::Vector3d moonPosition(-5000, 1200, 0 + 500 * progress);
|
||||
Math::Vector3d moonPosition(-5000, 1200, 800 * progress);
|
||||
drawCelestialBody(moonPosition, radius, color2);
|
||||
}
|
||||
|
||||
|
@ -314,11 +314,12 @@ void OpenGLRenderer::drawCelestialBody(Math::Vector3d position, float radius, by
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
copyToVertexArray(0, position);
|
||||
float adj = 1.25; // Perspective correction
|
||||
|
||||
for(int i = 0; i <= triangleAmount; i++) {
|
||||
copyToVertexArray(i + 1,
|
||||
Math::Vector3d(position.x(), position.y() + (radius * cos(i * twicePi / triangleAmount)),
|
||||
position.z() + (radius * sin(i * twicePi / triangleAmount)))
|
||||
position.z() + (adj * radius * sin(i * twicePi / triangleAmount)))
|
||||
);
|
||||
}
|
||||
|
||||
@ -336,7 +337,7 @@ void OpenGLRenderer::drawCelestialBody(Math::Vector3d position, float radius, by
|
||||
for(int i = 0; i <= triangleAmount; i++) {
|
||||
copyToVertexArray(i + 1,
|
||||
Math::Vector3d(position.x(), position.y() + (radius * cos(i * twicePi / triangleAmount)),
|
||||
position.z() + (radius * sin(i * twicePi / triangleAmount)))
|
||||
position.z() + (adj * radius * sin(i * twicePi / triangleAmount)))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -304,6 +304,7 @@ void OpenGLShaderRenderer::drawCelestialBody(Math::Vector3d position, float radi
|
||||
|
||||
int triangleAmount = 20;
|
||||
float twicePi = (float)(2.0 * M_PI);
|
||||
float adj = 1.25; // Perspective correction
|
||||
|
||||
// Quick billboard effect inspired from this code:
|
||||
// http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat
|
||||
@ -332,7 +333,7 @@ void OpenGLShaderRenderer::drawCelestialBody(Math::Vector3d position, float radi
|
||||
for(int i = 0; i <= triangleAmount; i++) {
|
||||
float x = position.x();
|
||||
float y = position.y() + (radius * cos(i * twicePi / triangleAmount));
|
||||
float z = position.z() + (radius * sin(i * twicePi / triangleAmount));
|
||||
float z = position.z() + (adj * radius * sin(i * twicePi / triangleAmount));
|
||||
copyToVertexArray(i + 1, Math::Vector3d(x, y, z));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user