Add shaders for planetographic grid
parent
7025800e98
commit
8005ac1577
|
@ -91,6 +91,10 @@ PlanetographicGrid::render(Renderer* renderer,
|
||||||
float discSizeInPixels,
|
float discSizeInPixels,
|
||||||
double tdb) const
|
double tdb) const
|
||||||
{
|
{
|
||||||
|
auto *prog = renderer->getShaderManager().getShader("uniform_color");
|
||||||
|
if (prog == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
// Compatibility
|
// Compatibility
|
||||||
Quaterniond q = Quaterniond(AngleAxis<double>(PI, Vector3d::UnitY())) * body.getEclipticToBodyFixed(tdb);
|
Quaterniond q = Quaterniond(AngleAxis<double>(PI, Vector3d::UnitY())) * body.getEclipticToBodyFixed(tdb);
|
||||||
Quaternionf qf = q.cast<float>();
|
Quaternionf qf = q.cast<float>();
|
||||||
|
@ -116,8 +120,6 @@ PlanetographicGrid::render(Renderer* renderer,
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glRotate(qf.conjugate());
|
glRotate(qf.conjugate());
|
||||||
glScale(scale * semiAxes);
|
glScale(scale * semiAxes);
|
||||||
|
@ -139,6 +141,8 @@ PlanetographicGrid::render(Renderer* renderer,
|
||||||
longitudeStep = 30.0f;
|
longitudeStep = 30.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prog->use();
|
||||||
|
|
||||||
for (float latitude = -90.0f + latitudeStep; latitude < 90.0f; latitude += latitudeStep)
|
for (float latitude = -90.0f + latitudeStep; latitude < 90.0f; latitude += latitudeStep)
|
||||||
{
|
{
|
||||||
float phi = degToRad(latitude);
|
float phi = degToRad(latitude);
|
||||||
|
@ -146,12 +150,12 @@ PlanetographicGrid::render(Renderer* renderer,
|
||||||
|
|
||||||
if (latitude == 0.0f)
|
if (latitude == 0.0f)
|
||||||
{
|
{
|
||||||
glColor(Renderer::PlanetEquatorColor);
|
prog->vec4Param("color") = Renderer::PlanetEquatorColor.toVector4();
|
||||||
glLineWidth(2.0f);
|
glLineWidth(2.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glColor(Renderer::PlanetographicGridColor);
|
prog->vec4Param("color") = Renderer::PlanetographicGridColor.toVector4();
|
||||||
}
|
}
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0.0f, (float) std::sin(phi), 0.0f);
|
glTranslatef(0.0f, (float) std::sin(phi), 0.0f);
|
||||||
|
@ -179,9 +183,9 @@ PlanetographicGrid::render(Renderer* renderer,
|
||||||
|
|
||||||
glVertexPointer(3, GL_FLOAT, 0, xyCircle);
|
glVertexPointer(3, GL_FLOAT, 0, xyCircle);
|
||||||
|
|
||||||
|
prog->vec4Param("color") = Renderer::PlanetographicGridColor.toVector4();
|
||||||
for (float longitude = 0.0f; longitude <= 180.0f; longitude += longitudeStep)
|
for (float longitude = 0.0f; longitude <= 180.0f; longitude += longitudeStep)
|
||||||
{
|
{
|
||||||
glColor(Renderer::PlanetographicGridColor);
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glRotatef(longitude, 0.0f, 1.0f, 0.0f);
|
glRotatef(longitude, 0.0f, 1.0f, 0.0f);
|
||||||
glDrawArrays(GL_LINE_LOOP, 0, circleSubdivisions);
|
glDrawArrays(GL_LINE_LOOP, 0, circleSubdivisions);
|
||||||
|
@ -242,11 +246,9 @@ PlanetographicGrid::render(Renderer* renderer,
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
glUseProgram(0);
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
}
|
}
|
||||||
|
@ -295,11 +297,13 @@ PlanetographicGrid::InitializeGeometry()
|
||||||
for (unsigned int i = 0; i < circleSubdivisions; i++)
|
for (unsigned int i = 0; i < circleSubdivisions; i++)
|
||||||
{
|
{
|
||||||
float theta = (float) (2.0 * PI) * (float) i / (float) circleSubdivisions;
|
float theta = (float) (2.0 * PI) * (float) i / (float) circleSubdivisions;
|
||||||
xyCircle[i * 3 + 0] = (float) std::cos(theta);
|
float s, c;
|
||||||
xyCircle[i * 3 + 1] = (float) std::sin(theta);
|
sincos(theta, s, c);
|
||||||
|
xyCircle[i * 3 + 0] = c;
|
||||||
|
xyCircle[i * 3 + 1] = s;
|
||||||
xyCircle[i * 3 + 2] = 0.0f;
|
xyCircle[i * 3 + 2] = 0.0f;
|
||||||
xzCircle[i * 3 + 0] = (float) std::cos(theta);
|
xzCircle[i * 3 + 0] = c;
|
||||||
xzCircle[i * 3 + 1] = 0.0f;
|
xzCircle[i * 3 + 1] = 0.0f;
|
||||||
xzCircle[i * 3 + 2] = (float) std::sin(theta);
|
xzCircle[i * 3 + 2] = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue