mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 13:33:38 +02:00
Merge pull request #3864 from huffman/entity-tools-front-draw
Update entity tools to draw grabbers in front
This commit is contained in:
commit
883fda241f
3 changed files with 90 additions and 28 deletions
|
@ -206,6 +206,8 @@ SelectionDisplay = (function () {
|
|||
var MINIMUM_DIMENSION = 0.001;
|
||||
|
||||
var GRABBER_DISTANCE_TO_SIZE_RATIO = 0.0075;
|
||||
|
||||
var showExtendedStretchHandles = false;
|
||||
|
||||
var spaceMode = SPACE_LOCAL;
|
||||
var mode = "UNKNOWN";
|
||||
|
@ -271,6 +273,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
dashed: false,
|
||||
lineWidth: grabberLineWidth,
|
||||
drawInFront: true,
|
||||
borderSize: 1.4,
|
||||
};
|
||||
|
||||
var grabberPropertiesEdge = {
|
||||
|
@ -282,6 +286,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
dashed: false,
|
||||
lineWidth: grabberLineWidth,
|
||||
drawInFront: true,
|
||||
borderSize: 1.4,
|
||||
};
|
||||
|
||||
var grabberPropertiesFace = {
|
||||
|
@ -293,6 +299,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
dashed: false,
|
||||
lineWidth: grabberLineWidth,
|
||||
drawInFront: true,
|
||||
borderSize: 1.4,
|
||||
};
|
||||
|
||||
var highlightBox = Overlays.addOverlay("cube", {
|
||||
|
@ -326,7 +334,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
size: 0.1,
|
||||
scale: 0.1,
|
||||
isFacingAvatar: true
|
||||
isFacingAvatar: true,
|
||||
drawInFront: true,
|
||||
});
|
||||
|
||||
// var normalLine = Overlays.addOverlay("line3d", {
|
||||
|
@ -533,7 +542,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
size: 0.1,
|
||||
scale: 0.1,
|
||||
isFacingAvatar: false
|
||||
isFacingAvatar: false,
|
||||
drawInFront: true,
|
||||
});
|
||||
|
||||
|
||||
|
@ -545,7 +555,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
size: 0.1,
|
||||
scale: 0.1,
|
||||
isFacingAvatar: false
|
||||
isFacingAvatar: false,
|
||||
drawInFront: true,
|
||||
});
|
||||
|
||||
|
||||
|
@ -557,7 +568,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
size: 0.1,
|
||||
scale: 0.1,
|
||||
isFacingAvatar: false
|
||||
isFacingAvatar: false,
|
||||
drawInFront: true,
|
||||
});
|
||||
|
||||
var allOverlays = [
|
||||
|
@ -1057,21 +1069,23 @@ SelectionDisplay = (function () {
|
|||
EdgeFL = Vec3.sum(position, EdgeFL);
|
||||
|
||||
var stretchHandlesVisible = spaceMode == SPACE_LOCAL;
|
||||
var extendedStretchHandlesVisible = stretchHandlesVisible && showExtendedStretchHandles;
|
||||
Overlays.editOverlay(grabberLBN, { visible: stretchHandlesVisible, rotation: rotation, position: LBN });
|
||||
Overlays.editOverlay(grabberRBN, { visible: stretchHandlesVisible, rotation: rotation, position: RBN });
|
||||
Overlays.editOverlay(grabberLBF, { visible: stretchHandlesVisible, rotation: rotation, position: LBF });
|
||||
Overlays.editOverlay(grabberRBF, { visible: stretchHandlesVisible, rotation: rotation, position: RBF });
|
||||
Overlays.editOverlay(grabberLTN, { visible: stretchHandlesVisible, rotation: rotation, position: LTN });
|
||||
Overlays.editOverlay(grabberRTN, { visible: stretchHandlesVisible, rotation: rotation, position: RTN });
|
||||
Overlays.editOverlay(grabberLTF, { visible: stretchHandlesVisible, rotation: rotation, position: LTF });
|
||||
Overlays.editOverlay(grabberRTF, { visible: stretchHandlesVisible, rotation: rotation, position: RTF });
|
||||
|
||||
Overlays.editOverlay(grabberLTN, { visible: extendedStretchHandlesVisible, rotation: rotation, position: LTN });
|
||||
Overlays.editOverlay(grabberRTN, { visible: extendedStretchHandlesVisible, rotation: rotation, position: RTN });
|
||||
Overlays.editOverlay(grabberLTF, { visible: extendedStretchHandlesVisible, rotation: rotation, position: LTF });
|
||||
Overlays.editOverlay(grabberRTF, { visible: extendedStretchHandlesVisible, rotation: rotation, position: RTF });
|
||||
|
||||
Overlays.editOverlay(grabberTOP, { visible: stretchHandlesVisible, rotation: rotation, position: TOP });
|
||||
Overlays.editOverlay(grabberBOTTOM, { visible: stretchHandlesVisible, rotation: rotation, position: BOTTOM });
|
||||
Overlays.editOverlay(grabberLEFT, { visible: stretchHandlesVisible, rotation: rotation, position: LEFT });
|
||||
Overlays.editOverlay(grabberRIGHT, { visible: stretchHandlesVisible, rotation: rotation, position: RIGHT });
|
||||
Overlays.editOverlay(grabberNEAR, { visible: stretchHandlesVisible, rotation: rotation, position: NEAR });
|
||||
Overlays.editOverlay(grabberFAR, { visible: stretchHandlesVisible, rotation: rotation, position: FAR });
|
||||
Overlays.editOverlay(grabberLEFT, { visible: extendedStretchHandlesVisible, rotation: rotation, position: LEFT });
|
||||
Overlays.editOverlay(grabberRIGHT, { visible: extendedStretchHandlesVisible, rotation: rotation, position: RIGHT });
|
||||
Overlays.editOverlay(grabberNEAR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: NEAR });
|
||||
Overlays.editOverlay(grabberFAR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: FAR });
|
||||
|
||||
Overlays.editOverlay(selectionBox, {
|
||||
position: position,
|
||||
|
@ -1080,18 +1094,18 @@ SelectionDisplay = (function () {
|
|||
visible: !(mode == "ROTATE_YAW" || mode == "ROTATE_PITCH" || mode == "ROTATE_ROLL"),
|
||||
});
|
||||
|
||||
Overlays.editOverlay(grabberEdgeTR, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeTR });
|
||||
Overlays.editOverlay(grabberEdgeTL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeTL });
|
||||
Overlays.editOverlay(grabberEdgeTF, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeTF });
|
||||
Overlays.editOverlay(grabberEdgeTN, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeTN });
|
||||
Overlays.editOverlay(grabberEdgeTR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeTR });
|
||||
Overlays.editOverlay(grabberEdgeTL, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeTL });
|
||||
Overlays.editOverlay(grabberEdgeTF, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeTF });
|
||||
Overlays.editOverlay(grabberEdgeTN, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeTN });
|
||||
Overlays.editOverlay(grabberEdgeBR, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeBR });
|
||||
Overlays.editOverlay(grabberEdgeBL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeBL });
|
||||
Overlays.editOverlay(grabberEdgeBF, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeBF });
|
||||
Overlays.editOverlay(grabberEdgeBN, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeBN });
|
||||
Overlays.editOverlay(grabberEdgeNR, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeNR });
|
||||
Overlays.editOverlay(grabberEdgeNL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeNL });
|
||||
Overlays.editOverlay(grabberEdgeFR, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeFR });
|
||||
Overlays.editOverlay(grabberEdgeFL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeFL });
|
||||
Overlays.editOverlay(grabberEdgeNR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeNR });
|
||||
Overlays.editOverlay(grabberEdgeNL, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeNL });
|
||||
Overlays.editOverlay(grabberEdgeFR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeFR });
|
||||
Overlays.editOverlay(grabberEdgeFL, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeFL });
|
||||
|
||||
var grabberMoveUpOffset = 0.1;
|
||||
grabberMoveUpPosition = { x: position.x, y: position.y + worldTop + grabberMoveUpOffset, z: position.z }
|
||||
|
@ -1507,10 +1521,10 @@ SelectionDisplay = (function () {
|
|||
addStretchTool(grabberEdgeTL, "STRETCH_EdgeTL", null, {x: -1, y: 1, z: 0});
|
||||
addStretchTool(grabberEdgeTF, "STRETCH_EdgeTF", null, {x: 0, y: 1, z: -1});
|
||||
addStretchTool(grabberEdgeTN, "STRETCH_EdgeTN", null, {x: 0, y: 1, z: 1});
|
||||
addStretchTool(grabberEdgeBR, "STRETCH_EdgeBR", null, {x: 1, y: -1, z: 0});
|
||||
addStretchTool(grabberEdgeBL, "STRETCH_EdgeBL", null, {x: -1, y: -1, z: 0});
|
||||
addStretchTool(grabberEdgeBF, "STRETCH_EdgeBF", null, {x: 0, y: -1, z: 1});
|
||||
addStretchTool(grabberEdgeBN, "STRETCH_EdgeBN", null, {x: 0, y: -1, z: -1});
|
||||
addStretchTool(grabberEdgeBR, "STRETCH_EdgeBR", null, {x: -1, y: 0, z: 0});
|
||||
addStretchTool(grabberEdgeBL, "STRETCH_EdgeBL", null, {x: 1, y: 0, z: 0});
|
||||
addStretchTool(grabberEdgeBF, "STRETCH_EdgeBF", null, {x: 0, y: 0, z: -1});
|
||||
addStretchTool(grabberEdgeBN, "STRETCH_EdgeBN", null, {x: 0, y: 0, z: 1});
|
||||
addStretchTool(grabberEdgeNR, "STRETCH_EdgeNR", null, {x: -1, y: 0, z: 1});
|
||||
addStretchTool(grabberEdgeNL, "STRETCH_EdgeNL", null, {x: 1, y: 0, z: 1});
|
||||
addStretchTool(grabberEdgeFR, "STRETCH_EdgeFR", null, {x: -1, y: 0, z: -1});
|
||||
|
@ -2289,7 +2303,7 @@ SelectionDisplay = (function () {
|
|||
size: grabberSize,
|
||||
});
|
||||
}
|
||||
var handleSize = Vec3.length(diff) * GRABBER_DISTANCE_TO_SIZE_RATIO * 5;
|
||||
var handleSize = Vec3.length(diff) * GRABBER_DISTANCE_TO_SIZE_RATIO * 10;
|
||||
Overlays.editOverlay(yawHandle, {
|
||||
scale: handleSize,
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "Cube3DOverlay.h"
|
||||
#include "renderer/GlowEffect.h"
|
||||
|
||||
Cube3DOverlay::Cube3DOverlay() {
|
||||
Cube3DOverlay::Cube3DOverlay() : _borderSize(0) {
|
||||
}
|
||||
|
||||
Cube3DOverlay::Cube3DOverlay(const Cube3DOverlay* cube3DOverlay) :
|
||||
|
@ -63,8 +63,27 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
|||
glm::vec3 positionToCenter = center - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
if (_isSolid) {
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
|
||||
if (_borderSize > 0) {
|
||||
// Draw a cube at a larger size behind the main cube, creating
|
||||
// a border effect.
|
||||
// Disable writing to the depth mask so that the "border" cube will not
|
||||
// occlude the main cube. This means the border could be covered by
|
||||
// overlays that are further back and drawn later, but this is good
|
||||
// enough for the use-case.
|
||||
glDepthMask(GL_FALSE);
|
||||
glPushMatrix();
|
||||
glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
||||
glScalef(dimensions.x * _borderSize, dimensions.y * _borderSize, dimensions.z * _borderSize);
|
||||
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
|
||||
glPopMatrix();
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
|
||||
glPopMatrix();
|
||||
} else {
|
||||
glLineWidth(_lineWidth);
|
||||
|
||||
|
@ -111,3 +130,22 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
|||
Cube3DOverlay* Cube3DOverlay::createClone() const {
|
||||
return new Cube3DOverlay(this);
|
||||
}
|
||||
|
||||
void Cube3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
Volume3DOverlay::setProperties(properties);
|
||||
|
||||
QScriptValue borderSize = properties.property("borderSize");
|
||||
|
||||
if (borderSize.isValid()) {
|
||||
float value = borderSize.toVariant().toFloat();
|
||||
setBorderSize(value);
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue Cube3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "borderSize") {
|
||||
return _borderSize;
|
||||
}
|
||||
|
||||
return Volume3DOverlay::getProperty(property);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,16 @@ public:
|
|||
virtual void render(RenderArgs* args);
|
||||
|
||||
virtual Cube3DOverlay* createClone() const;
|
||||
|
||||
float getBorderSize() const { return _borderSize; }
|
||||
|
||||
void setBorderSize(float value) { _borderSize = value; }
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
private:
|
||||
float _borderSize;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue