mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +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,
|
||||
color: { red: 0, green: 195, blue: 255},
|
||||
alpha: 0.1,
|
||||
solid: false,
|
||||
solid: true,
|
||||
visible: false,
|
||||
rotation: yawOverlayRotation
|
||||
});
|
||||
|
@ -1599,7 +1599,7 @@ var SelectionDisplay = function (opts) {
|
|||
size: 1,
|
||||
color: { red: 0, green: 195, blue: 215},
|
||||
alpha: 0.1,
|
||||
solid: false,
|
||||
solid: true,
|
||||
visible: false,
|
||||
rotation: yawOverlayRotation
|
||||
});
|
||||
|
@ -1610,8 +1610,9 @@ var SelectionDisplay = function (opts) {
|
|||
color: { red: 255, green: 190, blue: 190},
|
||||
alpha: 1,
|
||||
solid: false,
|
||||
isDashedLine: true,
|
||||
visible: false,
|
||||
rotation: yawOverlayRotation
|
||||
rotation: yawOverlayRotation,
|
||||
});
|
||||
|
||||
var yawHandleAngles = { x: 90, y: 90, z: 0 };
|
||||
|
@ -1619,7 +1620,6 @@ var SelectionDisplay = function (opts) {
|
|||
var yawHandle = Overlays.addOverlay("billboard", {
|
||||
url: "https://s3.amazonaws.com/uploads.hipchat.com/33953/231323/oocBjCwXpWlHpF9/rotate_arrow_black.png",
|
||||
position: { x:0, y: 0, z: 0},
|
||||
solid: true,
|
||||
color: { red: 0, green: 0, blue: 255 },
|
||||
alpha: 0.3,
|
||||
visible: false,
|
||||
|
@ -1636,7 +1636,6 @@ var SelectionDisplay = function (opts) {
|
|||
size: 1,
|
||||
color: { red: 0, green: 255, blue: 0},
|
||||
alpha: 1,
|
||||
solid: false,
|
||||
visible: false,
|
||||
rotation: pitchOverlayRotation
|
||||
});
|
||||
|
@ -1646,7 +1645,6 @@ var SelectionDisplay = function (opts) {
|
|||
var pitchHandle = Overlays.addOverlay("billboard", {
|
||||
url: "https://s3.amazonaws.com/uploads.hipchat.com/33953/231323/oocBjCwXpWlHpF9/rotate_arrow_black.png",
|
||||
position: { x:0, y: 0, z: 0},
|
||||
solid: true,
|
||||
color: { red: 0, green: 0, blue: 255 },
|
||||
alpha: 0.3,
|
||||
visible: false,
|
||||
|
@ -1663,7 +1661,6 @@ var SelectionDisplay = function (opts) {
|
|||
size: 1,
|
||||
color: { red: 255, green: 0, blue: 0},
|
||||
alpha: 1,
|
||||
solid: false,
|
||||
visible: false,
|
||||
rotation: rollOverlayRotation
|
||||
});
|
||||
|
@ -1673,7 +1670,6 @@ var SelectionDisplay = function (opts) {
|
|||
var rollHandle = Overlays.addOverlay("billboard", {
|
||||
url: "https://s3.amazonaws.com/uploads.hipchat.com/33953/231323/oocBjCwXpWlHpF9/rotate_arrow_black.png",
|
||||
position: { x:0, y: 0, z: 0},
|
||||
solid: true,
|
||||
color: { red: 0, green: 0, blue: 255 },
|
||||
alpha: 0.3,
|
||||
visible: false,
|
||||
|
@ -1725,7 +1721,6 @@ var SelectionDisplay = function (opts) {
|
|||
Overlays.editOverlay(yawOverlayInner,
|
||||
{
|
||||
visible: true,
|
||||
solid:false,
|
||||
lineWidth: 5.0,
|
||||
position: { x: properties.position.x,
|
||||
y: properties.position.y - (properties.dimensions.y / 2),
|
||||
|
@ -1738,7 +1733,6 @@ var SelectionDisplay = function (opts) {
|
|||
Overlays.editOverlay(yawOverlayOuter,
|
||||
{
|
||||
visible: true,
|
||||
solid:false,
|
||||
lineWidth: 5.0,
|
||||
position: { x: properties.position.x,
|
||||
y: properties.position.y - (properties.dimensions.y / 2),
|
||||
|
@ -1753,7 +1747,6 @@ var SelectionDisplay = function (opts) {
|
|||
Overlays.editOverlay(yawOverlayCurrent,
|
||||
{
|
||||
visible: true,
|
||||
solid:false,
|
||||
lineWidth: 5.0,
|
||||
position: { x: properties.position.x,
|
||||
y: properties.position.y - (properties.dimensions.y / 2),
|
||||
|
@ -1779,7 +1772,6 @@ var SelectionDisplay = function (opts) {
|
|||
Overlays.editOverlay(pitchOverlay,
|
||||
{
|
||||
visible: false,
|
||||
solid:false,
|
||||
lineWidth: 5.0,
|
||||
position: { x: properties.position.x + (properties.dimensions.x / 2),
|
||||
y: properties.position.y,
|
||||
|
@ -1802,7 +1794,6 @@ var SelectionDisplay = function (opts) {
|
|||
Overlays.editOverlay(rollOverlay,
|
||||
{
|
||||
visible: false,
|
||||
solid:false,
|
||||
lineWidth: 5.0,
|
||||
position: { x: properties.position.x,
|
||||
y: properties.position.y,
|
||||
|
|
|
@ -32,6 +32,11 @@ void Circle3DOverlay::render() {
|
|||
if (!_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;
|
||||
float alpha = getAlpha();
|
||||
|
@ -63,48 +68,81 @@ void Circle3DOverlay::render() {
|
|||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
|
||||
// Create the circle in the coordinates origin
|
||||
float outerRadius = getOuterRadius();
|
||||
float innerRadius = getInnerRadius();
|
||||
|
||||
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 outerRadius = getOuterRadius();
|
||||
float innerRadius = getInnerRadius(); // only used in solid case
|
||||
float startAt = getStartAt();
|
||||
float endAt = getEndAt();
|
||||
float angle = startAt;
|
||||
float angleInRadians = angle * PI_OVER_180;
|
||||
glm::vec2 firstInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
|
||||
glm::vec2 firstOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||
|
||||
glVertex2f(firstInnerPoint.x, firstInnerPoint.y);
|
||||
glVertex2f(firstOuterPoint.x, firstOuterPoint.y);
|
||||
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);
|
||||
|
||||
while (angle < endAt) {
|
||||
angleInRadians = angle * PI_OVER_180;
|
||||
glm::vec2 thisInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
|
||||
glm::vec2 thisOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||
float angle = startAt;
|
||||
float angleInRadians = angle * PI_OVER_180;
|
||||
glm::vec2 firstInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
|
||||
glm::vec2 firstOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||
|
||||
glVertex2f(thisOuterPoint.x, thisOuterPoint.y);
|
||||
glVertex2f(thisInnerPoint.x, thisInnerPoint.y);
|
||||
glVertex2f(firstInnerPoint.x, firstInnerPoint.y);
|
||||
glVertex2f(firstOuterPoint.x, firstOuterPoint.y);
|
||||
|
||||
while (angle < endAt) {
|
||||
angleInRadians = angle * PI_OVER_180;
|
||||
glm::vec2 thisInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
|
||||
glm::vec2 thisOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||
|
||||
glVertex2f(thisOuterPoint.x, thisOuterPoint.y);
|
||||
glVertex2f(thisInnerPoint.x, thisInnerPoint.y);
|
||||
|
||||
angle += SLICE_ANGLE;
|
||||
}
|
||||
angle += SLICE_ANGLE;
|
||||
}
|
||||
|
||||
// get the last slice portion....
|
||||
angle = endAt;
|
||||
angleInRadians = angle * PI_OVER_180;
|
||||
glm::vec2 lastInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
|
||||
glm::vec2 lastOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||
// get the last slice portion....
|
||||
angle = endAt;
|
||||
angleInRadians = angle * PI_OVER_180;
|
||||
glm::vec2 lastInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
|
||||
glm::vec2 lastOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||
|
||||
glVertex2f(lastOuterPoint.x, lastOuterPoint.y);
|
||||
glVertex2f(lastInnerPoint.x, lastInnerPoint.y);
|
||||
glVertex2f(lastOuterPoint.x, lastOuterPoint.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();
|
||||
|
@ -141,6 +179,8 @@ void Circle3DOverlay::setProperties(const QScriptValue &properties) {
|
|||
qDebug() << "endAt:" << getEndAt();
|
||||
qDebug() << "outerRadius:" << getOuterRadius();
|
||||
qDebug() << "innerRadius:" << getInnerRadius();
|
||||
qDebug() << "getIsSolid:" << getIsSolid();
|
||||
qDebug() << "getIsDashedLine:" << getIsDashedLine();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -115,4 +115,11 @@ void Volume3DOverlay::setProperties(const QScriptValue& properties) {
|
|||
if (properties.property("wire").isValid()) {
|
||||
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
|
||||
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& 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::quat& getRotation() const { return _rotation; }
|
||||
|
||||
// setters
|
||||
void setSize(float size) { _dimensions = glm::vec3(size, size, size); }
|
||||
void setIsSolid(bool isSolid) { _isSolid = isSolid; }
|
||||
void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; }
|
||||
void setDimensions(const glm::vec3& value) { _dimensions = value; }
|
||||
void setRotation(const glm::quat& value) { _rotation = value; }
|
||||
|
||||
|
@ -49,6 +52,7 @@ protected:
|
|||
glm::vec3 _dimensions;
|
||||
glm::quat _rotation;
|
||||
bool _isSolid;
|
||||
bool _isDashedLine;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue