mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
Merge pull request #4830 from ZappoMan/moreZoneProperties
New Zone Features
This commit is contained in:
commit
9bf4cf1262
11 changed files with 110 additions and 3 deletions
|
@ -1030,8 +1030,11 @@ function importSVO(importURL) {
|
||||||
var success = Clipboard.importEntities(importURL);
|
var success = Clipboard.importEntities(importURL);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
var position = getPositionToCreateEntity();
|
var VERY_LARGE = 10000;
|
||||||
|
var position = { x: 0, y: 0, z: 0};
|
||||||
|
if (Clipboard.getClipboardContentsLargestDimension() < VERY_LARGE) {
|
||||||
|
position = getPositionToCreateEntity();
|
||||||
|
}
|
||||||
var pastedEntityIDs = Clipboard.pasteEntities(position);
|
var pastedEntityIDs = Clipboard.pasteEntities(position);
|
||||||
|
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
|
@ -1295,6 +1298,25 @@ PropertiesTool = function(opts) {
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
selectionManager._update();
|
selectionManager._update();
|
||||||
}
|
}
|
||||||
|
} else if (data.action == "centerAtmosphereToZone") {
|
||||||
|
if (selectionManager.hasSelection()) {
|
||||||
|
selectionManager.saveProperties();
|
||||||
|
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||||
|
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
||||||
|
if (properties.type == "Zone") {
|
||||||
|
var centerOfZone = properties.boundingBox.center;
|
||||||
|
var atmosphereCenter = { x: centerOfZone.x,
|
||||||
|
y: centerOfZone.y - properties.atmosphere.innerRadius,
|
||||||
|
z: centerOfZone.z };
|
||||||
|
|
||||||
|
Entities.editEntity(selectionManager.selections[i], {
|
||||||
|
atmosphere: { center: atmosphereCenter },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pushCommandForSelections();
|
||||||
|
selectionManager._update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -300,6 +300,8 @@
|
||||||
var elZoneAtmosphereCenterX = document.getElementById("property-zone-atmosphere-center-x");
|
var elZoneAtmosphereCenterX = document.getElementById("property-zone-atmosphere-center-x");
|
||||||
var elZoneAtmosphereCenterY = document.getElementById("property-zone-atmosphere-center-y");
|
var elZoneAtmosphereCenterY = document.getElementById("property-zone-atmosphere-center-y");
|
||||||
var elZoneAtmosphereCenterZ = document.getElementById("property-zone-atmosphere-center-z");
|
var elZoneAtmosphereCenterZ = document.getElementById("property-zone-atmosphere-center-z");
|
||||||
|
var elCenterAtmosphereToZone = document.getElementById("center-atmosphere-in-zone");
|
||||||
|
|
||||||
var elZoneAtmosphereInnerRadius = document.getElementById("property-zone-atmosphere-inner-radius");
|
var elZoneAtmosphereInnerRadius = document.getElementById("property-zone-atmosphere-inner-radius");
|
||||||
var elZoneAtmosphereOuterRadius = document.getElementById("property-zone-atmosphere-outer-radius");
|
var elZoneAtmosphereOuterRadius = document.getElementById("property-zone-atmosphere-outer-radius");
|
||||||
var elZoneAtmosphereMieScattering = document.getElementById("property-zone-atmosphere-mie-scattering");
|
var elZoneAtmosphereMieScattering = document.getElementById("property-zone-atmosphere-mie-scattering");
|
||||||
|
@ -705,6 +707,12 @@
|
||||||
percentage: parseInt(elRescaleDimensionsPct.value),
|
percentage: parseInt(elRescaleDimensionsPct.value),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
elCenterAtmosphereToZone.addEventListener("click", function() {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "action",
|
||||||
|
action: "centerAtmosphereToZone",
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
window.onblur = function() {
|
window.onblur = function() {
|
||||||
// Fake a change event
|
// Fake a change event
|
||||||
|
@ -1156,6 +1164,9 @@
|
||||||
<div class="input-area">X <br><input class="coord" type='number' id="property-zone-atmosphere-center-x"></input></div>
|
<div class="input-area">X <br><input class="coord" type='number' id="property-zone-atmosphere-center-x"></input></div>
|
||||||
<div class="input-area">Y <br><input class="coord" type='number' id="property-zone-atmosphere-center-y"></input></div>
|
<div class="input-area">Y <br><input class="coord" type='number' id="property-zone-atmosphere-center-y"></input></div>
|
||||||
<div class="input-area">Z <br><input class="coord" type='number' id="property-zone-atmosphere-center-z"></input></div>
|
<div class="input-area">Z <br><input class="coord" type='number' id="property-zone-atmosphere-center-z"></input></div>
|
||||||
|
<div>
|
||||||
|
<input type="button" id="center-atmosphere-in-zone" value="Center to Zone">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="zone-section atmosphere-section property">
|
<div class="zone-section atmosphere-section property">
|
||||||
|
|
|
@ -3223,18 +3223,40 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
||||||
// compute starfield alpha based on distance from atmosphere
|
// compute starfield alpha based on distance from atmosphere
|
||||||
float alpha = 1.0f;
|
float alpha = 1.0f;
|
||||||
bool hasStars = true;
|
bool hasStars = true;
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
|
||||||
// TODO: handle this correctly for zones
|
// TODO: handle this correctly for zones
|
||||||
const EnvironmentData& closestData = _environment.getClosestData(theCamera.getPosition());
|
const EnvironmentData& closestData = _environment.getClosestData(theCamera.getPosition());
|
||||||
|
|
||||||
if (closestData.getHasStars()) {
|
if (closestData.getHasStars()) {
|
||||||
|
const float APPROXIMATE_DISTANCE_FROM_HORIZON = 0.1f;
|
||||||
|
const float DOUBLE_APPROXIMATE_DISTANCE_FROM_HORIZON = 0.2f;
|
||||||
|
|
||||||
|
glm::vec3 sunDirection = (getAvatarPosition() - closestData.getSunLocation())
|
||||||
|
/ closestData.getAtmosphereOuterRadius();
|
||||||
float height = glm::distance(theCamera.getPosition(), closestData.getAtmosphereCenter());
|
float height = glm::distance(theCamera.getPosition(), closestData.getAtmosphereCenter());
|
||||||
if (height < closestData.getAtmosphereInnerRadius()) {
|
if (height < closestData.getAtmosphereInnerRadius()) {
|
||||||
|
// If we're inside the atmosphere, then determine if our keyLight is below the horizon
|
||||||
alpha = 0.0f;
|
alpha = 0.0f;
|
||||||
|
|
||||||
|
if (sunDirection.y > -APPROXIMATE_DISTANCE_FROM_HORIZON) {
|
||||||
|
float directionY = glm::clamp(sunDirection.y,
|
||||||
|
-APPROXIMATE_DISTANCE_FROM_HORIZON, APPROXIMATE_DISTANCE_FROM_HORIZON)
|
||||||
|
+ APPROXIMATE_DISTANCE_FROM_HORIZON;
|
||||||
|
alpha = (directionY / DOUBLE_APPROXIMATE_DISTANCE_FROM_HORIZON);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (height < closestData.getAtmosphereOuterRadius()) {
|
} else if (height < closestData.getAtmosphereOuterRadius()) {
|
||||||
alpha = (height - closestData.getAtmosphereInnerRadius()) /
|
alpha = (height - closestData.getAtmosphereInnerRadius()) /
|
||||||
(closestData.getAtmosphereOuterRadius() - closestData.getAtmosphereInnerRadius());
|
(closestData.getAtmosphereOuterRadius() - closestData.getAtmosphereInnerRadius());
|
||||||
|
|
||||||
|
if (sunDirection.y > -APPROXIMATE_DISTANCE_FROM_HORIZON) {
|
||||||
|
float directionY = glm::clamp(sunDirection.y,
|
||||||
|
-APPROXIMATE_DISTANCE_FROM_HORIZON, APPROXIMATE_DISTANCE_FROM_HORIZON)
|
||||||
|
+ APPROXIMATE_DISTANCE_FROM_HORIZON;
|
||||||
|
alpha = (directionY / DOUBLE_APPROXIMATE_DISTANCE_FROM_HORIZON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hasStars = false;
|
hasStars = false;
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
ClipboardScriptingInterface::ClipboardScriptingInterface() {
|
ClipboardScriptingInterface::ClipboardScriptingInterface() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float ClipboardScriptingInterface::getClipboardContentsLargestDimension() {
|
||||||
|
return Application::getInstance()->getEntityClipboard()->getContentsLargestDimension();
|
||||||
|
}
|
||||||
|
|
||||||
bool ClipboardScriptingInterface::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs) {
|
bool ClipboardScriptingInterface::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs) {
|
||||||
return Application::getInstance()->exportEntities(filename, entityIDs);
|
return Application::getInstance()->exportEntities(filename, entityIDs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ signals:
|
||||||
void readyToImport();
|
void readyToImport();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
float getClipboardContentsLargestDimension(); /// returns the largest dimension of everything on the clipboard
|
||||||
bool importEntities(const QString& filename);
|
bool importEntities(const QString& filename);
|
||||||
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
|
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
|
||||||
bool exportEntities(const QString& filename, float x, float y, float z, float s);
|
bool exportEntities(const QString& filename, float x, float y, float z, float s);
|
||||||
|
|
|
@ -1068,6 +1068,27 @@ void EntityTree::debugDumpMap() {
|
||||||
qCDebug(entities) << "-----------------------------------------------------";
|
qCDebug(entities) << "-----------------------------------------------------";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ContentsDimensionOperator : public RecurseOctreeOperator {
|
||||||
|
public:
|
||||||
|
virtual bool preRecursion(OctreeElement* element);
|
||||||
|
virtual bool postRecursion(OctreeElement* element) { return true; }
|
||||||
|
float getLargestDimension() const { return _contentExtents.largestDimension(); }
|
||||||
|
private:
|
||||||
|
Extents _contentExtents;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ContentsDimensionOperator::preRecursion(OctreeElement* element) {
|
||||||
|
EntityTreeElement* entityTreeElement = static_cast<EntityTreeElement*>(element);
|
||||||
|
entityTreeElement->expandExtentsToContents(_contentExtents);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
float EntityTree::getContentsLargestDimension() {
|
||||||
|
ContentsDimensionOperator theOperator;
|
||||||
|
recurseTreeWithOperator(&theOperator);
|
||||||
|
return theOperator.getLargestDimension();
|
||||||
|
}
|
||||||
|
|
||||||
class DebugOperator : public RecurseOctreeOperator {
|
class DebugOperator : public RecurseOctreeOperator {
|
||||||
public:
|
public:
|
||||||
virtual bool preRecursion(OctreeElement* element);
|
virtual bool preRecursion(OctreeElement* element);
|
||||||
|
|
|
@ -166,6 +166,8 @@ public:
|
||||||
|
|
||||||
bool writeToMap(QVariantMap& entityDescription, OctreeElement* element, bool skipDefaultValues);
|
bool writeToMap(QVariantMap& entityDescription, OctreeElement* element, bool skipDefaultValues);
|
||||||
bool readFromMap(QVariantMap& entityDescription);
|
bool readFromMap(QVariantMap& entityDescription);
|
||||||
|
|
||||||
|
float getContentsLargestDimension();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deletingEntity(const EntityItemID& entityID);
|
void deletingEntity(const EntityItemID& entityID);
|
||||||
|
|
|
@ -819,6 +819,16 @@ bool EntityTreeElement::pruneChildren() {
|
||||||
return somethingPruned;
|
return somethingPruned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityTreeElement::expandExtentsToContents(Extents& extents) {
|
||||||
|
if (_entityItems->size()) {
|
||||||
|
for (uint16_t i = 0; i < _entityItems->size(); i++) {
|
||||||
|
EntityItem* entity = (*_entityItems)[i];
|
||||||
|
extents.add(entity->getAABox());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void EntityTreeElement::debugDump() {
|
void EntityTreeElement::debugDump() {
|
||||||
qCDebug(entities) << "EntityTreeElement...";
|
qCDebug(entities) << "EntityTreeElement...";
|
||||||
|
|
|
@ -196,6 +196,8 @@ public:
|
||||||
|
|
||||||
bool pruneChildren();
|
bool pruneChildren();
|
||||||
|
|
||||||
|
void expandExtentsToContents(Extents& extents);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void init(unsigned char * octalCode);
|
virtual void init(unsigned char * octalCode);
|
||||||
EntityTree* _myTree;
|
EntityTree* _myTree;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <glm/gtx/quaternion.hpp>
|
#include <glm/gtx/quaternion.hpp>
|
||||||
#include <glm/gtx/transform.hpp>
|
#include <glm/gtx/transform.hpp>
|
||||||
|
|
||||||
|
#include "AABox.h"
|
||||||
#include "Extents.h"
|
#include "Extents.h"
|
||||||
|
|
||||||
void Extents::reset() {
|
void Extents::reset() {
|
||||||
|
@ -37,6 +38,11 @@ void Extents::addPoint(const glm::vec3& point) {
|
||||||
maximum = glm::max(maximum, point);
|
maximum = glm::max(maximum, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Extents::add(const AABox& box) {
|
||||||
|
minimum = glm::min(minimum, box.getMinimumPoint());
|
||||||
|
maximum = glm::max(maximum, box.getMaximumPoint());
|
||||||
|
}
|
||||||
|
|
||||||
void Extents::rotate(const glm::quat& rotation) {
|
void Extents::rotate(const glm::quat& rotation) {
|
||||||
glm::vec3 bottomLeftNear(minimum.x, minimum.y, minimum.z);
|
glm::vec3 bottomLeftNear(minimum.x, minimum.y, minimum.z);
|
||||||
glm::vec3 bottomRightNear(maximum.x, minimum.y, minimum.z);
|
glm::vec3 bottomRightNear(maximum.x, minimum.y, minimum.z);
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "StreamUtils.h"
|
#include "StreamUtils.h"
|
||||||
|
|
||||||
|
class AABox;
|
||||||
|
|
||||||
class Extents {
|
class Extents {
|
||||||
public:
|
public:
|
||||||
/// set minimum and maximum to FLT_MAX and -FLT_MAX respectively
|
/// set minimum and maximum to FLT_MAX and -FLT_MAX respectively
|
||||||
|
@ -28,6 +30,10 @@ public:
|
||||||
/// expand current limits to contain other extents
|
/// expand current limits to contain other extents
|
||||||
void addExtents(const Extents& extents);
|
void addExtents(const Extents& extents);
|
||||||
|
|
||||||
|
/// \param aabox another intance of extents
|
||||||
|
/// expand current limits to contain other aabox
|
||||||
|
void add(const AABox& box);
|
||||||
|
|
||||||
/// \param point new point to compare against existing limits
|
/// \param point new point to compare against existing limits
|
||||||
/// compare point to current limits and expand them if necessary to contain point
|
/// compare point to current limits and expand them if necessary to contain point
|
||||||
void addPoint(const glm::vec3& point);
|
void addPoint(const glm::vec3& point);
|
||||||
|
|
Loading…
Reference in a new issue