Have the local avatar glow when moving.

This commit is contained in:
Andrzej Kapolka 2013-08-22 10:35:21 -07:00
parent 6dbaedd921
commit 165342bcc3
4 changed files with 24 additions and 5 deletions

View file

@ -46,7 +46,6 @@ void OculusManager::updateYawOffset() {
}
void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) {
yaw = pitch = roll = 0.0f;
#ifdef __APPLE__
_sensorFusion.GetOrientation().GetEulerAngles<Axis_Y, Axis_X, Axis_Z, Rotate_CCW, Handed_R>(&yaw, &pitch, &roll);

View file

@ -1477,7 +1477,17 @@ void Avatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) {
if (isMyAvatar() && Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_FIRST_PERSON) {
// Dont display body
} else if (_head.getFace().isFullFrame()) {
return;
}
// glow when moving
const float MIN_GLOW_SPEED = 0.01f;
bool glowing = _speed > MIN_GLOW_SPEED;
if (glowing) {
Application::getInstance()->getGlowEffect()->begin();
}
if (_head.getFace().isFullFrame()) {
// Render the full-frame video
float alpha = getBallRenderAlpha(BODY_BALL_HEAD_BASE, lookingInMirror);
if (alpha > 0.0f) {
@ -1558,6 +1568,10 @@ void Avatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) {
}
}
_hand.render(lookingInMirror);
if (glowing) {
Application::getInstance()->getGlowEffect()->end();
}
}

View file

@ -15,7 +15,7 @@
#include "ProgramObject.h"
#include "RenderUtil.h"
GlowEffect::GlowEffect() : _renderMode(DIFFUSE_ADD_MODE), _isOddFrame(false) {
GlowEffect::GlowEffect() : _renderMode(DIFFUSE_ADD_MODE), _isOddFrame(false), _intensity(0.0f) {
}
QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
@ -70,12 +70,14 @@ void GlowEffect::prepare() {
}
void GlowEffect::begin(float intensity) {
glBlendColor(0.0f, 0.0f, 0.0f, intensity);
// store the current intensity and add the new amount
_intensityStack.push(_intensity);
glBlendColor(0.0f, 0.0f, 0.0f, _intensity += intensity);
_isEmpty = false;
}
void GlowEffect::end() {
glBlendColor(0.0f, 0.0f, 0.0f, 0.0f);
glBlendColor(0.0f, 0.0f, 0.0f, _intensity = _intensityStack.pop());
}
static void maybeBind(QOpenGLFramebufferObject* fbo) {

View file

@ -10,6 +10,7 @@
#define __interface__GlowEffect__
#include <QObject>
#include <QStack>
class QOpenGLFramebufferObject;
@ -63,6 +64,9 @@ private:
bool _isEmpty; ///< set when nothing in the scene is currently glowing
bool _isOddFrame; ///< controls the alternation between texture targets in diffuse add mode
float _intensity;
QStack<float> _intensityStack;
};
#endif /* defined(__interface__GlowEffect__) */