mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 11:29:50 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into dont-use-other-avatar-sounds
This commit is contained in:
commit
c2873ef720
15 changed files with 206 additions and 211 deletions
|
@ -254,10 +254,10 @@ void AvatarMixer::broadcastAvatarData() {
|
||||||
// potentially update the max full rate distance for this frame
|
// potentially update the max full rate distance for this frame
|
||||||
maxAvatarDistanceThisFrame = std::max(maxAvatarDistanceThisFrame, distanceToAvatar);
|
maxAvatarDistanceThisFrame = std::max(maxAvatarDistanceThisFrame, distanceToAvatar);
|
||||||
|
|
||||||
if (distanceToAvatar != 0.0f
|
if (distanceToAvatar != 0.0f
|
||||||
&& distribution(generator) > (nodeData->getFullRateDistance() / distanceToAvatar)) {
|
&& distribution(generator) > (nodeData->getFullRateDistance() / distanceToAvatar)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarDataSequenceNumber lastSeqToReceiver = nodeData->getLastBroadcastSequenceNumber(otherNode->getUUID());
|
AvatarDataSequenceNumber lastSeqToReceiver = nodeData->getLastBroadcastSequenceNumber(otherNode->getUUID());
|
||||||
AvatarDataSequenceNumber lastSeqFromSender = otherNodeData->getLastReceivedSequenceNumber();
|
AvatarDataSequenceNumber lastSeqFromSender = otherNodeData->getLastReceivedSequenceNumber();
|
||||||
|
|
|
@ -1510,7 +1510,7 @@ PropertiesTool = function(opts) {
|
||||||
if (entity.properties.rotation !== undefined) {
|
if (entity.properties.rotation !== undefined) {
|
||||||
entity.properties.rotation = Quat.safeEulerAngles(entity.properties.rotation);
|
entity.properties.rotation = Quat.safeEulerAngles(entity.properties.rotation);
|
||||||
}
|
}
|
||||||
if (entity.properties.keyLight.direction !== undefined) {
|
if (entity.properties.keyLight !== undefined && entity.properties.keyLight.direction !== undefined) {
|
||||||
entity.properties.keyLight.direction = Vec3.multiply(RADIANS_TO_DEGREES, Vec3.toPolar(entity.properties.keyLight.direction));
|
entity.properties.keyLight.direction = Vec3.multiply(RADIANS_TO_DEGREES, Vec3.toPolar(entity.properties.keyLight.direction));
|
||||||
entity.properties.keyLight.direction.z = 0.0;
|
entity.properties.keyLight.direction.z = 0.0;
|
||||||
}
|
}
|
||||||
|
@ -1541,7 +1541,7 @@ PropertiesTool = function(opts) {
|
||||||
var rotation = data.properties.rotation;
|
var rotation = data.properties.rotation;
|
||||||
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
|
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
|
||||||
}
|
}
|
||||||
if (data.properties.keyLight.direction !== undefined) {
|
if (data.properties.keyLight !== undefined && data.properties.keyLight.direction !== undefined) {
|
||||||
data.properties.keyLight.direction = Vec3.fromPolar(
|
data.properties.keyLight.direction = Vec3.fromPolar(
|
||||||
data.properties.keyLight.direction.x * DEGREES_TO_RADIANS, data.properties.keyLight.direction.y * DEGREES_TO_RADIANS);
|
data.properties.keyLight.direction.x * DEGREES_TO_RADIANS, data.properties.keyLight.direction.y * DEGREES_TO_RADIANS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
//
|
|
||||||
// metavoxels.js
|
|
||||||
// examples
|
|
||||||
//
|
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
Script.setInterval(function() {
|
|
||||||
var spanner;
|
|
||||||
if (Math.random() < 0.5) {
|
|
||||||
spanner = new Sphere();
|
|
||||||
} else {
|
|
||||||
spanner = new Cuboid();
|
|
||||||
spanner.aspectX = 0.1 + Math.random() * 1.9;
|
|
||||||
spanner.aspectY = 0.1 + Math.random() * 1.9;
|
|
||||||
}
|
|
||||||
spanner.scale = 0.1 + Math.random() * 1.9;
|
|
||||||
spanner.rotation = Quat.fromPitchYawRollDegrees(Math.random() * 360.0, Math.random() * 360.0, Math.random() * 360.0);
|
|
||||||
spanner.translation = { x: 10.0 + Math.random() * 10.0, y: 10.0 + Math.random() * 10.0, z: 10.0 + Math.random() * 10.0 };
|
|
||||||
|
|
||||||
if (Math.random() < 0.5) {
|
|
||||||
var material = new MaterialObject();
|
|
||||||
if (Math.random() < 0.5) {
|
|
||||||
material.diffuse = "http://www.fungibleinsight.com/faces/grass.jpg";
|
|
||||||
} else {
|
|
||||||
material.diffuse = "http://www.fungibleinsight.com/faces/soil.jpg";
|
|
||||||
}
|
|
||||||
Metavoxels.setVoxelMaterial(spanner, material);
|
|
||||||
|
|
||||||
} else if (Math.random() < 0.5) {
|
|
||||||
Metavoxels.setVoxelColor(spanner, { red: Math.random() * 255.0, green: Math.random() * 255.0,
|
|
||||||
blue: Math.random() * 255.0 });
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Metavoxels.setVoxelColor(spanner, { red: 0, green: 0, blue: 0, alpha: 0 });
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
|
@ -830,7 +830,7 @@
|
||||||
elZoneKeyLightColorRed.addEventListener('change', zoneKeyLightColorChangeFunction);
|
elZoneKeyLightColorRed.addEventListener('change', zoneKeyLightColorChangeFunction);
|
||||||
elZoneKeyLightColorGreen.addEventListener('change', zoneKeyLightColorChangeFunction);
|
elZoneKeyLightColorGreen.addEventListener('change', zoneKeyLightColorChangeFunction);
|
||||||
elZoneKeyLightColorBlue.addEventListener('change', zoneKeyLightColorChangeFunction);
|
elZoneKeyLightColorBlue.addEventListener('change', zoneKeyLightColorChangeFunction);
|
||||||
elZoneKeyLightIntensity.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('intensity','keyLight'));
|
elZoneKeyLightIntensity.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('keyLight','intensity'));
|
||||||
elZoneKeyLightAmbientIntensity.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('keyLight','ambientIntensity'));
|
elZoneKeyLightAmbientIntensity.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('keyLight','ambientIntensity'));
|
||||||
var zoneKeyLightDirectionChangeFunction = createEmitGroupVec3PropertyUpdateFunction('keyLight','direction', elZoneKeyLightDirectionX, elZoneKeyLightDirectionY, elZoneKeyLightDirectionZ);
|
var zoneKeyLightDirectionChangeFunction = createEmitGroupVec3PropertyUpdateFunction('keyLight','direction', elZoneKeyLightDirectionX, elZoneKeyLightDirectionY, elZoneKeyLightDirectionZ);
|
||||||
elZoneKeyLightDirectionX.addEventListener('change', zoneKeyLightDirectionChangeFunction);
|
elZoneKeyLightDirectionX.addEventListener('change', zoneKeyLightDirectionChangeFunction);
|
||||||
|
@ -1520,7 +1520,7 @@
|
||||||
<div class="zone-section keyLight-section property">
|
<div class="zone-section keyLight-section property">
|
||||||
<div class="label">Ambient URL</div>
|
<div class="label">Ambient URL</div>
|
||||||
<div class="value">
|
<div class="value">
|
||||||
<input type="text" id="property-zone-skybox-url" class="url">
|
<input type="text" id="property-zone-key-ambient-url" class="url">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
if (this.painting) {
|
if (this.painting) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.whichHand = this.hand;
|
||||||
if (this.hand === RIGHT_HAND) {
|
if (this.hand === RIGHT_HAND) {
|
||||||
this.getHandPosition = MyAvatar.getRightPalmPosition;
|
this.getHandPosition = MyAvatar.getRightPalmPosition;
|
||||||
this.getHandRotation = MyAvatar.getRightPalmRotation;
|
this.getHandRotation = MyAvatar.getRightPalmRotation;
|
||||||
|
@ -183,6 +184,9 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseGrab: function() {
|
releaseGrab: function() {
|
||||||
|
if(this.hand !== this.whichHand) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.stopPainting();
|
this.stopPainting();
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -241,10 +245,8 @@
|
||||||
Overlays.deleteOverlay(this.laserPointer);
|
Overlays.deleteOverlay(this.laserPointer);
|
||||||
// this.eraseBoard();
|
// this.eraseBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// entity scripts always need to return a newly constructed object of our type
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
return new Whiteboard();
|
return new Whiteboard();
|
||||||
});
|
});
|
|
@ -16,186 +16,199 @@
|
||||||
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
var scriptURL = Script.resolvePath("whiteboardEntityScript.js");
|
var scriptURL = Script.resolvePath("whiteboardEntityScript.js");
|
||||||
|
var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/whiteboard.fbx";
|
||||||
|
|
||||||
|
var colorIndicatorBorderModelURL = "https://s3.amazonaws.com/hifi-public/eric/models/colorIndicatorBorder.fbx";
|
||||||
|
var eraserModelURL = "https://s3.amazonaws.com/hifi-public/eric/models/eraser.fbx";
|
||||||
|
var surfaceModelURL = "https://s3.amazonaws.com/hifi-public/eric/models/boardSurface.fbx";
|
||||||
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
||||||
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
||||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(rotation)));
|
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(rotation)));
|
||||||
center.y += 0.4;
|
|
||||||
|
var whiteboardDimensions, colorIndicatorBoxDimensions, colorIndicatorBox, eraser, blocker;
|
||||||
|
var colorBoxes = [];
|
||||||
|
|
||||||
var colors = [
|
var colors = [
|
||||||
hexToRgb("#2F8E84"),
|
|
||||||
hexToRgb("#66CCB3"),
|
hexToRgb("#66CCB3"),
|
||||||
hexToRgb("#A43C37"),
|
hexToRgb("#A43C37"),
|
||||||
hexToRgb("#491849"),
|
hexToRgb("#491849"),
|
||||||
hexToRgb("#6AB03B"),
|
hexToRgb("#6AB03B"),
|
||||||
hexToRgb("#993369"),
|
hexToRgb("#993369"),
|
||||||
hexToRgb("#9B47C2")
|
hexToRgb("#000000")
|
||||||
];
|
];
|
||||||
|
|
||||||
//WHITEBOARD
|
|
||||||
var whiteboardDimensions = {
|
|
||||||
x: 2,
|
|
||||||
y: 1.5,
|
|
||||||
z: 0.08
|
|
||||||
};
|
|
||||||
var whiteboard = Entities.addEntity({
|
var whiteboard = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
modelURL: "https://hifi-public.s3.amazonaws.com/ozan/support/for_eric/whiteboard/whiteboard.fbx",
|
shapeType: "box",
|
||||||
name: "whiteboard",
|
modelURL: modelURL,
|
||||||
|
name: "whiteboard base",
|
||||||
position: center,
|
position: center,
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
script: scriptURL,
|
|
||||||
dimensions: whiteboardDimensions,
|
|
||||||
color: {
|
|
||||||
red: 255,
|
|
||||||
green: 255,
|
|
||||||
blue: 255
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var colorIndicatorPosition = {
|
||||||
// COLOR INDICATOR BOX
|
x: center.x,
|
||||||
var colorIndicatorDimensions = {
|
y: center.y,
|
||||||
x: whiteboardDimensions.x,
|
z: center.z
|
||||||
y: 0.05,
|
|
||||||
z: 0.02
|
|
||||||
};
|
};
|
||||||
scriptURL = Script.resolvePath("colorIndicatorEntityScript.js");
|
colorIndicatorPosition.y += 1.55;
|
||||||
var colorIndicatorPosition = Vec3.sum(center, {
|
colorIndicatorPosition = Vec3.sum(colorIndicatorPosition, Vec3.multiply(-0.1, Quat.getFront(rotation)));
|
||||||
x: 0,
|
var colorIndicatorBorder = Entities.addEntity({
|
||||||
y: whiteboardDimensions.y / 2 + colorIndicatorDimensions.y / 2,
|
type: "Model",
|
||||||
z: 0
|
|
||||||
});
|
|
||||||
var colorIndicatorBox = Entities.addEntity({
|
|
||||||
type: "Box",
|
|
||||||
name: "Color Indicator",
|
|
||||||
color: colors[0],
|
|
||||||
rotation: rotation,
|
|
||||||
position: colorIndicatorPosition,
|
position: colorIndicatorPosition,
|
||||||
dimensions: colorIndicatorDimensions,
|
modelURL: colorIndicatorBorderModelURL,
|
||||||
script: scriptURL,
|
rotation: rotation,
|
||||||
userData: JSON.stringify({
|
shapeType: "box"
|
||||||
whiteboard: whiteboard
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Entities.editEntity(whiteboard, {
|
var surfaceCenter = Vec3.sum(center, Vec3.multiply(-0.1, Quat.getFront(rotation)));
|
||||||
|
surfaceCenter.y += 0.6;
|
||||||
|
var drawingSurface = Entities.addEntity({
|
||||||
|
type: "Model",
|
||||||
|
modelURL: surfaceModelURL,
|
||||||
|
shapeType: "box",
|
||||||
|
name: "whiteboard surface",
|
||||||
|
position: surfaceCenter,
|
||||||
|
script: scriptURL,
|
||||||
|
rotation: rotation,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
color: {
|
color: {
|
||||||
currentColor: colors[0]
|
currentColor: colors[0]
|
||||||
},
|
|
||||||
colorIndicator: colorIndicatorBox
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
//COLOR BOXES
|
|
||||||
var direction = Quat.getRight(rotation);
|
|
||||||
var colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2));
|
|
||||||
var colorBoxes = [];
|
|
||||||
var colorSquareDimensions = {
|
|
||||||
x: (whiteboardDimensions.x / 2) / (colors.length - 1),
|
|
||||||
y: 0.1,
|
|
||||||
z: 0.05
|
|
||||||
};
|
|
||||||
colorBoxPosition.y += whiteboardDimensions.y / 2 + colorIndicatorDimensions.y + colorSquareDimensions.y / 2;
|
|
||||||
var spaceBetweenColorBoxes = Vec3.multiply(direction, colorSquareDimensions.x * 2);
|
|
||||||
var scriptURL = Script.resolvePath("colorSelectorEntityScript.js");
|
|
||||||
for (var i = 0; i < colors.length; i++) {
|
|
||||||
var colorBox = Entities.addEntity({
|
|
||||||
type: "Box",
|
|
||||||
name: "Color Selector",
|
|
||||||
position: colorBoxPosition,
|
|
||||||
dimensions: colorSquareDimensions,
|
|
||||||
rotation: rotation,
|
|
||||||
color: colors[i],
|
|
||||||
script: scriptURL,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
whiteboard: whiteboard,
|
|
||||||
colorIndicator: colorIndicatorBox
|
|
||||||
})
|
|
||||||
});
|
|
||||||
colorBoxes.push(colorBox);
|
|
||||||
colorBoxPosition = Vec3.sum(colorBoxPosition, spaceBetweenColorBoxes);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// BLACK BOX
|
|
||||||
var blackBoxDimensions = {
|
|
||||||
x: 0.3,
|
|
||||||
y: 0.3,
|
|
||||||
z: 0.01
|
|
||||||
};
|
|
||||||
|
|
||||||
colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2 + blackBoxDimensions.x / 2 - 0.01));
|
|
||||||
colorBoxPosition.y += 0.3;
|
|
||||||
var fragShaderURL = Script.resolvePath('blackInk.fs?v1' + Math.random());
|
|
||||||
var blackBox = Entities.addEntity({
|
|
||||||
type: 'Box',
|
|
||||||
name: "Black Color",
|
|
||||||
position: colorBoxPosition,
|
|
||||||
dimensions: blackBoxDimensions,
|
|
||||||
rotation: rotation,
|
|
||||||
color: {
|
|
||||||
red: 0,
|
|
||||||
green: 0,
|
|
||||||
blue: 0
|
|
||||||
},
|
|
||||||
script: scriptURL,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
whiteboard: whiteboard,
|
|
||||||
version: 2,
|
|
||||||
ProceduralEntity: {
|
|
||||||
shaderUrl: fragShaderURL
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var lightPosition = Vec3.sum(center, Vec3.multiply(-3, Quat.getFront(rotation)));
|
||||||
|
var light = Entities.addEntity({
|
||||||
|
type: 'Light',
|
||||||
|
name: 'whiteboard light',
|
||||||
|
position: lightPosition,
|
||||||
|
dimensions: {x: 10, y: 10, z: 10},
|
||||||
|
intensity: 2,
|
||||||
|
color: {red: 255, green: 255, blue: 255}
|
||||||
|
});
|
||||||
|
|
||||||
var eraseBoxDimensions = {
|
var eraserPosition = Vec3.sum(center, {x: 0, y: 2.05, z: 0 });
|
||||||
x: 0.5,
|
eraserPosition = Vec3.sum(eraserPosition, Vec3.multiply(-0.1, rotation));
|
||||||
y: 0.1,
|
|
||||||
z: 0.01
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
var eraseBoxPosition = Vec3.sum(center, Vec3.multiply(direction, whiteboardDimensions.x / 2 + eraseBoxDimensions.x / 2 + 0.01));
|
|
||||||
eraseBoxPosition.y += 0.3;
|
|
||||||
scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
|
scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
|
||||||
var eraseAllText = Entities.addEntity({
|
var eraser = Entities.addEntity({
|
||||||
type: "Text",
|
type: "Model",
|
||||||
position: eraseBoxPosition,
|
modelURL: eraserModelURL,
|
||||||
|
position: eraserPosition,
|
||||||
name: "Eraser",
|
name: "Eraser",
|
||||||
script: scriptURL,
|
script: scriptURL,
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
dimensions: eraseBoxDimensions,
|
|
||||||
backgroundColor: {
|
|
||||||
red: 0,
|
|
||||||
green: 60,
|
|
||||||
blue: 0
|
|
||||||
},
|
|
||||||
textColor: {
|
|
||||||
red: 255,
|
|
||||||
green: 10,
|
|
||||||
blue: 10
|
|
||||||
},
|
|
||||||
text: "ERASE BOARD",
|
|
||||||
lineHeight: 0.07,
|
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
whiteboard: whiteboard
|
whiteboard: drawingSurface
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
whiteboardDimensions = Entities.getEntityProperties(whiteboard, "naturalDimensions").naturalDimensions;
|
||||||
|
colorIndicatorBorderDimensions = Entities.getEntityProperties(colorIndicatorBorder, "naturalDimensions").naturalDimensions;
|
||||||
|
setUp();
|
||||||
|
}, 2000)
|
||||||
|
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
var blockerPosition = Vec3.sum(center, {x: 0, y: -1, z: 0 });
|
||||||
|
blockerPosition = Vec3.sum(blockerPosition, Vec3.multiply(-1, Quat.getFront(rotation)));
|
||||||
|
blocker = Entities.addEntity({
|
||||||
|
type: "Box",
|
||||||
|
rotation: rotation,
|
||||||
|
position: blockerPosition,
|
||||||
|
dimensions: {x: whiteboardDimensions.x, y: 1, z: 0.1},
|
||||||
|
shapeType: "box",
|
||||||
|
visible: false
|
||||||
|
});
|
||||||
|
|
||||||
|
var eraseModelDimensions = Entities.getEntityProperties(eraser, "naturalDimensions").naturalDimensions;
|
||||||
|
Entities.editEntity(eraser, {dimensions: eraseModelDimensions});
|
||||||
|
Entities.editEntity(colorIndicatorBorder, {dimensions: colorIndicatorBorderDimensions});
|
||||||
|
|
||||||
|
scriptURL = Script.resolvePath("colorIndicatorEntityScript.js");
|
||||||
|
var colorIndicatorPosition = Vec3.sum(center, {
|
||||||
|
x: 0,
|
||||||
|
y: whiteboardDimensions.y / 2 + colorIndicatorBorderDimensions.y / 2,
|
||||||
|
z: 0
|
||||||
|
});
|
||||||
|
colorIndicatorPosition = Vec3.sum(colorIndicatorPosition, Vec3.multiply(-.1, Quat.getFront(rotation)));
|
||||||
|
var colorIndicatorBoxDimensions = Vec3.multiply(colorIndicatorBorderDimensions, 0.9);
|
||||||
|
colorIndicatorBox = Entities.addEntity({
|
||||||
|
type: "Box",
|
||||||
|
name: "Color Indicator",
|
||||||
|
color: colors[0],
|
||||||
|
rotation: rotation,
|
||||||
|
position: colorIndicatorPosition,
|
||||||
|
dimensions: colorIndicatorBoxDimensions,
|
||||||
|
script: scriptURL,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
whiteboard: drawingSurface
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
Entities.editEntity(drawingSurface, {
|
||||||
|
userData: JSON.stringify({
|
||||||
|
color: {
|
||||||
|
currentColor: colors[0]
|
||||||
|
},
|
||||||
|
colorIndicator: colorIndicatorBox
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
//COLOR BOXES
|
||||||
|
var direction = Quat.getRight(rotation);
|
||||||
|
var colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2));
|
||||||
|
var colorSquareDimensions = {
|
||||||
|
x: 0.13,
|
||||||
|
y: 0.13,
|
||||||
|
z: 0.002
|
||||||
|
};
|
||||||
|
|
||||||
|
var palleteDepthOffset = -0.07;
|
||||||
|
var palleteHeightOffset = -0.28;
|
||||||
|
|
||||||
|
colorBoxPosition = Vec3.sum(colorBoxPosition, Vec3.multiply(palleteDepthOffset, Quat.getFront(rotation)));
|
||||||
|
colorBoxPosition.y += palleteHeightOffset;
|
||||||
|
var spaceBetweenColorBoxes = Vec3.multiply(direction, colorSquareDimensions.x * 1.76);
|
||||||
|
var palleteXOffset = Vec3.multiply(direction, 0.43);
|
||||||
|
colorBoxPosition = Vec3.sum(colorBoxPosition, palleteXOffset);
|
||||||
|
var scriptURL = Script.resolvePath("colorSelectorEntityScript.js");
|
||||||
|
for (var i = 0; i < colors.length; i++) {
|
||||||
|
var colorBox = Entities.addEntity({
|
||||||
|
type: "Box",
|
||||||
|
name: "Color Selector",
|
||||||
|
position: colorBoxPosition,
|
||||||
|
dimensions: colorSquareDimensions,
|
||||||
|
rotation: rotation,
|
||||||
|
color: colors[i],
|
||||||
|
script: scriptURL,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
whiteboard: drawingSurface,
|
||||||
|
colorIndicator: colorIndicatorBox
|
||||||
|
})
|
||||||
|
});
|
||||||
|
colorBoxes.push(colorBox);
|
||||||
|
colorBoxPosition = Vec3.sum(colorBoxPosition, spaceBetweenColorBoxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
Entities.deleteEntity(whiteboard);
|
Entities.deleteEntity(whiteboard);
|
||||||
Entities.deleteEntity(eraseAllText);
|
Entities.deleteEntity(drawingSurface);
|
||||||
Entities.deleteEntity(blackBox);
|
Entities.deleteEntity(colorIndicatorBorder);
|
||||||
|
Entities.deleteEntity(eraser);
|
||||||
Entities.deleteEntity(colorIndicatorBox);
|
Entities.deleteEntity(colorIndicatorBox);
|
||||||
|
Entities.deleteEntity(blocker);
|
||||||
|
Entities.deleteEntity(light);
|
||||||
colorBoxes.forEach(function(colorBox) {
|
colorBoxes.forEach(function(colorBox) {
|
||||||
Entities.deleteEntity(colorBox);
|
Entities.deleteEntity(colorBox);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Uncomment this line to delete whiteboard and all associated entity on script close
|
// Uncomment this line to delete whiteboard and all associated entity on script close
|
||||||
Script.scriptEnding.connect(cleanup);
|
// Script.scriptEnding.connect(cleanup);
|
|
@ -197,7 +197,7 @@
|
||||||
"id": "rightHandOpen",
|
"id": "rightHandOpen",
|
||||||
"type": "clip",
|
"type": "clip",
|
||||||
"data": {
|
"data": {
|
||||||
"url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_right_hand.fbx",
|
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/grab/grab_right.fbx",
|
||||||
"startFrame": 0.0,
|
"startFrame": 0.0,
|
||||||
"endFrame": 0.0,
|
"endFrame": 0.0,
|
||||||
"timeScale": 1.0,
|
"timeScale": 1.0,
|
||||||
|
@ -209,9 +209,9 @@
|
||||||
"id": "rightHandClose",
|
"id": "rightHandClose",
|
||||||
"type": "clip",
|
"type": "clip",
|
||||||
"data": {
|
"data": {
|
||||||
"url": "http://hifi-public.s3.amazonaws.com/ozan/anim/squeeze_hands/right_hand_anim.fbx",
|
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/grab/grab_right.fbx",
|
||||||
"startFrame": 15.0,
|
"startFrame": 10.0,
|
||||||
"endFrame": 15.0,
|
"endFrame": 10.0,
|
||||||
"timeScale": 1.0,
|
"timeScale": 1.0,
|
||||||
"loopFlag": true
|
"loopFlag": true
|
||||||
},
|
},
|
||||||
|
@ -346,7 +346,7 @@
|
||||||
"id": "leftHandOpen",
|
"id": "leftHandOpen",
|
||||||
"type": "clip",
|
"type": "clip",
|
||||||
"data": {
|
"data": {
|
||||||
"url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_left_hand.fbx",
|
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/grab/grab_left.fbx",
|
||||||
"startFrame": 0.0,
|
"startFrame": 0.0,
|
||||||
"endFrame": 0.0,
|
"endFrame": 0.0,
|
||||||
"timeScale": 1.0,
|
"timeScale": 1.0,
|
||||||
|
@ -358,9 +358,9 @@
|
||||||
"id": "leftHandClose",
|
"id": "leftHandClose",
|
||||||
"type": "clip",
|
"type": "clip",
|
||||||
"data": {
|
"data": {
|
||||||
"url": "http://hifi-public.s3.amazonaws.com/ozan/anim/squeeze_hands/left_hand_anim.fbx",
|
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/grab/grab_left.fbx",
|
||||||
"startFrame": 15.0,
|
"startFrame": 10.0,
|
||||||
"endFrame": 15.0,
|
"endFrame": 10.0,
|
||||||
"timeScale": 1.0,
|
"timeScale": 1.0,
|
||||||
"loopFlag": true
|
"loopFlag": true
|
||||||
},
|
},
|
||||||
|
|
|
@ -313,7 +313,9 @@ QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
|
||||||
bool adjustedFormatForAudioDevice(const QAudioDeviceInfo& audioDevice,
|
bool adjustedFormatForAudioDevice(const QAudioDeviceInfo& audioDevice,
|
||||||
const QAudioFormat& desiredAudioFormat,
|
const QAudioFormat& desiredAudioFormat,
|
||||||
QAudioFormat& adjustedAudioFormat) {
|
QAudioFormat& adjustedAudioFormat) {
|
||||||
if (!audioDevice.isFormatSupported(desiredAudioFormat)) {
|
// FIXME: directly using 24khz has a bug somewhere that causes channels to be swapped.
|
||||||
|
// Continue using our internal resampler, for now.
|
||||||
|
if (true || !audioDevice.isFormatSupported(desiredAudioFormat)) {
|
||||||
qCDebug(audioclient) << "The desired format for audio I/O is" << desiredAudioFormat;
|
qCDebug(audioclient) << "The desired format for audio I/O is" << desiredAudioFormat;
|
||||||
qCDebug(audioclient, "The desired audio format is not supported by this device");
|
qCDebug(audioclient, "The desired audio format is not supported by this device");
|
||||||
|
|
||||||
|
@ -321,7 +323,7 @@ bool adjustedFormatForAudioDevice(const QAudioDeviceInfo& audioDevice,
|
||||||
adjustedAudioFormat = desiredAudioFormat;
|
adjustedAudioFormat = desiredAudioFormat;
|
||||||
adjustedAudioFormat.setChannelCount(2);
|
adjustedAudioFormat.setChannelCount(2);
|
||||||
|
|
||||||
if (audioDevice.isFormatSupported(adjustedAudioFormat)) {
|
if (false && audioDevice.isFormatSupported(adjustedAudioFormat)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
adjustedAudioFormat.setChannelCount(1);
|
adjustedAudioFormat.setChannelCount(1);
|
||||||
|
|
|
@ -50,7 +50,7 @@ AvatarSharedPointer AvatarHashMap::addAvatar(const QUuid& sessionUUID, const QWe
|
||||||
avatar->setOwningAvatarMixer(mixerWeakPointer);
|
avatar->setOwningAvatarMixer(mixerWeakPointer);
|
||||||
QWriteLocker locker(&_hashLock);
|
QWriteLocker locker(&_hashLock);
|
||||||
_avatarHash.insert(sessionUUID, avatar);
|
_avatarHash.insert(sessionUUID, avatar);
|
||||||
|
emit avatarAddedEvent(sessionUUID);
|
||||||
return avatar;
|
return avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,13 +137,16 @@ void AvatarHashMap::processKillAvatar(QSharedPointer<NLPacket> packet, SharedNod
|
||||||
// read the node id
|
// read the node id
|
||||||
QUuid sessionUUID = QUuid::fromRfc4122(packet->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
QUuid sessionUUID = QUuid::fromRfc4122(packet->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
||||||
removeAvatar(sessionUUID);
|
removeAvatar(sessionUUID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarHashMap::removeAvatar(const QUuid& sessionUUID) {
|
void AvatarHashMap::removeAvatar(const QUuid& sessionUUID) {
|
||||||
QWriteLocker locker(&_hashLock);
|
QWriteLocker locker(&_hashLock);
|
||||||
_avatarHash.remove(sessionUUID);
|
_avatarHash.remove(sessionUUID);
|
||||||
|
emit avatarRemovedEvent(sessionUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarHashMap::sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID) {
|
void AvatarHashMap::sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID) {
|
||||||
_lastOwnerSessionUUID = oldUUID;
|
_lastOwnerSessionUUID = oldUUID;
|
||||||
|
emit avatarSessionChangedEvent(sessionUUID, oldUUID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,11 @@ public:
|
||||||
void withAvatarHash(std::function<void(const AvatarHash& hash)>);
|
void withAvatarHash(std::function<void(const AvatarHash& hash)>);
|
||||||
int size() { return _avatarHash.size(); }
|
int size() { return _avatarHash.size(); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void avatarAddedEvent(const QUuid& sessionUUID);
|
||||||
|
void avatarRemovedEvent(const QUuid& sessionUUID);
|
||||||
|
void avatarSessionChangedEvent(const QUuid& sessionUUID,const QUuid& oldUUID);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool isAvatarInRange(const glm::vec3 & position, const float range);
|
bool isAvatarInRange(const glm::vec3 & position, const float range);
|
||||||
|
|
||||||
|
|
|
@ -775,7 +775,7 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons
|
||||||
}
|
}
|
||||||
// Don't respond to small continuous contacts.
|
// Don't respond to small continuous contacts.
|
||||||
const float COLLISION_MINUMUM_PENETRATION = 0.002f;
|
const float COLLISION_MINUMUM_PENETRATION = 0.002f;
|
||||||
if ((collision.type != CONTACT_EVENT_TYPE_START) && (glm::length(collision.penetration) < COLLISION_MINUMUM_PENETRATION)) {
|
if ((collision.type == CONTACT_EVENT_TYPE_CONTINUE) && (glm::length(collision.penetration) < COLLISION_MINUMUM_PENETRATION)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -736,18 +736,11 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
// is sending us data with a known "last simulated" time. That time is likely in the past, and therefore
|
// is sending us data with a known "last simulated" time. That time is likely in the past, and therefore
|
||||||
// this "new" data is actually slightly out of date. We calculate the time we need to skip forward and
|
// this "new" data is actually slightly out of date. We calculate the time we need to skip forward and
|
||||||
// use our simulation helper routine to get a best estimate of where the entity should be.
|
// use our simulation helper routine to get a best estimate of where the entity should be.
|
||||||
const float MIN_TIME_SKIP = 0.0f;
|
float skipTimeForward = (float)(now - lastSimulatedFromBufferAdjusted) / (float)(USECS_PER_SECOND);
|
||||||
const float MAX_TIME_SKIP = 1.0f; // in seconds
|
|
||||||
float skipTimeForward = glm::clamp((float)(now - lastSimulatedFromBufferAdjusted) / (float)(USECS_PER_SECOND),
|
// we want to extrapolate the motion forward to compensate for packet travel time, but
|
||||||
MIN_TIME_SKIP, MAX_TIME_SKIP);
|
// we don't want the side effect of flag setting.
|
||||||
if (skipTimeForward > 0.0f) {
|
simulateKinematicMotion(skipTimeForward, false);
|
||||||
#ifdef WANT_DEBUG
|
|
||||||
qCDebug(entities) << "skipTimeForward:" << skipTimeForward;
|
|
||||||
#endif
|
|
||||||
// we want to extrapolate the motion forward to compensate for packet travel time, but
|
|
||||||
// we don't want the side effect of flag setting.
|
|
||||||
simulateKinematicMotion(skipTimeForward, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overwriteLocalData) {
|
if (overwriteLocalData) {
|
||||||
|
@ -887,6 +880,15 @@ void EntityItem::simulate(const quint64& now) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityItem::simulateKinematicMotion(float timeElapsed, bool setFlags) {
|
void EntityItem::simulateKinematicMotion(float timeElapsed, bool setFlags) {
|
||||||
|
#ifdef WANT_DEBUG
|
||||||
|
qCDebug(entities) << "EntityItem::simulateKinematicMotion timeElapsed" << timeElapsed;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const float MIN_TIME_SKIP = 0.0f;
|
||||||
|
const float MAX_TIME_SKIP = 1.0f; // in seconds
|
||||||
|
|
||||||
|
timeElapsed = glm::clamp(timeElapsed, MIN_TIME_SKIP, MAX_TIME_SKIP);
|
||||||
|
|
||||||
if (hasActions()) {
|
if (hasActions()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,11 @@ void PhysicsEngine::stepSimulation() {
|
||||||
_myAvatarController->preSimulation();
|
_myAvatarController->preSimulation();
|
||||||
}
|
}
|
||||||
|
|
||||||
int numSubsteps = _dynamicsWorld->stepSimulation(timeStep, PHYSICS_ENGINE_MAX_NUM_SUBSTEPS, PHYSICS_ENGINE_FIXED_SUBSTEP);
|
auto onSubStep = [this]() {
|
||||||
|
updateContactMap();
|
||||||
|
};
|
||||||
|
|
||||||
|
int numSubsteps = _dynamicsWorld->stepSimulation(timeStep, PHYSICS_ENGINE_MAX_NUM_SUBSTEPS, PHYSICS_ENGINE_FIXED_SUBSTEP, onSubStep);
|
||||||
if (numSubsteps > 0) {
|
if (numSubsteps > 0) {
|
||||||
BT_PROFILE("postSimulation");
|
BT_PROFILE("postSimulation");
|
||||||
_numSubsteps += (uint32_t)numSubsteps;
|
_numSubsteps += (uint32_t)numSubsteps;
|
||||||
|
@ -268,7 +272,7 @@ void PhysicsEngine::stepSimulation() {
|
||||||
if (_myAvatarController) {
|
if (_myAvatarController) {
|
||||||
_myAvatarController->postSimulation();
|
_myAvatarController->postSimulation();
|
||||||
}
|
}
|
||||||
updateContactMap();
|
|
||||||
_hasOutgoingChanges = true;
|
_hasOutgoingChanges = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ ThreadSafeDynamicsWorld::ThreadSafeDynamicsWorld(
|
||||||
: btDiscreteDynamicsWorld(dispatcher, pairCache, constraintSolver, collisionConfiguration) {
|
: btDiscreteDynamicsWorld(dispatcher, pairCache, constraintSolver, collisionConfiguration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ThreadSafeDynamicsWorld::stepSimulation( btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep) {
|
int ThreadSafeDynamicsWorld::stepSimulation( btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep, SubStepCallback onSubStep) {
|
||||||
BT_PROFILE("stepSimulation");
|
BT_PROFILE("stepSimulation");
|
||||||
int subSteps = 0;
|
int subSteps = 0;
|
||||||
if (maxSubSteps) {
|
if (maxSubSteps) {
|
||||||
|
@ -70,6 +70,7 @@ int ThreadSafeDynamicsWorld::stepSimulation( btScalar timeStep, int maxSubSteps,
|
||||||
|
|
||||||
for (int i=0;i<clampedSimulationSteps;i++) {
|
for (int i=0;i<clampedSimulationSteps;i++) {
|
||||||
internalSingleStepSimulation(fixedTimeStep);
|
internalSingleStepSimulation(fixedTimeStep);
|
||||||
|
onSubStep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
|
|
||||||
#include "ObjectMotionState.h"
|
#include "ObjectMotionState.h"
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
using SubStepCallback = std::function<void()>;
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(class) ThreadSafeDynamicsWorld : public btDiscreteDynamicsWorld {
|
ATTRIBUTE_ALIGNED16(class) ThreadSafeDynamicsWorld : public btDiscreteDynamicsWorld {
|
||||||
public:
|
public:
|
||||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
@ -34,7 +38,7 @@ public:
|
||||||
btCollisionConfiguration* collisionConfiguration);
|
btCollisionConfiguration* collisionConfiguration);
|
||||||
|
|
||||||
// virtual overrides from btDiscreteDynamicsWorld
|
// virtual overrides from btDiscreteDynamicsWorld
|
||||||
int stepSimulation( btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
|
int stepSimulation( btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.), SubStepCallback onSubStep = []() { });
|
||||||
void synchronizeMotionStates();
|
void synchronizeMotionStates();
|
||||||
|
|
||||||
// btDiscreteDynamicsWorld::m_localTime is the portion of real-time that has not yet been simulated
|
// btDiscreteDynamicsWorld::m_localTime is the portion of real-time that has not yet been simulated
|
||||||
|
|
Loading…
Reference in a new issue