Merge pull request #5202 from Atlante45/overlay

Overlay have correct bounds
This commit is contained in:
Brad Hefta-Gaub 2015-06-24 19:00:55 -07:00
commit 6c4a4866d3
40 changed files with 316 additions and 471 deletions

View file

@ -123,7 +123,7 @@ var RainSquall = function (properties) {
function setUp() { function setUp() {
if (debug) { if (debug) {
squallCircle = Overlays.addOverlay("circle3d", { squallCircle = Overlays.addOverlay("circle3d", {
size: { x: 2 * squallRadius, y: 2 * squallRadius }, size: { x: squallRadius, y: squallRadius },
color: SQUALL_CIRCLE_COLOR, color: SQUALL_CIRCLE_COLOR,
alpha: SQUALL_CIRCLE_ALPHA, alpha: SQUALL_CIRCLE_ALPHA,
solid: true, solid: true,

View file

@ -392,7 +392,8 @@ SelectionDisplay = (function () {
var grabberSpotLightCircle = Overlays.addOverlay("circle3d", { var grabberSpotLightCircle = Overlays.addOverlay("circle3d", {
color: lightOverlayColor, color: lightOverlayColor,
isSolid: false isSolid: false,
visible: false
}); });
var grabberSpotLightLineT = Overlays.addOverlay("line3d", spotLightLineProperties); var grabberSpotLightLineT = Overlays.addOverlay("line3d", spotLightLineProperties);
var grabberSpotLightLineB = Overlays.addOverlay("line3d", spotLightLineProperties); var grabberSpotLightLineB = Overlays.addOverlay("line3d", spotLightLineProperties);
@ -409,17 +410,20 @@ SelectionDisplay = (function () {
var grabberPointLightCircleX = Overlays.addOverlay("circle3d", { var grabberPointLightCircleX = Overlays.addOverlay("circle3d", {
rotation: Quat.fromPitchYawRollDegrees(0, 90, 0), rotation: Quat.fromPitchYawRollDegrees(0, 90, 0),
color: lightOverlayColor, color: lightOverlayColor,
isSolid: false isSolid: false,
visible: false
}); });
var grabberPointLightCircleY = Overlays.addOverlay("circle3d", { var grabberPointLightCircleY = Overlays.addOverlay("circle3d", {
rotation: Quat.fromPitchYawRollDegrees(90, 0, 0), rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
color: lightOverlayColor, color: lightOverlayColor,
isSolid: false isSolid: false,
visible: false
}); });
var grabberPointLightCircleZ = Overlays.addOverlay("circle3d", { var grabberPointLightCircleZ = Overlays.addOverlay("circle3d", {
rotation: Quat.fromPitchYawRollDegrees(0, 0, 0), rotation: Quat.fromPitchYawRollDegrees(0, 0, 0),
color: lightOverlayColor, color: lightOverlayColor,
isSolid: false isSolid: false,
visible: false
}); });
var grabberPointLightT = Overlays.addOverlay("cube", grabberPropertiesEdge); var grabberPointLightT = Overlays.addOverlay("cube", grabberPropertiesEdge);
var grabberPointLightB = Overlays.addOverlay("cube", grabberPropertiesEdge); var grabberPointLightB = Overlays.addOverlay("cube", grabberPropertiesEdge);
@ -546,7 +550,7 @@ SelectionDisplay = (function () {
var rotateOverlayTarget = Overlays.addOverlay("circle3d", { var rotateOverlayTarget = Overlays.addOverlay("circle3d", {
position: { x:0, y: 0, z: 0}, position: { x:0, y: 0, z: 0},
size: rotateOverlayTargetSize * 2, size: rotateOverlayTargetSize,
color: { red: 0, green: 0, blue: 0 }, color: { red: 0, green: 0, blue: 0 },
alpha: 0.0, alpha: 0.0,
solid: true, solid: true,
@ -1186,7 +1190,7 @@ SelectionDisplay = (function () {
}); });
Overlays.editOverlay(grabberSpotLightCircle, { Overlays.editOverlay(grabberSpotLightCircle, {
position: NEAR, position: NEAR,
dimensions: { x: distance * 2, y: distance * 2, z: 1 }, dimensions: { x: distance, y: distance, z: 1 },
lineWidth: 1.5, lineWidth: 1.5,
rotation: rotation, rotation: rotation,
visible: true, visible: true,
@ -1258,19 +1262,19 @@ SelectionDisplay = (function () {
Overlays.editOverlay(grabberPointLightCircleX, { Overlays.editOverlay(grabberPointLightCircleX, {
position: position, position: position,
rotation: Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, 90, 0)), rotation: Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, 90, 0)),
dimensions: { x: properties.dimensions.z, y: properties.dimensions.z, z: 1 }, dimensions: { x: properties.dimensions.z / 2.0, y: properties.dimensions.z / 2.0, z: 1 },
visible: true, visible: true,
}); });
Overlays.editOverlay(grabberPointLightCircleY, { Overlays.editOverlay(grabberPointLightCircleY, {
position: position, position: position,
rotation: Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(90, 0, 0)), rotation: Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(90, 0, 0)),
dimensions: { x: properties.dimensions.z, y: properties.dimensions.z, z: 1 }, dimensions: { x: properties.dimensions.z / 2.0, y: properties.dimensions.z / 2.0, z: 1 },
visible: true, visible: true,
}); });
Overlays.editOverlay(grabberPointLightCircleZ, { Overlays.editOverlay(grabberPointLightCircleZ, {
position: position, position: position,
rotation: rotation, rotation: rotation,
dimensions: { x: properties.dimensions.z, y: properties.dimensions.z, z: 1 }, dimensions: { x: properties.dimensions.z / 2.0, y: properties.dimensions.z / 2.0, z: 1 },
visible: true, visible: true,
}); });
@ -1966,7 +1970,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(rotateOverlayInner, Overlays.editOverlay(rotateOverlayInner,
{ {
visible: true, visible: true,
size: innerRadius * 2, size: innerRadius,
innerRadius: 0.9, innerRadius: 0.9,
startAt: 0, startAt: 0,
endAt: 360, endAt: 360,
@ -1976,7 +1980,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(rotateOverlayOuter, Overlays.editOverlay(rotateOverlayOuter,
{ {
visible: true, visible: true,
size: outerRadius * 2, size: outerRadius,
innerRadius: 0.9, innerRadius: 0.9,
startAt: 0, startAt: 0,
endAt: 360, endAt: 360,
@ -1986,7 +1990,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(rotateOverlayCurrent, Overlays.editOverlay(rotateOverlayCurrent,
{ {
visible: true, visible: true,
size: outerRadius * 2, size: outerRadius,
startAt: 0, startAt: 0,
endAt: 0, endAt: 0,
innerRadius: 0.9, innerRadius: 0.9,
@ -2064,13 +2068,13 @@ SelectionDisplay = (function () {
if (snapToInner) { if (snapToInner) {
Overlays.editOverlay(rotateOverlayOuter, { startAt: 0, endAt: 360 }); Overlays.editOverlay(rotateOverlayOuter, { startAt: 0, endAt: 360 });
Overlays.editOverlay(rotateOverlayInner, { startAt: startAtRemainder, endAt: endAtRemainder }); Overlays.editOverlay(rotateOverlayInner, { startAt: startAtRemainder, endAt: endAtRemainder });
Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: innerRadius * 2, Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: innerRadius,
majorTickMarksAngle: innerSnapAngle, minorTickMarksAngle: 0, majorTickMarksAngle: innerSnapAngle, minorTickMarksAngle: 0,
majorTickMarksLength: -0.25, minorTickMarksLength: 0, }); majorTickMarksLength: -0.25, minorTickMarksLength: 0, });
} else { } else {
Overlays.editOverlay(rotateOverlayInner, { startAt: 0, endAt: 360 }); Overlays.editOverlay(rotateOverlayInner, { startAt: 0, endAt: 360 });
Overlays.editOverlay(rotateOverlayOuter, { startAt: startAtRemainder, endAt: endAtRemainder }); Overlays.editOverlay(rotateOverlayOuter, { startAt: startAtRemainder, endAt: endAtRemainder });
Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: outerRadius * 2, Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: outerRadius,
majorTickMarksAngle: 45.0, minorTickMarksAngle: 5, majorTickMarksAngle: 45.0, minorTickMarksAngle: 5,
majorTickMarksLength: 0.25, minorTickMarksLength: 0.1, }); majorTickMarksLength: 0.25, minorTickMarksLength: 0.1, });
} }
@ -2095,7 +2099,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(rotateOverlayInner, Overlays.editOverlay(rotateOverlayInner,
{ {
visible: true, visible: true,
size: innerRadius * 2, size: innerRadius,
innerRadius: 0.9, innerRadius: 0.9,
startAt: 0, startAt: 0,
endAt: 360, endAt: 360,
@ -2105,7 +2109,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(rotateOverlayOuter, Overlays.editOverlay(rotateOverlayOuter,
{ {
visible: true, visible: true,
size: outerRadius * 2, size: outerRadius,
innerRadius: 0.9, innerRadius: 0.9,
startAt: 0, startAt: 0,
endAt: 360, endAt: 360,
@ -2115,7 +2119,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(rotateOverlayCurrent, Overlays.editOverlay(rotateOverlayCurrent,
{ {
visible: true, visible: true,
size: outerRadius * 2, size: outerRadius,
startAt: 0, startAt: 0,
endAt: 0, endAt: 0,
innerRadius: 0.9, innerRadius: 0.9,
@ -2186,13 +2190,13 @@ SelectionDisplay = (function () {
if (snapToInner) { if (snapToInner) {
Overlays.editOverlay(rotateOverlayOuter, { startAt: 0, endAt: 360 }); Overlays.editOverlay(rotateOverlayOuter, { startAt: 0, endAt: 360 });
Overlays.editOverlay(rotateOverlayInner, { startAt: startAtRemainder, endAt: endAtRemainder }); Overlays.editOverlay(rotateOverlayInner, { startAt: startAtRemainder, endAt: endAtRemainder });
Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: innerRadius * 2, Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: innerRadius,
majorTickMarksAngle: innerSnapAngle, minorTickMarksAngle: 0, majorTickMarksAngle: innerSnapAngle, minorTickMarksAngle: 0,
majorTickMarksLength: -0.25, minorTickMarksLength: 0, }); majorTickMarksLength: -0.25, minorTickMarksLength: 0, });
} else { } else {
Overlays.editOverlay(rotateOverlayInner, { startAt: 0, endAt: 360 }); Overlays.editOverlay(rotateOverlayInner, { startAt: 0, endAt: 360 });
Overlays.editOverlay(rotateOverlayOuter, { startAt: startAtRemainder, endAt: endAtRemainder }); Overlays.editOverlay(rotateOverlayOuter, { startAt: startAtRemainder, endAt: endAtRemainder });
Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: outerRadius * 2, Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: outerRadius,
majorTickMarksAngle: 45.0, minorTickMarksAngle: 5, majorTickMarksAngle: 45.0, minorTickMarksAngle: 5,
majorTickMarksLength: 0.25, minorTickMarksLength: 0.1, }); majorTickMarksLength: 0.25, minorTickMarksLength: 0.1, });
} }
@ -2216,7 +2220,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(rotateOverlayInner, Overlays.editOverlay(rotateOverlayInner,
{ {
visible: true, visible: true,
size: innerRadius * 2, size: innerRadius,
innerRadius: 0.9, innerRadius: 0.9,
startAt: 0, startAt: 0,
endAt: 360, endAt: 360,
@ -2226,7 +2230,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(rotateOverlayOuter, Overlays.editOverlay(rotateOverlayOuter,
{ {
visible: true, visible: true,
size: outerRadius * 2, size: outerRadius,
innerRadius: 0.9, innerRadius: 0.9,
startAt: 0, startAt: 0,
endAt: 360, endAt: 360,
@ -2236,7 +2240,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(rotateOverlayCurrent, Overlays.editOverlay(rotateOverlayCurrent,
{ {
visible: true, visible: true,
size: outerRadius * 2, size: outerRadius,
startAt: 0, startAt: 0,
endAt: 0, endAt: 0,
innerRadius: 0.9, innerRadius: 0.9,
@ -2306,13 +2310,13 @@ SelectionDisplay = (function () {
if (snapToInner) { if (snapToInner) {
Overlays.editOverlay(rotateOverlayOuter, { startAt: 0, endAt: 360 }); Overlays.editOverlay(rotateOverlayOuter, { startAt: 0, endAt: 360 });
Overlays.editOverlay(rotateOverlayInner, { startAt: startAtRemainder, endAt: endAtRemainder }); Overlays.editOverlay(rotateOverlayInner, { startAt: startAtRemainder, endAt: endAtRemainder });
Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: innerRadius * 2, Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: innerRadius,
majorTickMarksAngle: innerSnapAngle, minorTickMarksAngle: 0, majorTickMarksAngle: innerSnapAngle, minorTickMarksAngle: 0,
majorTickMarksLength: -0.25, minorTickMarksLength: 0, }); majorTickMarksLength: -0.25, minorTickMarksLength: 0, });
} else { } else {
Overlays.editOverlay(rotateOverlayInner, { startAt: 0, endAt: 360 }); Overlays.editOverlay(rotateOverlayInner, { startAt: 0, endAt: 360 });
Overlays.editOverlay(rotateOverlayOuter, { startAt: startAtRemainder, endAt: endAtRemainder }); Overlays.editOverlay(rotateOverlayOuter, { startAt: startAtRemainder, endAt: endAtRemainder });
Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: outerRadius * 2, Overlays.editOverlay(rotateOverlayCurrent, { startAt: startAtCurrent, endAt: endAtCurrent, size: outerRadius,
majorTickMarksAngle: 45.0, minorTickMarksAngle: 5, majorTickMarksAngle: 45.0, minorTickMarksAngle: 5,
majorTickMarksLength: 0.25, minorTickMarksLength: 0.1, }); majorTickMarksLength: 0.25, minorTickMarksLength: 0.1, });
} }

View file

@ -16,15 +16,12 @@
#include "Application.h" #include "Application.h"
#include "Base3DOverlay.h" #include "Base3DOverlay.h"
const glm::vec3 DEFAULT_POSITION = glm::vec3(0.0f, 0.0f, 0.0f);
const float DEFAULT_LINE_WIDTH = 1.0f; const float DEFAULT_LINE_WIDTH = 1.0f;
const bool DEFAULT_IS_SOLID = false; const bool DEFAULT_IS_SOLID = false;
const bool DEFAULT_IS_DASHED_LINE = false; const bool DEFAULT_IS_DASHED_LINE = false;
Base3DOverlay::Base3DOverlay() : Base3DOverlay::Base3DOverlay() :
_position(DEFAULT_POSITION),
_lineWidth(DEFAULT_LINE_WIDTH), _lineWidth(DEFAULT_LINE_WIDTH),
_rotation(),
_isSolid(DEFAULT_IS_SOLID), _isSolid(DEFAULT_IS_SOLID),
_isDashedLine(DEFAULT_IS_DASHED_LINE), _isDashedLine(DEFAULT_IS_DASHED_LINE),
_ignoreRayIntersection(false), _ignoreRayIntersection(false),
@ -35,9 +32,8 @@ Base3DOverlay::Base3DOverlay() :
Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) : Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) :
Overlay(base3DOverlay), Overlay(base3DOverlay),
_position(base3DOverlay->_position), _transform(base3DOverlay->_transform),
_lineWidth(base3DOverlay->_lineWidth), _lineWidth(base3DOverlay->_lineWidth),
_rotation(base3DOverlay->_rotation),
_isSolid(base3DOverlay->_isSolid), _isSolid(base3DOverlay->_isSolid),
_isDashedLine(base3DOverlay->_isDashedLine), _isDashedLine(base3DOverlay->_isDashedLine),
_ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection), _ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection),
@ -46,14 +42,6 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) :
{ {
} }
Base3DOverlay::~Base3DOverlay() {
}
// TODO: Implement accurate getBounds() implementations
AABox Base3DOverlay::getBounds() const {
return AABox(_position, glm::vec3(1.0f));
}
void Base3DOverlay::setProperties(const QScriptValue& properties) { void Base3DOverlay::setProperties(const QScriptValue& properties) {
Overlay::setProperties(properties); Overlay::setProperties(properties);
@ -151,13 +139,13 @@ void Base3DOverlay::setProperties(const QScriptValue& properties) {
QScriptValue Base3DOverlay::getProperty(const QString& property) { QScriptValue Base3DOverlay::getProperty(const QString& property) {
if (property == "position" || property == "start" || property == "p1" || property == "point") { if (property == "position" || property == "start" || property == "p1" || property == "point") {
return vec3toScriptValue(_scriptEngine, _position); return vec3toScriptValue(_scriptEngine, getPosition());
} }
if (property == "lineWidth") { if (property == "lineWidth") {
return _lineWidth; return _lineWidth;
} }
if (property == "rotation") { if (property == "rotation") {
return quatToScriptValue(_scriptEngine, _rotation); return quatToScriptValue(_scriptEngine, getRotation());
} }
if (property == "isSolid" || property == "isFilled" || property == "solid" || property == "filed") { if (property == "isSolid" || property == "isFilled" || property == "solid" || property == "filed") {
return _isSolid; return _isSolid;

View file

@ -11,10 +11,7 @@
#ifndef hifi_Base3DOverlay_h #ifndef hifi_Base3DOverlay_h
#define hifi_Base3DOverlay_h #define hifi_Base3DOverlay_h
#include <glm/glm.hpp> #include <Transform.h>
#include <glm/gtc/quaternion.hpp>
#include <BoxBase.h>
#include "Overlay.h" #include "Overlay.h"
@ -24,32 +21,38 @@ class Base3DOverlay : public Overlay {
public: public:
Base3DOverlay(); Base3DOverlay();
Base3DOverlay(const Base3DOverlay* base3DOverlay); Base3DOverlay(const Base3DOverlay* base3DOverlay);
~Base3DOverlay();
// getters // getters
virtual bool is3D() const { return true; } virtual bool is3D() const { return true; }
const glm::vec3& getPosition() const { return _position; } const glm::vec3& getPosition() const { return _transform.getTranslation(); }
const glm::vec3& getCenter() const { return _position; } // TODO: consider implementing registration points in this class const glm::quat& getRotation() const { return _transform.getRotation(); }
const glm::vec3& getScale() const { return _transform.getScale(); }
// TODO: consider implementing registration points in this class
const glm::vec3& getCenter() const { return getPosition(); }
float getLineWidth() const { return _lineWidth; } float getLineWidth() const { return _lineWidth; }
bool getIsSolid() const { return _isSolid; } bool getIsSolid() const { return _isSolid; }
bool getIsDashedLine() const { return _isDashedLine; } bool getIsDashedLine() const { return _isDashedLine; }
bool getIsSolidLine() const { return !_isDashedLine; } bool getIsSolidLine() const { return !_isDashedLine; }
const glm::quat& getRotation() const { return _rotation; }
bool getIgnoreRayIntersection() const { return _ignoreRayIntersection; } bool getIgnoreRayIntersection() const { return _ignoreRayIntersection; }
bool getDrawInFront() const { return _drawInFront; } bool getDrawInFront() const { return _drawInFront; }
bool getDrawOnHUD() const { return _drawOnHUD; } bool getDrawOnHUD() const { return _drawOnHUD; }
// setters // setters
void setPosition(const glm::vec3& position) { _position = position; } void setPosition(const glm::vec3& value) { _transform.setTranslation(value); }
void setRotation(const glm::quat& value) { _transform.setRotation(value); }
void setScale(float value) { _transform.setScale(value); }
void setScale(const glm::vec3& value) { _transform.setScale(value); }
void setLineWidth(float lineWidth) { _lineWidth = lineWidth; } void setLineWidth(float lineWidth) { _lineWidth = lineWidth; }
void setIsSolid(bool isSolid) { _isSolid = isSolid; } void setIsSolid(bool isSolid) { _isSolid = isSolid; }
void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; } void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; }
void setRotation(const glm::quat& value) { _rotation = value; }
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; } void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
void setDrawInFront(bool value) { _drawInFront = value; } void setDrawInFront(bool value) { _drawInFront = value; }
void setDrawOnHUD(bool value) { _drawOnHUD = value; } void setDrawOnHUD(bool value) { _drawOnHUD = value; }
virtual AABox getBounds() const; virtual AABox getBounds() const = 0;
virtual void setProperties(const QScriptValue& properties); virtual void setProperties(const QScriptValue& properties);
virtual QScriptValue getProperty(const QString& property); virtual QScriptValue getProperty(const QString& property);
@ -62,9 +65,9 @@ public:
} }
protected: protected:
glm::vec3 _position; Transform _transform;
float _lineWidth; float _lineWidth;
glm::quat _rotation;
bool _isSolid; bool _isSolid;
bool _isDashedLine; bool _isDashedLine;
bool _ignoreRayIntersection; bool _ignoreRayIntersection;

View file

@ -9,26 +9,20 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "Application.h"
#include "GeometryUtil.h"
#include "PlaneShape.h"
#include "BillboardOverlay.h" #include "BillboardOverlay.h"
BillboardOverlay::BillboardOverlay() : #include "Application.h"
_fromImage(), #include "GeometryUtil.h"
_scale(1.0f),
_isFacingAvatar(true) BillboardOverlay::BillboardOverlay() {
{
_isLoaded = false; _isLoaded = false;
} }
BillboardOverlay::BillboardOverlay(const BillboardOverlay* billboardOverlay) : BillboardOverlay::BillboardOverlay(const BillboardOverlay* billboardOverlay) :
Base3DOverlay(billboardOverlay), Planar3DOverlay(billboardOverlay),
_url(billboardOverlay->_url), _url(billboardOverlay->_url),
_texture(billboardOverlay->_texture), _texture(billboardOverlay->_texture),
_fromImage(billboardOverlay->_fromImage), _fromImage(billboardOverlay->_fromImage),
_scale(billboardOverlay->_scale),
_isFacingAvatar(billboardOverlay->_isFacingAvatar) _isFacingAvatar(billboardOverlay->_isFacingAvatar)
{ {
} }
@ -46,8 +40,8 @@ void BillboardOverlay::render(RenderArgs* args) {
glm::quat rotation; glm::quat rotation;
if (_isFacingAvatar) { if (_isFacingAvatar) {
// rotate about vertical to face the camera // rotate about vertical to face the camera
rotation = Application::getInstance()->getCamera()->getRotation(); rotation = args->_viewFrustum->getOrientation();
rotation *= glm::angleAxis(glm::pi<float>(), glm::vec3(0.0f, 1.0f, 0.0f)); rotation *= glm::angleAxis(glm::pi<float>(), IDENTITY_UP);
rotation *= getRotation(); rotation *= getRotation();
} else { } else {
rotation = getRotation(); rotation = getRotation();
@ -89,11 +83,9 @@ void BillboardOverlay::render(RenderArgs* args) {
auto batch = args->_batch; auto batch = args->_batch;
if (batch) { if (batch) {
Transform transform; Transform transform = _transform;
transform.setTranslation(_position); transform.postScale(glm::vec3(getDimensions(), 1.0f));
transform.setRotation(rotation);
transform.setScale(_scale);
batch->setModelTransform(transform); batch->setModelTransform(transform);
batch->setUniformTexture(0, _texture->getGPUTexture()); batch->setUniformTexture(0, _texture->getGPUTexture());
@ -111,10 +103,10 @@ void BillboardOverlay::render(RenderArgs* args) {
glBindTexture(GL_TEXTURE_2D, _texture->getID()); glBindTexture(GL_TEXTURE_2D, _texture->getID());
glPushMatrix(); { glPushMatrix(); {
glTranslatef(_position.x, _position.y, _position.z); glTranslatef(getPosition().x, getPosition().y, getPosition().z);
glm::vec3 axis = glm::axis(rotation); glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glScalef(_scale, _scale, _scale); glScalef(_dimensions.x, _dimensions.y, 1.0f);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
glm::vec4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha)); glm::vec4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha));
@ -130,7 +122,7 @@ void BillboardOverlay::render(RenderArgs* args) {
} }
void BillboardOverlay::setProperties(const QScriptValue &properties) { void BillboardOverlay::setProperties(const QScriptValue &properties) {
Base3DOverlay::setProperties(properties); Planar3DOverlay::setProperties(properties);
QScriptValue urlValue = properties.property("url"); QScriptValue urlValue = properties.property("url");
if (urlValue.isValid()) { if (urlValue.isValid()) {
@ -171,11 +163,6 @@ void BillboardOverlay::setProperties(const QScriptValue &properties) {
} }
} }
QScriptValue scaleValue = properties.property("scale");
if (scaleValue.isValid()) {
_scale = scaleValue.toVariant().toFloat();
}
QScriptValue isFacingAvatarValue = properties.property("isFacingAvatar"); QScriptValue isFacingAvatarValue = properties.property("isFacingAvatar");
if (isFacingAvatarValue.isValid()) { if (isFacingAvatarValue.isValid()) {
_isFacingAvatar = isFacingAvatarValue.toVariant().toBool(); _isFacingAvatar = isFacingAvatarValue.toVariant().toBool();
@ -189,14 +176,11 @@ QScriptValue BillboardOverlay::getProperty(const QString& property) {
if (property == "subImage") { if (property == "subImage") {
return qRectToScriptValue(_scriptEngine, _fromImage); return qRectToScriptValue(_scriptEngine, _fromImage);
} }
if (property == "scale") {
return _scale;
}
if (property == "isFacingAvatar") { if (property == "isFacingAvatar") {
return _isFacingAvatar; return _isFacingAvatar;
} }
return Base3DOverlay::getProperty(property); return Planar3DOverlay::getProperty(property);
} }
void BillboardOverlay::setURL(const QString& url) { void BillboardOverlay::setURL(const QString& url) {
@ -212,13 +196,11 @@ bool BillboardOverlay::findRayIntersection(const glm::vec3& origin, const glm::v
float& distance, BoxFace& face) { float& distance, BoxFace& face) {
if (_texture) { if (_texture) {
glm::quat rotation; glm::quat rotation = getRotation();
if (_isFacingAvatar) { if (_isFacingAvatar) {
// rotate about vertical to face the camera // rotate about vertical to face the camera
rotation = Application::getInstance()->getCamera()->getRotation(); rotation = Application::getInstance()->getCamera()->getRotation();
rotation *= glm::angleAxis(glm::pi<float>(), glm::vec3(0.0f, 1.0f, 0.0f)); rotation *= glm::angleAxis(glm::pi<float>(), glm::vec3(0.0f, 1.0f, 0.0f));
} else {
rotation = _rotation;
} }
// Produce the dimensions of the billboard based on the image's aspect ratio and the overlay's scale. // Produce the dimensions of the billboard based on the image's aspect ratio and the overlay's scale.
@ -226,9 +208,9 @@ bool BillboardOverlay::findRayIntersection(const glm::vec3& origin, const glm::v
float width = isNull ? _texture->getWidth() : _fromImage.width(); float width = isNull ? _texture->getWidth() : _fromImage.width();
float height = isNull ? _texture->getHeight() : _fromImage.height(); float height = isNull ? _texture->getHeight() : _fromImage.height();
float maxSize = glm::max(width, height); float maxSize = glm::max(width, height);
glm::vec2 dimensions = _scale * glm::vec2(width / maxSize, height / maxSize); glm::vec2 dimensions = _dimensions * glm::vec2(width / maxSize, height / maxSize);
return findRayRectangleIntersection(origin, direction, rotation, _position, dimensions, distance); return findRayRectangleIntersection(origin, direction, rotation, getPosition(), dimensions, distance);
} }
return false; return false;

View file

@ -12,14 +12,11 @@
#ifndef hifi_BillboardOverlay_h #ifndef hifi_BillboardOverlay_h
#define hifi_BillboardOverlay_h #define hifi_BillboardOverlay_h
#include <QScopedPointer>
#include <QUrl>
#include <TextureCache.h> #include <TextureCache.h>
#include "Base3DOverlay.h" #include "Planar3DOverlay.h"
class BillboardOverlay : public Base3DOverlay { class BillboardOverlay : public Planar3DOverlay {
Q_OBJECT Q_OBJECT
public: public:
BillboardOverlay(); BillboardOverlay();
@ -29,7 +26,6 @@ public:
// setters // setters
void setURL(const QString& url); void setURL(const QString& url);
void setScale(float scale) { _scale = scale; }
void setIsFacingAvatar(bool isFacingAvatar) { _isFacingAvatar = isFacingAvatar; } void setIsFacingAvatar(bool isFacingAvatar) { _isFacingAvatar = isFacingAvatar; }
virtual void setProperties(const QScriptValue& properties); virtual void setProperties(const QScriptValue& properties);
@ -48,8 +44,7 @@ private:
QRect _fromImage; // where from in the image to sample QRect _fromImage; // where from in the image to sample
float _scale; bool _isFacingAvatar = true;
bool _isFacingAvatar;
}; };
#endif // hifi_BillboardOverlay_h #endif // hifi_BillboardOverlay_h

View file

@ -8,16 +8,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
// include this before QGLWidget, which includes an earlier version of OpenGL #include "Circle3DOverlay.h"
#include "InterfaceConfig.h"
#include <DeferredLightingEffect.h> #include <DeferredLightingEffect.h>
#include <GeometryCache.h> #include <GeometryCache.h>
#include <GlowEffect.h> #include <RegisteredMetaTypes.h>
#include <SharedUtil.h>
#include <StreamUtils.h>
#include "Circle3DOverlay.h"
Circle3DOverlay::Circle3DOverlay() : Circle3DOverlay::Circle3DOverlay() :
_startAt(0.0f), _startAt(0.0f),
@ -66,9 +62,6 @@ Circle3DOverlay::Circle3DOverlay(const Circle3DOverlay* circle3DOverlay) :
{ {
} }
Circle3DOverlay::~Circle3DOverlay() {
}
void Circle3DOverlay::render(RenderArgs* args) { void Circle3DOverlay::render(RenderArgs* args) {
if (!_visible) { if (!_visible) {
return; // do nothing if we're not visible return; // do nothing if we're not visible
@ -103,15 +96,13 @@ void Circle3DOverlay::render(RenderArgs* args) {
_lastColor = colorX; _lastColor = colorX;
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
Transform transform;
transform.setTranslation(getCenter());
transform.setRotation(getRotation());
transform.setScale(glm::vec3(getDimensions(), 0.01f) / 2.0f);
Q_ASSERT(args->_batch);
auto& batch = *args->_batch; auto& batch = *args->_batch;
batch._glLineWidth(_lineWidth); batch._glLineWidth(_lineWidth);
auto transform = _transform;
transform.postScale(glm::vec3(getDimensions(), 1.0f));
batch.setModelTransform(transform); batch.setModelTransform(transform);
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, false, false); DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, false, false);
@ -402,12 +393,12 @@ bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin,
if (intersects) { if (intersects) {
glm::vec3 hitPosition = origin + (distance * direction); glm::vec3 hitPosition = origin + (distance * direction);
glm::vec3 localHitPosition = glm::inverse(_rotation) * (hitPosition - _position); glm::vec3 localHitPosition = glm::inverse(getRotation()) * (hitPosition - getPosition());
localHitPosition.y = localHitPosition.y * _dimensions.x / _dimensions.y; // Scale to make circular localHitPosition.y = localHitPosition.y * getDimensions().x / getDimensions().y; // Scale to make circular
float distanceToHit = glm::length(localHitPosition); float distanceToHit = glm::length(localHitPosition);
float innerRadius = _dimensions.x / 2.0f * _innerRadius; float innerRadius = getDimensions().x / 2.0f * _innerRadius;
float outerRadius = _dimensions.x / 2.0f * _outerRadius; float outerRadius = getDimensions().x / 2.0f * _outerRadius;
intersects = innerRadius <= distanceToHit && distanceToHit <= outerRadius; intersects = innerRadius <= distanceToHit && distanceToHit <= outerRadius;
} }

View file

@ -11,6 +11,9 @@
#ifndef hifi_Circle3DOverlay_h #ifndef hifi_Circle3DOverlay_h
#define hifi_Circle3DOverlay_h #define hifi_Circle3DOverlay_h
// include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include "Planar3DOverlay.h" #include "Planar3DOverlay.h"
class Circle3DOverlay : public Planar3DOverlay { class Circle3DOverlay : public Planar3DOverlay {
@ -19,7 +22,7 @@ class Circle3DOverlay : public Planar3DOverlay {
public: public:
Circle3DOverlay(); Circle3DOverlay();
Circle3DOverlay(const Circle3DOverlay* circle3DOverlay); Circle3DOverlay(const Circle3DOverlay* circle3DOverlay);
~Circle3DOverlay();
virtual void render(RenderArgs* args); virtual void render(RenderArgs* args);
virtual void setProperties(const QScriptValue& properties); virtual void setProperties(const QScriptValue& properties);
virtual QScriptValue getProperty(const QString& property); virtual QScriptValue getProperty(const QString& property);

View file

@ -19,17 +19,11 @@
#include "Application.h" #include "Application.h"
#include "Cube3DOverlay.h" #include "Cube3DOverlay.h"
Cube3DOverlay::Cube3DOverlay() : _borderSize(0) {
}
Cube3DOverlay::Cube3DOverlay(const Cube3DOverlay* cube3DOverlay) : Cube3DOverlay::Cube3DOverlay(const Cube3DOverlay* cube3DOverlay) :
Volume3DOverlay(cube3DOverlay) Volume3DOverlay(cube3DOverlay)
{ {
} }
Cube3DOverlay::~Cube3DOverlay() {
}
void Cube3DOverlay::render(RenderArgs* args) { void Cube3DOverlay::render(RenderArgs* args) {
if (!_visible) { if (!_visible) {
return; // do nothing if we're not visible return; // do nothing if we're not visible

View file

@ -17,9 +17,9 @@ class Cube3DOverlay : public Volume3DOverlay {
Q_OBJECT Q_OBJECT
public: public:
Cube3DOverlay(); Cube3DOverlay() {}
Cube3DOverlay(const Cube3DOverlay* cube3DOverlay); Cube3DOverlay(const Cube3DOverlay* cube3DOverlay);
~Cube3DOverlay();
virtual void render(RenderArgs* args); virtual void render(RenderArgs* args);
virtual Cube3DOverlay* createClone() const; virtual Cube3DOverlay* createClone() const;

View file

@ -9,28 +9,29 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
// include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include "Grid3DOverlay.h"
#include <PathUtils.h> #include <PathUtils.h>
#include "Application.h" #include "Application.h"
#include "Grid3DOverlay.h"
ProgramObject Grid3DOverlay::_gridProgram; ProgramObject Grid3DOverlay::_gridProgram;
Grid3DOverlay::Grid3DOverlay() : Base3DOverlay(), Grid3DOverlay::Grid3DOverlay() :
_minorGridWidth(1.0), _minorGridWidth(1.0),
_majorGridEvery(5) { _majorGridEvery(5) {
} }
Grid3DOverlay::Grid3DOverlay(const Grid3DOverlay* grid3DOverlay) : Grid3DOverlay::Grid3DOverlay(const Grid3DOverlay* grid3DOverlay) :
Base3DOverlay(grid3DOverlay), Planar3DOverlay(grid3DOverlay),
_minorGridWidth(grid3DOverlay->_minorGridWidth), _minorGridWidth(grid3DOverlay->_minorGridWidth),
_majorGridEvery(grid3DOverlay->_majorGridEvery) _majorGridEvery(grid3DOverlay->_majorGridEvery)
{ {
} }
Grid3DOverlay::~Grid3DOverlay() {
}
void Grid3DOverlay::render(RenderArgs* args) { void Grid3DOverlay::render(RenderArgs* args) {
if (!_visible) { if (!_visible) {
return; // do nothing if we're not visible return; // do nothing if we're not visible
@ -41,7 +42,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
const float MAX_COLOR = 255.0f; const float MAX_COLOR = 255.0f;
// center the grid around the camera position on the plane // center the grid around the camera position on the plane
glm::vec3 rotated = glm::inverse(_rotation) * Application::getInstance()->getCamera()->getPosition(); glm::vec3 rotated = glm::inverse(getRotation()) * Application::getInstance()->getCamera()->getPosition();
float spacing = _minorGridWidth; float spacing = _minorGridWidth;
@ -53,7 +54,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
if (batch) { if (batch) {
Transform transform; Transform transform;
transform.setRotation(_rotation); transform.setRotation(getRotation());
// Minor grid // Minor grid
@ -61,7 +62,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
batch->_glLineWidth(1.0f); batch->_glLineWidth(1.0f);
auto position = glm::vec3(_minorGridWidth * (floorf(rotated.x / spacing) - MINOR_GRID_DIVISIONS / 2), auto position = glm::vec3(_minorGridWidth * (floorf(rotated.x / spacing) - MINOR_GRID_DIVISIONS / 2),
spacing * (floorf(rotated.y / spacing) - MINOR_GRID_DIVISIONS / 2), spacing * (floorf(rotated.y / spacing) - MINOR_GRID_DIVISIONS / 2),
_position.z); getPosition().z);
float scale = MINOR_GRID_DIVISIONS * spacing; float scale = MINOR_GRID_DIVISIONS * spacing;
transform.setTranslation(position); transform.setTranslation(position);
@ -78,7 +79,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
spacing *= _majorGridEvery; spacing *= _majorGridEvery;
auto position = glm::vec3(spacing * (floorf(rotated.x / spacing) - MAJOR_GRID_DIVISIONS / 2), auto position = glm::vec3(spacing * (floorf(rotated.x / spacing) - MAJOR_GRID_DIVISIONS / 2),
spacing * (floorf(rotated.y / spacing) - MAJOR_GRID_DIVISIONS / 2), spacing * (floorf(rotated.y / spacing) - MAJOR_GRID_DIVISIONS / 2),
_position.z); getPosition().z);
float scale = MAJOR_GRID_DIVISIONS * spacing; float scale = MAJOR_GRID_DIVISIONS * spacing;
transform.setTranslation(position); transform.setTranslation(position);
@ -161,7 +162,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
} }
void Grid3DOverlay::setProperties(const QScriptValue& properties) { void Grid3DOverlay::setProperties(const QScriptValue& properties) {
Base3DOverlay::setProperties(properties); Planar3DOverlay::setProperties(properties);
if (properties.property("minorGridWidth").isValid()) { if (properties.property("minorGridWidth").isValid()) {
_minorGridWidth = properties.property("minorGridWidth").toVariant().toFloat(); _minorGridWidth = properties.property("minorGridWidth").toVariant().toFloat();
@ -180,7 +181,7 @@ QScriptValue Grid3DOverlay::getProperty(const QString& property) {
return _majorGridEvery; return _majorGridEvery;
} }
return Base3DOverlay::getProperty(property); return Planar3DOverlay::getProperty(property);
} }
Grid3DOverlay* Grid3DOverlay::createClone() const { Grid3DOverlay* Grid3DOverlay::createClone() const {

View file

@ -15,20 +15,16 @@
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <glm/glm.hpp>
#include <ProgramObject.h> #include <ProgramObject.h>
#include <SharedUtil.h>
#include "Base3DOverlay.h" #include "Planar3DOverlay.h"
class Grid3DOverlay : public Base3DOverlay { class Grid3DOverlay : public Planar3DOverlay {
Q_OBJECT Q_OBJECT
public: public:
Grid3DOverlay(); Grid3DOverlay();
Grid3DOverlay(const Grid3DOverlay* grid3DOverlay); Grid3DOverlay(const Grid3DOverlay* grid3DOverlay);
~Grid3DOverlay();
virtual void render(RenderArgs* args); virtual void render(RenderArgs* args);
virtual void setProperties(const QScriptValue& properties); virtual void setProperties(const QScriptValue& properties);

View file

@ -8,17 +8,11 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
// include this before QGLWidget, which includes an earlier version of OpenGL #include "ImageOverlay.h"
#include "InterfaceConfig.h"
#include <QPainter>
#include <QSvgRenderer>
#include <DependencyManager.h> #include <DependencyManager.h>
#include <GeometryCache.h> #include <GeometryCache.h>
#include <SharedUtil.h> #include <RegisteredMetaTypes.h>
#include "ImageOverlay.h"
ImageOverlay::ImageOverlay() : ImageOverlay::ImageOverlay() :
_imageURL(), _imageURL(),
@ -38,9 +32,6 @@ ImageOverlay::ImageOverlay(const ImageOverlay* imageOverlay) :
{ {
} }
ImageOverlay::~ImageOverlay() {
}
// TODO: handle setting image multiple times, how do we manage releasing the bound texture? // TODO: handle setting image multiple times, how do we manage releasing the bound texture?
void ImageOverlay::setImageURL(const QUrl& url) { void ImageOverlay::setImageURL(const QUrl& url) {
_imageURL = url; _imageURL = url;

View file

@ -15,17 +15,11 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <QImage> #include <QImage>
#include <QNetworkReply>
#include <QRect> #include <QRect>
#include <QScriptValue>
#include <QString>
#include <QUrl> #include <QUrl>
#include <NetworkAccessManager.h>
#include <SharedUtil.h>
#include <TextureCache.h> #include <TextureCache.h>
#include "Overlay.h"
#include "Overlay2D.h" #include "Overlay2D.h"
class ImageOverlay : public Overlay2D { class ImageOverlay : public Overlay2D {
@ -34,7 +28,7 @@ class ImageOverlay : public Overlay2D {
public: public:
ImageOverlay(); ImageOverlay();
ImageOverlay(const ImageOverlay* imageOverlay); ImageOverlay(const ImageOverlay* imageOverlay);
~ImageOverlay();
virtual void render(RenderArgs* args); virtual void render(RenderArgs* args);
// getters // getters

View file

@ -13,6 +13,7 @@
#include <GlowEffect.h> #include <GlowEffect.h>
#include <GeometryCache.h> #include <GeometryCache.h>
#include <RegisteredMetaTypes.h>
#include "Line3DOverlay.h" #include "Line3DOverlay.h"
@ -33,13 +34,12 @@ Line3DOverlay::~Line3DOverlay() {
} }
AABox Line3DOverlay::getBounds() const { AABox Line3DOverlay::getBounds() const {
auto start = _position + _start; auto extents = Extents{};
auto end = _position + _end; extents.addPoint(_start);
extents.addPoint(_end);
auto min = glm::min(start, end); extents.transform(_transform);
auto max = glm::max(start, end);
return AABox(extents);
return AABox(min, max - min);
} }
void Line3DOverlay::render(RenderArgs* args) { void Line3DOverlay::render(RenderArgs* args) {
@ -55,14 +55,11 @@ void Line3DOverlay::render(RenderArgs* args) {
auto batch = args->_batch; auto batch = args->_batch;
if (batch) { if (batch) {
Transform transform; batch->setModelTransform(_transform);
transform.setTranslation(_position);
transform.setRotation(_rotation);
batch->setModelTransform(transform);
if (getIsDashedLine()) { if (getIsDashedLine()) {
// TODO: add support for color to renderDashedLine() // TODO: add support for color to renderDashedLine()
DependencyManager::get<GeometryCache>()->renderDashedLine(*batch, _position, _end, colorv4, _geometryCacheID); DependencyManager::get<GeometryCache>()->renderDashedLine(*batch, _start, _end, colorv4, _geometryCacheID);
} else { } else {
DependencyManager::get<GeometryCache>()->renderLine(*batch, _start, _end, colorv4, _geometryCacheID); DependencyManager::get<GeometryCache>()->renderLine(*batch, _start, _end, colorv4, _geometryCacheID);
} }
@ -87,7 +84,7 @@ void Line3DOverlay::render(RenderArgs* args) {
if (getIsDashedLine()) { if (getIsDashedLine()) {
// TODO: add support for color to renderDashedLine() // TODO: add support for color to renderDashedLine()
DependencyManager::get<GeometryCache>()->renderDashedLine(_position, _end, colorv4, _geometryCacheID); DependencyManager::get<GeometryCache>()->renderDashedLine(_start, _end, colorv4, _geometryCacheID);
} else { } else {
DependencyManager::get<GeometryCache>()->renderLine(_start, _end, colorv4, _geometryCacheID); DependencyManager::get<GeometryCache>()->renderLine(_start, _end, colorv4, _geometryCacheID);
} }

View file

@ -21,7 +21,7 @@ public:
Line3DOverlay(const Line3DOverlay* line3DOverlay); Line3DOverlay(const Line3DOverlay* line3DOverlay);
~Line3DOverlay(); ~Line3DOverlay();
virtual void render(RenderArgs* args); virtual void render(RenderArgs* args);
virtual AABox getBounds() const override; virtual AABox getBounds() const;
// getters // getters
const glm::vec3& getStart() const { return _start; } const glm::vec3& getStart() const { return _start; }

View file

@ -24,10 +24,6 @@ LocalModelsOverlay::LocalModelsOverlay(const LocalModelsOverlay* localModelsOver
Volume3DOverlay(localModelsOverlay), Volume3DOverlay(localModelsOverlay),
_entityTreeRenderer(localModelsOverlay->_entityTreeRenderer) _entityTreeRenderer(localModelsOverlay->_entityTreeRenderer)
{ {
}
LocalModelsOverlay::~LocalModelsOverlay() {
} }
void LocalModelsOverlay::update(float deltatime) { void LocalModelsOverlay::update(float deltatime) {
@ -46,7 +42,7 @@ void LocalModelsOverlay::render(RenderArgs* args) {
glPushMatrix(); { glPushMatrix(); {
Application* app = Application::getInstance(); Application* app = Application::getInstance();
glm::vec3 oldTranslation = app->getViewMatrixTranslation(); glm::vec3 oldTranslation = app->getViewMatrixTranslation();
app->setViewMatrixTranslation(oldTranslation + _position); app->setViewMatrixTranslation(oldTranslation + getPosition());
_entityTreeRenderer->render(args); _entityTreeRenderer->render(args);
Application::getInstance()->setViewMatrixTranslation(oldTranslation); Application::getInstance()->setViewMatrixTranslation(oldTranslation);
} glPopMatrix(); } glPopMatrix();

View file

@ -21,7 +21,6 @@ class LocalModelsOverlay : public Volume3DOverlay {
public: public:
LocalModelsOverlay(EntityTreeRenderer* entityTreeRenderer); LocalModelsOverlay(EntityTreeRenderer* entityTreeRenderer);
LocalModelsOverlay(const LocalModelsOverlay* localModelsOverlay); LocalModelsOverlay(const LocalModelsOverlay* localModelsOverlay);
~LocalModelsOverlay();
virtual void update(float deltatime); virtual void update(float deltatime);
virtual void render(RenderArgs* args); virtual void render(RenderArgs* args);

View file

@ -9,15 +9,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "ModelOverlay.h"
#include <Application.h> #include <Application.h>
#include <GlowEffect.h> #include <GlowEffect.h>
#include "ModelOverlay.h"
ModelOverlay::ModelOverlay() ModelOverlay::ModelOverlay()
: _model(), : _model(),
_modelTextures(QVariantMap()), _modelTextures(QVariantMap()),
_scale(1.0f),
_updateModel(false) _updateModel(false)
{ {
_model.init(); _model.init();
@ -25,12 +25,10 @@ ModelOverlay::ModelOverlay()
} }
ModelOverlay::ModelOverlay(const ModelOverlay* modelOverlay) : ModelOverlay::ModelOverlay(const ModelOverlay* modelOverlay) :
Base3DOverlay(modelOverlay), Volume3DOverlay(modelOverlay),
_model(), _model(),
_modelTextures(QVariantMap()), _modelTextures(QVariantMap()),
_url(modelOverlay->_url), _url(modelOverlay->_url),
_rotation(modelOverlay->_rotation),
_scale(modelOverlay->_scale),
_updateModel(false) _updateModel(false)
{ {
_model.init(); _model.init();
@ -45,8 +43,9 @@ void ModelOverlay::update(float deltatime) {
_updateModel = false; _updateModel = false;
_model.setSnapModelToCenter(true); _model.setSnapModelToCenter(true);
_model.setRotation(_rotation); _model.setScale(getScale());
_model.setTranslation(_position); _model.setRotation(getRotation());
_model.setTranslation(getPosition());
_model.setURL(_url); _model.setURL(_url);
_model.simulate(deltatime, true); _model.simulate(deltatime, true);
} else { } else {
@ -56,13 +55,13 @@ void ModelOverlay::update(float deltatime) {
} }
bool ModelOverlay::addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) { bool ModelOverlay::addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) {
Base3DOverlay::addToScene(overlay, scene, pendingChanges); Volume3DOverlay::addToScene(overlay, scene, pendingChanges);
_model.addToScene(scene, pendingChanges); _model.addToScene(scene, pendingChanges);
return true; return true;
} }
void ModelOverlay::removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) { void ModelOverlay::removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) {
Base3DOverlay::removeFromScene(overlay, scene, pendingChanges); Volume3DOverlay::removeFromScene(overlay, scene, pendingChanges);
_model.removeFromScene(scene, pendingChanges); _model.removeFromScene(scene, pendingChanges);
} }
@ -100,54 +99,26 @@ void ModelOverlay::render(RenderArgs* args) {
} }
void ModelOverlay::setProperties(const QScriptValue &properties) { void ModelOverlay::setProperties(const QScriptValue &properties) {
Base3DOverlay::setProperties(properties); auto position = getPosition();
auto rotation = getRotation();
auto scale = getDimensions();
Volume3DOverlay::setProperties(properties);
if (position != getPosition() || rotation != getRotation() || scale != getDimensions()) {
_model.setScaleToFit(true, getScale());
_updateModel = true;
}
QScriptValue urlValue = properties.property("url"); QScriptValue urlValue = properties.property("url");
if (urlValue.isValid()) { if (urlValue.isValid() && urlValue.isString()) {
_url = urlValue.toVariant().toString(); _url = urlValue.toString();
_updateModel = true; _updateModel = true;
_isLoaded = false; _isLoaded = false;
} }
QScriptValue scaleValue = properties.property("scale");
if (scaleValue.isValid()) {
_scale = scaleValue.toVariant().toFloat();
_model.setScaleToFit(true, _scale);
_updateModel = true;
}
QScriptValue rotationValue = properties.property("rotation");
if (rotationValue.isValid()) {
QScriptValue x = rotationValue.property("x");
QScriptValue y = rotationValue.property("y");
QScriptValue z = rotationValue.property("z");
QScriptValue w = rotationValue.property("w");
if (x.isValid() && y.isValid() && z.isValid() && w.isValid()) {
_rotation.x = x.toVariant().toFloat();
_rotation.y = y.toVariant().toFloat();
_rotation.z = z.toVariant().toFloat();
_rotation.w = w.toVariant().toFloat();
}
_updateModel = true;
}
QScriptValue dimensionsValue = properties.property("dimensions");
if (dimensionsValue.isValid()) {
QScriptValue x = dimensionsValue.property("x");
QScriptValue y = dimensionsValue.property("y");
QScriptValue z = dimensionsValue.property("z");
if (x.isValid() && y.isValid() && z.isValid()) {
glm::vec3 dimensions;
dimensions.x = x.toVariant().toFloat();
dimensions.y = y.toVariant().toFloat();
dimensions.z = z.toVariant().toFloat();
_model.setScaleToFit(true, dimensions);
}
_updateModel = true;
}
QScriptValue texturesValue = properties.property("textures"); QScriptValue texturesValue = properties.property("textures");
if (texturesValue.isValid()) { if (texturesValue.isValid() && texturesValue.toVariant().canConvert(QVariant::Map)) {
QVariantMap textureMap = texturesValue.toVariant().toMap(); QVariantMap textureMap = texturesValue.toVariant().toMap();
foreach(const QString& key, textureMap.keys()) { foreach(const QString& key, textureMap.keys()) {
@ -161,22 +132,12 @@ void ModelOverlay::setProperties(const QScriptValue &properties) {
_modelTextures[key] = newTextureURL; // Keep local track of textures for getProperty() _modelTextures[key] = newTextureURL; // Keep local track of textures for getProperty()
} }
} }
if (properties.property("position").isValid()) {
_updateModel = true;
}
} }
QScriptValue ModelOverlay::getProperty(const QString& property) { QScriptValue ModelOverlay::getProperty(const QString& property) {
if (property == "url") { if (property == "url") {
return _url.toString(); return _url.toString();
} }
if (property == "scale") {
return _scale;
}
if (property == "rotation") {
return quatToScriptValue(_scriptEngine, _rotation);
}
if (property == "dimensions") { if (property == "dimensions") {
return vec3toScriptValue(_scriptEngine, _model.getScaleToFitDimensions()); return vec3toScriptValue(_scriptEngine, _model.getScaleToFitDimensions());
} }
@ -192,7 +153,7 @@ QScriptValue ModelOverlay::getProperty(const QString& property) {
} }
} }
return Base3DOverlay::getProperty(property); return Volume3DOverlay::getProperty(property);
} }
bool ModelOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool ModelOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,

View file

@ -14,9 +14,9 @@
#include <Model.h> #include <Model.h>
#include "Base3DOverlay.h" #include "Volume3DOverlay.h"
class ModelOverlay : public Base3DOverlay { class ModelOverlay : public Volume3DOverlay {
Q_OBJECT Q_OBJECT
public: public:
ModelOverlay(); ModelOverlay();
@ -41,9 +41,6 @@ private:
QVariantMap _modelTextures; QVariantMap _modelTextures;
QUrl _url; QUrl _url;
glm::quat _rotation;
float _scale;
bool _updateModel; bool _updateModel;
}; };

View file

@ -8,12 +8,13 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
// include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include "Overlay.h" #include "Overlay.h"
#include <NumericalConstants.h> #include <NumericalConstants.h>
#include <RegisteredMetaTypes.h>
static const xColor DEFAULT_OVERLAY_COLOR = { 255, 255, 255 };
static const float DEFAULT_ALPHA = 0.7f;
Overlay::Overlay() : Overlay::Overlay() :
_renderItemID(render::Item::INVALID_ITEM_ID), _renderItemID(render::Item::INVALID_ITEM_ID),

View file

@ -14,18 +14,11 @@
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <QRect>
#include <QScriptValue>
#include <QString>
#include <RegisteredMetaTypes.h>
#include <SharedUtil.h> // for xColor #include <SharedUtil.h> // for xColor
#include <RenderArgs.h>
#include <AABox.h>
#include <render/Scene.h> #include <render/Scene.h>
const xColor DEFAULT_OVERLAY_COLOR = { 255, 255, 255 }; class QScriptEngine;
const float DEFAULT_ALPHA = 0.7f; class QScriptValue;
class Overlay : public QObject { class Overlay : public QObject {
Q_OBJECT Q_OBJECT
@ -37,7 +30,6 @@ public:
}; };
typedef std::shared_ptr<Overlay> Pointer; typedef std::shared_ptr<Overlay> Pointer;
typedef render::Payload<Overlay> Payload; typedef render::Payload<Overlay> Payload;
typedef std::shared_ptr<render::Item::PayloadInterface> PayloadPointer; typedef std::shared_ptr<render::Item::PayloadInterface> PayloadPointer;
@ -47,6 +39,8 @@ public:
void init(QScriptEngine* scriptEngine); void init(QScriptEngine* scriptEngine);
virtual void update(float deltatime) {} virtual void update(float deltatime) {}
virtual void render(RenderArgs* args) = 0; virtual void render(RenderArgs* args) = 0;
virtual AABox getBounds() const = 0;
virtual bool addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges); virtual bool addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges);
virtual void removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges); virtual void removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges);

View file

@ -8,16 +8,9 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
// include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include <SharedUtil.h>
#include "Overlay2D.h" #include "Overlay2D.h"
#include <RegisteredMetaTypes.h>
Overlay2D::Overlay2D() {
}
Overlay2D::Overlay2D(const Overlay2D* overlay2D) : Overlay2D::Overlay2D(const Overlay2D* overlay2D) :
Overlay(overlay2D), Overlay(overlay2D),
@ -25,7 +18,9 @@ Overlay2D::Overlay2D(const Overlay2D* overlay2D) :
{ {
} }
Overlay2D::~Overlay2D() { AABox Overlay2D::getBounds() const {
return AABox(glm::vec3(_bounds.x(), _bounds.y(), 0.0f),
glm::vec3(_bounds.width(), _bounds.height(), 0.01f));
} }
void Overlay2D::setProperties(const QScriptValue& properties) { void Overlay2D::setProperties(const QScriptValue& properties) {
@ -40,7 +35,7 @@ void Overlay2D::setProperties(const QScriptValue& properties) {
boundsRect.setHeight(bounds.property("height").toVariant().toInt()); boundsRect.setHeight(bounds.property("height").toVariant().toInt());
setBounds(boundsRect); setBounds(boundsRect);
} else { } else {
QRect oldBounds = getBounds(); QRect oldBounds = _bounds;
QRect newBounds = oldBounds; QRect newBounds = oldBounds;
if (properties.property("x").isValid()) { if (properties.property("x").isValid()) {

View file

@ -15,10 +15,6 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <QRect> #include <QRect>
#include <QScriptValue>
#include <QString>
#include <SharedUtil.h> // for xColor
#include "Overlay.h" #include "Overlay.h"
@ -26,9 +22,10 @@ class Overlay2D : public Overlay {
Q_OBJECT Q_OBJECT
public: public:
Overlay2D(); Overlay2D() {}
Overlay2D(const Overlay2D* overlay2D); Overlay2D(const Overlay2D* overlay2D);
~Overlay2D();
virtual AABox getBounds() const;
virtual bool is3D() const { return false; } virtual bool is3D() const { return false; }
@ -37,8 +34,8 @@ public:
int getY() const { return _bounds.y(); } int getY() const { return _bounds.y(); }
int getWidth() const { return _bounds.width(); } int getWidth() const { return _bounds.width(); }
int getHeight() const { return _bounds.height(); } int getHeight() const { return _bounds.height(); }
const QRect& getBounds() const { return _bounds; } const QRect& getBoundingRect() const { return _bounds; }
// setters // setters
void setX(int x) { _bounds.setX(x); } void setX(int x) { _bounds.setX(x); }
void setY(int y) { _bounds.setY(y); } void setY(int y) { _bounds.setY(y); }

View file

@ -8,14 +8,13 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "Overlays.h"
#include <QScriptValueIterator> #include <QScriptValueIterator>
#include <limits> #include <limits>
#include <typeinfo>
#include <Application.h> #include <Application.h>
#include <avatar/AvatarManager.h>
#include <LODManager.h>
#include <render/Scene.h> #include <render/Scene.h>
#include "BillboardOverlay.h" #include "BillboardOverlay.h"
@ -25,7 +24,6 @@
#include "Line3DOverlay.h" #include "Line3DOverlay.h"
#include "LocalModelsOverlay.h" #include "LocalModelsOverlay.h"
#include "ModelOverlay.h" #include "ModelOverlay.h"
#include "Overlays.h"
#include "Rectangle3DOverlay.h" #include "Rectangle3DOverlay.h"
#include "Sphere3DOverlay.h" #include "Sphere3DOverlay.h"
#include "Grid3DOverlay.h" #include "Grid3DOverlay.h"
@ -37,7 +35,6 @@ Overlays::Overlays() : _nextOverlayID(1) {
} }
Overlays::~Overlays() { Overlays::~Overlays() {
{ {
QWriteLocker lock(&_lock); QWriteLocker lock(&_lock);
QWriteLocker deleteLock(&_deleteLock); QWriteLocker deleteLock(&_deleteLock);
@ -99,9 +96,6 @@ void Overlays::cleanupOverlaysToDelete() {
void Overlays::renderHUD(RenderArgs* renderArgs) { void Overlays::renderHUD(RenderArgs* renderArgs) {
QReadLocker lock(&_lock); QReadLocker lock(&_lock);
auto lodManager = DependencyManager::get<LODManager>();
foreach(Overlay::Pointer thisOverlay, _overlaysHUD) { foreach(Overlay::Pointer thisOverlay, _overlaysHUD) {
if (thisOverlay->is3D()) { if (thisOverlay->is3D()) {
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
@ -284,7 +278,7 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
} else { } else {
Overlay2D* thisOverlay = static_cast<Overlay2D*>(i.value().get()); Overlay2D* thisOverlay = static_cast<Overlay2D*>(i.value().get());
if (thisOverlay->getVisible() && thisOverlay->isLoaded() && if (thisOverlay->getVisible() && thisOverlay->isLoaded() &&
thisOverlay->getBounds().contains(pointCopy.x, pointCopy.y, false)) { thisOverlay->getBoundingRect().contains(pointCopy.x, pointCopy.y, false)) {
return thisID; return thisID;
} }
} }

View file

@ -11,13 +11,13 @@
#ifndef hifi_Overlays_h #ifndef hifi_Overlays_h
#define hifi_Overlays_h #define hifi_Overlays_h
#include <QString> #include <QReadWriteLock>
#include <QScriptValue> #include <QScriptValue>
#include <QSignalMapper>
#include "Base3DOverlay.h"
#include "Overlay.h" #include "Overlay.h"
class PickRay;
class OverlayPropertyResult { class OverlayPropertyResult {
public: public:
OverlayPropertyResult(); OverlayPropertyResult();
@ -48,9 +48,11 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R
class Overlays : public QObject { class Overlays : public QObject {
Q_OBJECT Q_OBJECT
public: public:
Overlays(); Overlays();
~Overlays(); ~Overlays();
void init(); void init();
void update(float deltatime); void update(float deltatime);
void renderHUD(RenderArgs* renderArgs); void renderHUD(RenderArgs* renderArgs);

View file

@ -35,8 +35,8 @@
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) { template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) {
if (overlay->is3D() && !static_cast<Base3DOverlay*>(overlay.get())->getDrawOnHUD()) { if (overlay->is3D() && !std::dynamic_pointer_cast<Base3DOverlay>(overlay)->getDrawOnHUD()) {
if (static_cast<Base3DOverlay*>(overlay.get())->getDrawInFront()) { if (std::dynamic_pointer_cast<Base3DOverlay>(overlay)->getDrawInFront()) {
return ItemKey::Builder().withTypeShape().withLayered().build(); return ItemKey::Builder().withTypeShape().withLayered().build();
} else { } else {
return ItemKey::Builder::opaqueShape(); return ItemKey::Builder::opaqueShape();
@ -46,12 +46,7 @@ namespace render {
} }
} }
template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay) { template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay) {
if (overlay->is3D()) { return overlay->getBounds();
return static_cast<Base3DOverlay*>(overlay.get())->getBounds();
} else {
QRect bounds = static_cast<Overlay2D*>(overlay.get())->getBounds();
return AABox(glm::vec3(bounds.x(), bounds.y(), 0.0f), glm::vec3(bounds.width(), bounds.height(), 0.1f));
}
} }
template <> int payloadGetLayer(const Overlay::Pointer& overlay) { template <> int payloadGetLayer(const Overlay::Pointer& overlay) {
// MAgic number while we are defining the layering mechanism: // MAgic number while we are defining the layering mechanism:
@ -59,7 +54,7 @@ namespace render {
const int LAYER_3D_FRONT = 1; const int LAYER_3D_FRONT = 1;
const int LAYER_3D = 0; const int LAYER_3D = 0;
if (overlay->is3D()) { if (overlay->is3D()) {
return (static_cast<Base3DOverlay*>(overlay.get())->getDrawInFront() ? LAYER_3D_FRONT : LAYER_3D); return (std::dynamic_pointer_cast<Base3DOverlay>(overlay)->getDrawInFront() ? LAYER_3D_FRONT : LAYER_3D);
} else { } else {
return LAYER_2D; return LAYER_2D;
} }

View file

@ -8,32 +8,24 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
// include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include <PlaneShape.h>
#include <RayIntersectionInfo.h>
#include <SharedUtil.h>
#include <StreamUtils.h>
#include "GeometryUtil.h"
#include "Planar3DOverlay.h" #include "Planar3DOverlay.h"
const float DEFAULT_SIZE = 1.0f; #include <Extents.h>
#include <GeometryUtil.h>
Planar3DOverlay::Planar3DOverlay() : #include <RegisteredMetaTypes.h>
_dimensions(glm::vec2(DEFAULT_SIZE, DEFAULT_SIZE))
{
}
Planar3DOverlay::Planar3DOverlay(const Planar3DOverlay* planar3DOverlay) : Planar3DOverlay::Planar3DOverlay(const Planar3DOverlay* planar3DOverlay) :
Base3DOverlay(planar3DOverlay), Base3DOverlay(planar3DOverlay)
_dimensions(planar3DOverlay->_dimensions)
{ {
} }
Planar3DOverlay::~Planar3DOverlay() { AABox Planar3DOverlay::getBounds() const {
auto halfDimensions = glm::vec3{_dimensions / 2.0f, 0.01f};
auto extents = Extents{-halfDimensions, halfDimensions};
extents.transform(_transform);
return AABox(extents);
} }
void Planar3DOverlay::setProperties(const QScriptValue& properties) { void Planar3DOverlay::setProperties(const QScriptValue& properties) {
@ -86,7 +78,7 @@ void Planar3DOverlay::setProperties(const QScriptValue& properties) {
QScriptValue Planar3DOverlay::getProperty(const QString& property) { QScriptValue Planar3DOverlay::getProperty(const QString& property) {
if (property == "dimensions" || property == "scale" || property == "size") { if (property == "dimensions" || property == "scale" || property == "size") {
return vec2toScriptValue(_scriptEngine, _dimensions); return vec2toScriptValue(_scriptEngine, getDimensions());
} }
return Base3DOverlay::getProperty(property); return Base3DOverlay::getProperty(property);
@ -94,5 +86,5 @@ QScriptValue Planar3DOverlay::getProperty(const QString& property) {
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
float& distance, BoxFace& face) { float& distance, BoxFace& face) {
return findRayRectangleIntersection(origin, direction, _rotation, _position, _dimensions, distance); return findRayRectangleIntersection(origin, direction, getRotation(), getPosition(), getDimensions(), distance);
} }

View file

@ -14,34 +14,28 @@
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <glm/glm.hpp>
#include <QScriptValue>
#include "Base3DOverlay.h" #include "Base3DOverlay.h"
class Planar3DOverlay : public Base3DOverlay { class Planar3DOverlay : public Base3DOverlay {
Q_OBJECT Q_OBJECT
public: public:
Planar3DOverlay(); Planar3DOverlay() {}
Planar3DOverlay(const Planar3DOverlay* planar3DOverlay); Planar3DOverlay(const Planar3DOverlay* planar3DOverlay);
~Planar3DOverlay();
AABox getBounds() const;
// getters
const glm::vec2& getDimensions() const { return _dimensions; } glm::vec2 getDimensions() const { return _dimensions; }
void setDimensions(float value) { _dimensions = glm::vec2(value); }
// setters
void setSize(float size) { _dimensions = glm::vec2(size, size); }
void setDimensions(const glm::vec2& value) { _dimensions = value; } void setDimensions(const glm::vec2& value) { _dimensions = value; }
virtual void setProperties(const QScriptValue& properties); virtual void setProperties(const QScriptValue& properties);
virtual QScriptValue getProperty(const QString& property); virtual QScriptValue getProperty(const QString& property);
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face); virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face);
protected: protected:
glm::vec2 _dimensions; glm::vec2 _dimensions{1.0f, 1.0f};
}; };

View file

@ -11,12 +11,12 @@
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "Rectangle3DOverlay.h"
#include <GeometryCache.h> #include <GeometryCache.h>
#include <GlowEffect.h> #include <GlowEffect.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "Rectangle3DOverlay.h"
Rectangle3DOverlay::Rectangle3DOverlay() : Rectangle3DOverlay::Rectangle3DOverlay() :
_geometryCacheID(DependencyManager::get<GeometryCache>()->allocateID()) _geometryCacheID(DependencyManager::get<GeometryCache>()->allocateID())
{ {

View file

@ -17,17 +17,12 @@
#include "Sphere3DOverlay.h" #include "Sphere3DOverlay.h"
#include "Application.h" #include "Application.h"
Sphere3DOverlay::Sphere3DOverlay() {
}
Sphere3DOverlay::Sphere3DOverlay(const Sphere3DOverlay* Sphere3DOverlay) : Sphere3DOverlay::Sphere3DOverlay(const Sphere3DOverlay* Sphere3DOverlay) :
Volume3DOverlay(Sphere3DOverlay) Volume3DOverlay(Sphere3DOverlay)
{ {
} }
Sphere3DOverlay::~Sphere3DOverlay() {
}
void Sphere3DOverlay::render(RenderArgs* args) { void Sphere3DOverlay::render(RenderArgs* args) {
if (!_visible) { if (!_visible) {
return; // do nothing if we're not visible return; // do nothing if we're not visible
@ -42,11 +37,8 @@ void Sphere3DOverlay::render(RenderArgs* args) {
auto batch = args->_batch; auto batch = args->_batch;
if (batch) { if (batch) {
Transform transform; Transform transform = _transform;
transform.setTranslation(_position); transform.postScale(getDimensions());
transform.setRotation(_rotation);
transform.setScale(_dimensions);
batch->setModelTransform(transform); batch->setModelTransform(transform);
DependencyManager::get<GeometryCache>()->renderSphere(*batch, 1.0f, SLICES, SLICES, sphereColor, _isSolid); DependencyManager::get<GeometryCache>()->renderSphere(*batch, 1.0f, SLICES, SLICES, sphereColor, _isSolid);
} else { } else {

View file

@ -17,9 +17,9 @@ class Sphere3DOverlay : public Volume3DOverlay {
Q_OBJECT Q_OBJECT
public: public:
Sphere3DOverlay(); Sphere3DOverlay() {}
Sphere3DOverlay(const Sphere3DOverlay* Sphere3DOverlay); Sphere3DOverlay(const Sphere3DOverlay* Sphere3DOverlay);
~Sphere3DOverlay();
virtual void render(RenderArgs* args); virtual void render(RenderArgs* args);
virtual Sphere3DOverlay* createClone() const; virtual Sphere3DOverlay* createClone() const;

View file

@ -11,14 +11,17 @@
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "Application.h"
#include "Text3DOverlay.h" #include "Text3DOverlay.h"
#include <RenderDeferredTask.h> #include <RenderDeferredTask.h>
#include <TextRenderer3D.h>
#include "Application.h"
const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 }; const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 };
const float DEFAULT_BACKGROUND_ALPHA = 0.7f; const float DEFAULT_BACKGROUND_ALPHA = 0.7f;
const float DEFAULT_MARGIN = 0.1f; const float DEFAULT_MARGIN = 0.1f;
const int FIXED_FONT_POINT_SIZE = 40;
const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 80.0f; // this is a ratio determined through experimentation const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 80.0f; // this is a ratio determined through experimentation
const float LINE_SCALE_RATIO = 1.2f; const float LINE_SCALE_RATIO = 1.2f;
@ -32,6 +35,7 @@ Text3DOverlay::Text3DOverlay() :
_bottomMargin(DEFAULT_MARGIN), _bottomMargin(DEFAULT_MARGIN),
_isFacingAvatar(false) _isFacingAvatar(false)
{ {
_textRenderer = TextRenderer3D::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE);
} }
Text3DOverlay::Text3DOverlay(const Text3DOverlay* text3DOverlay) : Text3DOverlay::Text3DOverlay(const Text3DOverlay* text3DOverlay) :
@ -46,6 +50,7 @@ Text3DOverlay::Text3DOverlay(const Text3DOverlay* text3DOverlay) :
_bottomMargin(text3DOverlay->_bottomMargin), _bottomMargin(text3DOverlay->_bottomMargin),
_isFacingAvatar(text3DOverlay->_isFacingAvatar) _isFacingAvatar(text3DOverlay->_isFacingAvatar)
{ {
_textRenderer = TextRenderer3D::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE);
} }
Text3DOverlay::~Text3DOverlay() { Text3DOverlay::~Text3DOverlay() {
@ -77,58 +82,58 @@ void Text3DOverlay::render(RenderArgs* args) {
return; // do nothing if we're not visible return; // do nothing if we're not visible
} }
auto batch = args->_batch;
Q_ASSERT(args->_batch);
if (batch) { auto& batch = *args->_batch;
glm::quat rotation;
glm::quat rotation;
if (_isFacingAvatar) {
// rotate about vertical to face the camera if (_isFacingAvatar) {
rotation = Application::getInstance()->getCamera()->getRotation(); // rotate about vertical to face the camera
} else { rotation = args->_viewFrustum->getOrientation();
rotation = getRotation(); } else {
} rotation = getRotation();
Transform transform;
transform.setTranslation(_position);
transform.setRotation(rotation);
batch->setModelTransform(transform);
const float MAX_COLOR = 255.0f;
xColor backgroundColor = getBackgroundColor();
glm::vec4 quadColor(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
getBackgroundAlpha());
glm::vec2 dimensions = getDimensions();
glm::vec2 halfDimensions = dimensions * 0.5f;
const float SLIGHTLY_BEHIND = -0.005f;
glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
DependencyManager::get<GeometryCache>()->renderQuad(*batch, topLeft, bottomRight, quadColor);
// Same font properties as textSize()
float maxHeight = (float)_textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO;
float scaleFactor = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight;
glm::vec2 clipMinimum(0.0f, 0.0f);
glm::vec2 clipDimensions((dimensions.x - (_leftMargin + _rightMargin)) / scaleFactor,
(dimensions.y - (_topMargin + _bottomMargin)) / scaleFactor);
transform.setTranslation(_position);
transform.postTranslate(glm::vec3(-(halfDimensions.x - _leftMargin) , halfDimensions.y - _topMargin, 0.01f));
transform.setScale(scaleFactor);
batch->setModelTransform(transform);
glm::vec4 textColor = { _color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getAlpha() };
_textRenderer->draw(*batch, 0, 0, _text, textColor);
batch->setPipeline(DrawOverlay3D::getOpaquePipeline());
} }
Transform transform;
transform.setTranslation(getPosition());
transform.setRotation(rotation);
transform.setScale(getScale());
batch.setModelTransform(transform);
const float MAX_COLOR = 255.0f;
xColor backgroundColor = getBackgroundColor();
glm::vec4 quadColor(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
getBackgroundAlpha());
glm::vec2 dimensions = getDimensions();
glm::vec2 halfDimensions = dimensions * 0.5f;
const float SLIGHTLY_BEHIND = -0.005f;
glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, quadColor);
// Same font properties as textSize()
float maxHeight = (float)_textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO;
float scaleFactor = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight;
glm::vec2 clipMinimum(0.0f, 0.0f);
glm::vec2 clipDimensions((dimensions.x - (_leftMargin + _rightMargin)) / scaleFactor,
(dimensions.y - (_topMargin + _bottomMargin)) / scaleFactor);
transform.setTranslation(getPosition());
transform.postTranslate(glm::vec3(-(halfDimensions.x - _leftMargin) , halfDimensions.y - _topMargin, 0.01f));
transform.setScale(scaleFactor);
batch.setModelTransform(transform);
glm::vec4 textColor = { _color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getAlpha() };
_textRenderer->draw(batch, 0, 0, _text, textColor);
batch.setPipeline(DrawOverlay3D::getOpaquePipeline());
} }
void Text3DOverlay::setProperties(const QScriptValue& properties) { void Text3DOverlay::setProperties(const QScriptValue& properties) {

View file

@ -16,12 +16,9 @@
#include <QString> #include <QString>
#include <RenderArgs.h>
#include <TextRenderer3D.h>
#include "Planar3DOverlay.h" #include "Planar3DOverlay.h"
const int FIXED_FONT_POINT_SIZE = 40; class TextRenderer3D;
class Text3DOverlay : public Planar3DOverlay { class Text3DOverlay : public Planar3DOverlay {
Q_OBJECT Q_OBJECT
@ -60,7 +57,7 @@ public:
virtual Text3DOverlay* createClone() const; virtual Text3DOverlay* createClone() const;
private: private:
TextRenderer3D* _textRenderer = TextRenderer3D::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE); TextRenderer3D* _textRenderer = nullptr;
QString _text; QString _text;
xColor _backgroundColor; xColor _backgroundColor;

View file

@ -11,11 +11,14 @@
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "TextOverlay.h"
#include <DependencyManager.h> #include <DependencyManager.h>
#include <GeometryCache.h> #include <GeometryCache.h>
#include <RegisteredMetaTypes.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <TextRenderer.h>
#include "TextOverlay.h"
TextOverlay::TextOverlay() : TextOverlay::TextOverlay() :
_backgroundColor(DEFAULT_BACKGROUND_COLOR), _backgroundColor(DEFAULT_BACKGROUND_COLOR),

View file

@ -14,14 +14,10 @@
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <QRect>
#include <QScriptValue>
#include <QString> #include <QString>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <TextRenderer.h>
#include "Overlay.h"
#include "Overlay2D.h" #include "Overlay2D.h"
const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 }; const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 };
@ -30,6 +26,8 @@ const int DEFAULT_MARGIN = 10;
const int DEFAULT_FONTSIZE = 11; const int DEFAULT_FONTSIZE = 11;
const int DEFAULT_FONT_WEIGHT = 50; const int DEFAULT_FONT_WEIGHT = 50;
class TextRenderer;
class TextOverlay : public Overlay2D { class TextOverlay : public Overlay2D {
Q_OBJECT Q_OBJECT

View file

@ -8,32 +8,22 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>
// include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include <AABox.h>
#include <SharedUtil.h>
#include <StreamUtils.h>
#include "Volume3DOverlay.h" #include "Volume3DOverlay.h"
const float DEFAULT_SIZE = 1.0f; #include <Extents.h>
#include <RegisteredMetaTypes.h>
Volume3DOverlay::Volume3DOverlay() :
_dimensions(glm::vec3(DEFAULT_SIZE, DEFAULT_SIZE, DEFAULT_SIZE))
{
}
Volume3DOverlay::Volume3DOverlay(const Volume3DOverlay* volume3DOverlay) : Volume3DOverlay::Volume3DOverlay(const Volume3DOverlay* volume3DOverlay) :
Base3DOverlay(volume3DOverlay), Base3DOverlay(volume3DOverlay)
_dimensions(volume3DOverlay->_dimensions)
{ {
} }
Volume3DOverlay::~Volume3DOverlay() { AABox Volume3DOverlay::getBounds() const {
auto extents = Extents{_localBoundingBox};
extents.rotate(getRotation());
extents.shiftBy(getPosition());
return AABox(extents);
} }
void Volume3DOverlay::setProperties(const QScriptValue& properties) { void Volume3DOverlay::setProperties(const QScriptValue& properties) {
@ -58,26 +48,30 @@ void Volume3DOverlay::setProperties(const QScriptValue& properties) {
QScriptValue z = dimensions.property("z"); QScriptValue z = dimensions.property("z");
if (x.isValid() && y.isValid() && z.isValid()) { if (x.isValid() && x.isNumber() &&
newDimensions.x = x.toVariant().toFloat(); y.isValid() && y.isNumber() &&
newDimensions.y = y.toVariant().toFloat(); z.isValid() && z.isNumber()) {
newDimensions.z = z.toVariant().toFloat(); newDimensions.x = x.toNumber();
newDimensions.y = y.toNumber();
newDimensions.z = z.toNumber();
validDimensions = true; validDimensions = true;
} else { } else {
QScriptValue width = dimensions.property("width"); QScriptValue width = dimensions.property("width");
QScriptValue height = dimensions.property("height"); QScriptValue height = dimensions.property("height");
QScriptValue depth = dimensions.property("depth"); QScriptValue depth = dimensions.property("depth");
if (width.isValid() && height.isValid() && depth.isValid()) { if (width.isValid() && width.isNumber() &&
newDimensions.x = width.toVariant().toFloat(); height.isValid() && height.isNumber() &&
newDimensions.y = height.toVariant().toFloat(); depth.isValid() && depth.isNumber()) {
newDimensions.z = depth.toVariant().toFloat(); newDimensions.x = width.toNumber();
newDimensions.y = height.toNumber();
newDimensions.z = depth.toNumber();
validDimensions = true; validDimensions = true;
} }
} }
// size, scale, dimensions is special, it might just be a single scalar, check that here // size, scale, dimensions is special, it might just be a single scalar, check that here
if (!validDimensions && dimensions.isNumber()) { if (!validDimensions && dimensions.isNumber()) {
float size = dimensions.toVariant().toFloat(); float size = dimensions.toNumber();
newDimensions.x = size; newDimensions.x = size;
newDimensions.y = size; newDimensions.y = size;
newDimensions.z = size; newDimensions.z = size;
@ -92,7 +86,7 @@ void Volume3DOverlay::setProperties(const QScriptValue& properties) {
QScriptValue Volume3DOverlay::getProperty(const QString& property) { QScriptValue Volume3DOverlay::getProperty(const QString& property) {
if (property == "dimensions" || property == "scale" || property == "size") { if (property == "dimensions" || property == "scale" || property == "size") {
return vec3toScriptValue(_scriptEngine, _dimensions); return vec3toScriptValue(_scriptEngine, getDimensions());
} }
return Base3DOverlay::getProperty(property); return Base3DOverlay::getProperty(property);
@ -100,24 +94,14 @@ QScriptValue Volume3DOverlay::getProperty(const QString& property) {
bool Volume3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool Volume3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
float& distance, BoxFace& face) { float& distance, BoxFace& face) {
// extents is the entity relative, scaled, centered extents of the entity // extents is the entity relative, scaled, centered extents of the entity
glm::vec3 position = getPosition(); glm::mat4 worldToEntityMatrix;
glm::mat4 rotation = glm::mat4_cast(getRotation()); _transform.getInverseMatrix(worldToEntityMatrix);
glm::mat4 translation = glm::translate(position);
glm::mat4 entityToWorldMatrix = translation * rotation;
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);
glm::vec3 dimensions = _dimensions;
glm::vec3 corner = dimensions * -0.5f; // since we're going to do the ray picking in the overlay frame of reference
AABox overlayFrameBox(corner, dimensions);
glm::vec3 overlayFrameOrigin = glm::vec3(worldToEntityMatrix * glm::vec4(origin, 1.0f)); glm::vec3 overlayFrameOrigin = glm::vec3(worldToEntityMatrix * glm::vec4(origin, 1.0f));
glm::vec3 overlayFrameDirection = glm::vec3(worldToEntityMatrix * glm::vec4(direction, 0.0f)); glm::vec3 overlayFrameDirection = glm::vec3(worldToEntityMatrix * glm::vec4(direction, 0.0f));
// we can use the AABox's ray intersection by mapping our origin and direction into the overlays frame // we can use the AABox's ray intersection by mapping our origin and direction into the overlays frame
// and testing intersection there. // and testing intersection there.
if (overlayFrameBox.findRayIntersection(overlayFrameOrigin, overlayFrameDirection, distance, face)) { return _localBoundingBox.findRayIntersection(overlayFrameOrigin, overlayFrameDirection, distance, face);
return true;
}
return false;
} }

View file

@ -14,36 +14,29 @@
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <glm/glm.hpp>
#include <QScriptValue>
#include "Base3DOverlay.h" #include "Base3DOverlay.h"
class Volume3DOverlay : public Base3DOverlay { class Volume3DOverlay : public Base3DOverlay {
Q_OBJECT Q_OBJECT
public: public:
Volume3DOverlay(); Volume3DOverlay() {}
Volume3DOverlay(const Volume3DOverlay* volume3DOverlay); Volume3DOverlay(const Volume3DOverlay* volume3DOverlay);
~Volume3DOverlay();
virtual AABox getBounds() const;
// getters
const glm::vec3& getCenter() const { return _position; } // TODO: consider adding registration point!! const glm::vec3& getDimensions() const { return _localBoundingBox.getDimensions(); }
glm::vec3 getCorner() const { return _position - (_dimensions * 0.5f); } // TODO: consider adding registration point!! void setDimensions(float value) { _localBoundingBox.setBox(glm::vec3(-value / 2.0f), value); }
const glm::vec3& getDimensions() const { return _dimensions; } void setDimensions(const glm::vec3& value) { _localBoundingBox.setBox(-value / 2.0f, value); }
// setters
void setSize(float size) { _dimensions = glm::vec3(size, size, size); }
void setDimensions(const glm::vec3& value) { _dimensions = value; }
virtual void setProperties(const QScriptValue& properties); virtual void setProperties(const QScriptValue& properties);
virtual QScriptValue getProperty(const QString& property); virtual QScriptValue getProperty(const QString& property);
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face); virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face);
protected: protected:
glm::vec3 _dimensions; // Centered local bounding box
AABox _localBoundingBox;
}; };

View file

@ -10,12 +10,14 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "Extents.h"
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <glm/gtx/transform.hpp> #include <glm/gtx/transform.hpp>
#include "AABox.h" #include "AABox.h"
#include "Extents.h" #include "Transform.h"
void Extents::reset() { void Extents::reset() {
minimum = glm::vec3(FLT_MAX); minimum = glm::vec3(FLT_MAX);
@ -78,3 +80,10 @@ void Extents::rotate(const glm::quat& rotation) {
glm::max(topRightNearRotated, glm::max(topRightNearRotated,
glm::max(topLeftFarRotated,topRightFarRotated))))))); glm::max(topLeftFarRotated,topRightFarRotated)))))));
} }
void Extents::transform(const Transform& transform) {
scale(transform.getScale());
rotate(transform.getRotation());
shiftBy(transform.getTranslation());
}

View file

@ -20,6 +20,7 @@
#include "StreamUtils.h" #include "StreamUtils.h"
class AABox; class AABox;
class Transform;
class Extents { class Extents {
public: public:
@ -56,6 +57,13 @@ public:
/// rotate the extents around orign by rotation /// rotate the extents around orign by rotation
void rotate(const glm::quat& rotation); void rotate(const glm::quat& rotation);
/// scale the extents around orign by scale
void scale(float scale) { minimum *= scale; maximum *= scale; }
void scale(const glm::vec3& scale) { minimum *= scale; maximum *= scale; }
// Transform the extents with transform
void transform(const Transform& transform);
glm::vec3 size() const { return maximum - minimum; } glm::vec3 size() const { return maximum - minimum; }
float largestDimension() const {glm::vec3 s = size(); return glm::max(s[0], s[1], s[2]); } float largestDimension() const {glm::vec3 s = size(); return glm::max(s[0], s[1], s[2]); }