Adding a color indicator to whiteboard

This commit is contained in:
ericrius1 2015-10-14 15:58:10 -07:00
parent 0b92bc11f6
commit cfca0fe8c0
4 changed files with 41 additions and 35 deletions

View file

@ -16,16 +16,10 @@
Script.include("../../libraries/utils.js"); Script.include("../../libraries/utils.js");
var scriptURL = Script.resolvePath("whiteboardEntityScript.js"); var scriptURL = Script.resolvePath("whiteboardEntityScript.js");
var rotation = Quat.safeEulerAngles(Camera.getOrientation()); var rotation = Quat.safeEulerAngles(Camera.getOrientation());
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0); rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(rotation))); var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(rotation)));
center.y += 0.4; center.y += 0.4;
var whiteboardDimensions = {
x: 2,
y: 1.5,
z: 0.01
};
var colors = [ var colors = [
hexToRgb("#2F8E84"), hexToRgb("#2F8E84"),
@ -36,8 +30,16 @@ var colors = [
hexToRgb("#993369"), hexToRgb("#993369"),
hexToRgb("#9B47C2") hexToRgb("#9B47C2")
]; ];
//WHITEBOARD
var whiteboardDimensions = {
x: 2,
y: 1.5,
z: 0.02
};
var whiteboard = Entities.addEntity({ var whiteboard = Entities.addEntity({
type: "Box", type: "Model",
modelURL: "https://hifi-public.s3.amazonaws.com/ozan/support/for_eric/whiteboard/whiteboard.fbx",
name: "whiteboard", name: "whiteboard",
position: center, position: center,
rotation: rotation, rotation: rotation,
@ -53,19 +55,34 @@ var whiteboard = Entities.addEntity({
}) })
}); });
//COLORS
// COLOR INDICATOR BOX
var colorIndicatorDimensions = {
x: whiteboardDimensions.x,
y: 0.2,
z: 0.02
};
scriptURL = Script.resolvePath("colorIndicatorEntityScript.js");
var colorIndicatorPosition = Vec3.sum(center, {x: 0, y: whiteboardDimensions.y/2, z: 0});
var colorIndicatorBox = Entities.addEntity({
type: "Box",
color: colors[0],
rotation: rotation,
position: colorIndicatorPosition,
dimensions: colorIndicatorDimensions,
script: scriptURL
});
//COLOR BOXES
var direction = Quat.getRight(rotation); var direction = Quat.getRight(rotation);
var colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2)); var colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2));
var colorBoxes = []; var colorBoxes = [];
var colorSquareDimensions = { var colorSquareDimensions = {
x: (whiteboardDimensions.x / 2) / (colors.length - 1), x: (whiteboardDimensions.x / 2) / (colors.length - 1),
y: 0.1, y: 0.1,
z: 0.05 z: 0.05
}; };
colorBoxPosition.y += whiteboardDimensions.y / 2 + colorSquareDimensions.y / 2 - 0.01; colorBoxPosition.y += whiteboardDimensions.y / 2 + colorIndicatorDimensions.y/2 + colorSquareDimensions.y / 2 - 0.01;
var spaceBetweenColorBoxes = Vec3.multiply(direction, colorSquareDimensions.x * 2); var spaceBetweenColorBoxes = Vec3.multiply(direction, colorSquareDimensions.x * 2);
var scriptURL = Script.resolvePath("colorSelectorEntityScript.js"); var scriptURL = Script.resolvePath("colorSelectorEntityScript.js");
for (var i = 0; i < colors.length; i++) { for (var i = 0; i < colors.length; i++) {
@ -77,13 +94,16 @@ for (var i = 0; i < colors.length; i++) {
color: colors[i], color: colors[i],
script: scriptURL, script: scriptURL,
userData: JSON.stringify({ userData: JSON.stringify({
whiteboard: whiteboard whiteboard: whiteboard,
colorIndicator: colorIndicatorBox
}) })
}); });
colorBoxes.push(colorBox); colorBoxes.push(colorBox);
colorBoxPosition = Vec3.sum(colorBoxPosition, spaceBetweenColorBoxes); colorBoxPosition = Vec3.sum(colorBoxPosition, spaceBetweenColorBoxes);
} }
// BLACK BOX
var blackBoxDimensions = {x: .2, y: .2, z: 0.05}; var blackBoxDimensions = {x: .2, y: .2, z: 0.05};
colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2 + blackBoxDimensions.x/2 - 0.01)); colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2 + blackBoxDimensions.x/2 - 0.01));
colorBoxPosition.y += 0.3; colorBoxPosition.y += 0.3;
@ -146,4 +166,4 @@ function cleanup() {
// Uncomment this line to delete whiteboard and all associated entity on script close // Uncomment this line to delete whiteboard and all associated entity on script close
// Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);

View file

@ -416,20 +416,15 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
QString faceName = object.property("face").toVariant().toString(); QString faceName = object.property("face").toVariant().toString();
if (faceName == "MIN_X_FACE") { if (faceName == "MIN_X_FACE") {
value.face = MIN_X_FACE; value.face = MIN_X_FACE;
} } else if (faceName == "MAX_X_FACE") {
else if (faceName == "MAX_X_FACE") {
value.face = MAX_X_FACE; value.face = MAX_X_FACE;
} } else if (faceName == "MIN_Y_FACE") {
else if (faceName == "MIN_Y_FACE") {
value.face = MIN_Y_FACE; value.face = MIN_Y_FACE;
} } else if (faceName == "MAX_Y_FACE") {
else if (faceName == "MAX_Y_FACE") {
value.face = MAX_Y_FACE; value.face = MAX_Y_FACE;
} } else if (faceName == "MIN_Z_FACE") {
else if (faceName == "MIN_Z_FACE") {
value.face = MIN_Z_FACE; value.face = MIN_Z_FACE;
} } else {
else {
value.face = MAX_Z_FACE; value.face = MAX_Z_FACE;
}; };
QScriptValue intersection = object.property("intersection"); QScriptValue intersection = object.property("intersection");

View file

@ -501,17 +501,8 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con
int entityNumber = 0; int entityNumber = 0;
bool somethingIntersected = false; bool somethingIntersected = false;
forEachEntity([&](EntityItemPointer entity) { forEachEntity([&](EntityItemPointer entity) {
if (entityIdsToInclude.size() > 0) { if (entityIdsToInclude.size() > 0 && !entityIdsToInclude.contains(entity->getID())) {
bool entityInWhiteList = false; return;
// We only want to search whitelist if there is one, otherwise everything except blacklisted items are valid
for (int i = 0; i < entityIdsToInclude.size(); i++) {
if (entityIdsToInclude.at(i) == entity->getID()) {
entityInWhiteList = true;
}
}
if (!entityInWhiteList) {
return;
}
} }
AABox entityBox = entity->getAABox(); AABox entityBox = entity->getAABox();

View file

@ -724,7 +724,7 @@ bool Octree::findRayIntersection(const glm::vec3& origin, const glm::vec3& direc
OctreeElementPointer& element, float& distance, OctreeElementPointer& element, float& distance,
BoxFace& face, glm::vec3& surfaceNormal, const QVector<QUuid>& entityIdsToInclude, void** intersectedObject, BoxFace& face, glm::vec3& surfaceNormal, const QVector<QUuid>& entityIdsToInclude, void** intersectedObject,
Octree::lockType lockType, bool* accurateResult, bool precisionPicking) { Octree::lockType lockType, bool* accurateResult, bool precisionPicking) {
RayArgs args = { origin, direction, element, distance, face, surfaceNormal, entityIdsToInclude, intersectedObject, false, precisionPicking}; RayArgs args = { origin, direction, element, distance, face, surfaceNormal, intersectedObject, false, precisionPicking};
distance = FLT_MAX; distance = FLT_MAX;
bool requireLock = lockType == Octree::Lock; bool requireLock = lockType == Octree::Lock;