mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:17:40 +02:00
added support for dashed lines for 3D Circle overlays
This commit is contained in:
parent
16cdc2614f
commit
7fc6eecca7
4 changed files with 89 additions and 47 deletions
|
@ -1589,7 +1589,7 @@ var SelectionDisplay = function (opts) {
|
||||||
size: 1,
|
size: 1,
|
||||||
color: { red: 0, green: 195, blue: 255},
|
color: { red: 0, green: 195, blue: 255},
|
||||||
alpha: 0.1,
|
alpha: 0.1,
|
||||||
solid: false,
|
solid: true,
|
||||||
visible: false,
|
visible: false,
|
||||||
rotation: yawOverlayRotation
|
rotation: yawOverlayRotation
|
||||||
});
|
});
|
||||||
|
@ -1599,7 +1599,7 @@ var SelectionDisplay = function (opts) {
|
||||||
size: 1,
|
size: 1,
|
||||||
color: { red: 0, green: 195, blue: 215},
|
color: { red: 0, green: 195, blue: 215},
|
||||||
alpha: 0.1,
|
alpha: 0.1,
|
||||||
solid: false,
|
solid: true,
|
||||||
visible: false,
|
visible: false,
|
||||||
rotation: yawOverlayRotation
|
rotation: yawOverlayRotation
|
||||||
});
|
});
|
||||||
|
@ -1610,8 +1610,9 @@ var SelectionDisplay = function (opts) {
|
||||||
color: { red: 255, green: 190, blue: 190},
|
color: { red: 255, green: 190, blue: 190},
|
||||||
alpha: 1,
|
alpha: 1,
|
||||||
solid: false,
|
solid: false,
|
||||||
|
isDashedLine: true,
|
||||||
visible: false,
|
visible: false,
|
||||||
rotation: yawOverlayRotation
|
rotation: yawOverlayRotation,
|
||||||
});
|
});
|
||||||
|
|
||||||
var yawHandleAngles = { x: 90, y: 90, z: 0 };
|
var yawHandleAngles = { x: 90, y: 90, z: 0 };
|
||||||
|
@ -1619,7 +1620,6 @@ var SelectionDisplay = function (opts) {
|
||||||
var yawHandle = Overlays.addOverlay("billboard", {
|
var yawHandle = Overlays.addOverlay("billboard", {
|
||||||
url: "https://s3.amazonaws.com/uploads.hipchat.com/33953/231323/oocBjCwXpWlHpF9/rotate_arrow_black.png",
|
url: "https://s3.amazonaws.com/uploads.hipchat.com/33953/231323/oocBjCwXpWlHpF9/rotate_arrow_black.png",
|
||||||
position: { x:0, y: 0, z: 0},
|
position: { x:0, y: 0, z: 0},
|
||||||
solid: true,
|
|
||||||
color: { red: 0, green: 0, blue: 255 },
|
color: { red: 0, green: 0, blue: 255 },
|
||||||
alpha: 0.3,
|
alpha: 0.3,
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -1636,7 +1636,6 @@ var SelectionDisplay = function (opts) {
|
||||||
size: 1,
|
size: 1,
|
||||||
color: { red: 0, green: 255, blue: 0},
|
color: { red: 0, green: 255, blue: 0},
|
||||||
alpha: 1,
|
alpha: 1,
|
||||||
solid: false,
|
|
||||||
visible: false,
|
visible: false,
|
||||||
rotation: pitchOverlayRotation
|
rotation: pitchOverlayRotation
|
||||||
});
|
});
|
||||||
|
@ -1646,7 +1645,6 @@ var SelectionDisplay = function (opts) {
|
||||||
var pitchHandle = Overlays.addOverlay("billboard", {
|
var pitchHandle = Overlays.addOverlay("billboard", {
|
||||||
url: "https://s3.amazonaws.com/uploads.hipchat.com/33953/231323/oocBjCwXpWlHpF9/rotate_arrow_black.png",
|
url: "https://s3.amazonaws.com/uploads.hipchat.com/33953/231323/oocBjCwXpWlHpF9/rotate_arrow_black.png",
|
||||||
position: { x:0, y: 0, z: 0},
|
position: { x:0, y: 0, z: 0},
|
||||||
solid: true,
|
|
||||||
color: { red: 0, green: 0, blue: 255 },
|
color: { red: 0, green: 0, blue: 255 },
|
||||||
alpha: 0.3,
|
alpha: 0.3,
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -1663,7 +1661,6 @@ var SelectionDisplay = function (opts) {
|
||||||
size: 1,
|
size: 1,
|
||||||
color: { red: 255, green: 0, blue: 0},
|
color: { red: 255, green: 0, blue: 0},
|
||||||
alpha: 1,
|
alpha: 1,
|
||||||
solid: false,
|
|
||||||
visible: false,
|
visible: false,
|
||||||
rotation: rollOverlayRotation
|
rotation: rollOverlayRotation
|
||||||
});
|
});
|
||||||
|
@ -1673,7 +1670,6 @@ var SelectionDisplay = function (opts) {
|
||||||
var rollHandle = Overlays.addOverlay("billboard", {
|
var rollHandle = Overlays.addOverlay("billboard", {
|
||||||
url: "https://s3.amazonaws.com/uploads.hipchat.com/33953/231323/oocBjCwXpWlHpF9/rotate_arrow_black.png",
|
url: "https://s3.amazonaws.com/uploads.hipchat.com/33953/231323/oocBjCwXpWlHpF9/rotate_arrow_black.png",
|
||||||
position: { x:0, y: 0, z: 0},
|
position: { x:0, y: 0, z: 0},
|
||||||
solid: true,
|
|
||||||
color: { red: 0, green: 0, blue: 255 },
|
color: { red: 0, green: 0, blue: 255 },
|
||||||
alpha: 0.3,
|
alpha: 0.3,
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -1725,7 +1721,6 @@ var SelectionDisplay = function (opts) {
|
||||||
Overlays.editOverlay(yawOverlayInner,
|
Overlays.editOverlay(yawOverlayInner,
|
||||||
{
|
{
|
||||||
visible: true,
|
visible: true,
|
||||||
solid:false,
|
|
||||||
lineWidth: 5.0,
|
lineWidth: 5.0,
|
||||||
position: { x: properties.position.x,
|
position: { x: properties.position.x,
|
||||||
y: properties.position.y - (properties.dimensions.y / 2),
|
y: properties.position.y - (properties.dimensions.y / 2),
|
||||||
|
@ -1738,7 +1733,6 @@ var SelectionDisplay = function (opts) {
|
||||||
Overlays.editOverlay(yawOverlayOuter,
|
Overlays.editOverlay(yawOverlayOuter,
|
||||||
{
|
{
|
||||||
visible: true,
|
visible: true,
|
||||||
solid:false,
|
|
||||||
lineWidth: 5.0,
|
lineWidth: 5.0,
|
||||||
position: { x: properties.position.x,
|
position: { x: properties.position.x,
|
||||||
y: properties.position.y - (properties.dimensions.y / 2),
|
y: properties.position.y - (properties.dimensions.y / 2),
|
||||||
|
@ -1753,7 +1747,6 @@ var SelectionDisplay = function (opts) {
|
||||||
Overlays.editOverlay(yawOverlayCurrent,
|
Overlays.editOverlay(yawOverlayCurrent,
|
||||||
{
|
{
|
||||||
visible: true,
|
visible: true,
|
||||||
solid:false,
|
|
||||||
lineWidth: 5.0,
|
lineWidth: 5.0,
|
||||||
position: { x: properties.position.x,
|
position: { x: properties.position.x,
|
||||||
y: properties.position.y - (properties.dimensions.y / 2),
|
y: properties.position.y - (properties.dimensions.y / 2),
|
||||||
|
@ -1779,7 +1772,6 @@ var SelectionDisplay = function (opts) {
|
||||||
Overlays.editOverlay(pitchOverlay,
|
Overlays.editOverlay(pitchOverlay,
|
||||||
{
|
{
|
||||||
visible: false,
|
visible: false,
|
||||||
solid:false,
|
|
||||||
lineWidth: 5.0,
|
lineWidth: 5.0,
|
||||||
position: { x: properties.position.x + (properties.dimensions.x / 2),
|
position: { x: properties.position.x + (properties.dimensions.x / 2),
|
||||||
y: properties.position.y,
|
y: properties.position.y,
|
||||||
|
@ -1802,7 +1794,6 @@ var SelectionDisplay = function (opts) {
|
||||||
Overlays.editOverlay(rollOverlay,
|
Overlays.editOverlay(rollOverlay,
|
||||||
{
|
{
|
||||||
visible: false,
|
visible: false,
|
||||||
solid:false,
|
|
||||||
lineWidth: 5.0,
|
lineWidth: 5.0,
|
||||||
position: { x: properties.position.x,
|
position: { x: properties.position.x,
|
||||||
y: properties.position.y,
|
y: properties.position.y,
|
||||||
|
|
|
@ -33,6 +33,11 @@ void Circle3DOverlay::render() {
|
||||||
return; // do nothing if we're not visible
|
return; // do nothing if we're not visible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float PI_OVER_180 = 3.14159265358979f / 180.0f;
|
||||||
|
float FULL_CIRCLE = 360.0f;
|
||||||
|
float SLICES = 180.0f; // The amount of segment to create the circle
|
||||||
|
float SLICE_ANGLE = FULL_CIRCLE / SLICES;
|
||||||
|
|
||||||
//const int slices = 15;
|
//const int slices = 15;
|
||||||
float alpha = getAlpha();
|
float alpha = getAlpha();
|
||||||
xColor color = getColor();
|
xColor color = getColor();
|
||||||
|
@ -64,18 +69,17 @@ void Circle3DOverlay::render() {
|
||||||
|
|
||||||
// Create the circle in the coordinates origin
|
// Create the circle in the coordinates origin
|
||||||
float outerRadius = getOuterRadius();
|
float outerRadius = getOuterRadius();
|
||||||
float innerRadius = getInnerRadius();
|
float innerRadius = getInnerRadius(); // only used in solid case
|
||||||
|
|
||||||
glLineWidth(_lineWidth);
|
|
||||||
glBegin(GL_QUAD_STRIP);
|
|
||||||
|
|
||||||
const float PI_OVER_180 = 3.14159265358979f / 180.0f;
|
|
||||||
const float FULL_CIRCLE = 360.0f;
|
|
||||||
const float SLICES = 180.0f; // The amount of segment to create the circle
|
|
||||||
const float SLICE_ANGLE = FULL_CIRCLE / SLICES;
|
|
||||||
|
|
||||||
float startAt = getStartAt();
|
float startAt = getStartAt();
|
||||||
float endAt = getEndAt();
|
float endAt = getEndAt();
|
||||||
|
|
||||||
|
glLineWidth(_lineWidth);
|
||||||
|
|
||||||
|
// for our overlay, is solid means we draw a ring between the inner and outer radius of the circle, otherwise
|
||||||
|
// we just draw a line...
|
||||||
|
if (getIsSolid()) {
|
||||||
|
glBegin(GL_QUAD_STRIP);
|
||||||
|
|
||||||
float angle = startAt;
|
float angle = startAt;
|
||||||
float angleInRadians = angle * PI_OVER_180;
|
float angleInRadians = angle * PI_OVER_180;
|
||||||
glm::vec2 firstInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
|
glm::vec2 firstInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
|
||||||
|
@ -105,6 +109,40 @@ void Circle3DOverlay::render() {
|
||||||
glVertex2f(lastInnerPoint.x, lastInnerPoint.y);
|
glVertex2f(lastInnerPoint.x, lastInnerPoint.y);
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
} else {
|
||||||
|
if (getIsDashedLine()) {
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
} else {
|
||||||
|
glBegin(GL_LINE_STRIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float angle = startAt;
|
||||||
|
float angleInRadians = angle * PI_OVER_180;
|
||||||
|
glm::vec2 firstPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||||
|
glVertex2f(firstPoint.x, firstPoint.y);
|
||||||
|
|
||||||
|
while (angle < endAt) {
|
||||||
|
angle += SLICE_ANGLE;
|
||||||
|
angleInRadians = angle * PI_OVER_180;
|
||||||
|
glm::vec2 thisPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||||
|
glVertex2f(thisPoint.x, thisPoint.y);
|
||||||
|
|
||||||
|
if (getIsDashedLine()) {
|
||||||
|
angle += SLICE_ANGLE / 2.0f; // short gap
|
||||||
|
angleInRadians = angle * PI_OVER_180;
|
||||||
|
glm::vec2 dashStartPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||||
|
glVertex2f(dashStartPoint.x, dashStartPoint.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the last slice portion....
|
||||||
|
angle = endAt;
|
||||||
|
angleInRadians = angle * PI_OVER_180;
|
||||||
|
glm::vec2 lastOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||||
|
glVertex2f(lastOuterPoint.x, lastOuterPoint.y);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -141,6 +179,8 @@ void Circle3DOverlay::setProperties(const QScriptValue &properties) {
|
||||||
qDebug() << "endAt:" << getEndAt();
|
qDebug() << "endAt:" << getEndAt();
|
||||||
qDebug() << "outerRadius:" << getOuterRadius();
|
qDebug() << "outerRadius:" << getOuterRadius();
|
||||||
qDebug() << "innerRadius:" << getInnerRadius();
|
qDebug() << "innerRadius:" << getInnerRadius();
|
||||||
|
qDebug() << "getIsSolid:" << getIsSolid();
|
||||||
|
qDebug() << "getIsDashedLine:" << getIsDashedLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -115,4 +115,11 @@ void Volume3DOverlay::setProperties(const QScriptValue& properties) {
|
||||||
if (properties.property("wire").isValid()) {
|
if (properties.property("wire").isValid()) {
|
||||||
setIsSolid(!properties.property("wire").toVariant().toBool());
|
setIsSolid(!properties.property("wire").toVariant().toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (properties.property("isDashedLine").isValid()) {
|
||||||
|
setIsDashedLine(properties.property("isDashedLine").toVariant().toBool());
|
||||||
|
}
|
||||||
|
if (properties.property("dashed").isValid()) {
|
||||||
|
setIsDashedLine(!properties.property("dashed").toVariant().toBool());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,17 @@ public:
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
bool getIsSolid() const { return _isSolid; }
|
bool getIsSolid() const { return _isSolid; }
|
||||||
|
bool getIsDashedLine() const { return _isDashedLine; }
|
||||||
|
bool getIsSolidLine() const { return !_isDashedLine; }
|
||||||
const glm::vec3& getPosition() const { return _position; }
|
const glm::vec3& getPosition() const { return _position; }
|
||||||
const glm::vec3& getCenter() const { return _position; } // TODO: registration point!!
|
const glm::vec3& getCenter() const { return _position; } // TODO: consider adding registration point!!
|
||||||
const glm::vec3& getDimensions() const { return _dimensions; }
|
const glm::vec3& getDimensions() const { return _dimensions; }
|
||||||
const glm::quat& getRotation() const { return _rotation; }
|
const glm::quat& getRotation() const { return _rotation; }
|
||||||
|
|
||||||
// setters
|
// setters
|
||||||
void setSize(float size) { _dimensions = glm::vec3(size, size, size); }
|
void setSize(float size) { _dimensions = glm::vec3(size, size, size); }
|
||||||
void setIsSolid(bool isSolid) { _isSolid = isSolid; }
|
void setIsSolid(bool isSolid) { _isSolid = isSolid; }
|
||||||
|
void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; }
|
||||||
void setDimensions(const glm::vec3& value) { _dimensions = value; }
|
void setDimensions(const glm::vec3& value) { _dimensions = value; }
|
||||||
void setRotation(const glm::quat& value) { _rotation = value; }
|
void setRotation(const glm::quat& value) { _rotation = value; }
|
||||||
|
|
||||||
|
@ -49,6 +52,7 @@ protected:
|
||||||
glm::vec3 _dimensions;
|
glm::vec3 _dimensions;
|
||||||
glm::quat _rotation;
|
glm::quat _rotation;
|
||||||
bool _isSolid;
|
bool _isSolid;
|
||||||
|
bool _isDashedLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue