Merge branch 'master' of https://github.com/highfidelity/hifi into temp1

This commit is contained in:
samcake 2015-05-01 12:04:34 -07:00
commit 1448ab21b6
18 changed files with 251 additions and 177 deletions

View file

@ -45,10 +45,11 @@ if (WIN32)
# 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.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) else ()
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-strict-aliasing -Wno-unused-parameter")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas") if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-strict-aliasing -Wno-unused-parameter -ggdb") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
endif ()
endif(WIN32) endif(WIN32)
if (NOT MSVC12) if (NOT MSVC12)

View file

@ -1213,6 +1213,9 @@ PropertiesTool = function(opts) {
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z); data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
} }
Entities.editEntity(selectionManager.selections[0], data.properties); Entities.editEntity(selectionManager.selections[0], data.properties);
if (data.properties.name != undefined) {
entityListTool.sendUpdate();
}
} }
pushCommandForSelections(); pushCommandForSelections();
selectionManager._update(); selectionManager._update();

View file

@ -5,17 +5,13 @@ var deltaMouse = {
z: 0 z: 0
} }
var entityProps; var entityProps;
var box, box2, ground; var targetPosition;
var baseMoveFactor = .001;
var finalMoveMultiplier;
var avatarEntityDistance;
var camYaw, dv;
var prevPosition;
var newPosition;
var flingVelocity;
var flingMultiplier = 10;
var moveUpDown = false; var moveUpDown = false;
var savedGravity;
var currentPosition, currentVelocity;
var grabSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/CloseClamp.wav");
var releaseSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/ReleaseClamp.wav");
var DROP_DISTANCE = 5.0; var DROP_DISTANCE = 5.0;
var DROP_COLOR = { var DROP_COLOR = {
@ -23,14 +19,9 @@ var DROP_COLOR = {
green: 200, green: 200,
blue: 200 blue: 200
}; };
var DROP_WIDTH = 4; var DROP_WIDTH = 2;
var autoBox = false;
if (autoBox) {
setUpTestObjects();
}
var dropLine = Overlays.addOverlay("line3d", { var dropLine = Overlays.addOverlay("line3d", {
start: { start: {
x: 0, x: 0,
@ -50,104 +41,80 @@ var dropLine = Overlays.addOverlay("line3d", {
function mousePressEvent(event) { function mousePressEvent(event) {
if(!event.isLeftButton){ if (!event.isLeftButton) {
return; return;
} }
var pickRay = Camera.computePickRay(event.x, event.y); var pickRay = Camera.computePickRay(event.x, event.y);
var intersection = Entities.findRayIntersection(pickRay); var intersection = Entities.findRayIntersection(pickRay);
if (intersection.intersects && intersection.properties.collisionsWillMove) { if (intersection.intersects && intersection.properties.collisionsWillMove) {
grabbedEntity = intersection.entityID; grabbedEntity = intersection.entityID;
var props = Entities.getEntityProperties(grabbedEntity) var props = Entities.getEntityProperties(grabbedEntity)
prevPosition = props.position;
isGrabbing = true; isGrabbing = true;
savedGravity = props.gravity; targetPosition = props.position;
Overlays.editOverlay(dropLine, { currentPosition = props.position;
currentVelocity = props.velocity;
updateDropLine(targetPosition);
Audio.playSound(grabSound, {
position: props.position,
volume: 0.4
});
}
}
function updateDropLine(position) {
Overlays.editOverlay(dropLine, {
visible: true, visible: true,
start: props.position, start: position,
end: Vec3.sum(props.position, { end: Vec3.sum(position, {
x: 0, x: 0,
y: -DROP_DISTANCE, y: -DROP_DISTANCE,
z: 0 z: 0
}) })
}); })
Entities.editEntity(grabbedEntity, {
gravity: {
x: 0,
y: 0,
z: 0
}
});
//We need to store entity's current gravity, and then disable it while we move
}
} }
function mouseReleaseEvent() { function mouseReleaseEvent() {
if (isGrabbing) { if (isGrabbing) {
// flingObject(); isGrabbing = false;
Entities.editEntity(grabbedEntity, { Overlays.editOverlay(dropLine, {
gravity: savedGravity visible: false
}); });
targetPosition = null;
Audio.playSound(grabSound, {
position: entityProps.position,
volume: 0.25
});
} }
isGrabbing = false;
Overlays.editOverlay(dropLine, {
visible: false
});
}
function flingObject() {
//calculate velocity to give object base on current and previous position
entityProps = Entities.getEntityProperties(grabbedEntity);
flingVelocity = Vec3.subtract(entityProps.position, prevPosition);
flingVelocity = Vec3.multiply(flingMultiplier, flingVelocity);
Entities.editEntity(grabbedEntity, {
velocity: flingVelocity
});
} }
function mouseMoveEvent(event) { function mouseMoveEvent(event) {
if (isGrabbing) { if (isGrabbing) {
entityProps = Entities.getEntityProperties(grabbedEntity);
avatarEntityDistance = Vec3.distance(MyAvatar.position, entityProps.position);
finalMoveMultiplier = baseMoveFactor * Math.pow(avatarEntityDistance, 1.5);
deltaMouse.x = event.x - prevMouse.x; deltaMouse.x = event.x - prevMouse.x;
if (!moveUpDown) { if (!moveUpDown) {
deltaMouse.z = event.y - prevMouse.y; deltaMouse.z = event.y - prevMouse.y;
deltaMouse.y = 0;
} else { } else {
deltaMouse.y = (event.y - prevMouse.y) * -1; deltaMouse.y = (event.y - prevMouse.y) * -1;
deltaMouse.z = 0;
} }
finalMoveMultiplier = baseMoveFactor * Math.pow(avatarEntityDistance, 1.5); // Update the target position by the amount the mouse moved
deltaMouse = Vec3.multiply(deltaMouse, finalMoveMultiplier); var camYaw = Quat.safeEulerAngles(Camera.getOrientation()).y;
camYaw = Quat.safeEulerAngles(Camera.getOrientation()).y; var dPosition = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, camYaw, 0), deltaMouse);
dv = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, camYaw, 0), deltaMouse); // Adjust target position for the object by the mouse move
newPosition = Vec3.sum(entityProps.position, dv); var avatarEntityDistance = Vec3.distance(Camera.getPosition(), currentPosition);
Entities.editEntity(grabbedEntity, { // Scale distance we want to move by the distance from the camera to the grabbed object
position: newPosition // TODO: Correct SCREEN_TO_METERS to be correct for the actual FOV, resolution
}); var SCREEN_TO_METERS = 0.001;
Overlays.editOverlay(dropLine, { targetPosition = Vec3.sum(targetPosition, Vec3.multiply(dPosition, avatarEntityDistance * SCREEN_TO_METERS));
start: newPosition,
end: Vec3.sum(newPosition, {
x: 0,
y: -DROP_DISTANCE,
z: 0
})
});
flingVelocity = Vec3.subtract(entityProps.position, prevPosition);
flingVelocity = Vec3.multiply(flingMultiplier, flingVelocity);
Entities.editEntity(grabbedEntity, {
velocity: flingVelocity
});
prevPosition = entityProps.position;
} }
prevMouse.x = event.x; prevMouse.x = event.x;
prevMouse.y = event.y; prevMouse.y = event.y;
} }
function keyReleaseEvent(event) { function keyReleaseEvent(event) {
if (event.text === "SHIFT") { if (event.text === "SHIFT") {
moveUpDown = false; moveUpDown = false;
@ -160,69 +127,34 @@ function keyPressEvent(event) {
} }
} }
function update(deltaTime) {
if (isGrabbing) {
function setUpTestObjects() { entityProps = Entities.getEntityProperties(grabbedEntity);
var distance = 4; currentPosition = entityProps.position;
box = Entities.addEntity({ currentVelocity = entityProps.velocity;
type: 'Box',
position: Vec3.sum(MyAvatar.position, Vec3.multiply(distance, Quat.getFront(Camera.getOrientation()))),
dimensions: {
x: .5,
y: .5,
z: .5
},
color: {
red: 200,
green: 50,
blue: 192
},
collisionsWillMove: true,
gravity: {
x: 0,
y: -1,
z: 0
}
});
box2 = Entities.addEntity({ var dPosition = Vec3.subtract(targetPosition, currentPosition);
type: 'Box', var CLOSE_ENOUGH = 0.001;
position: Vec3.sum(MyAvatar.position, Vec3.multiply(distance + 1, Quat.getFront(Camera.getOrientation()))), if (Vec3.length(dPosition) > CLOSE_ENOUGH) {
dimensions: { // compute current velocity in the direction we want to move
x: .5, var velocityTowardTarget = Vec3.dot(currentVelocity, Vec3.normalize(dPosition));
y: .5, // compute the speed we would like to be going toward the target position
z: .5 var SPRING_RATE = 0.35;
}, var DAMPING_RATE = 0.55;
color: { var desiredVelocity = Vec3.multiply(dPosition, (1.0 / deltaTime) * SPRING_RATE);
red: 200, // compute how much we want to add to the existing velocity
green: 50, var addedVelocity = Vec3.subtract(desiredVelocity, velocityTowardTarget);
blue: 192 var newVelocity = Vec3.sum(currentVelocity, addedVelocity);
}, // Add Damping
collisionsWillMove: true, newVelocity = Vec3.subtract(newVelocity, Vec3.multiply(newVelocity, DAMPING_RATE));
gravity: { // Update entity
x: 0, Entities.editEntity(grabbedEntity, {
y: -1, velocity: newVelocity
z: 0 })
} }
}); updateDropLine(currentPosition);
}
ground = Entities.addEntity({
type: 'Box',
position: {
x: MyAvatar.position.x,
y: MyAvatar.position.y - 5,
z: MyAvatar.position.z
},
dimensions: {
x: 100,
y: 2,
z: 100
},
color: {
red: 20,
green: 200,
blue: 50
}
});
} }
Controller.mouseMoveEvent.connect(mouseMoveEvent); Controller.mouseMoveEvent.connect(mouseMoveEvent);
@ -230,3 +162,5 @@ Controller.mousePressEvent.connect(mousePressEvent);
Controller.mouseReleaseEvent.connect(mouseReleaseEvent); Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
Controller.keyPressEvent.connect(keyPressEvent); Controller.keyPressEvent.connect(keyPressEvent);
Controller.keyReleaseEvent.connect(keyReleaseEvent); Controller.keyReleaseEvent.connect(keyReleaseEvent);
Script.update.connect(update);

View file

@ -13,7 +13,7 @@
var DESC_STRING = ' ▴'; var DESC_STRING = ' ▴';
function loaded() { function loaded() {
entityList = new List('entity-list', { valueNames: ['type', 'url']}); entityList = new List('entity-list', { valueNames: ['name', 'type', 'url']});
entityList.clear(); entityList.clear();
elEntityTable = document.getElementById("entity-table"); elEntityTable = document.getElementById("entity-table");
elEntityTableBody = document.getElementById("entity-table-body"); elEntityTableBody = document.getElementById("entity-table-body");
@ -22,6 +22,9 @@
elTeleport = document.getElementById("teleport"); elTeleport = document.getElementById("teleport");
elNoEntitiesMessage = document.getElementById("no-entities"); elNoEntitiesMessage = document.getElementById("no-entities");
document.getElementById("entity-name").onclick = function() {
setSortColumn('name');
};
document.getElementById("entity-type").onclick = function() { document.getElementById("entity-type").onclick = function() {
setSortColumn('type'); setSortColumn('type');
}; };
@ -56,31 +59,34 @@
})); }));
} }
function addEntity(id, type, url) { function addEntity(id, name, type, url) {
if (entities[id] === undefined) { if (entities[id] === undefined) {
var urlParts = url.split('/'); var urlParts = url.split('/');
var filename = urlParts[urlParts.length - 1]; var filename = urlParts[urlParts.length - 1];
entityList.add([{ id: id, type: type, url: filename }], function(items) { entityList.add([{ id: id, name: name, type: type, url: filename }], function(items) {
var el = items[0].elm; var el = items[0].elm;
var id = items[0]._values.id; var id = items[0]._values.id;
entities[id] = { entities[id] = {
id: id, id: id,
name: id, name: name,
el: el, el: el,
item: items[0],
}; };
el.setAttribute('id', 'entity_' + id); el.setAttribute('id', 'entity_' + id);
el.setAttribute('title', url); el.setAttribute('title', url);
el.dataset.entityId = id; el.dataset.entityId = id;
el.onclick = onRowClicked; el.onclick = onRowClicked;
el.ondblclick = onRowDoubleClicked; el.ondblclick = onRowDoubleClicked;
el.innerHTML
}); });
if (refreshEntityListTimer) { if (refreshEntityListTimer) {
clearTimeout(refreshEntityListTimer); clearTimeout(refreshEntityListTimer);
} }
refreshEntityListTimer = setTimeout(refreshEntityListObject, 50); refreshEntityListTimer = setTimeout(refreshEntityListObject, 50);
} else {
var item = entities[id].item;
item.values({ name: name, url: url });
} }
} }
@ -90,6 +96,7 @@
} }
var elSortOrder = { var elSortOrder = {
name: document.querySelector('#entity-name .sort-order'),
type: document.querySelector('#entity-type .sort-order'), type: document.querySelector('#entity-type .sort-order'),
url: document.querySelector('#entity-url .sort-order'), url: document.querySelector('#entity-url .sort-order'),
} }
@ -164,7 +171,7 @@
elNoEntitiesMessage.style.display = "none"; elNoEntitiesMessage.style.display = "none";
for (var i = 0; i < newEntities.length; i++) { for (var i = 0; i < newEntities.length; i++) {
var id = newEntities[i].id; var id = newEntities[i].id;
addEntity(id, newEntities[i].type, newEntities[i].url); addEntity(id, newEntities[i].name, newEntities[i].type, newEntities[i].url);
} }
updateSelectedEntities(data.selectedIDs); updateSelectedEntities(data.selectedIDs);
} }
@ -190,6 +197,7 @@
<thead> <thead>
<tr> <tr>
<th id="entity-type" data-sort="type">Type <span class="sort-order" style="display: inline">&nbsp;&#x25BE;</span></th> <th id="entity-type" data-sort="type">Type <span class="sort-order" style="display: inline">&nbsp;&#x25BE;</span></th>
<th id="entity-name" data-sort="type">Name <span class="sort-order" style="display: inline">&nbsp;&#x25BE;</span></th>
<th id="entity-url" data-sort="url">URL <span class="sort-order" style="display: none">&nbsp;&#x25BE;</span></th> <th id="entity-url" data-sort="url">URL <span class="sort-order" style="display: none">&nbsp;&#x25BE;</span></th>
</tr> </tr>
</thead> </thead>
@ -197,6 +205,7 @@
<tr> <tr>
<td class="id" style="display: none">Type</td> <td class="id" style="display: none">Type</td>
<td class="type">Type</td> <td class="type">Type</td>
<td class="name">Name</td>
<td class="url"><div class='outer'><div class='inner'>URL</div></div></td> <td class="url"><div class='outer'><div class='inner'>URL</div></div></td>
</tr> </tr>
</tbody> </tbody>

View file

@ -98,6 +98,7 @@
var allSections = []; var allSections = [];
var elID = document.getElementById("property-id"); var elID = document.getElementById("property-id");
var elType = document.getElementById("property-type"); var elType = document.getElementById("property-type");
var elName = document.getElementById("property-name");
var elLocked = document.getElementById("property-locked"); var elLocked = document.getElementById("property-locked");
var elVisible = document.getElementById("property-visible"); var elVisible = document.getElementById("property-visible");
var elPositionX = document.getElementById("property-pos-x"); var elPositionX = document.getElementById("property-pos-x");
@ -262,6 +263,8 @@
enableChildren(document.getElementById("properties-list"), 'input'); enableChildren(document.getElementById("properties-list"), 'input');
} }
elName.value = properties.name;
elVisible.checked = properties.visible; elVisible.checked = properties.visible;
elPositionX.value = properties.position.x.toFixed(2); elPositionX.value = properties.position.x.toFixed(2);
@ -395,6 +398,7 @@
} }
elLocked.addEventListener('change', createEmitCheckedPropertyUpdateFunction('locked')); elLocked.addEventListener('change', createEmitCheckedPropertyUpdateFunction('locked'));
elName.addEventListener('change', createEmitTextPropertyUpdateFunction('name'));
elVisible.addEventListener('change', createEmitCheckedPropertyUpdateFunction('visible')); elVisible.addEventListener('change', createEmitCheckedPropertyUpdateFunction('visible'));
var positionChangeFunction = createEmitVec3PropertyUpdateFunction( var positionChangeFunction = createEmitVec3PropertyUpdateFunction(
@ -590,6 +594,12 @@
<label id="property-id" class="selectable"></label> <label id="property-id" class="selectable"></label>
</div> </div>
</div> </div>
<div class="property">
<span class="label" style="float: left; margin-right: 6px">Name</span>
<div class="value" style="overflow: hidden;">
<input type="text" id="property-name"></input>
</div>
</div>
<div class="property"> <div class="property">
<span class="label">Locked</span> <span class="label">Locked</span>
<span class="value"> <span class="value">

View file

@ -301,3 +301,7 @@ input[type="number"]::-webkit-inner-spin-button:hover,
input[type="number"]::-webkit-inner-spin-button:active{ input[type="number"]::-webkit-inner-spin-button:active{
opacity: .8; opacity: .8;
} }
input#property-name {
width: 100%;
}

View file

@ -31,7 +31,7 @@ EntityListTool = function(opts) {
webView.eventBridge.emitScriptEvent(JSON.stringify(data)); webView.eventBridge.emitScriptEvent(JSON.stringify(data));
}); });
function sendUpdate() { that.sendUpdate = function() {
var entities = []; var entities = [];
var ids = Entities.findEntities(MyAvatar.position, 100); var ids = Entities.findEntities(MyAvatar.position, 100);
for (var i = 0; i < ids.length; i++) { for (var i = 0; i < ids.length; i++) {
@ -39,6 +39,7 @@ EntityListTool = function(opts) {
var properties = Entities.getEntityProperties(id); var properties = Entities.getEntityProperties(id);
entities.push({ entities.push({
id: id.id, id: id.id,
name: properties.name,
type: properties.type, type: properties.type,
url: properties.type == "Model" ? properties.modelURL : "", url: properties.type == "Model" ? properties.modelURL : "",
}); });
@ -76,7 +77,7 @@ EntityListTool = function(opts) {
Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
} }
} else if (data.type == "refresh") { } else if (data.type == "refresh") {
sendUpdate(); that.sendUpdate();
} else if (data.type == "teleport") { } else if (data.type == "teleport") {
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
MyAvatar.position = selectionManager.worldPosition; MyAvatar.position = selectionManager.worldPosition;

63
examples/lotsoBlocks.js Normal file
View file

@ -0,0 +1,63 @@
var NUM_BLOCKS = 200;
var size;
var SPAWN_RANGE = 10;
var boxes = [];
var basePosition, avatarRot;
var isAssignmentScript = false;
if(isAssignmentScript){
basePosition = {x: 8000, y: 8000, z: 8000};
}
else {
avatarRot = Quat.fromPitchYawRollDegrees(0, MyAvatar.bodyYaw, 0.0);
basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(SPAWN_RANGE * 3, Quat.getFront(avatarRot)));
}
basePosition.y -= SPAWN_RANGE;
var ground = Entities.addEntity({
type: "Model",
modelURL: "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx",
dimensions: {
x: 100,
y: 2,
z: 100
},
position: basePosition,
shapeType: 'box'
});
basePosition.y += SPAWN_RANGE + 2;
for (var i = 0; i < NUM_BLOCKS; i++) {
size = randFloat(-.2, 0.7);
boxes.push(Entities.addEntity({
type: 'Box',
dimensions: {
x: size,
y: size,
z: size
},
position: {
x: basePosition.x + randFloat(-SPAWN_RANGE, SPAWN_RANGE),
y: basePosition.y - randFloat(-SPAWN_RANGE, SPAWN_RANGE),
z: basePosition.z + randFloat(-SPAWN_RANGE, SPAWN_RANGE)
},
color: {red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255},
collisionsWillMove: true,
gravity: {x: 0, y: 0, z: 0}
}));
}
function cleanup() {
Entities.deleteEntity(ground);
boxes.forEach(function(box){
Entities.deleteEntity(box);
});
}
Script.scriptEnding.connect(cleanup);
function randFloat(low, high) {
return low + Math.random() * ( high - low );
}

View file

@ -35,6 +35,14 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR, glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha()); getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
bool highlightSimulationOwnership = false;
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
auto nodeList = DependencyManager::get<NodeList>();
const QUuid& myNodeID = nodeList->getSessionUUID();
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
}
glPushMatrix(); glPushMatrix();
glTranslatef(position.x, position.y, position.z); glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation); glm::vec3 axis = glm::axis(rotation);
@ -43,8 +51,11 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
glm::vec3 positionToCenter = center - position; glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z); glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor); if (highlightSimulationOwnership) {
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
} else {
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
}
glPopMatrix(); glPopMatrix();
glPopMatrix(); glPopMatrix();
}; };

View file

@ -109,6 +109,33 @@ void RenderableModelEntityItem::remapTextures() {
} }
void RenderableModelEntityItem::renderBoundingBox(RenderArgs* args) {
glm::vec3 position = getPosition();
glm::vec3 center = getCenter();
glm::vec3 dimensions = getDimensions();
glm::quat rotation = getRotation();
// float size = glm::length(dimensions) / 2.0f;
const float MAX_COLOR = 255.0f;
glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR,
getColor()[GREEN_INDEX] / MAX_COLOR,
getColor()[BLUE_INDEX] / MAX_COLOR,
getLocalRenderAlpha());
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glPushMatrix();
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
glPopMatrix();
glPopMatrix();
}
void RenderableModelEntityItem::render(RenderArgs* args) { void RenderableModelEntityItem::render(RenderArgs* args) {
PerformanceTimer perfTimer("RMEIrender"); PerformanceTimer perfTimer("RMEIrender");
assert(getType() == EntityTypes::Model); assert(getType() == EntityTypes::Model);
@ -117,7 +144,6 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
glm::vec3 position = getPosition(); glm::vec3 position = getPosition();
glm::vec3 dimensions = getDimensions(); glm::vec3 dimensions = getDimensions();
float size = glm::length(dimensions);
bool highlightSimulationOwnership = false; bool highlightSimulationOwnership = false;
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) { if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
@ -126,6 +152,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
highlightSimulationOwnership = (getSimulatorID() == myNodeID); highlightSimulationOwnership = (getSimulatorID() == myNodeID);
} }
bool didDraw = false;
if (drawAsModel && !highlightSimulationOwnership) { if (drawAsModel && !highlightSimulationOwnership) {
remapTextures(); remapTextures();
glPushMatrix(); glPushMatrix();
@ -179,34 +206,20 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
if (args && (args->_renderMode == RenderArgs::SHADOW_RENDER_MODE)) { if (args && (args->_renderMode == RenderArgs::SHADOW_RENDER_MODE)) {
if (movingOrAnimating) { if (movingOrAnimating) {
_model->renderInScene(alpha, args); _model->renderInScene(alpha, args);
didDraw = true;
} }
} else { } else {
_model->renderInScene(alpha, args); _model->renderInScene(alpha, args);
didDraw = true;
} }
} else {
// if we couldn't get a model, then just draw a cube
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
glPopMatrix();
} }
} else {
// if we couldn't get a model, then just draw a cube
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
glPopMatrix();
} }
} }
glPopMatrix(); glPopMatrix();
} else { }
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
glPushMatrix(); if (!didDraw) {
glTranslatef(position.x, position.y, position.z); renderBoundingBox(args);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
glPopMatrix();
} }
} }

View file

@ -42,6 +42,7 @@ public:
virtual void somethingChangedNotification() { _needsInitialSimulation = true; } virtual void somethingChangedNotification() { _needsInitialSimulation = true; }
void renderBoundingBox(RenderArgs* args);
virtual void render(RenderArgs* args); virtual void render(RenderArgs* args);
virtual bool supportsDetailedRayIntersection() const { return true; } virtual bool supportsDetailedRayIntersection() const { return true; }
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,

View file

@ -63,6 +63,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) :
_simulatorID(ENTITY_ITEM_DEFAULT_SIMULATOR_ID), _simulatorID(ENTITY_ITEM_DEFAULT_SIMULATOR_ID),
_simulatorIDChangedTime(0), _simulatorIDChangedTime(0),
_marketplaceID(ENTITY_ITEM_DEFAULT_MARKETPLACE_ID), _marketplaceID(ENTITY_ITEM_DEFAULT_MARKETPLACE_ID),
_name(ENTITY_ITEM_DEFAULT_NAME),
_physicsInfo(NULL), _physicsInfo(NULL),
_dirtyFlags(0), _dirtyFlags(0),
_element(NULL) _element(NULL)
@ -105,6 +106,7 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
requestedProperties += PROP_LOCKED; requestedProperties += PROP_LOCKED;
requestedProperties += PROP_USER_DATA; requestedProperties += PROP_USER_DATA;
requestedProperties += PROP_MARKETPLACE_ID; requestedProperties += PROP_MARKETPLACE_ID;
requestedProperties += PROP_NAME;
requestedProperties += PROP_SIMULATOR_ID; requestedProperties += PROP_SIMULATOR_ID;
return requestedProperties; return requestedProperties;
@ -231,6 +233,7 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
APPEND_ENTITY_PROPERTY(PROP_USER_DATA, appendValue, getUserData()); APPEND_ENTITY_PROPERTY(PROP_USER_DATA, appendValue, getUserData());
APPEND_ENTITY_PROPERTY(PROP_SIMULATOR_ID, appendValue, getSimulatorID()); APPEND_ENTITY_PROPERTY(PROP_SIMULATOR_ID, appendValue, getSimulatorID());
APPEND_ENTITY_PROPERTY(PROP_MARKETPLACE_ID, appendValue, getMarketplaceID()); APPEND_ENTITY_PROPERTY(PROP_MARKETPLACE_ID, appendValue, getMarketplaceID());
APPEND_ENTITY_PROPERTY(PROP_NAME, appendValue, getName());
appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, appendSubclassData(packetData, params, entityTreeElementExtraEncodeData,
requestedProperties, requestedProperties,
@ -528,7 +531,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
READ_ENTITY_PROPERTY_SETTER(PROP_DIMENSIONS, glm::vec3, updateDimensionsInDomainUnits); READ_ENTITY_PROPERTY_SETTER(PROP_DIMENSIONS, glm::vec3, updateDimensionsInDomainUnits);
} }
} }
READ_ENTITY_PROPERTY_QUAT_SETTER(PROP_ROTATION, updateRotation); READ_ENTITY_PROPERTY_QUAT_SETTER(PROP_ROTATION, updateRotation);
READ_ENTITY_PROPERTY_SETTER(PROP_DENSITY, float, updateDensity); READ_ENTITY_PROPERTY_SETTER(PROP_DENSITY, float, updateDensity);
if (useMeters) { if (useMeters) {
@ -566,6 +569,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
READ_ENTITY_PROPERTY_STRING(PROP_MARKETPLACE_ID, setMarketplaceID); READ_ENTITY_PROPERTY_STRING(PROP_MARKETPLACE_ID, setMarketplaceID);
} }
READ_ENTITY_PROPERTY_STRING(PROP_NAME, setName);
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData); bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData);
//////////////////////////////////// ////////////////////////////////////
@ -897,6 +902,7 @@ EntityItemProperties EntityItem::getProperties() const {
COPY_ENTITY_PROPERTY_TO_PROPERTIES(userData, getUserData); COPY_ENTITY_PROPERTY_TO_PROPERTIES(userData, getUserData);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(simulatorID, getSimulatorID); COPY_ENTITY_PROPERTY_TO_PROPERTIES(simulatorID, getSimulatorID);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(marketplaceID, getMarketplaceID); COPY_ENTITY_PROPERTY_TO_PROPERTIES(marketplaceID, getMarketplaceID);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(name, getName);
properties._defaultSettings = false; properties._defaultSettings = false;
@ -928,6 +934,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(userData, setUserData); SET_ENTITY_PROPERTY_FROM_PROPERTIES(userData, setUserData);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(simulatorID, setSimulatorID); SET_ENTITY_PROPERTY_FROM_PROPERTIES(simulatorID, setSimulatorID);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(marketplaceID, setMarketplaceID); SET_ENTITY_PROPERTY_FROM_PROPERTIES(marketplaceID, setMarketplaceID);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(name, setName);
if (somethingChanged) { if (somethingChanged) {
somethingChangedNotification(); // notify derived classes that something has changed somethingChangedNotification(); // notify derived classes that something has changed

View file

@ -229,6 +229,9 @@ public:
float getAngularDamping() const { return _angularDamping; } float getAngularDamping() const { return _angularDamping; }
void setAngularDamping(float value) { _angularDamping = value; } void setAngularDamping(float value) { _angularDamping = value; }
QString getName() const { return _name; }
void setName(const QString& value) { _name = value; }
bool getVisible() const { return _visible; } bool getVisible() const { return _visible; }
void setVisible(bool value) { _visible = value; } void setVisible(bool value) { _visible = value; }
bool isVisible() const { return _visible; } bool isVisible() const { return _visible; }
@ -348,6 +351,7 @@ protected:
QUuid _simulatorID; // id of Node which is currently responsible for simulating this Entity QUuid _simulatorID; // id of Node which is currently responsible for simulating this Entity
quint64 _simulatorIDChangedTime; // when was _simulatorID last updated? quint64 _simulatorIDChangedTime; // when was _simulatorID last updated?
QString _marketplaceID; QString _marketplaceID;
QString _name;
// NOTE: Damping is applied like this: v *= pow(1 - damping, dt) // NOTE: Damping is applied like this: v *= pow(1 - damping, dt)
// //

View file

@ -86,6 +86,7 @@ EntityItemProperties::EntityItemProperties() :
CONSTRUCT_PROPERTY(stageAltitude, ZoneEntityItem::DEFAULT_STAGE_ALTITUDE), CONSTRUCT_PROPERTY(stageAltitude, ZoneEntityItem::DEFAULT_STAGE_ALTITUDE),
CONSTRUCT_PROPERTY(stageDay, ZoneEntityItem::DEFAULT_STAGE_DAY), CONSTRUCT_PROPERTY(stageDay, ZoneEntityItem::DEFAULT_STAGE_DAY),
CONSTRUCT_PROPERTY(stageHour, ZoneEntityItem::DEFAULT_STAGE_HOUR), CONSTRUCT_PROPERTY(stageHour, ZoneEntityItem::DEFAULT_STAGE_HOUR),
CONSTRUCT_PROPERTY(name, ENTITY_ITEM_DEFAULT_NAME),
_id(UNKNOWN_ENTITY_ID), _id(UNKNOWN_ENTITY_ID),
_idSet(false), _idSet(false),
@ -281,6 +282,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_LOCAL_GRAVITY, localGravity); CHECK_PROPERTY_CHANGE(PROP_LOCAL_GRAVITY, localGravity);
CHECK_PROPERTY_CHANGE(PROP_PARTICLE_RADIUS, particleRadius); CHECK_PROPERTY_CHANGE(PROP_PARTICLE_RADIUS, particleRadius);
CHECK_PROPERTY_CHANGE(PROP_MARKETPLACE_ID, marketplaceID); CHECK_PROPERTY_CHANGE(PROP_MARKETPLACE_ID, marketplaceID);
CHECK_PROPERTY_CHANGE(PROP_NAME, name);
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_COLOR, keyLightColor); CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_COLOR, keyLightColor);
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_INTENSITY, keyLightIntensity); CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_INTENSITY, keyLightIntensity);
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_AMBIENT_INTENSITY, keyLightAmbientIntensity); CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_AMBIENT_INTENSITY, keyLightAmbientIntensity);
@ -361,6 +363,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE(localGravity); COPY_PROPERTY_TO_QSCRIPTVALUE(localGravity);
COPY_PROPERTY_TO_QSCRIPTVALUE(particleRadius); COPY_PROPERTY_TO_QSCRIPTVALUE(particleRadius);
COPY_PROPERTY_TO_QSCRIPTVALUE(marketplaceID); COPY_PROPERTY_TO_QSCRIPTVALUE(marketplaceID);
COPY_PROPERTY_TO_QSCRIPTVALUE(name);
COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR(keyLightColor); COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR(keyLightColor);
COPY_PROPERTY_TO_QSCRIPTVALUE(keyLightIntensity); COPY_PROPERTY_TO_QSCRIPTVALUE(keyLightIntensity);
@ -462,6 +465,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) {
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(localGravity, setLocalGravity); COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(localGravity, setLocalGravity);
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(particleRadius, setParticleRadius); COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(particleRadius, setParticleRadius);
COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING(marketplaceID, setMarketplaceID); COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING(marketplaceID, setMarketplaceID);
COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING(name, setName);
COPY_PROPERTY_FROM_QSCRIPTVALUE_COLOR(keyLightColor, setKeyLightColor); COPY_PROPERTY_FROM_QSCRIPTVALUE_COLOR(keyLightColor, setKeyLightColor);
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(keyLightIntensity, setKeyLightIntensity); COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(keyLightIntensity, setKeyLightIntensity);
@ -681,6 +685,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
} }
APPEND_ENTITY_PROPERTY(PROP_MARKETPLACE_ID, appendValue, properties.getMarketplaceID()); APPEND_ENTITY_PROPERTY(PROP_MARKETPLACE_ID, appendValue, properties.getMarketplaceID());
APPEND_ENTITY_PROPERTY(PROP_NAME, appendValue, properties.getName());
} }
if (propertyCount > 0) { if (propertyCount > 0) {
int endOfEntityItemData = packetData->getUncompressedByteOffset(); int endOfEntityItemData = packetData->getUncompressedByteOffset();
@ -929,6 +934,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
} }
READ_ENTITY_PROPERTY_STRING_TO_PROPERTIES(PROP_MARKETPLACE_ID, setMarketplaceID); READ_ENTITY_PROPERTY_STRING_TO_PROPERTIES(PROP_MARKETPLACE_ID, setMarketplaceID);
READ_ENTITY_PROPERTY_STRING_TO_PROPERTIES(PROP_NAME, setName);
return valid; return valid;
} }
@ -978,6 +984,7 @@ void EntityItemProperties::markAllChanged() {
_registrationPointChanged = true; _registrationPointChanged = true;
_angularVelocityChanged = true; _angularVelocityChanged = true;
_angularDampingChanged = true; _angularDampingChanged = true;
_nameChanged = true;
_visibleChanged = true; _visibleChanged = true;
_colorChanged = true; _colorChanged = true;
_modelURLChanged = true; _modelURLChanged = true;

View file

@ -97,6 +97,7 @@ enum EntityPropertyList {
PROP_MARKETPLACE_ID, PROP_MARKETPLACE_ID,
PROP_ACCELERATION, PROP_ACCELERATION,
PROP_SIMULATOR_ID, PROP_SIMULATOR_ID,
PROP_NAME,
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// ATTENTION: add new properties ABOVE this line // ATTENTION: add new properties ABOVE this line
@ -239,6 +240,7 @@ public:
DEFINE_PROPERTY(PROP_STAGE_ALTITUDE, StageAltitude, stageAltitude, float); DEFINE_PROPERTY(PROP_STAGE_ALTITUDE, StageAltitude, stageAltitude, float);
DEFINE_PROPERTY(PROP_STAGE_DAY, StageDay, stageDay, quint16); DEFINE_PROPERTY(PROP_STAGE_DAY, StageDay, stageDay, quint16);
DEFINE_PROPERTY(PROP_STAGE_HOUR, StageHour, stageHour, float); DEFINE_PROPERTY(PROP_STAGE_HOUR, StageHour, stageHour, float);
DEFINE_PROPERTY_REF(PROP_NAME, Name, name, QString);
public: public:
@ -331,6 +333,7 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Dimensions, dimensions, "in meters"); DEBUG_PROPERTY_IF_CHANGED(debug, properties, Dimensions, dimensions, "in meters");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Velocity, velocity, "in meters"); DEBUG_PROPERTY_IF_CHANGED(debug, properties, Velocity, velocity, "in meters");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Name, name, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Visible, visible, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, Visible, visible, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Rotation, rotation, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, Rotation, rotation, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Density, density, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, Density, density, "");

View file

@ -55,4 +55,6 @@ const float ENTITY_ITEM_DEFAULT_ANGULAR_DAMPING = 0.39347f; // approx timescale
const bool ENTITY_ITEM_DEFAULT_IGNORE_FOR_COLLISIONS = false; const bool ENTITY_ITEM_DEFAULT_IGNORE_FOR_COLLISIONS = false;
const bool ENTITY_ITEM_DEFAULT_COLLISIONS_WILL_MOVE = false; const bool ENTITY_ITEM_DEFAULT_COLLISIONS_WILL_MOVE = false;
const QString ENTITY_ITEM_DEFAULT_NAME = QString("");
#endif // hifi_EntityItemPropertiesDefaults_h #endif // hifi_EntityItemPropertiesDefaults_h

View file

@ -74,7 +74,7 @@ PacketVersion versionForPacketType(PacketType type) {
return 1; return 1;
case PacketTypeEntityAddOrEdit: case PacketTypeEntityAddOrEdit:
case PacketTypeEntityData: case PacketTypeEntityData:
return VERSION_ENTITIES_ZONE_ENTITIES_HAVE_DYNAMIC_SHAPE; return VERSION_ENTITIES_HAVE_NAMES;
case PacketTypeEntityErase: case PacketTypeEntityErase:
return 2; return 2;
case PacketTypeAudioStreamStats: case PacketTypeAudioStreamStats:

View file

@ -139,5 +139,6 @@ const PacketVersion VERSION_ENTITIES_HAVE_ACCELERATION = 15;
const PacketVersion VERSION_ENTITIES_HAVE_UUIDS = 16; const PacketVersion VERSION_ENTITIES_HAVE_UUIDS = 16;
const PacketVersion VERSION_ENTITIES_ZONE_ENTITIES_EXIST = 17; const PacketVersion VERSION_ENTITIES_ZONE_ENTITIES_EXIST = 17;
const PacketVersion VERSION_ENTITIES_ZONE_ENTITIES_HAVE_DYNAMIC_SHAPE = 18; const PacketVersion VERSION_ENTITIES_ZONE_ENTITIES_HAVE_DYNAMIC_SHAPE = 18;
const PacketVersion VERSION_ENTITIES_HAVE_NAMES = 19;
#endif // hifi_PacketHeaders_h #endif // hifi_PacketHeaders_h