Merge branch 'master' of https://github.com/highfidelity/hifi into yellow

This commit is contained in:
Sam Gateau 2015-07-23 16:32:00 -07:00
commit a002560003
7 changed files with 50 additions and 26 deletions

View file

@ -54,7 +54,7 @@
using namespace std;
const glm::vec3 DEFAULT_UP_DIRECTION(0.0f, 1.0f, 0.0f);
const float YAW_SPEED = 500.0f; // degrees/sec
const float YAW_SPEED = 150.0f; // degrees/sec
const float PITCH_SPEED = 100.0f; // degrees/sec
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
@ -1290,22 +1290,34 @@ bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const {
void MyAvatar::updateOrientation(float deltaTime) {
// Smoothly rotate body with arrow keys
_bodyYawDelta -= _driveKeys[ROT_RIGHT] * YAW_SPEED * deltaTime;
_bodyYawDelta += _driveKeys[ROT_LEFT] * YAW_SPEED * deltaTime;
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
float driveLeft = _driveKeys[ROT_LEFT] - _driveKeys[ROT_RIGHT];
float targetSpeed = (_driveKeys[ROT_LEFT] - _driveKeys[ROT_RIGHT]) * YAW_SPEED;
if (targetSpeed != 0.0f) {
const float ROTATION_RAMP_TIMESCALE = 0.1f;
float blend = deltaTime / ROTATION_RAMP_TIMESCALE;
if (blend > 1.0f) {
blend = 1.0f;
}
_bodyYawDelta = (1.0f - blend) * _bodyYawDelta + blend * targetSpeed;
} else if (_bodyYawDelta != 0.0f) {
// attenuate body rotation speed
const float ROTATION_DECAY_TIMESCALE = 0.05f;
float attenuation = 1.0f - deltaTime / ROTATION_DECAY_TIMESCALE;
if (attenuation < 0.0f) {
attenuation = 0.0f;
}
_bodyYawDelta *= attenuation;
float MINIMUM_ROTATION_RATE = 2.0f;
if (fabsf(_bodyYawDelta) < MINIMUM_ROTATION_RATE) {
_bodyYawDelta = 0.0f;
}
}
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
// update body orientation by movement inputs
setOrientation(getOrientation() *
glm::quat(glm::radians(glm::vec3(0.0f, _bodyYawDelta, 0.0f) * deltaTime)));
// decay body rotation momentum
const float BODY_SPIN_FRICTION = 7.5f;
float bodySpinMomentum = 1.0f - BODY_SPIN_FRICTION * deltaTime;
if (bodySpinMomentum < 0.0f) { bodySpinMomentum = 0.0f; }
_bodyYawDelta *= bodySpinMomentum;
float MINIMUM_ROTATION_RATE = 2.0f;
if (fabs(_bodyYawDelta) < MINIMUM_ROTATION_RATE) { _bodyYawDelta = 0.0f; }
glm::quat(glm::radians(glm::vec3(0.0f, _bodyYawDelta * deltaTime, 0.0f))));
if (qApp->isHMDMode()) {
// these angles will be in radians

View file

@ -21,6 +21,9 @@ float evalOpaqueFinalAlpha(float alpha, float mapAlpha) {
return mix(alpha * glowIntensity, 1.0 - alpha * glowIntensity, step(mapAlpha, alphaThreshold));
}
const vec3 DEFAULT_SPECULAR = vec3(0.1);
const float DEFAULT_SHININESS = 10;
void packDeferredFragment(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess) {
if (alpha != glowIntensity) {
discard;

View file

@ -142,6 +142,10 @@ void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured,
bool emmisive, bool depthBias) {
SimpleProgramKey config{textured, culled, emmisive, depthBias};
batch.setPipeline(getPipeline(config));
gpu::ShaderPointer program = (config.isEmissive()) ? _emissiveShader : _simpleShader;
int glowIntensity = program->getUniforms().findLocation("glowIntensity");
batch._glUniform1f(glowIntensity, 1.0f);
if (!config.isTextured()) {
// If it is not textured, bind white texture and keep using textured pipeline

View file

@ -22,6 +22,5 @@ void main(void) {
normalize(interpolatedNormal.xyz),
glowIntensity,
gl_Color.rgb,
gl_FrontMaterial.specular.rgb,
gl_FrontMaterial.shininess);
DEFAULT_SPECULAR, DEFAULT_SHININESS);
}

View file

@ -27,6 +27,5 @@ void main(void) {
normalize(interpolatedNormal.xyz),
glowIntensity * texel.a,
gl_Color.rgb * texel.rgb,
gl_FrontMaterial.specular.rgb,
gl_FrontMaterial.shininess);
DEFAULT_SPECULAR, DEFAULT_SHININESS);
}

View file

@ -27,7 +27,6 @@ void main(void) {
normalize(interpolatedNormal.xyz),
glowIntensity * texel.a,
gl_Color.rgb,
gl_FrontMaterial.specular.rgb,
gl_FrontMaterial.shininess,
DEFAULT_SPECULAR, DEFAULT_SHININESS,
texel.rgb);
}

View file

@ -46,13 +46,21 @@
static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
qCDebug(scriptengine) << "script:print()<<" << context->argument(0).toString();
QString message = context->argument(0).toString()
.replace("\\", "\\\\")
.replace("\n", "\\n")
.replace("\r", "\\r")
.replace("'", "\\'");
QString message = "";
for (int i = 0; i < context->argumentCount(); i++) {
if (i > 0) {
message += " ";
}
message += context->argument(i).toString();
}
qCDebug(scriptengine) << "script:print()<<" << message;
message = message.replace("\\", "\\\\")
.replace("\n", "\\n")
.replace("\r", "\\r")
.replace("'", "\\'");
engine->evaluate("Script.print('" + message + "')");
return QScriptValue();
}