Renderer changes:

- Added camera orientation property to RenderContext, to be used with software
path for point sprites.
- Enabled location label color overrides
ver1_6_1
Chris Laurel 2008-07-25 23:31:00 +00:00
parent 33aff556f9
commit 99ee3a4102
5 changed files with 63 additions and 78 deletions

View File

@ -134,6 +134,20 @@ RenderContext::getPointScale() const
}
void
RenderContext::setCameraOrientation(const Quatf& q)
{
cameraOrientation = q;
}
Quatf
RenderContext::getCameraOrientation() const
{
return cameraOrientation;
}
void
RenderContext::drawGroup(const Mesh::PrimitiveGroup& group)
{

View File

@ -10,6 +10,7 @@
#ifndef _CELENGINE_RENDCONTEXT_H_
#define _CELENGINE_RENDCONTEXT_H_
#include <celmath/quaternion.h>
#include "mesh.h"
#include "shadermanager.h"
@ -44,11 +45,15 @@ class RenderContext
void setPointScale(float);
float getPointScale() const;
void setCameraOrientation(const Quatf& q);
Quatf getCameraOrientation() const;
private:
const Mesh::Material* material;
bool locked;
RenderPass renderPass;
float pointScale;
Quatf cameraOrientation; // required for drawing billboards
protected:
bool usePointSize;

View File

@ -4400,31 +4400,7 @@ static void renderBumpMappedMesh(const GLContext& context,
// The 'default' light vector for the bump map is (0, 0, 1). Determine
// a rotation transformation that will move the sun direction to
// this vector.
Quatf lightOrientation;
{
Vec3f zeroLightDirection(0, 0, 1);
Vec3f axis = lightDirection ^ zeroLightDirection;
float cosAngle = zeroLightDirection * lightDirection;
float angle = 0.0f;
float epsilon = 1e-5f;
if (cosAngle + 1 < epsilon)
{
axis = Vec3f(0, 1, 0);
angle = (float) PI;
}
else if (cosAngle - 1 > -epsilon)
{
axis = Vec3f(0, 1, 0);
angle = 0.0f;
}
else
{
axis.normalize();
angle = (float) acos(cosAngle);
}
lightOrientation.setAxisAngle(axis, angle);
}
Quatf lightOrientation = Quatf::vecToVecRotation(Vec3f(0.0f, 0.0f, 1.0f), lightDirection);
glEnable(GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_ZERO);
@ -4495,31 +4471,7 @@ static void renderSmoothMesh(const GLContext& context,
// The 'default' light vector for the bump map is (0, 0, 1). Determine
// a rotation transformation that will move the sun direction to
// this vector.
Quatf lightOrientation;
{
Vec3f zeroLightDirection(0, 0, 1);
Vec3f axis = lightDirection ^ zeroLightDirection;
float cosAngle = zeroLightDirection * lightDirection;
float angle = 0.0f;
float epsilon = 1e-5f;
if (cosAngle + 1 < epsilon)
{
axis = Vec3f(0, 1, 0);
angle = (float) PI;
}
else if (cosAngle - 1 > -epsilon)
{
axis = Vec3f(0, 1, 0);
angle = 0.0f;
}
else
{
axis.normalize();
angle = (float) acos(cosAngle);
}
lightOrientation.setAxisAngle(axis, angle);
}
Quatf lightOrientation = Quatf::vecToVecRotation(Vec3f(0.0f, 0.0f, 1.0f), lightDirection);
SetupCombinersSmooth(baseTexture, *normalizationTex, ambientColor, invert);
@ -6861,9 +6813,10 @@ void Renderer::renderLocations(const Body& body,
else if (featureType & (Location::EruptiveCenter))
locationMarker = &genericLocationRep;
Color labelColor = location.isLabelColorOverridden() ? location.getLabelColor() : LocationLabelColor;
addObjectAnnotation(locationMarker,
location.getName(true),
LocationLabelColor,
labelColor,
Point3f((float) labelPos.x, (float) labelPos.y, (float) labelPos.z));
}
}
@ -7187,7 +7140,7 @@ void Renderer::renderObject(Point3f pos,
-pos.y / semiAxes.y,
-pos.z / semiAxes.z) * planetMat;
ri.orientation = cameraOrientation;
ri.orientation = cameraOrientation * ~obj.orientation;
ri.pixWidth = discSizeInPixels;
ri.pointScale = 2.0f * obj.radius / pixelSize;
@ -7383,13 +7336,14 @@ void Renderer::renderObject(Point3f pos,
if (lit)
{
renderGeometry_GLSL(geometry,
ri,
texOverride,
ls,
obj.atmosphere,
obj.radius,
renderFlags,
planetMat);
ri,
texOverride,
ls,
obj.atmosphere,
obj.radius,
renderFlags,
planetMat,
astro::daysToSecs(now - astro::J2000));
}
else
{
@ -7398,7 +7352,8 @@ void Renderer::renderObject(Point3f pos,
texOverride,
obj.radius,
renderFlags,
planetMat);
planetMat,
astro::daysToSecs(now - astro::J2000));
}
for (unsigned int i = 1; i < 8;/*context->getMaxTextures();*/ i++)

View File

@ -258,15 +258,19 @@ void renderSphere_GLSL(const RenderInfo& ri,
}
// Render a mesh object
/*! Render a mesh object
* Parameters:
* tsec : animation clock time in seconds
*/
void renderGeometry_GLSL(Geometry* geometry,
const RenderInfo& ri,
ResourceHandle texOverride,
const LightingState& ls,
const Atmosphere* atmosphere,
float radius,
int renderFlags,
const Mat4f& planetMat)
const RenderInfo& ri,
ResourceHandle texOverride,
const LightingState& ls,
const Atmosphere* atmosphere,
float radius,
int renderFlags,
const Mat4f& planetMat,
double tsec)
{
glDisable(GL_LIGHTING);
@ -277,6 +281,7 @@ void renderGeometry_GLSL(Geometry* geometry,
rc.setAtmosphere(atmosphere);
}
rc.setCameraOrientation(ri.orientation);
rc.setPointScale(ri.pointScale);
// Handle extended material attributes (per model only, not per submesh)
@ -295,19 +300,23 @@ void renderGeometry_GLSL(Geometry* geometry,
rc.lock();
}
geometry->render(rc);
geometry->render(rc, tsec);
glx::glUseProgramObjectARB(0);
}
// Render a mesh object unlit
/*! Render a mesh object without lighting.
* Parameters:
* tsec : animation clock time in seconds
*/
void renderGeometry_GLSL_Unlit(Geometry* geometry,
const RenderInfo& ri,
ResourceHandle texOverride,
float radius,
int renderFlags,
const Mat4f& planetMat)
const RenderInfo& ri,
ResourceHandle texOverride,
float radius,
int renderFlags,
const Mat4f& planetMat,
double tsec)
{
glDisable(GL_LIGHTING);
@ -328,7 +337,7 @@ void renderGeometry_GLSL_Unlit(Geometry* geometry,
rc.lock();
}
geometry->render(rc);
geometry->render(rc, tsec);
glx::glUseProgramObjectARB(0);
}

View File

@ -33,7 +33,8 @@ void renderGeometry_GLSL(Geometry* geometry,
const Atmosphere* atmosphere,
float radius,
int renderFlags,
const Mat4f& planetMat);
const Mat4f& planetMat,
double tsec);
void renderClouds_GLSL(const RenderInfo& ri,
const LightingState& ls,
@ -71,7 +72,8 @@ void renderGeometry_GLSL_Unlit(Geometry* geometry,
ResourceHandle texOverride,
float radius,
int renderFlags,
const Mat4f& planetMat);
const Mat4f& planetMat,
double tsec);
#endif // _CELENGINE_RENDERGLSL_H_