mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
merge
This commit is contained in:
commit
0a0eba8277
13 changed files with 219 additions and 142 deletions
|
@ -40,7 +40,8 @@ if (WIN32)
|
||||||
endif ()
|
endif ()
|
||||||
message (WINDOW_SDK_PATH= ${WINDOW_SDK_PATH})
|
message (WINDOW_SDK_PATH= ${WINDOW_SDK_PATH})
|
||||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WINDOW_SDK_PATH})
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WINDOW_SDK_PATH})
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
# /wd4351 disables warning C4351: new behavior: elements of array will be default initialized
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4351")
|
||||||
# /LARGEADDRESSAWARE enables 32-bit apps to use more than 2GB of memory.
|
# /LARGEADDRESSAWARE enables 32-bit apps to use more than 2GB of memory.
|
||||||
# Caveats: http://stackoverflow.com/questions/2288728/drawbacks-of-using-largeaddressaware-for-32-bit-windows-executables
|
# Caveats: http://stackoverflow.com/questions/2288728/drawbacks-of-using-largeaddressaware-for-32-bit-windows-executables
|
||||||
# TODO: Remove when building 64-bit.
|
# TODO: Remove when building 64-bit.
|
||||||
|
|
|
@ -153,6 +153,26 @@ if (showScore) {
|
||||||
|
|
||||||
var BULLET_VELOCITY = 10.0;
|
var BULLET_VELOCITY = 10.0;
|
||||||
|
|
||||||
|
function entityCollisionWithEntity(entity1, entity2, collision) {
|
||||||
|
if (entity2 === targetID) {
|
||||||
|
score++;
|
||||||
|
if (showScore) {
|
||||||
|
Overlays.editOverlay(text, { text: "Score: " + score } );
|
||||||
|
}
|
||||||
|
|
||||||
|
// We will delete the bullet and target in 1/2 sec, but for now we can see them bounce!
|
||||||
|
Script.setTimeout(deleteBulletAndTarget, 500);
|
||||||
|
|
||||||
|
// Turn the target and the bullet white
|
||||||
|
Entities.editEntity(entity1, { color: { red: 255, green: 255, blue: 255 }});
|
||||||
|
Entities.editEntity(entity2, { color: { red: 255, green: 255, blue: 255 }});
|
||||||
|
|
||||||
|
// play the sound near the camera so the shooter can hear it
|
||||||
|
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||||
|
Audio.playSound(targetHitSound, audioOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function shootBullet(position, velocity, grenade) {
|
function shootBullet(position, velocity, grenade) {
|
||||||
var BULLET_SIZE = 0.10;
|
var BULLET_SIZE = 0.10;
|
||||||
var BULLET_LIFETIME = 10.0;
|
var BULLET_LIFETIME = 10.0;
|
||||||
|
@ -178,6 +198,7 @@ function shootBullet(position, velocity, grenade) {
|
||||||
ignoreCollisions: false,
|
ignoreCollisions: false,
|
||||||
collisionsWillMove: true
|
collisionsWillMove: true
|
||||||
});
|
});
|
||||||
|
Script.addEventHandler(bulletID, "collisionWithEntity", entityCollisionWithEntity);
|
||||||
|
|
||||||
// Play firing sounds
|
// Play firing sounds
|
||||||
audioOptions.position = position;
|
audioOptions.position = position;
|
||||||
|
@ -310,27 +331,6 @@ function makePlatform(gravity, scale, size) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function entityCollisionWithEntity(entity1, entity2, collision) {
|
|
||||||
if (((entity1.id == bulletID.id) || (entity1.id == targetID.id)) &&
|
|
||||||
((entity2.id == bulletID.id) || (entity2.id == targetID.id))) {
|
|
||||||
score++;
|
|
||||||
if (showScore) {
|
|
||||||
Overlays.editOverlay(text, { text: "Score: " + score } );
|
|
||||||
}
|
|
||||||
|
|
||||||
// We will delete the bullet and target in 1/2 sec, but for now we can see them bounce!
|
|
||||||
Script.setTimeout(deleteBulletAndTarget, 500);
|
|
||||||
|
|
||||||
// Turn the target and the bullet white
|
|
||||||
Entities.editEntity(entity1, { color: { red: 255, green: 255, blue: 255 }});
|
|
||||||
Entities.editEntity(entity2, { color: { red: 255, green: 255, blue: 255 }});
|
|
||||||
|
|
||||||
// play the sound near the camera so the shooter can hear it
|
|
||||||
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
|
||||||
Audio.playSound(targetHitSound, audioOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function keyPressEvent(event) {
|
function keyPressEvent(event) {
|
||||||
// if our tools are off, then don't do anything
|
// if our tools are off, then don't do anything
|
||||||
if (event.text == "t") {
|
if (event.text == "t") {
|
||||||
|
@ -505,7 +505,6 @@ function scriptEnding() {
|
||||||
clearPose();
|
clearPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
|
||||||
Script.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||||
|
|
53
examples/example/entityCollisionExample.js
Normal file
53
examples/example/entityCollisionExample.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
//
|
||||||
|
// entityCollisionExample.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// Created by Howard Stearns on 5/25/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This is an example script that demonstrates use of the per-entity event handlers.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
function someCollisionFunction(entityA, entityB, collision) {
|
||||||
|
print("collision: " + JSON.stringify({a: entityA, b: entityB, c: collision}));
|
||||||
|
}
|
||||||
|
|
||||||
|
var position = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));
|
||||||
|
var properties = {
|
||||||
|
type: "Box",
|
||||||
|
position: position,
|
||||||
|
collisionsWillMove: true,
|
||||||
|
color: { red: 200, green: 0, blue: 0 }
|
||||||
|
};
|
||||||
|
var collider = Entities.addEntity(properties);
|
||||||
|
var armed = false;
|
||||||
|
function togglePrinting() {
|
||||||
|
print('togglePrinting from ' + armed + ' on ' + collider);
|
||||||
|
if (armed) {
|
||||||
|
Script.removeEventHandler(collider, "collisionWithEntity", someCollisionFunction);
|
||||||
|
} else {
|
||||||
|
Script.addEventHandler(collider, "collisionWithEntity", someCollisionFunction);
|
||||||
|
}
|
||||||
|
armed = !armed;
|
||||||
|
print("Red box " + (armed ? "will" : "will not") + " print on collision.");
|
||||||
|
}
|
||||||
|
togglePrinting();
|
||||||
|
|
||||||
|
properties.position.y += 0.2;
|
||||||
|
properties.color.blue += 200;
|
||||||
|
// A handy target for the collider to hit.
|
||||||
|
var target = Entities.addEntity(properties);
|
||||||
|
|
||||||
|
properties.position.y += 0.2;
|
||||||
|
properties.color.green += 200;
|
||||||
|
var button = Entities.addEntity(properties);
|
||||||
|
Script.addEventHandler(button, "clickReleaseOnEntity", togglePrinting);
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(function () {
|
||||||
|
Entities.deleteEntity(collider);
|
||||||
|
Entities.deleteEntity(target);
|
||||||
|
Entities.deleteEntity(button);
|
||||||
|
});
|
|
@ -33,8 +33,8 @@ var cuePosition;
|
||||||
var startStroke = 0;
|
var startStroke = 0;
|
||||||
|
|
||||||
// Sounds to use
|
// Sounds to use
|
||||||
hitSounds = [];
|
var hitSound = HIFI_PUBLIC_BUCKET + "sounds/Collisions-ballhitsandcatches/billiards/collision1.wav";
|
||||||
hitSounds.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "Collisions-ballhitsandcatches/billiards/collision1.wav"));
|
SoundCache.getSound(hitSound);
|
||||||
|
|
||||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
var screenSize = Controller.getViewportDimensions();
|
var screenSize = Controller.getViewportDimensions();
|
||||||
|
@ -127,6 +127,7 @@ function makeBalls(pos) {
|
||||||
ignoreCollisions: false,
|
ignoreCollisions: false,
|
||||||
damping: 0.50,
|
damping: 0.50,
|
||||||
shapeType: "sphere",
|
shapeType: "sphere",
|
||||||
|
collisionSoundURL: hitSound,
|
||||||
collisionsWillMove: true }));
|
collisionsWillMove: true }));
|
||||||
ballPosition.z += (BALL_SIZE + BALL_GAP) * SCALE;
|
ballPosition.z += (BALL_SIZE + BALL_GAP) * SCALE;
|
||||||
ballNumber++;
|
ballNumber++;
|
||||||
|
@ -225,26 +226,11 @@ function update(deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function entityCollisionWithEntity(entity1, entity2, collision) {
|
|
||||||
/*
|
|
||||||
NOT WORKING YET
|
|
||||||
if ((entity1.id == cueBall.id) || (entity2.id == cueBall.id)) {
|
|
||||||
print("Cue ball collision!");
|
|
||||||
//audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
|
||||||
//Audio.playSound(hitSounds[0], { position: Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())) });
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (isObjectBall(entity1.id) || isObjectBall(entity2.id)) {
|
|
||||||
print("Object ball collision");
|
|
||||||
} */
|
|
||||||
}
|
|
||||||
|
|
||||||
tableCenter = Vec3.sum(MyAvatar.position, Vec3.multiply(4.0, Quat.getFront(Camera.getOrientation())));
|
tableCenter = Vec3.sum(MyAvatar.position, Vec3.multiply(4.0, Quat.getFront(Camera.getOrientation())));
|
||||||
|
|
||||||
makeTable(tableCenter);
|
makeTable(tableCenter);
|
||||||
makeBalls(tableCenter);
|
makeBalls(tableCenter);
|
||||||
|
|
||||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||||
|
|
|
@ -21,6 +21,16 @@ var gameOver = false;
|
||||||
var invaderStepsPerCycle = 120; // the number of update steps it takes then invaders to move one column to the right
|
var invaderStepsPerCycle = 120; // the number of update steps it takes then invaders to move one column to the right
|
||||||
var invaderStepOfCycle = 0; // current iteration in the cycle
|
var invaderStepOfCycle = 0; // current iteration in the cycle
|
||||||
var invaderMoveDirection = 1; // 1 for moving to right, -1 for moving to left
|
var invaderMoveDirection = 1; // 1 for moving to right, -1 for moving to left
|
||||||
|
var LEFT = ",";
|
||||||
|
var RIGHT = ".";
|
||||||
|
var FIRE = "SPACE";
|
||||||
|
var QUIT = "q";
|
||||||
|
|
||||||
|
print("Use:");
|
||||||
|
print(LEFT + " to move left");
|
||||||
|
print(RIGHT + " to move right");
|
||||||
|
print(FIRE + " to fire");
|
||||||
|
print(QUIT + " to quit");
|
||||||
|
|
||||||
// game length...
|
// game length...
|
||||||
var itemLifetimes = 60; // 1 minute
|
var itemLifetimes = 60; // 1 minute
|
||||||
|
@ -65,8 +75,8 @@ var myShipProperties;
|
||||||
|
|
||||||
// create the rows of space invaders
|
// create the rows of space invaders
|
||||||
var invaders = new Array();
|
var invaders = new Array();
|
||||||
var numberOfRows = 5;
|
var numberOfRows = 3 // FIXME 5;
|
||||||
var invadersPerRow = 8;
|
var invadersPerRow = 3 // FIXME 8;
|
||||||
var emptyColumns = 2; // number of invader width columns not filled with invaders
|
var emptyColumns = 2; // number of invader width columns not filled with invaders
|
||||||
var invadersBottomCorner = { x: gameAt.x, y: middleY , z: gameAt.z };
|
var invadersBottomCorner = { x: gameAt.x, y: middleY , z: gameAt.z };
|
||||||
var rowHeight = ((gameAt.y + gameSize.y) - invadersBottomCorner.y) / numberOfRows;
|
var rowHeight = ((gameAt.y + gameSize.y) - invadersBottomCorner.y) / numberOfRows;
|
||||||
|
@ -80,7 +90,6 @@ var stepsToGround = (middleY - gameAt.y) / yPerStep;
|
||||||
var maxInvaderRowOffset=stepsToGround;
|
var maxInvaderRowOffset=stepsToGround;
|
||||||
|
|
||||||
// missile related items
|
// missile related items
|
||||||
var missileFired = false;
|
|
||||||
var myMissile;
|
var myMissile;
|
||||||
|
|
||||||
// sounds
|
// sounds
|
||||||
|
@ -174,6 +183,7 @@ function initializeInvaders() {
|
||||||
invaderPosition = getInvaderPosition(row, column);
|
invaderPosition = getInvaderPosition(row, column);
|
||||||
invaders[row][column] = Entities.addEntity({
|
invaders[row][column] = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
|
shapeType: "box",
|
||||||
position: invaderPosition,
|
position: invaderPosition,
|
||||||
velocity: { x: 0, y: 0, z: 0 },
|
velocity: { x: 0, y: 0, z: 0 },
|
||||||
gravity: { x: 0, y: 0, z: 0 },
|
gravity: { x: 0, y: 0, z: 0 },
|
||||||
|
@ -181,6 +191,7 @@ function initializeInvaders() {
|
||||||
dimensions: { x: invaderSize * 2, y: invaderSize * 2, z: invaderSize * 2 },
|
dimensions: { x: invaderSize * 2, y: invaderSize * 2, z: invaderSize * 2 },
|
||||||
color: { red: 255, green: 0, blue: 0 },
|
color: { red: 255, green: 0, blue: 0 },
|
||||||
modelURL: invaderModels[row].modelURL,
|
modelURL: invaderModels[row].modelURL,
|
||||||
|
collisionsWillMove: true,
|
||||||
lifetime: itemLifetimes
|
lifetime: itemLifetimes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -264,17 +275,17 @@ Script.update.connect(update);
|
||||||
function cleanupGame() {
|
function cleanupGame() {
|
||||||
print("cleaning up game...");
|
print("cleaning up game...");
|
||||||
Entities.deleteEntity(myShip);
|
Entities.deleteEntity(myShip);
|
||||||
print("cleanupGame() ... Entities.deleteEntity(myShip)... myShip.id="+myShip.id);
|
print("cleanupGame() ... Entities.deleteEntity(myShip)... myShip="+myShip);
|
||||||
for (var row = 0; row < numberOfRows; row++) {
|
for (var row = 0; row < numberOfRows; row++) {
|
||||||
for (var column = 0; column < invadersPerRow; column++) {
|
for (var column = 0; column < invadersPerRow; column++) {
|
||||||
Entities.deleteEntity(invaders[row][column]);
|
Entities.deleteEntity(invaders[row][column]);
|
||||||
print("cleanupGame() ... Entities.deleteEntity(invaders[row][column])... invaders[row][column].id="
|
print("cleanupGame() ... Entities.deleteEntity(invaders[row][column])... invaders[row][column]="
|
||||||
+invaders[row][column].id);
|
+invaders[row][column]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up our missile
|
// clean up our missile
|
||||||
if (missileFired) {
|
if (myMissile) {
|
||||||
Entities.deleteEntity(myMissile);
|
Entities.deleteEntity(myMissile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,15 +304,23 @@ function moveShipTo(position) {
|
||||||
Entities.editEntity(myShip, { position: position });
|
Entities.editEntity(myShip, { position: position });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function entityCollisionWithEntity(entityA, entityB, collision) {
|
||||||
|
print("entityCollisionWithEntity() a="+entityA + " b=" + entityB);
|
||||||
|
Vec3.print('entityCollisionWithEntity() penetration=', collision.penetration);
|
||||||
|
Vec3.print('entityCollisionWithEntity() contactPoint=', collision.contactPoint);
|
||||||
|
|
||||||
|
deleteIfInvader(entityB);
|
||||||
|
}
|
||||||
|
|
||||||
function fireMissile() {
|
function fireMissile() {
|
||||||
// we only allow one missile at a time...
|
// we only allow one missile at a time...
|
||||||
var canFire = false;
|
var canFire = false;
|
||||||
|
|
||||||
// If we've fired a missile, then check to see if it's still alive
|
// If we've fired a missile, then check to see if it's still alive
|
||||||
if (missileFired) {
|
if (myMissile) {
|
||||||
var missileProperties = Entities.getEntityProperties(myMissile);
|
var missileProperties = Entities.getEntityProperties(myMissile);
|
||||||
|
|
||||||
if (!missileProperties) {
|
if (!missileProperties || (missileProperties.type === 'Unknown')) {
|
||||||
print("canFire = true");
|
print("canFire = true");
|
||||||
canFire = true;
|
canFire = true;
|
||||||
}
|
}
|
||||||
|
@ -322,11 +341,12 @@ function fireMissile() {
|
||||||
velocity: { x: 0, y: 5, z: 0},
|
velocity: { x: 0, y: 5, z: 0},
|
||||||
gravity: { x: 0, y: 0, z: 0 },
|
gravity: { x: 0, y: 0, z: 0 },
|
||||||
damping: 0,
|
damping: 0,
|
||||||
dimensions: { x: missileSize * 2, y: missileSize * 2, z: missileSize * 2 },
|
collisionsWillMove: true,
|
||||||
|
dimensions: { x: missileSize, y: missileSize, z: missileSize },
|
||||||
color: { red: 0, green: 0, blue: 255 },
|
color: { red: 0, green: 0, blue: 255 },
|
||||||
lifetime: 5
|
lifetime: 5
|
||||||
});
|
});
|
||||||
|
Script.addEventHandler(myMissile, "collisionWithEntity", entityCollisionWithEntity);
|
||||||
var options = {}
|
var options = {}
|
||||||
if (soundInMyHead) {
|
if (soundInMyHead) {
|
||||||
options.position = { x: MyAvatar.position.x + 0.0,
|
options.position = { x: MyAvatar.position.x + 0.0,
|
||||||
|
@ -335,30 +355,30 @@ function fireMissile() {
|
||||||
} else {
|
} else {
|
||||||
options.position = missilePosition;
|
options.position = missilePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
Audio.playSound(shootSound, options);
|
Audio.playSound(shootSound, options);
|
||||||
|
|
||||||
missileFired = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function keyPressEvent(key) {
|
function keyPressEvent(key) {
|
||||||
//print("keyPressEvent key.text="+key.text);
|
//print("keyPressEvent key.text="+key.text);
|
||||||
if (key.text == ",") {
|
|
||||||
|
if (key.text == LEFT) {
|
||||||
myShipProperties.position.x -= 0.1;
|
myShipProperties.position.x -= 0.1;
|
||||||
if (myShipProperties.position.x < gameAt.x) {
|
if (myShipProperties.position.x < gameAt.x) {
|
||||||
myShipProperties.position.x = gameAt.x;
|
myShipProperties.position.x = gameAt.x;
|
||||||
}
|
}
|
||||||
moveShipTo(myShipProperties.position);
|
moveShipTo(myShipProperties.position);
|
||||||
} else if (key.text == ".") {
|
} else if (key.text == RIGHT) {
|
||||||
myShipProperties.position.x += 0.1;
|
myShipProperties.position.x += 0.1;
|
||||||
if (myShipProperties.position.x > gameAt.x + gameSize.x) {
|
if (myShipProperties.position.x > gameAt.x + gameSize.x) {
|
||||||
myShipProperties.position.x = gameAt.x + gameSize.x;
|
myShipProperties.position.x = gameAt.x + gameSize.x;
|
||||||
}
|
}
|
||||||
moveShipTo(myShipProperties.position);
|
moveShipTo(myShipProperties.position);
|
||||||
} else if (key.text == "f") {
|
} else if (key.text == FIRE) {
|
||||||
fireMissile();
|
fireMissile();
|
||||||
} else if (key.text == "q") {
|
} else if (key.text == QUIT) {
|
||||||
endGame();
|
endGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,7 +390,7 @@ Controller.captureKeyEvents({text: " "});
|
||||||
function deleteIfInvader(possibleInvaderEntity) {
|
function deleteIfInvader(possibleInvaderEntity) {
|
||||||
for (var row = 0; row < numberOfRows; row++) {
|
for (var row = 0; row < numberOfRows; row++) {
|
||||||
for (var column = 0; column < invadersPerRow; column++) {
|
for (var column = 0; column < invadersPerRow; column++) {
|
||||||
if (invaders[row][column].id && invaders[row][column].id == possibleInvaderEntity.id) {
|
if (invaders[row][column] == possibleInvaderEntity) {
|
||||||
Entities.deleteEntity(possibleInvaderEntity);
|
Entities.deleteEntity(possibleInvaderEntity);
|
||||||
Entities.deleteEntity(myMissile);
|
Entities.deleteEntity(myMissile);
|
||||||
|
|
||||||
|
@ -390,20 +410,6 @@ function deleteIfInvader(possibleInvaderEntity) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function entityCollisionWithEntity(entityA, entityB, collision) {
|
|
||||||
print("entityCollisionWithEntity() a.id="+entityA.id + " b.id=" + entityB.id);
|
|
||||||
Vec3.print('entityCollisionWithEntity() penetration=', collision.penetration);
|
|
||||||
Vec3.print('entityCollisionWithEntity() contactPoint=', collision.contactPoint);
|
|
||||||
if (missileFired) {
|
|
||||||
if (myMissile.id == entityA.id) {
|
|
||||||
deleteIfInvader(entityB);
|
|
||||||
} else if (myMissile.id == entityB.id) {
|
|
||||||
deleteIfInvader(entityA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
|
||||||
|
|
||||||
|
|
||||||
// initialize the game...
|
// initialize the game...
|
||||||
initializeMyShip();
|
initializeMyShip();
|
||||||
|
|
|
@ -12,17 +12,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
print("hello...");
|
print("The global collision event is obsolete. Please instead use:");
|
||||||
|
print(" the collisionSoundURL property on entities, or");
|
||||||
|
print(" entityCollisionExample.js");
|
||||||
function entityCollisionWithEntity(entityA, entityB, collision) {
|
|
||||||
print("entityCollisionWithParticle()..");
|
|
||||||
print(" entityA.getID()=" + entityA.id);
|
|
||||||
print(" entityB.getID()=" + entityB.id);
|
|
||||||
Vec3.print('penetration=', collision.penetration);
|
|
||||||
Vec3.print('contactPoint=', collision.contactPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
|
||||||
|
|
||||||
print("here... hello...");
|
|
||||||
|
|
|
@ -18,30 +18,50 @@ var position, positionOffset, prevPosition;
|
||||||
var nearLinePosition;
|
var nearLinePosition;
|
||||||
var strokes = [];
|
var strokes = [];
|
||||||
var STROKE_ADJUST = 0.005;
|
var STROKE_ADJUST = 0.005;
|
||||||
var DISTANCE_DRAW_THRESHOLD = .03;
|
var DISTANCE_DRAW_THRESHOLD = .02;
|
||||||
var drawDistance = 0;
|
var drawDistance = 0;
|
||||||
|
|
||||||
var userCanDraw = true;
|
var LINE_WIDTH = 20;
|
||||||
|
|
||||||
|
var userCanPoint = false;
|
||||||
|
var userCanDraw = false;
|
||||||
|
|
||||||
var BUTTON_SIZE = 32;
|
var BUTTON_SIZE = 32;
|
||||||
var PADDING = 3;
|
var PADDING = 3;
|
||||||
|
|
||||||
var buttonOffColor = {red: 250, green: 10, blue: 10};
|
var buttonOffColor = {
|
||||||
var buttonOnColor = {red: 10, green: 200, blue: 100};
|
red: 250,
|
||||||
|
green: 10,
|
||||||
|
blue: 10
|
||||||
|
};
|
||||||
|
var buttonOnColor = {
|
||||||
|
red: 10,
|
||||||
|
green: 200,
|
||||||
|
blue: 100
|
||||||
|
};
|
||||||
|
|
||||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
var screenSize = Controller.getViewportDimensions();
|
var screenSize = Controller.getViewportDimensions();
|
||||||
|
|
||||||
var drawButton = Overlays.addOverlay("image", {
|
var drawButton = Overlays.addOverlay("image", {
|
||||||
x: screenSize.x / 2 - BUTTON_SIZE * 2 + PADDING,
|
x: screenSize.x / 2 - BUTTON_SIZE + PADDING * 2,
|
||||||
y: screenSize.y - (BUTTON_SIZE + PADDING),
|
y: screenSize.y - (BUTTON_SIZE + PADDING),
|
||||||
width: BUTTON_SIZE,
|
width: BUTTON_SIZE,
|
||||||
height: BUTTON_SIZE,
|
height: BUTTON_SIZE,
|
||||||
imageURL: HIFI_PUBLIC_BUCKET + "images/pencil.png?v2",
|
imageURL: HIFI_PUBLIC_BUCKET + "images/pencil.png?v2",
|
||||||
color: buttonOnColor,
|
color: buttonOffColor,
|
||||||
alpha: 1
|
alpha: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var pointerButton = Overlays.addOverlay("image", {
|
||||||
|
x: screenSize.x / 2 - BUTTON_SIZE * 2 + PADDING,
|
||||||
|
y: screenSize.y - (BUTTON_SIZE + PADDING),
|
||||||
|
width: BUTTON_SIZE,
|
||||||
|
height: BUTTON_SIZE,
|
||||||
|
imageURL: HIFI_PUBLIC_BUCKET + "images/laser.png",
|
||||||
|
color: buttonOffColor,
|
||||||
|
alpha: 1
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,8 +70,16 @@ center.y += 0.5;
|
||||||
var whiteBoard = Entities.addEntity({
|
var whiteBoard = Entities.addEntity({
|
||||||
type: "Box",
|
type: "Box",
|
||||||
position: center,
|
position: center,
|
||||||
dimensions: {x: 1, y: 1, z: .001},
|
dimensions: {
|
||||||
color: {red: 255, green: 255, blue: 255}
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: .001
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function calculateNearLinePosition(targetPosition) {
|
function calculateNearLinePosition(targetPosition) {
|
||||||
|
@ -73,6 +101,9 @@ function removeLine() {
|
||||||
|
|
||||||
|
|
||||||
function createOrUpdateLine(event) {
|
function createOrUpdateLine(event) {
|
||||||
|
if (!userCanPoint) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking
|
var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking
|
||||||
var props = Entities.getEntityProperties(intersection.entityID);
|
var props = Entities.getEntityProperties(intersection.entityID);
|
||||||
|
@ -82,14 +113,13 @@ function createOrUpdateLine(event) {
|
||||||
var subtractVec = Vec3.multiply(Vec3.normalize(pickRay.direction), STROKE_ADJUST);
|
var subtractVec = Vec3.multiply(Vec3.normalize(pickRay.direction), STROKE_ADJUST);
|
||||||
startPosition = Vec3.subtract(startPosition, subtractVec);
|
startPosition = Vec3.subtract(startPosition, subtractVec);
|
||||||
nearLinePosition = calculateNearLinePosition(intersection.intersection);
|
nearLinePosition = calculateNearLinePosition(intersection.intersection);
|
||||||
positionOffset= Vec3.subtract(startPosition, nearLinePosition);
|
positionOffset = Vec3.subtract(startPosition, nearLinePosition);
|
||||||
if (lineIsRezzed) {
|
if (lineIsRezzed) {
|
||||||
Entities.editEntity(lineEntityID, {
|
Entities.editEntity(lineEntityID, {
|
||||||
position: nearLinePosition,
|
position: nearLinePosition,
|
||||||
dimensions: positionOffset,
|
dimensions: positionOffset,
|
||||||
lifetime: 15 + props.lifespan // renew lifetime
|
|
||||||
});
|
});
|
||||||
if(userCanDraw){
|
if (userCanDraw) {
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,7 +134,6 @@ function createOrUpdateLine(event) {
|
||||||
green: 255,
|
green: 255,
|
||||||
blue: 255
|
blue: 255
|
||||||
},
|
},
|
||||||
lifetime: 15 // if someone crashes while pointing, don't leave the line there forever.
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,11 +141,11 @@ function createOrUpdateLine(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw(){
|
function draw() {
|
||||||
|
|
||||||
//We only want to draw line if distance between starting and previous point is large enough
|
//We only want to draw line if distance between starting and previous point is large enough
|
||||||
drawDistance = Vec3.distance(startPosition, prevPosition);
|
drawDistance = Vec3.distance(startPosition, prevPosition);
|
||||||
if( drawDistance < DISTANCE_DRAW_THRESHOLD){
|
if (drawDistance < DISTANCE_DRAW_THRESHOLD) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,8 +154,12 @@ function draw(){
|
||||||
type: "Line",
|
type: "Line",
|
||||||
position: prevPosition,
|
position: prevPosition,
|
||||||
dimensions: offset,
|
dimensions: offset,
|
||||||
color: {red: 200, green: 40, blue: 200},
|
color: {
|
||||||
// lifetime: 20
|
red: 200,
|
||||||
|
green: 40,
|
||||||
|
blue: 200
|
||||||
|
},
|
||||||
|
lineWidth: LINE_WIDTH
|
||||||
}));
|
}));
|
||||||
prevPosition = startPosition;
|
prevPosition = startPosition;
|
||||||
}
|
}
|
||||||
|
@ -138,12 +171,38 @@ function mousePressEvent(event) {
|
||||||
});
|
});
|
||||||
if (clickedOverlay == drawButton) {
|
if (clickedOverlay == drawButton) {
|
||||||
userCanDraw = !userCanDraw;
|
userCanDraw = !userCanDraw;
|
||||||
if(userCanDraw === true){
|
if (userCanDraw === true) {
|
||||||
Overlays.editOverlay(drawButton, {color: buttonOnColor});
|
Overlays.editOverlay(drawButton, {
|
||||||
|
color: buttonOnColor
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Overlays.editOverlay(drawButton, {color: buttonOffColor});
|
Overlays.editOverlay(drawButton, {
|
||||||
|
color: buttonOffColor
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (clickedOverlay == pointerButton) {
|
||||||
|
userCanPoint = !userCanPoint;
|
||||||
|
if (userCanPoint === true) {
|
||||||
|
Overlays.editOverlay(pointerButton, {
|
||||||
|
color: buttonOnColor
|
||||||
|
});
|
||||||
|
if (userCanDraw === true) {
|
||||||
|
|
||||||
|
Overlays.editOverlay(drawButton, {
|
||||||
|
color: buttonOnColor
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Overlays.editOverlay(pointerButton, {
|
||||||
|
color: buttonOffColor
|
||||||
|
});
|
||||||
|
Overlays.editOverlay(drawButton, {
|
||||||
|
color: buttonOffColor
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!event.isLeftButton || altHeld) {
|
if (!event.isLeftButton || altHeld) {
|
||||||
return;
|
return;
|
||||||
|
@ -154,6 +213,7 @@ function mousePressEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function mouseMoveEvent(event) {
|
function mouseMoveEvent(event) {
|
||||||
createOrUpdateLine(event);
|
createOrUpdateLine(event);
|
||||||
}
|
}
|
||||||
|
@ -182,13 +242,14 @@ function keyReleaseEvent(event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup(){
|
function cleanup() {
|
||||||
Entities.deleteEntity(whiteBoard);
|
Entities.deleteEntity(whiteBoard);
|
||||||
for(var i =0; i < strokes.length; i++){
|
for (var i = 0; i < strokes.length; i++) {
|
||||||
Entities.deleteEntity(strokes[i]);
|
Entities.deleteEntity(strokes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Overlays.deleteOverlay(drawButton);
|
Overlays.deleteOverlay(drawButton);
|
||||||
|
Overlays.deleteOverlay(pointerButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2159,9 +2159,6 @@ void Application::init() {
|
||||||
|
|
||||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||||
|
|
||||||
connect(&_entitySimulation, &EntitySimulation::entityCollisionWithEntity,
|
|
||||||
entityScriptingInterface.data(), &EntityScriptingInterface::entityCollisionWithEntity);
|
|
||||||
|
|
||||||
// connect the _entityCollisionSystem to our EntityTreeRenderer since that's what handles running entity scripts
|
// connect the _entityCollisionSystem to our EntityTreeRenderer since that's what handles running entity scripts
|
||||||
connect(&_entitySimulation, &EntitySimulation::entityCollisionWithEntity,
|
connect(&_entitySimulation, &EntitySimulation::entityCollisionWithEntity,
|
||||||
&_entities, &EntityTreeRenderer::entityCollisionWithEntity);
|
&_entities, &EntityTreeRenderer::entityCollisionWithEntity);
|
||||||
|
|
|
@ -147,9 +147,9 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec3 getNeckPosition() const;
|
Q_INVOKABLE glm::vec3 getNeckPosition() const;
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec3 getAcceleration() { return _acceleration; }
|
Q_INVOKABLE const glm::vec3& getAcceleration() const { return _acceleration; }
|
||||||
Q_INVOKABLE glm::vec3 getAngularVelocity() { return _angularVelocity; }
|
Q_INVOKABLE const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
|
||||||
Q_INVOKABLE glm::vec3 getAngularAcceleration() { return _angularAcceleration; }
|
Q_INVOKABLE const glm::vec3& getAngularAcceleration() const { return _angularAcceleration; }
|
||||||
|
|
||||||
|
|
||||||
/// Scales a world space position vector relative to the avatar position and scale
|
/// Scales a world space position vector relative to the avatar position and scale
|
||||||
|
|
|
@ -141,13 +141,6 @@ static const float STARTING_DDE_MESSAGE_TIME = 0.033f;
|
||||||
static const float DEFAULT_DDE_EYE_CLOSING_THRESHOLD = 0.8f;
|
static const float DEFAULT_DDE_EYE_CLOSING_THRESHOLD = 0.8f;
|
||||||
static const int CALIBRATION_SAMPLES = 150;
|
static const int CALIBRATION_SAMPLES = 150;
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
// warning C4351: new behavior: elements of array 'DdeFaceTracker::_lastEyeBlinks' will be default initialized
|
|
||||||
// warning C4351: new behavior: elements of array 'DdeFaceTracker::_filteredEyeBlinks' will be default initialized
|
|
||||||
// warning C4351: new behavior: elements of array 'DdeFaceTracker::_lastEyeCoefficients' will be default initialized
|
|
||||||
#pragma warning(disable:4351)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DdeFaceTracker::DdeFaceTracker() :
|
DdeFaceTracker::DdeFaceTracker() :
|
||||||
DdeFaceTracker(QHostAddress::Any, DDE_SERVER_PORT, DDE_CONTROL_PORT)
|
DdeFaceTracker(QHostAddress::Any, DDE_SERVER_PORT, DDE_CONTROL_PORT)
|
||||||
{
|
{
|
||||||
|
@ -214,10 +207,6 @@ DdeFaceTracker::~DdeFaceTracker() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#pragma warning(default:4351)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void DdeFaceTracker::init() {
|
void DdeFaceTracker::init() {
|
||||||
FaceTracker::init();
|
FaceTracker::init();
|
||||||
setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::UseCamera) && !_isMuted);
|
setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::UseCamera) && !_isMuted);
|
||||||
|
|
|
@ -301,7 +301,7 @@ public:
|
||||||
int getReceiveRate() const;
|
int getReceiveRate() const;
|
||||||
|
|
||||||
void setVelocity(const glm::vec3 velocity) { _velocity = velocity; }
|
void setVelocity(const glm::vec3 velocity) { _velocity = velocity; }
|
||||||
Q_INVOKABLE glm::vec3 getVelocity() const { return _velocity; }
|
Q_INVOKABLE const glm::vec3& getVelocity() const { return _velocity; }
|
||||||
const glm::vec3& getTargetVelocity() const { return _targetVelocity; }
|
const glm::vec3& getTargetVelocity() const { return _targetVelocity; }
|
||||||
|
|
||||||
bool shouldDie() const { return _owningAvatarMixer.isNull() || getUsecsSinceLastUpdate() > AVATAR_SILENCE_THRESHOLD_USECS; }
|
bool shouldDie() const { return _owningAvatarMixer.isNull() || getUsecsSinceLastUpdate() > AVATAR_SILENCE_THRESHOLD_USECS; }
|
||||||
|
|
|
@ -490,19 +490,21 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEffectEntityItem::setMaxParticles(quint32 maxParticles) {
|
void ParticleEffectEntityItem::setMaxParticles(quint32 maxParticles) {
|
||||||
_maxParticles = maxParticles;
|
if (_maxParticles != maxParticles) {
|
||||||
|
_maxParticles = maxParticles;
|
||||||
|
|
||||||
// TODO: try to do something smart here and preserve the state of existing particles.
|
// TODO: try to do something smart here and preserve the state of existing particles.
|
||||||
|
|
||||||
// resize vectors
|
// resize vectors
|
||||||
_particleLifetimes.resize(_maxParticles);
|
_particleLifetimes.resize(_maxParticles);
|
||||||
_particlePositions.resize(_maxParticles);
|
_particlePositions.resize(_maxParticles);
|
||||||
_particleVelocities.resize(_maxParticles);
|
_particleVelocities.resize(_maxParticles);
|
||||||
|
|
||||||
// effectivly clear all particles and start emitting new ones from scratch.
|
// effectivly clear all particles and start emitting new ones from scratch.
|
||||||
_particleHeadIndex = 0;
|
_particleHeadIndex = 0;
|
||||||
_particleTailIndex = 0;
|
_particleTailIndex = 0;
|
||||||
_timeUntilNextEmit = 0.0f;
|
_timeUntilNextEmit = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// because particles are in a ring buffer, this isn't trivial
|
// because particles are in a ring buffer, this isn't trivial
|
||||||
|
|
|
@ -32,12 +32,6 @@ Assignment::Type Assignment::typeForNodeType(NodeType_t nodeType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
//warning C4351: new behavior: elements of array 'Assignment::_payload' will be default initialized
|
|
||||||
// We're disabling this warning because the new behavior which is to initialize the array with 0 is acceptable to us.
|
|
||||||
#pragma warning(disable:4351)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Assignment::Assignment() :
|
Assignment::Assignment() :
|
||||||
_uuid(),
|
_uuid(),
|
||||||
_command(Assignment::RequestCommand),
|
_command(Assignment::RequestCommand),
|
||||||
|
|
Loading…
Reference in a new issue