mirror of
https://github.com/lubosz/overte.git
synced 2025-04-16 14:16:36 +02:00
merge upstream/master into andrew/inertia
This commit is contained in:
commit
d032eab0de
10 changed files with 132 additions and 67 deletions
|
@ -17,9 +17,13 @@ var sound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/220Sine.wav");
|
|||
|
||||
var soundPlaying = false;
|
||||
|
||||
var offset = Vec3.normalize(Quat.getFront(MyAvatar.orientation));
|
||||
var position = Vec3.sum(MyAvatar.position, offset);
|
||||
|
||||
function update(deltaTime) {
|
||||
if (!Audio.isInjectorPlaying(soundPlaying)) {
|
||||
soundPlaying = Audio.playSound(sound, {
|
||||
position: position,
|
||||
loop: true
|
||||
});
|
||||
print("Started sound loop");
|
||||
|
|
|
@ -243,9 +243,9 @@ CameraManager = function() {
|
|||
}
|
||||
|
||||
that.mousePressEvent = function(event) {
|
||||
if (cameraTool.mousePressEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
// if (cameraTool.mousePressEvent(event)) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
if (!that.enabled) return;
|
||||
|
||||
|
@ -291,7 +291,7 @@ CameraManager = function() {
|
|||
|
||||
that.updateCamera = function() {
|
||||
if (!that.enabled || Camera.mode != "independent") {
|
||||
cameraTool.update();
|
||||
// cameraTool.update();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ CameraManager = function() {
|
|||
|
||||
Camera.setOrientation(q);
|
||||
|
||||
cameraTool.update();
|
||||
// cameraTool.update();
|
||||
}
|
||||
|
||||
function normalizeDegrees(degrees) {
|
||||
|
@ -383,7 +383,7 @@ CameraManager = function() {
|
|||
|
||||
Controller.wheelEvent.connect(that.wheelEvent);
|
||||
|
||||
var cameraTool = new CameraTool(that);
|
||||
// var cameraTool = new CameraTool(that);
|
||||
|
||||
return that;
|
||||
}
|
||||
|
|
|
@ -2907,7 +2907,7 @@ void Application::updateShadowMap() {
|
|||
|
||||
{
|
||||
PerformanceTimer perfTimer("entities");
|
||||
_entities.render(RenderArgs::SHADOW_RENDER_MODE);
|
||||
// _entities.render(RenderArgs::SHADOW_RENDER_MODE);
|
||||
}
|
||||
|
||||
// render JS/scriptable overlays
|
||||
|
|
|
@ -146,11 +146,6 @@ void SixenseManager::update(float deltaTime) {
|
|||
#ifdef HAVE_SIXENSE
|
||||
Hand* hand = Application::getInstance()->getAvatar()->getHand();
|
||||
if (_isInitialized && _isEnabled) {
|
||||
// Disable the hands (and return to default pose) if both controllers are at base station
|
||||
for (std::vector<PalmData>::iterator it = hand->getPalms().begin(); it != hand->getPalms().end(); it++) {
|
||||
it->setActive(!_controllersAtBase);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
SixenseBaseFunction sixenseGetNumActiveControllers =
|
||||
(SixenseBaseFunction) _sixenseLibrary->resolve("sixenseGetNumActiveControllers");
|
||||
|
@ -213,6 +208,14 @@ void SixenseManager::update(float deltaTime) {
|
|||
qDebug("Found new Sixense controller, ID %i", data->controller_index);
|
||||
}
|
||||
|
||||
// Disable the hands (and return to default pose) if both controllers are at base station
|
||||
if (foundHand) {
|
||||
palm->setActive(!_controllersAtBase);
|
||||
} else {
|
||||
palm->setActive(false); // if this isn't a Sixsense ID palm, always make it inactive
|
||||
}
|
||||
|
||||
|
||||
// Read controller buttons and joystick into the hand
|
||||
palm->setControllerButtons(data->buttons);
|
||||
palm->setTrigger(data->trigger);
|
||||
|
|
|
@ -63,8 +63,8 @@ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
|||
_changedOnServer = 0;
|
||||
|
||||
_position = glm::vec3(0,0,0);
|
||||
_rotation = DEFAULT_ROTATION;
|
||||
_dimensions = DEFAULT_DIMENSIONS;
|
||||
_rotation = DEFAULT_ROTATION;
|
||||
_glowLevel = DEFAULT_GLOW_LEVEL;
|
||||
_localRenderAlpha = DEFAULT_LOCAL_RENDER_ALPHA;
|
||||
_mass = DEFAULT_MASS;
|
||||
|
@ -72,13 +72,15 @@ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
|||
_gravity = DEFAULT_GRAVITY;
|
||||
_damping = DEFAULT_DAMPING;
|
||||
_lifetime = DEFAULT_LIFETIME;
|
||||
_userData = DEFAULT_USER_DATA;
|
||||
_script = DEFAULT_SCRIPT;
|
||||
_registrationPoint = DEFAULT_REGISTRATION_POINT;
|
||||
_angularVelocity = DEFAULT_ANGULAR_VELOCITY;
|
||||
_angularDamping = DEFAULT_ANGULAR_DAMPING;
|
||||
_visible = DEFAULT_VISIBLE;
|
||||
_ignoreForCollisions = DEFAULT_IGNORE_FOR_COLLISIONS;
|
||||
_collisionsWillMove = DEFAULT_COLLISIONS_WILL_MOVE;
|
||||
_locked = DEFAULT_LOCKED;
|
||||
_userData = DEFAULT_USER_DATA;
|
||||
|
||||
recalculateCollisionShape();
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ void JointState::clearTransformTranslation() {
|
|||
void JointState::applyRotationDelta(const glm::quat& delta, bool constrain, float priority) {
|
||||
// NOTE: delta is in model-frame
|
||||
assert(_fbxJoint != NULL);
|
||||
if (priority < _animationPriority || delta.null) {
|
||||
if (priority < _animationPriority || delta == glm::quat()) {
|
||||
return;
|
||||
}
|
||||
_animationPriority = priority;
|
||||
|
|
|
@ -590,7 +590,6 @@ void Model::recalculateMeshBoxes(bool pickAgainstTriangles) {
|
|||
bool calculatedMeshTrianglesNeeded = pickAgainstTriangles && !_calculatedMeshTrianglesValid;
|
||||
|
||||
if (!_calculatedMeshBoxesValid || calculatedMeshTrianglesNeeded) {
|
||||
PerformanceTimer perfTimer("calculatedMeshBoxes");
|
||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||
int numberOfMeshes = geometry.meshes.size();
|
||||
_calculatedMeshBoxes.resize(numberOfMeshes);
|
||||
|
|
|
@ -45,15 +45,13 @@ void main(void) {
|
|||
// compute the view space position using the depth
|
||||
float z = near / (depthVal * depthScale - 1.0);
|
||||
vec4 position = vec4((depthTexCoordOffset + gl_TexCoord[0].st * depthTexCoordScale) * z, z, 0.0);
|
||||
|
||||
// get the normal from the map
|
||||
vec4 normal = normalVal;
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((normalVal.a >= 0.45) && (normalVal.a <= 0.55)) {
|
||||
normal.a = 1.0;
|
||||
normalVal.a = 0.0;
|
||||
gl_FragColor = vec4(diffuseVal.rgb * specularVal.rgb, 1.0);
|
||||
} else {
|
||||
vec3 normalizedNormal = normalize(normal.xyz * 2.0 - vec3(1.0));
|
||||
// get the normal from the map
|
||||
vec3 normalizedNormal = normalize(normalVal.xyz * 2.0 - vec3(1.0));
|
||||
|
||||
// compute the base color based on OpenGL lighting model
|
||||
float diffuse = dot(normalizedNormal, gl_LightSource[0].position.xyz);
|
||||
|
@ -67,6 +65,6 @@ void main(void) {
|
|||
|
||||
// add specular contribution
|
||||
vec4 specularColor = specularVal;
|
||||
gl_FragColor = vec4(baseColor.rgb + pow(specular, specularColor.a * 128.0) * specularColor.rgb, normal.a);
|
||||
gl_FragColor = vec4(baseColor.rgb + pow(specular, specularColor.a * 128.0) * specularColor.rgb, normalVal.a);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,36 +46,66 @@ uniform vec2 depthTexCoordOffset;
|
|||
uniform vec2 depthTexCoordScale;
|
||||
|
||||
void main(void) {
|
||||
float depthVal = texture2D(depthMap, gl_TexCoord[0].st).r;
|
||||
vec4 normalVal = texture2D(normalMap, gl_TexCoord[0].st);
|
||||
vec4 diffuseVal = texture2D(diffuseMap, gl_TexCoord[0].st);
|
||||
vec4 specularVal = texture2D(specularMap, gl_TexCoord[0].st);
|
||||
|
||||
// compute the view space position using the depth
|
||||
float z = near / (texture2D(depthMap, gl_TexCoord[0].st).r * depthScale - 1.0);
|
||||
float z = near / (depthVal * depthScale - 1.0);
|
||||
vec4 position = vec4((depthTexCoordOffset + gl_TexCoord[0].st * depthTexCoordScale) * z, z, 1.0);
|
||||
|
||||
// compute the index of the cascade to use and the corresponding texture coordinates
|
||||
int shadowIndex = int(dot(step(vec3(position.z), shadowDistances), vec3(1.0, 1.0, 1.0)));
|
||||
vec3 shadowTexCoord = vec3(dot(gl_EyePlaneS[shadowIndex], position), dot(gl_EyePlaneT[shadowIndex], position),
|
||||
dot(gl_EyePlaneR[shadowIndex], position));
|
||||
|
||||
// get the normal from the map
|
||||
vec4 normal = texture2D(normalMap, gl_TexCoord[0].st);
|
||||
vec4 normalizedNormal = normalize(normal * 2.0 - vec4(1.0, 1.0, 1.0, 2.0));
|
||||
|
||||
// average values from the shadow map
|
||||
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
|
||||
float facingLight = step(0.0, diffuse) * 0.25 *
|
||||
|
||||
// evaluate the shadow test but only relevant for light facing fragments
|
||||
float shadowAttenuation = (0.25 *
|
||||
(shadow2D(shadowMap, shadowTexCoord + vec3(-shadowScale, -shadowScale, 0.0)).r +
|
||||
shadow2D(shadowMap, shadowTexCoord + vec3(-shadowScale, shadowScale, 0.0)).r +
|
||||
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, -shadowScale, 0.0)).r +
|
||||
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, shadowScale, 0.0)).r);
|
||||
|
||||
// compute the base color based on OpenGL lighting model
|
||||
vec4 baseColor = texture2D(diffuseMap, gl_TexCoord[0].st) * (gl_FrontLightModelProduct.sceneColor +
|
||||
gl_FrontLightProduct[0].ambient + gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
|
||||
|
||||
// compute the specular multiplier (sans exponent)
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),
|
||||
normalizedNormal));
|
||||
|
||||
// add specular contribution
|
||||
vec4 specularColor = texture2D(specularMap, gl_TexCoord[0].st);
|
||||
gl_FragColor = vec4(baseColor.rgb + pow(specular, specularColor.a * 128.0) * specularColor.rgb, normal.a);
|
||||
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, shadowScale, 0.0)).r));
|
||||
|
||||
// get the normal from the map
|
||||
vec3 normalizedNormal = normalize(normalVal.xyz * 2.0 - vec3(1.0));
|
||||
|
||||
// how much this fragment faces the light direction
|
||||
float diffuse = dot(normalizedNormal, gl_LightSource[0].position.xyz);
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((normalVal.a >= 0.45) && (normalVal.a <= 0.55)) {
|
||||
normalVal.a = 0.0;
|
||||
|
||||
// need to catch normals perpendicular to the projection plane hence the magic number for the threshold
|
||||
// it should be just 0, but we have innacurracy so we need to overshoot
|
||||
const float PERPENDICULAR_THRESHOLD = -0.005;
|
||||
float facingLight = step(PERPENDICULAR_THRESHOLD, diffuse);
|
||||
|
||||
// evaluate the shadow test but only relevant for light facing fragments
|
||||
float lightAttenuation = (1 - facingLight) + facingLight * shadowAttenuation;
|
||||
|
||||
// diffuse light is the lightmap dimmed by shadow
|
||||
vec3 diffuseLight = lightAttenuation * specularVal.rgb;
|
||||
// ambient is a tiny percentage of the lightmap and only when in the shadow
|
||||
vec3 ambientLight = (1 - lightAttenuation) * 0.5 * specularVal.rgb;
|
||||
|
||||
gl_FragColor = vec4(diffuseVal.rgb * (ambientLight + diffuseLight), 1.0);
|
||||
} else {
|
||||
|
||||
// average values from the shadow map
|
||||
float facingLight = step(0.0, diffuse) * shadowAttenuation;
|
||||
|
||||
// compute the base color based on OpenGL lighting model
|
||||
vec3 baseColor = diffuseVal.rgb * (gl_FrontLightModelProduct.sceneColor.rgb +
|
||||
gl_FrontLightProduct[0].ambient.rgb + gl_FrontLightProduct[0].diffuse.rgb * (diffuse * facingLight));
|
||||
|
||||
// compute the specular multiplier (sans exponent)
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position.xyz - normalize(position.xyz)),
|
||||
normalizedNormal));
|
||||
|
||||
// add specular contribution
|
||||
vec4 specularColor = specularVal;
|
||||
gl_FragColor = vec4(baseColor.rgb + pow(specular, specularColor.a * 128.0) * specularColor.rgb, normalVal.a);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,34 +43,63 @@ uniform vec2 depthTexCoordOffset;
|
|||
uniform vec2 depthTexCoordScale;
|
||||
|
||||
void main(void) {
|
||||
float depthVal = texture2D(depthMap, gl_TexCoord[0].st).r;
|
||||
vec4 normalVal = texture2D(normalMap, gl_TexCoord[0].st);
|
||||
vec4 diffuseVal = texture2D(diffuseMap, gl_TexCoord[0].st);
|
||||
vec4 specularVal = texture2D(specularMap, gl_TexCoord[0].st);
|
||||
|
||||
// compute the view space position using the depth
|
||||
float z = near / (texture2D(depthMap, gl_TexCoord[0].st).r * depthScale - 1.0);
|
||||
float z = near / (depthVal * depthScale - 1.0);
|
||||
vec4 position = vec4((depthTexCoordOffset + gl_TexCoord[0].st * depthTexCoordScale) * z, z, 1.0);
|
||||
|
||||
|
||||
// compute the corresponding texture coordinates
|
||||
vec3 shadowTexCoord = vec3(dot(gl_EyePlaneS[0], position), dot(gl_EyePlaneT[0], position), dot(gl_EyePlaneR[0], position));
|
||||
|
||||
// get the normal from the map
|
||||
vec4 normal = texture2D(normalMap, gl_TexCoord[0].st);
|
||||
vec4 normalizedNormal = normalize(normal * 2.0 - vec4(1.0, 1.0, 1.0, 2.0));
|
||||
|
||||
// average values from the shadow map
|
||||
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
|
||||
float facingLight = step(0.0, diffuse) * 0.25 *
|
||||
|
||||
// evaluate the shadow test but only relevant for light facing fragments
|
||||
float shadowAttenuation = (0.25 *
|
||||
(shadow2D(shadowMap, shadowTexCoord + vec3(-shadowScale, -shadowScale, 0.0)).r +
|
||||
shadow2D(shadowMap, shadowTexCoord + vec3(-shadowScale, shadowScale, 0.0)).r +
|
||||
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, -shadowScale, 0.0)).r +
|
||||
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, shadowScale, 0.0)).r);
|
||||
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, shadowScale, 0.0)).r));
|
||||
|
||||
// get the normal from the map
|
||||
vec3 normalizedNormal = normalize(normalVal.xyz * 2.0 - vec3(1.0));
|
||||
|
||||
// how much this fragment faces the light direction
|
||||
float diffuse = dot(normalizedNormal, gl_LightSource[0].position.xyz);
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((normalVal.a >= 0.45) && (normalVal.a <= 0.55)) {
|
||||
normalVal.a = 0.0;
|
||||
|
||||
// need to catch normals perpendicular to the projection plane hence the magic number for the threshold
|
||||
// it should be just 0, be we have innacurracy so we need to overshoot
|
||||
const float PERPENDICULAR_THRESHOLD = -0.005;
|
||||
float facingLight = step(PERPENDICULAR_THRESHOLD, diffuse);
|
||||
|
||||
// compute the base color based on OpenGL lighting model
|
||||
vec4 baseColor = texture2D(diffuseMap, gl_TexCoord[0].st) * (gl_FrontLightModelProduct.sceneColor +
|
||||
gl_FrontLightProduct[0].ambient + gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
|
||||
|
||||
// compute the specular multiplier (sans exponent)
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),
|
||||
normalizedNormal));
|
||||
|
||||
// add specular contribution
|
||||
vec4 specularColor = texture2D(specularMap, gl_TexCoord[0].st);
|
||||
gl_FragColor = vec4(baseColor.rgb + pow(specular, specularColor.a * 128.0) * specularColor.rgb, normal.a);
|
||||
// evaluate the shadow test but only relevant for light facing fragments
|
||||
float lightAttenuation = (1 - facingLight) + facingLight * shadowAttenuation;
|
||||
|
||||
// diffuse light is the lightmap dimmed by shadow
|
||||
vec3 diffuseLight = lightAttenuation * specularVal.rgb;
|
||||
// ambient is a tiny percentage of the lightmap and only when in the shadow
|
||||
vec3 ambientLight = (1 - lightAttenuation) * 0.5 * specularVal.rgb;
|
||||
|
||||
gl_FragColor = vec4(diffuseVal.rgb * (ambientLight + diffuseLight), 1.0);
|
||||
} else {
|
||||
// average values from the shadow map
|
||||
float facingLight = step(0.0, diffuse) * shadowAttenuation;
|
||||
|
||||
// compute the base color based on OpenGL lighting model
|
||||
vec3 baseColor = diffuseVal.rgb * (gl_FrontLightModelProduct.sceneColor.rgb +
|
||||
gl_FrontLightProduct[0].ambient.rgb + gl_FrontLightProduct[0].diffuse.rgb * (diffuse * facingLight));
|
||||
|
||||
// compute the specular multiplier (sans exponent)
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position.xyz - normalize(position.xyz)),
|
||||
normalizedNormal));
|
||||
|
||||
// add specular contribution
|
||||
vec4 specularColor = specularVal;
|
||||
gl_FragColor = vec4(baseColor.rgb + pow(specular, specularColor.a * 128.0) * specularColor.rgb, normalVal.a);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue