Rave tweaks per Ryan's request: Mood lighting for the avatars. This also sets us up to have light coming from the effects, if we want.

This commit is contained in:
Eric Johnston 2013-08-06 16:45:15 -07:00
parent 8a912feb32
commit 378cb343ae
4 changed files with 45 additions and 20 deletions

View file

@ -2935,6 +2935,27 @@ void Application::displayOculus(Camera& whichCamera) {
glPopMatrix();
}
void Application::setupWorldLight(Camera& whichCamera) {
// Setup 3D lights (after the camera transform, so that they are positioned in world space)
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glm::vec3 relativeSunLoc = glm::normalize(_environment.getClosestData(whichCamera.getPosition()).getSunLocation() -
whichCamera.getPosition());
GLfloat light_position0[] = { relativeSunLoc.x, relativeSunLoc.y, relativeSunLoc.z, 0.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
GLfloat ambient_color[] = { 0.7, 0.7, 0.8 };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 };
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0};
glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color);
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
glMateriali(GL_FRONT, GL_SHININESS, 96);
}
void Application::displaySide(Camera& whichCamera) {
// transform by eye offset
@ -2964,22 +2985,7 @@ void Application::displaySide(Camera& whichCamera) {
glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z);
// Setup 3D lights (after the camera transform, so that they are positioned in world space)
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glm::vec3 relativeSunLoc = glm::normalize(_environment.getClosestData(whichCamera.getPosition()).getSunLocation() -
whichCamera.getPosition());
GLfloat light_position0[] = { relativeSunLoc.x, relativeSunLoc.y, relativeSunLoc.z, 0.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
GLfloat ambient_color[] = { 0.7, 0.7, 0.8 };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 };
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0};
glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color);
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
glMateriali(GL_FRONT, GL_SHININESS, 96);
setupWorldLight(whichCamera);
if (_renderStarsOn->isChecked()) {
if (!_stars.getFileLoaded()) {
@ -3074,7 +3080,7 @@ void Application::displaySide(Camera& whichCamera) {
glEnable(GL_LIGHTING);
}
_myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS);
_myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);
if (_renderAvatarsOn->isChecked()) {
// Render avatars of other nodes
@ -3110,6 +3116,8 @@ void Application::displaySide(Camera& whichCamera) {
}
}
_myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera);
if (_renderParticleSystemOn->isChecked()) {
if (_particleSystemInitialized) {
_particleSystem.render();

View file

@ -118,6 +118,7 @@ public:
GeometryCache* getGeometryCache() { return &_geometryCache; }
void resetSongMixMenuItem();
void setupWorldLight(Camera& whichCamera);
virtual void nodeAdded(Node* node);
virtual void nodeKilled(Node* node);

View file

@ -1220,11 +1220,27 @@ void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) {
}
}
void Avatar::renderScreenTint(ScreenTintLayer layer) {
void Avatar::renderScreenTint(ScreenTintLayer layer, Camera& whichCamera) {
if (layer == SCREEN_TINT_BEFORE_AVATARS) {
if (_hand.isRaveGloveActive()) {
_hand.renderRaveGloveStage();
// Set some mood lighting
GLfloat ambient_color[] = { 0.0, 0.0, 0.0 };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
GLfloat diffuse_color[] = { 0.4, 0.0, 0.0 };
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
GLfloat specular_color[] = { 0.0, 0.0, 0.0, 0.0};
glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color);
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
glMateriali(GL_FRONT, GL_SHININESS, 0);
}
}
else if (layer == SCREEN_TINT_BEFORE_AVATARS) {
if (_hand.isRaveGloveActive()) {
// Restore the world lighting
Application::getInstance()->setupWorldLight(whichCamera);
}
}
}

View file

@ -117,7 +117,7 @@ enum ScreenTintLayer
SCREEN_TINT_BEFORE_LANDSCAPE = 0,
SCREEN_TINT_BEFORE_AVATARS,
SCREEN_TINT_BEFORE_MY_AVATAR,
SCREEN_TINT_AFTER_MY_AVATAR,
SCREEN_TINT_AFTER_AVATARS,
NUM_SCREEN_TINT_LAYERS
};
@ -136,7 +136,7 @@ public:
void addBodyYaw(float bodyYaw) {_bodyYaw += bodyYaw;};
void addBodyYawDelta(float bodyYawDelta) {_bodyYawDelta += bodyYawDelta;}
void render(bool lookingInMirror, bool renderAvatarBalls);
void renderScreenTint(ScreenTintLayer layer);
void renderScreenTint(ScreenTintLayer layer, Camera& whichCamera);
//setters
void setMousePressed (bool mousePressed ) { _mousePressed = mousePressed;}