Add property getting for all 3D overlays
This commit is contained in:
parent
725d56d41f
commit
9e19641a1d
@ -193,6 +193,20 @@ print("Cube overlay color =\n"
|
||||
+ "green: " + cubeColor.green + "\n"
|
||||
+ "blue: " + cubeColor.blue
|
||||
);
|
||||
var modelOverlayProperties = {
|
||||
textures: {
|
||||
filename1: "http://url1",
|
||||
filename2: "http://url2"
|
||||
}
|
||||
}
|
||||
var modelOverlay = Overlays.addOverlay("model", modelOverlayProperties);
|
||||
var textures = Overlays.getProperty(modelOverlay, "textures");
|
||||
var textureValues = "";
|
||||
for (key in textures) {
|
||||
textureValues += "\n" + key + ": " + textures[key];
|
||||
}
|
||||
print("Model overlay textures =" + textureValues);
|
||||
Overlays.deleteOverlay(modelOverlay);
|
||||
print("Unknown overlay property =\n" + Overlays.getProperty(1000, "text")); // value = undefined
|
||||
|
||||
// When our script shuts down, we should clean up all of our overlays
|
||||
|
@ -119,9 +119,28 @@ void Base3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
}
|
||||
|
||||
QScriptValue Base3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "position") {
|
||||
if (property == "position" || property == "start" || property == "p1" || property == "point") {
|
||||
return vec3toScriptValue(_scriptEngine, _position);
|
||||
}
|
||||
if (property == "lineWidth") {
|
||||
return _lineWidth;
|
||||
}
|
||||
if (property == "rotation") {
|
||||
return quatToScriptValue(_scriptEngine, _rotation);
|
||||
}
|
||||
if (property == "isSolid" || property == "isFilled" || property == "solid" || property == "filed") {
|
||||
return _isSolid;
|
||||
}
|
||||
if (property == "isWire" || property == "wire") {
|
||||
return !_isSolid;
|
||||
}
|
||||
if (property == "isDashedLine" || property == "dashed") {
|
||||
return _isDashedLine;
|
||||
}
|
||||
if (property == "ignoreRayIntersection") {
|
||||
return _ignoreRayIntersection;
|
||||
}
|
||||
|
||||
return Overlay::getProperty(property);
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,28 @@ void BillboardOverlay::setProperties(const QScriptValue &properties) {
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue BillboardOverlay::getProperty(const QString& property) {
|
||||
if (property == "url") {
|
||||
return _url;
|
||||
}
|
||||
if (property == "subImage") {
|
||||
QScriptValue subImage = _scriptEngine->newObject();
|
||||
subImage.setProperty("x", _fromImage.x());
|
||||
subImage.setProperty("y", _fromImage.y());
|
||||
subImage.setProperty("width", _fromImage.width());
|
||||
subImage.setProperty("height", _fromImage.height());
|
||||
return subImage;
|
||||
}
|
||||
if (property == "scale") {
|
||||
return _scale;
|
||||
}
|
||||
if (property == "isFacingAvatar") {
|
||||
return _isFacingAvatar;
|
||||
}
|
||||
|
||||
return Base3DOverlay::getProperty(property);
|
||||
}
|
||||
|
||||
void BillboardOverlay::setURL(const QString& url) {
|
||||
setBillboardURL(url);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
void setClipFromSource(const QRect& bounds) { _fromImage = bounds; }
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face) const;
|
||||
|
||||
|
@ -299,6 +299,45 @@ void Circle3DOverlay::setProperties(const QScriptValue &properties) {
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue Circle3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "startAt") {
|
||||
return _startAt;
|
||||
}
|
||||
if (property == "endAt") {
|
||||
return _endAt;
|
||||
}
|
||||
if (property == "outerRadius") {
|
||||
return _outerRadius;
|
||||
}
|
||||
if (property == "innerRadius") {
|
||||
return _innerRadius;
|
||||
}
|
||||
if (property == "hasTickMarks") {
|
||||
return _hasTickMarks;
|
||||
}
|
||||
if (property == "majorTickMarksAngle") {
|
||||
return _majorTickMarksAngle;
|
||||
}
|
||||
if (property == "minorTickMarksAngle") {
|
||||
return _minorTickMarksAngle;
|
||||
}
|
||||
if (property == "majorTickMarksLength") {
|
||||
return _majorTickMarksLength;
|
||||
}
|
||||
if (property == "minorTickMarksLength") {
|
||||
return _minorTickMarksLength;
|
||||
}
|
||||
if (property == "majorTickMarksColor") {
|
||||
return xColorToScriptValue(_scriptEngine, _majorTickMarksColor);
|
||||
}
|
||||
if (property == "minorTickMarksColor") {
|
||||
return xColorToScriptValue(_scriptEngine, _minorTickMarksColor);
|
||||
}
|
||||
|
||||
return Planar3DOverlay::getProperty(property);
|
||||
}
|
||||
|
||||
|
||||
bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin,
|
||||
const glm::vec3& direction, float& distance, BoxFace& face) const {
|
||||
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
~Circle3DOverlay();
|
||||
virtual void render(RenderArgs* args);
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
float getStartAt() const { return _startAt; }
|
||||
float getEndAt() const { return _endAt; }
|
||||
|
@ -116,3 +116,14 @@ void Grid3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
_majorGridEvery = properties.property("majorGridEvery").toVariant().toInt();
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue Grid3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "minorGridWidth") {
|
||||
return _minorGridWidth;
|
||||
}
|
||||
if (property == "majorGridEvery") {
|
||||
return _majorGridEvery;
|
||||
}
|
||||
|
||||
return Base3DOverlay::getProperty(property);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
|
||||
virtual void render(RenderArgs* args);
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
private:
|
||||
float _minorGridWidth;
|
||||
|
@ -79,3 +79,11 @@ void Line3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue Line3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "end" || property == "endPoint" || property == "p2") {
|
||||
return vec3toScriptValue(_scriptEngine, _end);
|
||||
}
|
||||
|
||||
return Base3DOverlay::getProperty(property);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
void setEnd(const glm::vec3& end) { _end = end; }
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
protected:
|
||||
glm::vec3 _end;
|
||||
|
@ -103,3 +103,14 @@ void LocalVoxelsOverlay::setProperties(const QScriptValue &properties) {
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue LocalVoxelsOverlay::getProperty(const QString& property) {
|
||||
if (property == "scale") {
|
||||
return vec3toScriptValue(_scriptEngine, getDimensions());
|
||||
}
|
||||
if (property == "name") {
|
||||
return _treeName;
|
||||
}
|
||||
|
||||
return Volume3DOverlay::getProperty(property);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,8 @@ public:
|
||||
virtual void render(RenderArgs* args);
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
private:
|
||||
static QMap<QString, WeakVoxelSystemPointer> _voxelSystemMap; // treeName/voxelSystem
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
ModelOverlay::ModelOverlay()
|
||||
: _model(),
|
||||
_modelTextures(QVariantMap()),
|
||||
_scale(1.0f),
|
||||
_updateModel(false)
|
||||
{
|
||||
@ -114,6 +115,8 @@ void ModelOverlay::setProperties(const QScriptValue &properties) {
|
||||
QMetaObject::invokeMethod(&_model, "setTextureWithNameToURL", Qt::AutoConnection,
|
||||
Q_ARG(const QString&, key),
|
||||
Q_ARG(const QUrl&, newTextureURL));
|
||||
|
||||
_modelTextures[key] = newTextureURL; // Keep local track of textures for getProperty()
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,6 +125,34 @@ void ModelOverlay::setProperties(const QScriptValue &properties) {
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue ModelOverlay::getProperty(const QString& property) {
|
||||
if (property == "url") {
|
||||
return _url.toString();
|
||||
}
|
||||
if (property == "scale") {
|
||||
return _scale;
|
||||
}
|
||||
if (property == "rotation") {
|
||||
return quatToScriptValue(_scriptEngine, _rotation);
|
||||
}
|
||||
if (property == "dimensions") {
|
||||
return vec3toScriptValue(_scriptEngine, _model.getScaleToFitDimensions());
|
||||
}
|
||||
if (property == "textures") {
|
||||
if (_modelTextures.size() > 0) {
|
||||
QScriptValue textures = _scriptEngine->newObject();
|
||||
foreach(const QString& key, _modelTextures.keys()) {
|
||||
textures.setProperty(key, _modelTextures[key].toString());
|
||||
}
|
||||
return textures;
|
||||
} else {
|
||||
return QScriptValue();
|
||||
}
|
||||
}
|
||||
|
||||
return Base3DOverlay::getProperty(property);
|
||||
}
|
||||
|
||||
bool ModelOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face) const {
|
||||
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
virtual void update(float deltatime);
|
||||
virtual void render(RenderArgs* args);
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face) const;
|
||||
virtual bool findRayIntersectionExtraInfo(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face, QString& extraInfo) const;
|
||||
@ -31,6 +32,7 @@ public:
|
||||
private:
|
||||
|
||||
Model _model;
|
||||
QVariantMap _modelTextures;
|
||||
|
||||
QUrl _url;
|
||||
glm::quat _rotation;
|
||||
|
@ -77,6 +77,14 @@ void Planar3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue Planar3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "dimensions" || property == "scale" || property == "size") {
|
||||
return vec2toScriptValue(_scriptEngine, _dimensions);
|
||||
}
|
||||
|
||||
Base3DOverlay::getProperty(property);
|
||||
}
|
||||
|
||||
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face) const {
|
||||
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
void setDimensions(const glm::vec2& value) { _dimensions = value; }
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face) const;
|
||||
|
||||
|
@ -179,4 +179,31 @@ void Text3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
|
||||
}
|
||||
|
||||
QScriptValue Text3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "text") {
|
||||
return _text;
|
||||
}
|
||||
if (property == "backgroundColor") {
|
||||
return xColorToScriptValue(_scriptEngine, _backgroundColor);
|
||||
}
|
||||
if (property == "lineHeight") {
|
||||
return _lineHeight;
|
||||
}
|
||||
if (property == "leftMargin") {
|
||||
return _leftMargin;
|
||||
}
|
||||
if (property == "topMargin") {
|
||||
return _topMargin;
|
||||
}
|
||||
if (property == "rightMargin") {
|
||||
return _rightMargin;
|
||||
}
|
||||
if (property == "bottomMargin") {
|
||||
return _bottomMargin;
|
||||
}
|
||||
if (property == "isFacingAvatar") {
|
||||
return _isFacingAvatar;
|
||||
}
|
||||
|
||||
return Planar3DOverlay::getProperty(property);
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
void setIsFacingAvatar(bool isFacingAvatar) { _isFacingAvatar = isFacingAvatar; }
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
private:
|
||||
void enableClipPlane(GLenum plane, float x, float y, float z, float w);
|
||||
|
@ -85,6 +85,14 @@ void Volume3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue Volume3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "dimensions" || property == "scale" || property == "size") {
|
||||
return vec3toScriptValue(_scriptEngine, _dimensions);
|
||||
}
|
||||
|
||||
return Base3DOverlay::getProperty(property);
|
||||
}
|
||||
|
||||
bool Volume3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face) const {
|
||||
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
void setDimensions(const glm::vec3& value) { _dimensions = value; }
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user