Merge branch 'master' of https://github.com/highfidelity/hifi into team-teaching

This commit is contained in:
Atlante45 2015-05-22 17:16:51 +02:00
commit f089143cf1
9 changed files with 575 additions and 493 deletions

View file

@ -254,12 +254,15 @@ $(document).ready(function(){
});
$('#' + Settings.FORM_ID).on('click', '#' + Settings.DISCONNECT_ACCOUNT_BTN_ID, function(e){
$(this).blur();
disonnectHighFidelityAccount();
e.preventDefault();
});
$('#' + Settings.FORM_ID).on('click', '#' + Settings.CONNECT_ACCOUNT_BTN_ID, function(e){
$(this).blur();
prepareAccessTokenPrompt();
e.preventDefault();
});
var panelsSource = $('#panels-template').html()
@ -345,7 +348,7 @@ function disonnectHighFidelityAccount() {
+ "</br></br>This could cause your domain to appear offline and no longer be reachable via any place names.",
type: "warning",
html: true,
showCancelButton: true,
showCancelButton: true
}, function(){
// we need to post to settings to clear the access-token
$(Settings.ACCESS_TOKEN_SELECTOR).val('').change();

View file

@ -18,3 +18,4 @@ Script.load("notifications.js");
Script.load("look.js");
Script.load("users.js");
Script.load("grab.js");
Script.load("pointer.js");

View file

@ -762,7 +762,7 @@ function mouseClickEvent(event) {
selectionManager.addEntity(foundEntity, true);
}
print("Model selected: " + foundEntity.id);
print("Model selected: " + foundEntity);
selectionDisplay.select(selectedEntityID, event);
if (Menu.isOptionChecked(MENU_AUTO_FOCUS_ON_SELECT)) {
@ -1201,7 +1201,7 @@ PropertiesTool = function(opts) {
var selections = [];
for (var i = 0; i < selectionManager.selections.length; i++) {
var entity = {};
entity.id = selectionManager.selections[i].id;
entity.id = selectionManager.selections[i];
entity.properties = Entities.getEntityProperties(selectionManager.selections[i]);
entity.properties.rotation = Quat.safeEulerAngles(entity.properties.rotation);
selections.push(entity);
@ -1251,7 +1251,7 @@ PropertiesTool = function(opts) {
var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2),
var diff = { x: 0, y: dY, z: 0 };
for (var i = 0; i < selectionManager.selections.length; i++) {
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
var properties = selectionManager.savedProperties[selectionManager.selections[i]];
var newPosition = Vec3.sum(properties.position, diff);
Entities.editEntity(selectionManager.selections[i], {
position: newPosition,
@ -1264,7 +1264,7 @@ PropertiesTool = function(opts) {
if (selectionManager.hasSelection()) {
selectionManager.saveProperties();
for (var i = 0; i < selectionManager.selections.length; i++) {
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
var properties = selectionManager.savedProperties[selectionManager.selections[i]];
var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2;
var dY = grid.getOrigin().y - bottomY;
var diff = { x: 0, y: dY, z: 0 };
@ -1280,7 +1280,7 @@ PropertiesTool = function(opts) {
if (selectionManager.hasSelection()) {
selectionManager.saveProperties();
for (var i = 0; i < selectionManager.selections.length; i++) {
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
var properties = selectionManager.savedProperties[selectionManager.selections[i]];
var naturalDimensions = properties.naturalDimensions;
// If any of the natural dimensions are not 0, resize
@ -1302,7 +1302,7 @@ PropertiesTool = function(opts) {
if (selectionManager.hasSelection()) {
selectionManager.saveProperties();
for (var i = 0; i < selectionManager.selections.length; i++) {
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
var properties = selectionManager.savedProperties[selectionManager.selections[i]];
Entities.editEntity(selectionManager.selections[i], {
dimensions: Vec3.multiply(multiplier, properties.dimensions),
});
@ -1314,7 +1314,7 @@ PropertiesTool = function(opts) {
if (selectionManager.hasSelection()) {
selectionManager.saveProperties();
for (var i = 0; i < selectionManager.selections.length; i++) {
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
var properties = selectionManager.savedProperties[selectionManager.selections[i]];
if (properties.type == "Zone") {
var centerOfZone = properties.boundingBox.center;
var atmosphereCenter = { x: centerOfZone.x,

View file

@ -25,8 +25,18 @@ var ALTITUDE_RATE = 200.0;
var RADIUS_RATE = 1.0 / 100.0;
var PAN_RATE = 50.0;
var Y_AXIS = { x: 0, y: 1, z: 0 };
var X_AXIS = { x: 1, y: 0, z: 0 };
var Y_AXIS = {
x: 0,
y: 1,
z: 0
};
var X_AXIS = {
x: 1,
y: 0,
z: 0
};
var LOOK_AT_TIME = 500;
var alt = false;
var shift = false;
@ -34,6 +44,7 @@ var control = false;
var isActive = false;
var oldMode = Camera.mode;
var noMode = 0;
var orbitMode = 1;
var radialMode = 2;
@ -46,9 +57,21 @@ var mouseLastX = 0;
var mouseLastY = 0;
var center = { x: 0, y: 0, z: 0 };
var position = { x: 0, y: 0, z: 0 };
var vector = { x: 0, y: 0, z: 0 };
var center = {
x: 0,
y: 0,
z: 0
};
var position = {
x: 0,
y: 0,
z: 0
};
var vector = {
x: 0,
y: 0,
z: 0
};
var radius = 0.0;
var azimuth = 0.0;
var altitude = 0.0;
@ -56,6 +79,10 @@ var altitude = 0.0;
var avatarPosition;
var avatarOrientation;
var rotatingTowardsTarget = false;
var targetCamOrientation;
var oldPosition, oldOrientation;
function orientationOf(vector) {
var direction,
@ -76,9 +103,11 @@ function handleRadialMode(dx, dy) {
radius = 1;
}
vector = { x: (Math.cos(altitude) * Math.cos(azimuth)) * radius,
vector = {
x: (Math.cos(altitude) * Math.cos(azimuth)) * radius,
y: Math.sin(altitude) * radius,
z: (Math.cos(altitude) * Math.sin(azimuth)) * radius };
z: (Math.cos(altitude) * Math.sin(azimuth)) * radius
};
position = Vec3.sum(center, vector);
Camera.setPosition(position);
Camera.setOrientation(orientationOf(vector));
@ -94,9 +123,11 @@ function handleOrbitMode(dx, dy) {
altitude = -PI / 2.0;
}
vector = { x:(Math.cos(altitude) * Math.cos(azimuth)) * radius,
vector = {
x: (Math.cos(altitude) * Math.cos(azimuth)) * radius,
y: Math.sin(altitude) * radius,
z:(Math.cos(altitude) * Math.sin(azimuth)) * radius };
z: (Math.cos(altitude) * Math.sin(azimuth)) * radius
};
position = Vec3.sum(center, vector);
Camera.setPosition(position);
Camera.setOrientation(orientationOf(vector));
@ -119,13 +150,17 @@ function handlePanMode(dx, dy) {
function saveCameraState() {
oldMode = Camera.mode;
var oldPosition = Camera.getPosition();
oldPosition = Camera.getPosition();
oldOrientation = Camera.getOrientation();
Camera.mode = "independent";
Camera.setPosition(oldPosition);
}
function restoreCameraState() {
Camera.mode = oldMode;
Camera.setPosition(oldPosition);
Camera.setOrientation(oldOrientation);
}
function handleModes() {
@ -202,6 +237,8 @@ function keyReleaseEvent(event) {
if (event.text == "ALT") {
alt = false;
changed = true;
mode = noMode;
restoreCameraState();
}
if (event.text == "CONTROL") {
control = false;
@ -226,7 +263,7 @@ function mousePressEvent(event) {
// Compute trajectories related values
var pickRay = Camera.computePickRay(mouseLastX, mouseLastY);
var modelIntersection = Entities.findRayIntersection(pickRay);
var modelIntersection = Entities.findRayIntersection(pickRay, true);
position = Camera.getPosition();
@ -238,29 +275,25 @@ function mousePressEvent(event) {
if (modelIntersection.intersects && modelIntersection.accurate) {
distance = modelIntersection.distance;
center = modelIntersection.properties.position;
center = modelIntersection.intersection;
string = "Inspecting model";
}
if ((distance == -1 || Vec3.length(Vec3.subtract(avatarTarget, position)) < distance) &&
(avatarTarget.x != 0 || avatarTarget.y != 0 || avatarTarget.z != 0)) {
distance = Vec3.length(Vec3.subtract(avatarTarget, position));
center = avatarTarget;
string = "Inspecting avatar";
}
if (distance == -1) {
return;
}
//We've selected our target, now orbit towards it automatically
rotatingTowardsTarget = true;
//calculate our target cam rotation
Script.setTimeout(function() {
rotatingTowardsTarget = false;
}, LOOK_AT_TIME);
vector = Vec3.subtract(position, center);
targetCamOrientation = orientationOf(vector);
radius = Vec3.length(vector);
azimuth = Math.atan2(vector.z, vector.x);
altitude = Math.asin(vector.y / Vec3.length(vector));
print(string);
isActive = true;
}
}
}
function mouseReleaseEvent(event) {
@ -270,7 +303,7 @@ function mouseReleaseEvent(event) {
}
function mouseMoveEvent(event) {
if (isActive && mode != noMode) {
if (isActive && mode != noMode && !rotatingTowardsTarget) {
if (mode == radialMode) {
handleRadialMode(event.x - mouseLastX, event.y - mouseLastY);
}
@ -281,13 +314,21 @@ function mouseMoveEvent(event) {
handlePanMode(event.x - mouseLastX, event.y - mouseLastY);
}
}
mouseLastX = event.x;
mouseLastY = event.y;
}
}
function update() {
handleModes();
if (rotatingTowardsTarget) {
rotateTowardsTarget();
}
}
function rotateTowardsTarget() {
var newOrientation = Quat.mix(Camera.getOrientation(), targetCamOrientation, .1);
Camera.setOrientation(newOrientation);
}
function scriptEnding() {

View file

@ -1,7 +1,7 @@
var lineEntityID = null;
var lineIsRezzed = false;
var altHeld = false;
var lineCreated = false;
function nearLinePoint(targetPosition) {
var handPosition = MyAvatar.getRightPalmPosition();
@ -40,7 +40,11 @@ function createOrUpdateLine(event) {
type: "Line",
position: nearLinePoint(intersection.intersection),
dimensions: dim,
color: { red: 255, green: 255, blue: 255 },
color: {
red: 255,
green: 255,
blue: 255
},
lifetime: 15 // if someone crashes while pointing, don't leave the line there forever.
});
}
@ -51,11 +55,12 @@ function createOrUpdateLine(event) {
function mousePressEvent(event) {
if (!event.isLeftButton) {
if (!event.isLeftButton || altHeld) {
return;
}
Controller.mouseMoveEvent.connect(mouseMoveEvent);
createOrUpdateLine(event);
lineCreated = true;
}
@ -65,13 +70,30 @@ function mouseMoveEvent(event) {
function mouseReleaseEvent(event) {
if (!event.isLeftButton) {
if (!lineCreated) {
return;
}
Controller.mouseMoveEvent.disconnect(mouseMoveEvent);
removeLine();
lineCreated = false;
}
function keyPressEvent(event) {
if (event.text == "ALT") {
altHeld = true;
}
}
function keyReleaseEvent(event) {
if (event.text == "ALT") {
altHeld = false;
}
}
Controller.mousePressEvent.connect(mousePressEvent);
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
Controller.keyPressEvent.connect(keyPressEvent);
Controller.keyReleaseEvent.connect(keyReleaseEvent);

View file

@ -38,6 +38,7 @@ static const QString DDE_PROGRAM_PATH = "/dde.app/Contents/MacOS/dde";
static const QStringList DDE_ARGUMENTS = QStringList()
<< "--udp=" + DDE_SERVER_ADDR.toString() + ":" + QString::number(DDE_SERVER_PORT)
<< "--receiver=" + QString::number(DDE_CONTROL_PORT)
<< "--facedet_interval=500" // ms
<< "--headless";
static const int NUM_EXPRESSIONS = 46;

View file

@ -706,6 +706,11 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
}
if (properties.getType() == EntityTypes::ParticleEffect) {
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, properties.getAnimationFPS());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, properties.getAnimationFrameIndex());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, properties.getAnimationIsPlaying());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_SETTINGS, properties.getAnimationSettings());
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, properties.getTextures());
APPEND_ENTITY_PROPERTY(PROP_MAX_PARTICLES, properties.getMaxParticles());
APPEND_ENTITY_PROPERTY(PROP_LIFESPAN, properties.getLifespan());
APPEND_ENTITY_PROPERTY(PROP_EMIT_RATE, properties.getEmitRate());
@ -940,6 +945,12 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
}
if (properties.getType() == EntityTypes::ParticleEffect) {
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ANIMATION_FPS, float, setAnimationFPS);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ANIMATION_FRAME_INDEX, float, setAnimationFrameIndex);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ANIMATION_PLAYING, bool, setAnimationIsPlaying);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ANIMATION_SETTINGS, QString, setAnimationSettings);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXTURES, QString, setTextures);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MAX_PARTICLES, float, setMaxParticles);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LIFESPAN, float, setLifespan);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_EMIT_RATE, float, setEmitRate);

View file

@ -130,6 +130,7 @@ QString nameForPacketType(PacketType packetType) {
PACKET_TYPE_NAME_LOOKUP(PacketTypeUnverifiedPingReply);
PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityAdd);
PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityEdit);
PACKET_TYPE_NAME_LOOKUP(PacketTypeParticleEntitiesFix);
default:
return QString("Type: ") + QString::number((int)packetType);
}

View file

@ -79,7 +79,8 @@ enum PacketType {
PacketTypeIceServerHeartbeat, // 50
PacketTypeIceServerHeartbeatResponse,
PacketTypeUnverifiedPing,
PacketTypeUnverifiedPingReply
PacketTypeUnverifiedPingReply,
PacketTypeParticleEntitiesFix
};
typedef char PacketVersion;
@ -179,5 +180,6 @@ const PacketVersion VERSION_ENTITIES_HAVE_LINE_TYPE = 24;
const PacketVersion VERSION_ENTITIES_HAVE_COLLISION_SOUND_URL = 25;
const PacketVersion VERSION_ENTITIES_HAVE_FRICTION = 26;
const PacketVersion VERSION_NO_ENTITY_ID_SWAP = 27;
const PacketVersion VERSION_ENTITIES_PARTICLE_FIX = 28;
#endif // hifi_PacketHeaders_h