mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 05:53:32 +02:00
Adding a color indicator to whiteboard
This commit is contained in:
parent
0b92bc11f6
commit
cfca0fe8c0
4 changed files with 41 additions and 35 deletions
examples/painting/whiteboard
libraries
|
@ -16,16 +16,10 @@
|
|||
|
||||
Script.include("../../libraries/utils.js");
|
||||
var scriptURL = Script.resolvePath("whiteboardEntityScript.js");
|
||||
|
||||
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
||||
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(rotation)));
|
||||
center.y += 0.4;
|
||||
var whiteboardDimensions = {
|
||||
x: 2,
|
||||
y: 1.5,
|
||||
z: 0.01
|
||||
};
|
||||
|
||||
var colors = [
|
||||
hexToRgb("#2F8E84"),
|
||||
|
@ -36,8 +30,16 @@ var colors = [
|
|||
hexToRgb("#993369"),
|
||||
hexToRgb("#9B47C2")
|
||||
];
|
||||
|
||||
//WHITEBOARD
|
||||
var whiteboardDimensions = {
|
||||
x: 2,
|
||||
y: 1.5,
|
||||
z: 0.02
|
||||
};
|
||||
var whiteboard = Entities.addEntity({
|
||||
type: "Box",
|
||||
type: "Model",
|
||||
modelURL: "https://hifi-public.s3.amazonaws.com/ozan/support/for_eric/whiteboard/whiteboard.fbx",
|
||||
name: "whiteboard",
|
||||
position: center,
|
||||
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 colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2));
|
||||
|
||||
var colorBoxes = [];
|
||||
|
||||
var colorSquareDimensions = {
|
||||
x: (whiteboardDimensions.x / 2) / (colors.length - 1),
|
||||
y: 0.1,
|
||||
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 scriptURL = Script.resolvePath("colorSelectorEntityScript.js");
|
||||
for (var i = 0; i < colors.length; i++) {
|
||||
|
@ -77,13 +94,16 @@ for (var i = 0; i < colors.length; i++) {
|
|||
color: colors[i],
|
||||
script: scriptURL,
|
||||
userData: JSON.stringify({
|
||||
whiteboard: whiteboard
|
||||
whiteboard: whiteboard,
|
||||
colorIndicator: colorIndicatorBox
|
||||
})
|
||||
});
|
||||
colorBoxes.push(colorBox);
|
||||
colorBoxPosition = Vec3.sum(colorBoxPosition, spaceBetweenColorBoxes);
|
||||
}
|
||||
|
||||
|
||||
// BLACK BOX
|
||||
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.y += 0.3;
|
||||
|
@ -146,4 +166,4 @@ function cleanup() {
|
|||
|
||||
|
||||
// Uncomment this line to delete whiteboard and all associated entity on script close
|
||||
// Script.scriptEnding.connect(cleanup);
|
||||
Script.scriptEnding.connect(cleanup);
|
|
@ -416,20 +416,15 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
|
|||
QString faceName = object.property("face").toVariant().toString();
|
||||
if (faceName == "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;
|
||||
}
|
||||
else if (faceName == "MIN_Y_FACE") {
|
||||
} else if (faceName == "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;
|
||||
}
|
||||
else if (faceName == "MIN_Z_FACE") {
|
||||
} else if (faceName == "MIN_Z_FACE") {
|
||||
value.face = MIN_Z_FACE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
value.face = MAX_Z_FACE;
|
||||
};
|
||||
QScriptValue intersection = object.property("intersection");
|
||||
|
|
|
@ -501,17 +501,8 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con
|
|||
int entityNumber = 0;
|
||||
bool somethingIntersected = false;
|
||||
forEachEntity([&](EntityItemPointer entity) {
|
||||
if (entityIdsToInclude.size() > 0) {
|
||||
bool entityInWhiteList = false;
|
||||
// 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;
|
||||
}
|
||||
if (entityIdsToInclude.size() > 0 && !entityIdsToInclude.contains(entity->getID())) {
|
||||
return;
|
||||
}
|
||||
|
||||
AABox entityBox = entity->getAABox();
|
||||
|
|
|
@ -724,7 +724,7 @@ bool Octree::findRayIntersection(const glm::vec3& origin, const glm::vec3& direc
|
|||
OctreeElementPointer& element, float& distance,
|
||||
BoxFace& face, glm::vec3& surfaceNormal, const QVector<QUuid>& entityIdsToInclude, void** intersectedObject,
|
||||
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;
|
||||
|
||||
bool requireLock = lockType == Octree::Lock;
|
||||
|
|
Loading…
Reference in a new issue