mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into physics-continuous-collision-detection
This commit is contained in:
commit
26daa58c65
31 changed files with 392 additions and 255 deletions
|
@ -489,7 +489,7 @@ function MyController(hand) {
|
||||||
if (grabbableData.wantsTrigger) {
|
if (grabbableData.wantsTrigger) {
|
||||||
this.setState(STATE_NEAR_TRIGGER);
|
this.setState(STATE_NEAR_TRIGGER);
|
||||||
return;
|
return;
|
||||||
} else if (!props.locked) {
|
} else if (!props.locked && props.collisionsWillMove) {
|
||||||
this.setState(STATE_NEAR_GRABBING);
|
this.setState(STATE_NEAR_GRABBING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
144
examples/drylake/explodeHelicopter.js
Normal file
144
examples/drylake/explodeHelicopter.js
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
var explosionSound = SoundCache.getSound("https://s3.amazonaws.com/hifi-public/eric/sounds/explosion.wav");
|
||||||
|
|
||||||
|
var partsURLS = [{
|
||||||
|
url: "https://s3.amazonaws.com/hifi-public/eric/models/blade.fbx",
|
||||||
|
dimensions: {
|
||||||
|
x: 2,
|
||||||
|
y: 2,
|
||||||
|
z: 2
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "https://s3.amazonaws.com/hifi-public/eric/models/body.fbx",
|
||||||
|
dimensions: {
|
||||||
|
x: 2.2,
|
||||||
|
y: 2.98,
|
||||||
|
z: 7.96
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "https://s3.amazonaws.com/hifi-public/eric/models/tail.fbx",
|
||||||
|
dimensions: {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
var parts = [];
|
||||||
|
var emitters = [];
|
||||||
|
|
||||||
|
var explodePosition;
|
||||||
|
var helicopter;
|
||||||
|
var entities = Entities.findEntities(MyAvatar.position, 2000);
|
||||||
|
for (i = 0; i < entities.length; i++) {
|
||||||
|
var name = Entities.getEntityProperties(entities[i], 'name').name;
|
||||||
|
if (name === "Helicopter") {
|
||||||
|
var helicopter = entities[i];
|
||||||
|
explodeHelicopter(Entities.getEntityProperties(helicopter, 'position').position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function explodeHelicopter(explodePosition) {
|
||||||
|
Audio.playSound(explosionSound, {
|
||||||
|
position: explodePosition,
|
||||||
|
volume: 0.5
|
||||||
|
});
|
||||||
|
Entities.deleteEntity(helicopter);
|
||||||
|
for (var i = 0; i < partsURLS.length; i++) {
|
||||||
|
var position = Vec3.sum(explodePosition, {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
});
|
||||||
|
var part = Entities.addEntity({
|
||||||
|
type: "Model",
|
||||||
|
modelURL: partsURLS[i].url,
|
||||||
|
dimensions: partsURLS[i].dimensions,
|
||||||
|
position: position,
|
||||||
|
shapeType: "box",
|
||||||
|
collisionsWillMove: true,
|
||||||
|
damping: 0,
|
||||||
|
gravity: {
|
||||||
|
x: 0,
|
||||||
|
y: -9.6,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
velocity: {
|
||||||
|
x: Math.random(),
|
||||||
|
y: -10,
|
||||||
|
z: Math.random()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var emitter = Entities.addEntity({
|
||||||
|
type: "ParticleEffect",
|
||||||
|
name: "fire",
|
||||||
|
isEmitting: true,
|
||||||
|
textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png",
|
||||||
|
position: explodePosition,
|
||||||
|
emitRate: 100,
|
||||||
|
colorStart: {
|
||||||
|
red: 70,
|
||||||
|
green: 70,
|
||||||
|
blue: 137
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 200,
|
||||||
|
green: 99,
|
||||||
|
blue: 42
|
||||||
|
},
|
||||||
|
colorFinish: {
|
||||||
|
red: 255,
|
||||||
|
green: 99,
|
||||||
|
blue: 32
|
||||||
|
},
|
||||||
|
radiusSpread: 0.2,
|
||||||
|
radiusStart: 0.3,
|
||||||
|
radiusEnd: 0.04,
|
||||||
|
particleRadius: 0.09,
|
||||||
|
radiusFinish: 0.0,
|
||||||
|
emitSpeed: 0.1,
|
||||||
|
speedSpread: 0.1,
|
||||||
|
alphaStart: 0.1,
|
||||||
|
alpha: 0.7,
|
||||||
|
alphaFinish: 0.1,
|
||||||
|
emitOrientation: Quat.fromPitchYawRollDegrees(-90, 0, 0),
|
||||||
|
emitDimensions: {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: 0.1
|
||||||
|
},
|
||||||
|
polarFinish: Math.PI,
|
||||||
|
polarStart: 0,
|
||||||
|
|
||||||
|
accelerationSpread: {
|
||||||
|
x: 0.1,
|
||||||
|
y: 0.01,
|
||||||
|
z: 0.1
|
||||||
|
},
|
||||||
|
lifespan: 1,
|
||||||
|
});
|
||||||
|
emitters.push(emitter)
|
||||||
|
parts.push(part);
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
var pos = Entities.getEntityProperties(parts[1], "position").position;
|
||||||
|
Entities.editEntity(emitters[0], {position: Vec3.sum(pos, {x: Math.random(), y: Math.random(), z: Math.random()})});
|
||||||
|
Entities.editEntity(emitters[1], {position: Vec3.sum(pos, {x: Math.random(), y: Math.random(), z: Math.random()})});
|
||||||
|
Entities.editEntity(emitters[2], {position: Vec3.sum(pos, {x: Math.random(), y: Math.random(), z: Math.random()})});
|
||||||
|
}, 5000)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
parts.forEach(function(part) {
|
||||||
|
Entities.deleteEntity(part);
|
||||||
|
});
|
||||||
|
emitters.forEach(function(emitter){
|
||||||
|
Entities.deleteEntity(emitter);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
132
examples/drylake/helicopter.js
Normal file
132
examples/drylake/helicopter.js
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx?v3";
|
||||||
|
var animationURL = "https://s3.amazonaws.com/hifi-public/eric/models/bladeAnimation.fbx?v7";
|
||||||
|
var spawnPosition = {
|
||||||
|
x: 1031,
|
||||||
|
y: 145,
|
||||||
|
z: 1041
|
||||||
|
};
|
||||||
|
|
||||||
|
var speed = 0;
|
||||||
|
|
||||||
|
var helicopterSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/ryan/helicopter.L.wav");
|
||||||
|
var audioInjector = Audio.playSound(helicopterSound, {
|
||||||
|
volume: 0.3,
|
||||||
|
loop: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// These constants define the Spotlight position and orientation relative to the model
|
||||||
|
var MODEL_LIGHT_POSITION = {
|
||||||
|
x: 2,
|
||||||
|
y: 0,
|
||||||
|
z: -5
|
||||||
|
};
|
||||||
|
var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, {
|
||||||
|
x: 1,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
// Evaluate the world light entity positions and orientations from the model ones
|
||||||
|
function evalLightWorldTransform(modelPos, modelRot) {
|
||||||
|
|
||||||
|
return {
|
||||||
|
p: Vec3.sum(modelPos, Vec3.multiplyQbyV(modelRot, MODEL_LIGHT_POSITION)),
|
||||||
|
q: Quat.multiply(modelRot, MODEL_LIGHT_ROTATION)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var helicopter = Entities.addEntity({
|
||||||
|
type: "Model",
|
||||||
|
name: "Helicopter",
|
||||||
|
modelURL: modelURL,
|
||||||
|
animation: {
|
||||||
|
url: animationURL,
|
||||||
|
running: true,
|
||||||
|
fps: 180
|
||||||
|
|
||||||
|
},
|
||||||
|
dimensions: {
|
||||||
|
x: 12.13,
|
||||||
|
y: 3.14,
|
||||||
|
z: 9.92
|
||||||
|
},
|
||||||
|
position: spawnPosition,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var spotlight = Entities.addEntity({
|
||||||
|
type: "Light",
|
||||||
|
name: "helicopter light",
|
||||||
|
intensity: 2,
|
||||||
|
color: {
|
||||||
|
red: 200,
|
||||||
|
green: 200,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
intensity: 1,
|
||||||
|
dimensions: {
|
||||||
|
x: 2,
|
||||||
|
y: 2,
|
||||||
|
z: 200
|
||||||
|
},
|
||||||
|
exponent: 0.01,
|
||||||
|
cutoff: 10,
|
||||||
|
isSpotlight: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var debugLight = Entities.addEntity({
|
||||||
|
type: "Box",
|
||||||
|
dimensions: {
|
||||||
|
x: .1,
|
||||||
|
y: .1,
|
||||||
|
z: .3
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 200,
|
||||||
|
green: 200,
|
||||||
|
blue: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
Entities.deleteEntity(debugLight);
|
||||||
|
Entities.deleteEntity(helicopter);
|
||||||
|
Entities.deleteEntity(spotlight);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
var modelProperties = Entities.getEntityProperties(helicopter, ['position', 'rotation']);
|
||||||
|
var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation);
|
||||||
|
Entities.editEntity(spotlight, {
|
||||||
|
position: lightTransform.p,
|
||||||
|
rotation: lightTransform.q
|
||||||
|
});
|
||||||
|
Entities.editEntity(debugLight, {
|
||||||
|
position: lightTransform.p,
|
||||||
|
rotation: lightTransform.q
|
||||||
|
});
|
||||||
|
|
||||||
|
audioInjector.setOptions({
|
||||||
|
position: modelProperties.position,
|
||||||
|
});
|
||||||
|
|
||||||
|
//Move forward
|
||||||
|
var newRotation = Quat.multiply(modelProperties.rotation, {
|
||||||
|
x: 0,
|
||||||
|
y: .002,
|
||||||
|
z: 0,
|
||||||
|
w: 1
|
||||||
|
})
|
||||||
|
var newPosition = Vec3.sum(modelProperties.position, Vec3.multiply(speed, Quat.getFront(modelProperties.rotation)));
|
||||||
|
Entities.editEntity(helicopter, {
|
||||||
|
position: newPosition,
|
||||||
|
rotation: newRotation
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Script.update.connect(update);
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
|
@ -15,7 +15,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include('../utilities/tools/vector.js');
|
Script.include('../../utilities/tools/vector.js');
|
||||||
|
|
||||||
var URL = "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Scripts/planets/";
|
var URL = "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Scripts/planets/";
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include("libraries/overlayUtils.js");
|
Script.include("overlayUtils.js");
|
||||||
|
|
||||||
var MOUSE_SENSITIVITY = 0.9;
|
var MOUSE_SENSITIVITY = 0.9;
|
||||||
var SCROLL_SENSITIVITY = 0.05;
|
var SCROLL_SENSITIVITY = 0.05;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
var ENTITY_LIST_HTML_URL = Script.resolvePath('../html/entityList.html');
|
||||||
|
|
||||||
EntityListTool = function(opts) {
|
EntityListTool = function(opts) {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
var url = Script.resolvePath('html/entityList.html');
|
var url = ENTITY_LIST_HTML_URL;
|
||||||
var webView = new WebWindow('Entities', url, 200, 280, true);
|
var webView = new WebWindow('Entities', url, 200, 280, true);
|
||||||
|
|
||||||
var searchRadius = 100;
|
var searchRadius = 100;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html');
|
||||||
|
|
||||||
Grid = function(opts) {
|
Grid = function(opts) {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
|
@ -228,7 +230,7 @@ GridTool = function(opts) {
|
||||||
var verticalGrid = opts.verticalGrid;
|
var verticalGrid = opts.verticalGrid;
|
||||||
var listeners = [];
|
var listeners = [];
|
||||||
|
|
||||||
var url = Script.resolvePath('html/gridControls.html');
|
var url = GRID_CONTROLS_HTML_URL;
|
||||||
var webView = new WebWindow('Grid', url, 200, 280, true);
|
var webView = new WebWindow('Grid', url, 200, 280, true);
|
||||||
|
|
||||||
horizontalGrid.addListener(function(data) {
|
horizontalGrid.addListener(function(data) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include("../toys/breakdanceCore.js");
|
Script.include("../../../breakdanceCore.js");
|
||||||
|
|
||||||
OmniToolModules.Breakdance = function() {
|
OmniToolModules.Breakdance = function() {
|
||||||
print("OmniToolModules.Breakdance...");
|
print("OmniToolModules.Breakdance...");
|
||||||
|
@ -32,4 +32,4 @@ OmniToolModules.Breakdance.prototype.onUpdate = function(deltaTime) {
|
||||||
breakdanceEnd();
|
breakdanceEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
OmniToolModuleType = "Breakdance";
|
OmniToolModuleType = "Breakdance";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
Script.include("avatarRelativeOverlays.js");
|
Script.include("../../avatarRelativeOverlays.js");
|
||||||
|
|
||||||
OmniToolModules.Test = function(omniTool, activeEntityId) {
|
OmniToolModules.Test = function(omniTool, activeEntityId) {
|
||||||
this.omniTool = omniTool;
|
this.omniTool = omniTool;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// included here to ensure walkApi.js can be used as an API, separate from walk.js
|
// included here to ensure walkApi.js can be used as an API, separate from walk.js
|
||||||
Script.include("./libraries/walkConstants.js");
|
Script.include("walkConstants.js");
|
||||||
|
|
||||||
Avatar = function() {
|
Avatar = function() {
|
||||||
// if Hydras are connected, the only way to enable use is to never set any arm joint rotation
|
// if Hydras are connected, the only way to enable use is to never set any arm joint rotation
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var WALK_SETTINGS_HTML_URL = Script.resolvePath('../html/walkSettings.html');
|
||||||
|
|
||||||
WalkSettings = function() {
|
WalkSettings = function() {
|
||||||
var _visible = false;
|
var _visible = false;
|
||||||
var _innerWidth = Window.innerWidth;
|
var _innerWidth = Window.innerWidth;
|
||||||
|
@ -69,7 +71,7 @@ WalkSettings = function() {
|
||||||
// web window
|
// web window
|
||||||
const PANEL_WIDTH = 200;
|
const PANEL_WIDTH = 200;
|
||||||
const PANEL_HEIGHT = 180;
|
const PANEL_HEIGHT = 180;
|
||||||
var _url = Script.resolvePath('html/walkSettings.html');
|
var _url = WALK_SETTINGS_HTML_URL;
|
||||||
var _webWindow = new WebWindow('Walk Settings', _url, PANEL_WIDTH, PANEL_HEIGHT, false);
|
var _webWindow = new WebWindow('Walk Settings', _url, PANEL_WIDTH, PANEL_HEIGHT, false);
|
||||||
_webWindow.setVisible(false);
|
_webWindow.setVisible(false);
|
||||||
_webWindow.eventBridge.webEventReceived.connect(function(data) {
|
_webWindow.eventBridge.webEventReceived.connect(function(data) {
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// FIXME Script paths have to be relative to the caller, in this case libraries/OmniTool.js
|
// FIXME Script paths have to be relative to the caller, in this case libraries/OmniTool.js
|
||||||
Script.include("../magBalls/constants.js");
|
Script.include("magBalls/constants.js");
|
||||||
Script.include("../magBalls/graph.js");
|
Script.include("magBalls/graph.js");
|
||||||
Script.include("../magBalls/edgeSpring.js");
|
Script.include("magBalls/edgeSpring.js");
|
||||||
Script.include("../magBalls/magBalls.js");
|
Script.include("magBalls/magBalls.js");
|
||||||
Script.include("avatarRelativeOverlays.js");
|
Script.include("libraries/avatarRelativeOverlays.js");
|
||||||
|
|
||||||
OmniToolModuleType = "MagBallsController"
|
OmniToolModuleType = "MagBallsController"
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ MODE_INFO[BALL_EDIT_MODE_ADD] = {
|
||||||
},
|
},
|
||||||
colors: [ COLORS.GREEN, COLORS.BLUE ],
|
colors: [ COLORS.GREEN, COLORS.BLUE ],
|
||||||
// FIXME use an http path or find a way to get the relative path to the file
|
// FIXME use an http path or find a way to get the relative path to the file
|
||||||
url: Script.resolvePath('../html/magBalls/addMode.html'),
|
url: Script.resolvePath('html/magBalls/addMode.html'),
|
||||||
};
|
};
|
||||||
|
|
||||||
MODE_INFO[BALL_EDIT_MODE_DELETE] = {
|
MODE_INFO[BALL_EDIT_MODE_DELETE] = {
|
||||||
|
@ -45,7 +45,7 @@ MODE_INFO[BALL_EDIT_MODE_DELETE] = {
|
||||||
},
|
},
|
||||||
colors: [ COLORS.RED, COLORS.BLUE ],
|
colors: [ COLORS.RED, COLORS.BLUE ],
|
||||||
// FIXME use an http path or find a way to get the relative path to the file
|
// FIXME use an http path or find a way to get the relative path to the file
|
||||||
url: Script.resolvePath('../html/magBalls/deleteMode.html'),
|
url: Script.resolvePath('html/magBalls/deleteMode.html'),
|
||||||
};
|
};
|
||||||
|
|
||||||
var UI_POSITION_MODE_LABEL = Vec3.multiply(0.5,
|
var UI_POSITION_MODE_LABEL = Vec3.multiply(0.5,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include("libraries/utils.js");
|
Script.include("../libraries/utils.js");
|
||||||
|
|
||||||
|
|
||||||
var RIGHT_HAND = 1;
|
var RIGHT_HAND = 1;
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||||
|
|
||||||
Script.include("../../utilities.js");
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/models/bubblewand/wand.fbx';
|
var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/models/bubblewand/wand.fbx';
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
Script.include("../../utilities.js");
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/models/bubblewand/bubble.fbx";
|
var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/models/bubblewand/bubble.fbx";
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
Script.include("../../utilities.js");
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
var _this;
|
var _this;
|
||||||
// this is the "constructor" for the entity as a JS object we don't do much here
|
// this is the "constructor" for the entity as a JS object we don't do much here
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||||
Script.include("../../utilities.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var scriptURL = Script.resolvePath('pingPongGun.js');
|
var scriptURL = Script.resolvePath('pingPongGun.js');
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||||
Script.include("../../utilities.js");
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
var scriptURL = Script.resolvePath('wallTarget.js');
|
var scriptURL = Script.resolvePath('wallTarget.js');
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ "from": "Standard.RX", "to": "Actions.Yaw" },
|
{ "from": "Standard.RX", "to": "Actions.Yaw" },
|
||||||
|
|
||||||
{ "from": "Standard.RY",
|
{ "from": "Standard.RY",
|
||||||
"when": "Application.Grounded",
|
"when": "Application.Grounded",
|
||||||
"to": "Actions.Up",
|
"to": "Actions.Up",
|
||||||
|
|
|
@ -1132,14 +1132,6 @@ void MyAvatar::setJointRotations(QVector<glm::quat> jointRotations) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setJointTranslations(QVector<glm::vec3> jointTranslations) {
|
|
||||||
int numStates = glm::min(_skeletonModel.getJointStateCount(), jointTranslations.size());
|
|
||||||
for (int i = 0; i < numStates; ++i) {
|
|
||||||
// HACK: ATM only Recorder calls setJointTranslations() so we hardcode its priority here
|
|
||||||
_skeletonModel.setJointTranslation(i, true, jointTranslations[i], RECORDER_PRIORITY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyAvatar::setJointData(int index, const glm::quat& rotation, const glm::vec3& translation) {
|
void MyAvatar::setJointData(int index, const glm::quat& rotation, const glm::vec3& translation) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "setJointData", Q_ARG(int, index), Q_ARG(const glm::quat&, rotation),
|
QMetaObject::invokeMethod(this, "setJointData", Q_ARG(int, index), Q_ARG(const glm::quat&, rotation),
|
||||||
|
@ -1608,7 +1600,6 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
// Comfort Mode: If you press any of the left/right rotation drive keys or input, you'll
|
// Comfort Mode: If you press any of the left/right rotation drive keys or input, you'll
|
||||||
// get an instantaneous 15 degree turn. If you keep holding the key down you'll get another
|
// get an instantaneous 15 degree turn. If you keep holding the key down you'll get another
|
||||||
// snap turn every half second.
|
// snap turn every half second.
|
||||||
quint64 now = usecTimestampNow();
|
|
||||||
if (_driveKeys[STEP_YAW] != 0.0f) {
|
if (_driveKeys[STEP_YAW] != 0.0f) {
|
||||||
totalBodyYaw += _driveKeys[STEP_YAW];
|
totalBodyYaw += _driveKeys[STEP_YAW];
|
||||||
}
|
}
|
||||||
|
@ -1676,8 +1667,6 @@ glm::vec3 MyAvatar::applyKeyboardMotor(float deltaTime, const glm::vec3& localVe
|
||||||
float motorEfficiency = glm::clamp(deltaTime / timescale, 0.0f, 1.0f);
|
float motorEfficiency = glm::clamp(deltaTime / timescale, 0.0f, 1.0f);
|
||||||
|
|
||||||
glm::vec3 newLocalVelocity = localVelocity;
|
glm::vec3 newLocalVelocity = localVelocity;
|
||||||
float stepControllerInput = fabsf(_driveKeys[STEP_TRANSLATE_Z]) + fabsf(_driveKeys[STEP_TRANSLATE_Z]) + fabsf(_driveKeys[STEP_TRANSLATE_Z]);
|
|
||||||
quint64 now = usecTimestampNow();
|
|
||||||
|
|
||||||
// FIXME how do I implement step translation as well?
|
// FIXME how do I implement step translation as well?
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,6 @@ public:
|
||||||
void clearLookAtTargetAvatar();
|
void clearLookAtTargetAvatar();
|
||||||
|
|
||||||
virtual void setJointRotations(QVector<glm::quat> jointRotations) override;
|
virtual void setJointRotations(QVector<glm::quat> jointRotations) override;
|
||||||
virtual void setJointTranslations(QVector<glm::vec3> jointTranslations) override;
|
|
||||||
virtual void setJointData(int index, const glm::quat& rotation, const glm::vec3& translation) override;
|
virtual void setJointData(int index, const glm::quat& rotation, const glm::vec3& translation) override;
|
||||||
virtual void setJointRotation(int index, const glm::quat& rotation) override;
|
virtual void setJointRotation(int index, const glm::quat& rotation) override;
|
||||||
virtual void setJointTranslation(int index, const glm::vec3& translation) override;
|
virtual void setJointTranslation(int index, const glm::vec3& translation) override;
|
||||||
|
|
|
@ -246,24 +246,38 @@ void Player::play() {
|
||||||
nextFrame.getScale(),
|
nextFrame.getScale(),
|
||||||
_frameInterpolationFactor);
|
_frameInterpolationFactor);
|
||||||
_avatar->setTargetScale(context->scale * scale);
|
_avatar->setTargetScale(context->scale * scale);
|
||||||
|
|
||||||
|
// Joint array playback
|
||||||
QVector<glm::quat> jointRotations(currentFrame.getJointRotations().size());
|
// FIXME: THis is still using a deprecated path to assign the joint orientation since setting the full RawJointData array doesn't
|
||||||
for (int i = 0; i < currentFrame.getJointRotations().size(); ++i) {
|
// work for Avatar. We need to fix this working with the animation team
|
||||||
jointRotations[i] = safeMix(currentFrame.getJointRotations()[i],
|
const auto& prevJointArray = currentFrame.getJointArray();
|
||||||
nextFrame.getJointRotations()[i],
|
const auto& nextJointArray = currentFrame.getJointArray();
|
||||||
_frameInterpolationFactor);
|
QVector<JointData> jointArray(prevJointArray.size());
|
||||||
|
QVector<glm::quat> jointRotations(prevJointArray.size()); // FIXME: remove once the setRawJointData is fixed
|
||||||
|
QVector<glm::vec3> jointTranslations(prevJointArray.size()); // FIXME: remove once the setRawJointData is fixed
|
||||||
|
|
||||||
|
for (int i = 0; i < jointArray.size(); i++) {
|
||||||
|
const auto& prevJoint = prevJointArray[i];
|
||||||
|
const auto& nextJoint = nextJointArray[i];
|
||||||
|
auto& joint = jointArray[i];
|
||||||
|
|
||||||
|
// Rotation
|
||||||
|
joint.rotationSet = prevJoint.rotationSet || nextJoint.rotationSet;
|
||||||
|
if (joint.rotationSet) {
|
||||||
|
joint.rotation = safeMix(prevJoint.rotation, nextJoint.rotation, _frameInterpolationFactor);
|
||||||
|
jointRotations[i] = joint.rotation; // FIXME: remove once the setRawJointData is fixed
|
||||||
|
}
|
||||||
|
|
||||||
|
joint.translationSet = prevJoint.translationSet || nextJoint.translationSet;
|
||||||
|
if (joint.translationSet) {
|
||||||
|
joint.translation = glm::mix(prevJoint.translation, nextJoint.translation, _frameInterpolationFactor);
|
||||||
|
jointTranslations[i] = joint.translation; // FIXME: remove once the setRawJointData is fixed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<glm::vec3> jointTranslations(currentFrame.getJointTranslations().size());
|
// _avatar->setRawJointData(jointArray); // FIXME: Enable once the setRawJointData is fixed
|
||||||
for (int i = 0; i < currentFrame.getJointTranslations().size(); ++i) {
|
_avatar->setJointRotations(jointRotations); // FIXME: remove once the setRawJointData is fixed
|
||||||
jointTranslations[i] =
|
// _avatar->setJointTranslations(jointTranslations); // FIXME: remove once the setRawJointData is fixed
|
||||||
currentFrame.getJointTranslations()[i] * (1.0f - _frameInterpolationFactor) +
|
|
||||||
nextFrame.getJointTranslations()[i] * _frameInterpolationFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
_avatar->setJointRotations(jointRotations);
|
|
||||||
_avatar->setJointTranslations(jointTranslations);
|
|
||||||
|
|
||||||
HeadData* head = const_cast<HeadData*>(_avatar->getHeadData());
|
HeadData* head = const_cast<HeadData*>(_avatar->getHeadData());
|
||||||
if (head) {
|
if (head) {
|
||||||
|
@ -423,3 +437,4 @@ bool Player::computeCurrentFrame() {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,12 +100,15 @@ void Recorder::record() {
|
||||||
const RecordingContext& context = _recording->getContext();
|
const RecordingContext& context = _recording->getContext();
|
||||||
RecordingFrame frame;
|
RecordingFrame frame;
|
||||||
frame.setBlendshapeCoefficients(_avatar->getHeadData()->getBlendshapeCoefficients());
|
frame.setBlendshapeCoefficients(_avatar->getHeadData()->getBlendshapeCoefficients());
|
||||||
frame.setJointRotations(_avatar->getJointRotations());
|
|
||||||
|
// Capture the full skeleton joint data
|
||||||
|
auto& jointData = _avatar->getRawJointData();
|
||||||
|
frame.setJointArray(jointData);
|
||||||
|
|
||||||
frame.setTranslation(context.orientationInv * (_avatar->getPosition() - context.position));
|
frame.setTranslation(context.orientationInv * (_avatar->getPosition() - context.position));
|
||||||
frame.setRotation(context.orientationInv * _avatar->getOrientation());
|
frame.setRotation(context.orientationInv * _avatar->getOrientation());
|
||||||
frame.setScale(_avatar->getTargetScale() / context.scale);
|
frame.setScale(_avatar->getTargetScale() / context.scale);
|
||||||
|
|
||||||
|
|
||||||
const HeadData* head = _avatar->getHeadData();
|
const HeadData* head = _avatar->getHeadData();
|
||||||
if (head) {
|
if (head) {
|
||||||
glm::vec3 rotationDegrees = glm::vec3(head->getFinalPitch(),
|
glm::vec3 rotationDegrees = glm::vec3(head->getFinalPitch(),
|
||||||
|
@ -123,7 +126,7 @@ void Recorder::record() {
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
qCDebug(avatars) << "Recording frame #" << _recording->getFrameNumber();
|
qCDebug(avatars) << "Recording frame #" << _recording->getFrameNumber();
|
||||||
qCDebug(avatars) << "Blendshapes:" << frame.getBlendshapeCoefficients().size();
|
qCDebug(avatars) << "Blendshapes:" << frame.getBlendshapeCoefficients().size();
|
||||||
qCDebug(avatars) << "JointRotations:" << frame.getJointRotations().size();
|
qCDebug(avatars) << "JointArray:" << frame.getJointArray().size();
|
||||||
qCDebug(avatars) << "Translation:" << frame.getTranslation();
|
qCDebug(avatars) << "Translation:" << frame.getTranslation();
|
||||||
qCDebug(avatars) << "Rotation:" << frame.getRotation();
|
qCDebug(avatars) << "Rotation:" << frame.getRotation();
|
||||||
qCDebug(avatars) << "Scale:" << frame.getScale();
|
qCDebug(avatars) << "Scale:" << frame.getScale();
|
||||||
|
|
|
@ -229,22 +229,27 @@ void writeRecordingToFile(RecordingPointer recording, const QString& filename) {
|
||||||
++maskIndex;
|
++maskIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joint Rotations
|
const auto& jointArray = frame.getJointArray();
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
numJoints = frame.getJointRotations().size();
|
numJoints = jointArray.size();
|
||||||
stream << numJoints;
|
stream << numJoints;
|
||||||
mask.resize(mask.size() + numJoints);
|
// 2 fields per joints
|
||||||
|
mask.resize(mask.size() + numJoints * 2);
|
||||||
}
|
}
|
||||||
for (quint32 j = 0; j < numJoints; ++j) {
|
for (quint32 j = 0; j < numJoints; j++) {
|
||||||
if (i == 0 ||
|
const auto& joint = jointArray[j];
|
||||||
frame._jointRotations[j] != previousFrame._jointRotations[j]) {
|
if (true) { //(joint.rotationSet) {
|
||||||
writeQuat(stream, frame._jointRotations[j]);
|
writeQuat(stream, joint.rotation);
|
||||||
// TODO -- handle translations
|
mask.setBit(maskIndex);
|
||||||
|
}
|
||||||
|
maskIndex++;
|
||||||
|
if (joint.translationSet) {
|
||||||
|
writeVec3(stream, joint.translation);
|
||||||
mask.setBit(maskIndex);
|
mask.setBit(maskIndex);
|
||||||
}
|
}
|
||||||
maskIndex++;
|
maskIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translation
|
// Translation
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
mask.resize(mask.size() + 1);
|
mask.resize(mask.size() + 1);
|
||||||
|
@ -408,11 +413,7 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename.endsWith(".rec") || filename.endsWith(".REC")) {
|
if (!filename.endsWith(".hfr") && !filename.endsWith(".HFR")) {
|
||||||
qCDebug(avatars) << "Old .rec format";
|
|
||||||
readRecordingFromRecFile(recording, filename, byteArray);
|
|
||||||
return recording;
|
|
||||||
} else if (!filename.endsWith(".hfr") && !filename.endsWith(".HFR")) {
|
|
||||||
qCDebug(avatars) << "File extension not recognized";
|
qCDebug(avatars) << "File extension not recognized";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,19 +553,28 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString
|
||||||
stream >> frame._blendshapeCoefficients[j];
|
stream >> frame._blendshapeCoefficients[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Joint Rotations
|
// Joint Array
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
stream >> numJoints;
|
stream >> numJoints;
|
||||||
}
|
}
|
||||||
frame._jointRotations.resize(numJoints);
|
|
||||||
|
frame._jointArray.resize(numJoints);
|
||||||
for (quint32 j = 0; j < numJoints; ++j) {
|
for (quint32 j = 0; j < numJoints; ++j) {
|
||||||
if (!mask[maskIndex++] || !readQuat(stream, frame._jointRotations[j])) {
|
auto& joint = frame._jointArray[2];
|
||||||
frame._jointRotations[j] = previousFrame._jointRotations[j];
|
|
||||||
|
if (mask[maskIndex++] && readQuat(stream, joint.rotation)) {
|
||||||
|
joint.rotationSet = true;
|
||||||
|
} else {
|
||||||
|
joint.rotationSet = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask[maskIndex++] || readVec3(stream, joint.translation)) {
|
||||||
|
joint.translationSet = true;
|
||||||
|
} else {
|
||||||
|
joint.translationSet = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO -- handle translations
|
|
||||||
|
|
||||||
if (!mask[maskIndex++] || !readVec3(stream, frame._translation)) {
|
if (!mask[maskIndex++] || !readVec3(stream, frame._translation)) {
|
||||||
frame._translation = previousFrame._translation;
|
frame._translation = previousFrame._translation;
|
||||||
}
|
}
|
||||||
|
@ -649,167 +659,3 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString
|
||||||
return recording;
|
return recording;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RecordingPointer readRecordingFromRecFile(RecordingPointer recording, const QString& filename, const QByteArray& byteArray) {
|
|
||||||
QElapsedTimer timer;
|
|
||||||
timer.start();
|
|
||||||
|
|
||||||
if (!recording) {
|
|
||||||
recording = QSharedPointer<Recording>::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream fileStream(byteArray);
|
|
||||||
|
|
||||||
fileStream >> recording->_timestamps;
|
|
||||||
RecordingFrame baseFrame;
|
|
||||||
|
|
||||||
// Blendshape coefficients
|
|
||||||
fileStream >> baseFrame._blendshapeCoefficients;
|
|
||||||
|
|
||||||
// Joint Rotations
|
|
||||||
int jointRotationSize;
|
|
||||||
fileStream >> jointRotationSize;
|
|
||||||
baseFrame._jointRotations.resize(jointRotationSize);
|
|
||||||
for (int i = 0; i < jointRotationSize; ++i) {
|
|
||||||
fileStream >> baseFrame._jointRotations[i].x >> baseFrame._jointRotations[i].y >> baseFrame._jointRotations[i].z >> baseFrame._jointRotations[i].w;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO -- handle translations
|
|
||||||
|
|
||||||
fileStream >> baseFrame._translation.x >> baseFrame._translation.y >> baseFrame._translation.z;
|
|
||||||
fileStream >> baseFrame._rotation.x >> baseFrame._rotation.y >> baseFrame._rotation.z >> baseFrame._rotation.w;
|
|
||||||
fileStream >> baseFrame._scale;
|
|
||||||
fileStream >> baseFrame._headRotation.x >> baseFrame._headRotation.y >> baseFrame._headRotation.z >> baseFrame._headRotation.w;
|
|
||||||
fileStream >> baseFrame._leanSideways;
|
|
||||||
fileStream >> baseFrame._leanForward;
|
|
||||||
|
|
||||||
|
|
||||||
// Fake context
|
|
||||||
RecordingContext& context = recording->getContext();
|
|
||||||
context.globalTimestamp = usecTimestampNow();
|
|
||||||
context.domain = DependencyManager::get<NodeList>()->getDomainHandler().getHostname();
|
|
||||||
context.position = glm::vec3(144.5f, 3.3f, 181.3f);
|
|
||||||
context.orientation = glm::angleAxis(glm::radians(-92.5f), glm::vec3(0, 1, 0));;
|
|
||||||
context.scale = baseFrame._scale;
|
|
||||||
context.headModel = "http://public.highfidelity.io/models/heads/Emily_v4.fst";
|
|
||||||
context.skeletonModel = "http://public.highfidelity.io/models/skeletons/EmilyCutMesh_A.fst";
|
|
||||||
context.displayName = "Leslie";
|
|
||||||
context.attachments.clear();
|
|
||||||
AttachmentData data;
|
|
||||||
data.modelURL = "http://public.highfidelity.io/models/attachments/fbx.fst";
|
|
||||||
data.jointName = "RightHand" ;
|
|
||||||
data.translation = glm::vec3(0.04f, 0.07f, 0.0f);
|
|
||||||
data.rotation = glm::angleAxis(glm::radians(102.0f), glm::vec3(0, 1, 0));
|
|
||||||
data.scale = 0.20f;
|
|
||||||
context.attachments << data;
|
|
||||||
|
|
||||||
context.orientationInv = glm::inverse(context.orientation);
|
|
||||||
|
|
||||||
baseFrame._translation = glm::vec3();
|
|
||||||
baseFrame._rotation = glm::quat();
|
|
||||||
baseFrame._scale = 1.0f;
|
|
||||||
|
|
||||||
recording->_frames << baseFrame;
|
|
||||||
|
|
||||||
for (int i = 1; i < recording->_timestamps.size(); ++i) {
|
|
||||||
QBitArray mask;
|
|
||||||
QByteArray buffer;
|
|
||||||
QDataStream stream(&buffer, QIODevice::ReadOnly);
|
|
||||||
RecordingFrame frame;
|
|
||||||
RecordingFrame& previousFrame = recording->_frames.last();
|
|
||||||
|
|
||||||
fileStream >> mask;
|
|
||||||
fileStream >> buffer;
|
|
||||||
int maskIndex = 0;
|
|
||||||
|
|
||||||
// Blendshape Coefficients
|
|
||||||
frame._blendshapeCoefficients.resize(baseFrame._blendshapeCoefficients.size());
|
|
||||||
for (int i = 0; i < baseFrame._blendshapeCoefficients.size(); ++i) {
|
|
||||||
if (mask[maskIndex++]) {
|
|
||||||
stream >> frame._blendshapeCoefficients[i];
|
|
||||||
} else {
|
|
||||||
frame._blendshapeCoefficients[i] = previousFrame._blendshapeCoefficients[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Joint Rotations
|
|
||||||
frame._jointRotations.resize(baseFrame._jointRotations.size());
|
|
||||||
for (int i = 0; i < baseFrame._jointRotations.size(); ++i) {
|
|
||||||
if (mask[maskIndex++]) {
|
|
||||||
stream >> frame._jointRotations[i].x >> frame._jointRotations[i].y >> frame._jointRotations[i].z >> frame._jointRotations[i].w;
|
|
||||||
} else {
|
|
||||||
frame._jointRotations[i] = previousFrame._jointRotations[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO -- handle translations
|
|
||||||
|
|
||||||
if (mask[maskIndex++]) {
|
|
||||||
stream >> frame._translation.x >> frame._translation.y >> frame._translation.z;
|
|
||||||
frame._translation = context.orientationInv * frame._translation;
|
|
||||||
} else {
|
|
||||||
frame._translation = previousFrame._translation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mask[maskIndex++]) {
|
|
||||||
stream >> frame._rotation.x >> frame._rotation.y >> frame._rotation.z >> frame._rotation.w;
|
|
||||||
} else {
|
|
||||||
frame._rotation = previousFrame._rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mask[maskIndex++]) {
|
|
||||||
stream >> frame._scale;
|
|
||||||
} else {
|
|
||||||
frame._scale = previousFrame._scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mask[maskIndex++]) {
|
|
||||||
stream >> frame._headRotation.x >> frame._headRotation.y >> frame._headRotation.z >> frame._headRotation.w;
|
|
||||||
} else {
|
|
||||||
frame._headRotation = previousFrame._headRotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mask[maskIndex++]) {
|
|
||||||
stream >> frame._leanSideways;
|
|
||||||
} else {
|
|
||||||
frame._leanSideways = previousFrame._leanSideways;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mask[maskIndex++]) {
|
|
||||||
stream >> frame._leanForward;
|
|
||||||
} else {
|
|
||||||
frame._leanForward = previousFrame._leanForward;
|
|
||||||
}
|
|
||||||
|
|
||||||
recording->_frames << frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray audioArray;
|
|
||||||
fileStream >> audioArray;
|
|
||||||
|
|
||||||
// Cut down audio if necessary
|
|
||||||
int SAMPLE_SIZE = 2; // 16 bits
|
|
||||||
int MSEC_PER_SEC = 1000;
|
|
||||||
int audioLength = recording->getLength() * SAMPLE_SIZE * (AudioConstants::SAMPLE_RATE / MSEC_PER_SEC);
|
|
||||||
audioArray.chop(audioArray.size() - audioLength);
|
|
||||||
|
|
||||||
recording->addAudioPacket(audioArray);
|
|
||||||
|
|
||||||
qCDebug(avatars) << "Read " << byteArray.size() << " bytes in " << timer.elapsed() << " ms.";
|
|
||||||
|
|
||||||
// Set new filename
|
|
||||||
QString newFilename = filename;
|
|
||||||
if (newFilename.startsWith("http") || newFilename.startsWith("https") || newFilename.startsWith("ftp")) {
|
|
||||||
newFilename = QUrl(newFilename).fileName();
|
|
||||||
}
|
|
||||||
if (newFilename.endsWith(".rec") || newFilename.endsWith(".REC")) {
|
|
||||||
newFilename.chop(qstrlen(".rec"));
|
|
||||||
}
|
|
||||||
newFilename.append(".hfr");
|
|
||||||
newFilename = QFileInfo(newFilename).absoluteFilePath();
|
|
||||||
|
|
||||||
// Set recording to new format
|
|
||||||
writeRecordingToFile(recording, newFilename);
|
|
||||||
qCDebug(avatars) << "Recording has been successfully converted at" << newFilename;
|
|
||||||
return recording;
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ class AttachmentData;
|
||||||
class Recording;
|
class Recording;
|
||||||
class RecordingFrame;
|
class RecordingFrame;
|
||||||
class Sound;
|
class Sound;
|
||||||
|
class JointData;
|
||||||
|
|
||||||
typedef QSharedPointer<Recording> RecordingPointer;
|
typedef QSharedPointer<Recording> RecordingPointer;
|
||||||
|
|
||||||
|
@ -82,8 +83,7 @@ private:
|
||||||
class RecordingFrame {
|
class RecordingFrame {
|
||||||
public:
|
public:
|
||||||
QVector<float> getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
|
QVector<float> getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
|
||||||
QVector<glm::quat> getJointRotations() const { return _jointRotations; }
|
QVector<JointData> getJointArray() const { return _jointArray; }
|
||||||
QVector<glm::vec3> getJointTranslations() const { return _jointTranslations; }
|
|
||||||
glm::vec3 getTranslation() const { return _translation; }
|
glm::vec3 getTranslation() const { return _translation; }
|
||||||
glm::quat getRotation() const { return _rotation; }
|
glm::quat getRotation() const { return _rotation; }
|
||||||
float getScale() const { return _scale; }
|
float getScale() const { return _scale; }
|
||||||
|
@ -94,8 +94,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setBlendshapeCoefficients(QVector<float> blendshapeCoefficients);
|
void setBlendshapeCoefficients(QVector<float> blendshapeCoefficients);
|
||||||
void setJointRotations(QVector<glm::quat> jointRotations) { _jointRotations = jointRotations; }
|
void setJointArray(const QVector<JointData>& jointArray) { _jointArray = jointArray; }
|
||||||
void setJointTranslations(QVector<glm::vec3> jointTranslations) { _jointTranslations = jointTranslations; }
|
|
||||||
void setTranslation(const glm::vec3& translation) { _translation = translation; }
|
void setTranslation(const glm::vec3& translation) { _translation = translation; }
|
||||||
void setRotation(const glm::quat& rotation) { _rotation = rotation; }
|
void setRotation(const glm::quat& rotation) { _rotation = rotation; }
|
||||||
void setScale(float scale) { _scale = scale; }
|
void setScale(float scale) { _scale = scale; }
|
||||||
|
@ -106,8 +105,8 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<float> _blendshapeCoefficients;
|
QVector<float> _blendshapeCoefficients;
|
||||||
QVector<glm::quat> _jointRotations;
|
QVector<JointData> _jointArray;
|
||||||
QVector<glm::vec3> _jointTranslations;
|
|
||||||
glm::vec3 _translation;
|
glm::vec3 _translation;
|
||||||
glm::quat _rotation;
|
glm::quat _rotation;
|
||||||
float _scale;
|
float _scale;
|
||||||
|
@ -125,6 +124,5 @@ private:
|
||||||
|
|
||||||
void writeRecordingToFile(RecordingPointer recording, const QString& filename);
|
void writeRecordingToFile(RecordingPointer recording, const QString& filename);
|
||||||
RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString& filename);
|
RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString& filename);
|
||||||
RecordingPointer readRecordingFromRecFile(RecordingPointer recording, const QString& filename, const QByteArray& byteArray);
|
|
||||||
|
|
||||||
#endif // hifi_Recording_h
|
#endif // hifi_Recording_h
|
||||||
|
|
|
@ -218,7 +218,6 @@ void RenderableParticleEffectEntityItem::updateRenderItem() {
|
||||||
_vertices.clear();
|
_vertices.clear();
|
||||||
|
|
||||||
// build vertices from particle positions and radiuses
|
// build vertices from particle positions and radiuses
|
||||||
glm::vec3 frustumPosition = frustum->getPosition();
|
|
||||||
glm::vec3 dir = frustum->getDirection();
|
glm::vec3 dir = frustum->getDirection();
|
||||||
for (auto&& particle : particleDetails) {
|
for (auto&& particle : particleDetails) {
|
||||||
glm::vec3 right = glm::normalize(glm::cross(glm::vec3(0.0f, 1.0f, 0.0f), dir));
|
glm::vec3 right = glm::normalize(glm::cross(glm::vec3(0.0f, 1.0f, 0.0f), dir));
|
||||||
|
|
|
@ -6,4 +6,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Deck.h"
|
|
||||||
|
// FIXME -- DO NOT include headers in empty CPP files, it produces warnings. Once we define new symbols
|
||||||
|
// and some actual code here, we can uncomment this include.
|
||||||
|
//#include "Deck.h"
|
||||||
|
|
|
@ -80,6 +80,7 @@ FrameType Frame::registerFrameType(const QString& frameTypeName) {
|
||||||
std::call_once(once, [&] {
|
std::call_once(once, [&] {
|
||||||
auto headerType = frameTypes.registerValue("com.highfidelity.recording.Header");
|
auto headerType = frameTypes.registerValue("com.highfidelity.recording.Header");
|
||||||
Q_ASSERT(headerType == Frame::TYPE_HEADER);
|
Q_ASSERT(headerType == Frame::TYPE_HEADER);
|
||||||
|
Q_UNUSED(headerType); // FIXME - build system on unix still not upgraded to Qt 5.5.1 so Q_ASSERT still produces warnings
|
||||||
});
|
});
|
||||||
return frameTypes.registerValue(frameTypeName);
|
return frameTypes.registerValue(frameTypeName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,9 +135,6 @@ void Model::reset() {
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
_rig->reset(geometry.joints);
|
_rig->reset(geometry.joints);
|
||||||
}
|
}
|
||||||
_meshGroupsKnown = false;
|
|
||||||
_readyWhenAdded = false; // in case any of our users are using scenes
|
|
||||||
invalidCalculatedMeshBoxes(); // if we have to reload, we need to assume our mesh boxes are all invalid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Model::updateGeometry() {
|
bool Model::updateGeometry() {
|
||||||
|
@ -1156,6 +1153,9 @@ void Model::segregateMeshGroups() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_ASSERT(_renderItems.isEmpty()); // We should not have any existing renderItems if we enter this section of code
|
||||||
|
Q_ASSERT(_renderItemsSet.isEmpty()); // We should not have any existing renderItemsSet if we enter this section of code
|
||||||
|
|
||||||
_renderItemsSet.clear();
|
_renderItemsSet.clear();
|
||||||
|
|
||||||
// Run through all of the meshes, and place them into their segregated, but unsorted buckets
|
// Run through all of the meshes, and place them into their segregated, but unsorted buckets
|
||||||
|
|
|
@ -902,14 +902,19 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac
|
||||||
BatchLoader* loader = new BatchLoader(urls);
|
BatchLoader* loader = new BatchLoader(urls);
|
||||||
|
|
||||||
auto evaluateScripts = [=](const QMap<QUrl, QString>& data) {
|
auto evaluateScripts = [=](const QMap<QUrl, QString>& data) {
|
||||||
|
auto parentURL = _parentURL;
|
||||||
for (QUrl url : urls) {
|
for (QUrl url : urls) {
|
||||||
QString contents = data[url];
|
QString contents = data[url];
|
||||||
if (contents.isNull()) {
|
if (contents.isNull()) {
|
||||||
qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
|
qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
|
||||||
} else {
|
} else {
|
||||||
|
// Set the parent url so that path resolution will be relative
|
||||||
|
// to this script's url during its initial evaluation
|
||||||
|
_parentURL = url.toString();
|
||||||
QScriptValue result = evaluate(contents, url.toString());
|
QScriptValue result = evaluate(contents, url.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_parentURL = parentURL;
|
||||||
|
|
||||||
if (callback.isFunction()) {
|
if (callback.isFunction()) {
|
||||||
QScriptValue(callback).call();
|
QScriptValue(callback).call();
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
|
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
|
|
||||||
#define QVERIFY Q_ASSERT
|
|
||||||
|
|
||||||
using namespace recording;
|
using namespace recording;
|
||||||
FrameType TEST_FRAME_TYPE { Frame::TYPE_INVALID };
|
FrameType TEST_FRAME_TYPE { Frame::TYPE_INVALID };
|
||||||
|
|
||||||
|
@ -30,7 +28,8 @@ void testFrameTypeRegistration() {
|
||||||
auto backMap = recording::Frame::getFrameTypeNames();
|
auto backMap = recording::Frame::getFrameTypeNames();
|
||||||
QVERIFY(backMap.count(TEST_FRAME_TYPE) == 1);
|
QVERIFY(backMap.count(TEST_FRAME_TYPE) == 1);
|
||||||
QVERIFY(backMap[TEST_FRAME_TYPE] == TEST_NAME);
|
QVERIFY(backMap[TEST_FRAME_TYPE] == TEST_NAME);
|
||||||
QVERIFY(backMap[recording::Frame::TYPE_HEADER] == HEADER_NAME);
|
auto typeHeader = recording::Frame::TYPE_HEADER;
|
||||||
|
QVERIFY(backMap[typeHeader] == HEADER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testFilePersist() {
|
void testFilePersist() {
|
||||||
|
@ -95,6 +94,7 @@ void testClipOrdering() {
|
||||||
for (auto writeFrame = writeClip->nextFrame(); writeFrame; writeFrame = writeClip->nextFrame()) {
|
for (auto writeFrame = writeClip->nextFrame(); writeFrame; writeFrame = writeClip->nextFrame()) {
|
||||||
QVERIFY(writeClip->position() >= lastFrameTimeOffset);
|
QVERIFY(writeClip->position() >= lastFrameTimeOffset);
|
||||||
}
|
}
|
||||||
|
Q_UNUSED(lastFrameTimeOffset); // FIXME - Unix build not yet upgraded to Qt 5.5.1 we can remove this once it is
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
|
|
Loading…
Reference in a new issue