mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Removed background mode from code (still in the protocol).
This commit is contained in:
parent
1e2413bade
commit
adbc4d0c39
5 changed files with 319 additions and 8 deletions
|
@ -385,7 +385,6 @@ void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer&
|
|||
setSkyboxMode((ComponentMode)entity->getSkyboxMode());
|
||||
|
||||
editBackground();
|
||||
setBackgroundMode(entity->getBackgroundMode());
|
||||
setSkyboxColor(_skyboxProperties.getColorVec3());
|
||||
setProceduralUserData(entity->getUserData());
|
||||
setSkyboxURL(_skyboxProperties.getURL());
|
||||
|
|
|
@ -62,7 +62,6 @@ EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredPr
|
|||
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(compoundShapeURL, getCompoundShapeURL);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(backgroundMode, getBackgroundMode);
|
||||
|
||||
// Contains a QString property, must be synchronized
|
||||
withReadLock([&] {
|
||||
|
@ -116,7 +115,6 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie
|
|||
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, setShapeType);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(backgroundMode, setBackgroundMode);
|
||||
|
||||
// Contains a QString property, must be synchronized
|
||||
withWriteLock([&] {
|
||||
|
@ -175,7 +173,6 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
|||
|
||||
READ_ENTITY_PROPERTY(PROP_SHAPE_TYPE, ShapeType, setShapeType);
|
||||
READ_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL);
|
||||
READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode);
|
||||
|
||||
int bytesFromSkybox;
|
||||
withWriteLock([&] {
|
||||
|
@ -265,7 +262,6 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
|
|||
|
||||
APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)getShapeType());
|
||||
APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, getCompoundShapeURL());
|
||||
APPEND_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, (uint32_t)getBackgroundMode()); // could this be a uint16??
|
||||
|
||||
_skyboxProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties,
|
||||
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||
|
|
|
@ -69,9 +69,6 @@ public:
|
|||
KeyLightPropertyGroup getKeyLightProperties() const { return resultWithReadLock<KeyLightPropertyGroup>([&] { return _keyLightProperties; }); }
|
||||
AmbientLightPropertyGroup getAmbientLightProperties() const { return resultWithReadLock<AmbientLightPropertyGroup>([&] { return _ambientLightProperties; }); }
|
||||
|
||||
void setBackgroundMode(BackgroundMode value) { _backgroundMode = value; _backgroundPropertiesChanged = true; }
|
||||
BackgroundMode getBackgroundMode() const { return _backgroundMode; }
|
||||
|
||||
void setHazeMode(const uint32_t value);
|
||||
uint32_t getHazeMode() const;
|
||||
|
||||
|
|
153
libraries/script-engine/src/SceneScriptingInterface.cpp
Normal file
153
libraries/script-engine/src/SceneScriptingInterface.cpp
Normal file
|
@ -0,0 +1,153 @@
|
|||
//
|
||||
// SceneScriptingInterface.cpp
|
||||
// libraries/script-engine
|
||||
//
|
||||
// Created by Sam Gateau on 2/24/15.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "SceneScriptingInterface.h"
|
||||
|
||||
#include <procedural/ProceduralSkybox.h>
|
||||
|
||||
float SceneScripting::Location::getLongitude() const {
|
||||
return _skyStage->getOriginLongitude();
|
||||
}
|
||||
|
||||
float SceneScripting::Location::getLatitude() const {
|
||||
return _skyStage->getOriginLatitude();
|
||||
}
|
||||
|
||||
float SceneScripting::Location::getAltitude() const {
|
||||
return _skyStage->getOriginSurfaceAltitude();
|
||||
}
|
||||
|
||||
void SceneScripting::Location::setLongitude(float longitude) {
|
||||
_skyStage->setOriginLongitude(longitude);
|
||||
}
|
||||
|
||||
void SceneScripting::Location::setLatitude(float latitude) {
|
||||
_skyStage->setOriginLatitude(latitude);
|
||||
}
|
||||
|
||||
void SceneScripting::Location::setAltitude(float altitude) {
|
||||
_skyStage->setOriginSurfaceAltitude(altitude);
|
||||
}
|
||||
|
||||
void SceneScripting::Time::setHour(float hour) {
|
||||
_skyStage->setDayTime(hour);
|
||||
}
|
||||
|
||||
float SceneScripting::Time::getHour() const {
|
||||
return _skyStage->getDayTime();
|
||||
}
|
||||
|
||||
void SceneScripting::Time::setDay(int day) {
|
||||
_skyStage->setYearTime(day);
|
||||
}
|
||||
|
||||
int SceneScripting::Time::getDay() const {
|
||||
return _skyStage->getYearTime();
|
||||
}
|
||||
|
||||
glm::vec3 SceneScripting::KeyLight::getColor() const {
|
||||
return _skyStage->getSunColor();
|
||||
}
|
||||
|
||||
void SceneScripting::KeyLight::setColor(const glm::vec3& color) {
|
||||
_skyStage->setSunColor(color);
|
||||
}
|
||||
|
||||
float SceneScripting::KeyLight::getIntensity() const {
|
||||
return _skyStage->getSunIntensity();
|
||||
}
|
||||
|
||||
void SceneScripting::KeyLight::setIntensity(float intensity) {
|
||||
_skyStage->setSunIntensity(intensity);
|
||||
}
|
||||
|
||||
float SceneScripting::KeyLight::getAmbientIntensity() const {
|
||||
return _skyStage->getSunAmbientIntensity();
|
||||
}
|
||||
|
||||
void SceneScripting::KeyLight::setAmbientIntensity(float intensity) {
|
||||
_skyStage->setSunAmbientIntensity(intensity);
|
||||
}
|
||||
|
||||
void SceneScripting::KeyLight::setAmbientSphere(const gpu::SHPointer& sphere) {
|
||||
_skyStage->setSunAmbientSphere(sphere);
|
||||
}
|
||||
|
||||
void SceneScripting::KeyLight::setAmbientMap(const gpu::TexturePointer& map) {
|
||||
_skyStage->setSunAmbientMap(map);
|
||||
}
|
||||
|
||||
|
||||
glm::vec3 SceneScripting::KeyLight::getDirection() const {
|
||||
return _skyStage->getSunDirection();
|
||||
}
|
||||
|
||||
void SceneScripting::KeyLight::setDirection(const glm::vec3& direction) {
|
||||
_skyStage->setSunDirection(direction);
|
||||
}
|
||||
|
||||
void SceneScripting::Stage::setOrientation(const glm::quat& orientation) const {
|
||||
_skyStage->setOriginOrientation(orientation);
|
||||
}
|
||||
|
||||
void SceneScripting::Stage::setLocation(float longitude, float latitude, float altitude) {
|
||||
_skyStage->setOriginLocation(longitude, latitude, altitude);
|
||||
}
|
||||
|
||||
void SceneScripting::Stage::setSunModelEnable(bool isEnabled) {
|
||||
_skyStage->setSunModelEnable(isEnabled);
|
||||
}
|
||||
|
||||
bool SceneScripting::Stage::isSunModelEnabled() const {
|
||||
return _skyStage->isSunModelEnabled();
|
||||
}
|
||||
|
||||
void SceneScripting::Stage::setBackgroundMode(const QString& mode) {
|
||||
if (mode == QString("inherit")) {
|
||||
_skyStage->setBackgroundMode(model::SunSkyStage::NO_BACKGROUND);
|
||||
} else if (mode == QString("skybox")) {
|
||||
_skyStage->setBackgroundMode(model::SunSkyStage::SKY_BOX);
|
||||
}
|
||||
}
|
||||
|
||||
QString SceneScripting::Stage::getBackgroundMode() const {
|
||||
switch (_skyStage->getBackgroundMode()) {
|
||||
case model::SunSkyStage::NO_BACKGROUND:
|
||||
return QString("inherit");
|
||||
case model::SunSkyStage::SKY_BOX:
|
||||
return QString("skybox");
|
||||
default:
|
||||
return QString("inherit");
|
||||
};
|
||||
}
|
||||
|
||||
SceneScriptingInterface::SceneScriptingInterface() : _stage{ new SceneScripting::Stage{ _skyStage } } {
|
||||
// Let's make sure the sunSkyStage is using a proceduralSkybox
|
||||
_skyStage->setSkybox(model::SkyboxPointer(new ProceduralSkybox()));
|
||||
}
|
||||
|
||||
void SceneScriptingInterface::setShouldRenderAvatars(bool shouldRenderAvatars) {
|
||||
if (shouldRenderAvatars != _shouldRenderAvatars) {
|
||||
_shouldRenderAvatars = shouldRenderAvatars;
|
||||
emit shouldRenderAvatarsChanged(_shouldRenderAvatars);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneScriptingInterface::setShouldRenderEntities(bool shouldRenderEntities) {
|
||||
if (shouldRenderEntities != _shouldRenderEntities) {
|
||||
_shouldRenderEntities = shouldRenderEntities;
|
||||
emit shouldRenderEntitiesChanged(_shouldRenderEntities);
|
||||
}
|
||||
}
|
||||
|
||||
model::SunSkyStagePointer SceneScriptingInterface::getSkyStage() const {
|
||||
return _skyStage;
|
||||
}
|
166
libraries/script-engine/src/SceneScriptingInterface.h
Normal file
166
libraries/script-engine/src/SceneScriptingInterface.h
Normal file
|
@ -0,0 +1,166 @@
|
|||
//
|
||||
// SceneScriptingInterface.h
|
||||
// libraries/script-engine
|
||||
//
|
||||
// Created by Sam Gateau on 2/24/15.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_SceneScriptingInterface_h
|
||||
#define hifi_SceneScriptingInterface_h
|
||||
|
||||
#include <qscriptengine.h> // QObject
|
||||
#include <DependencyManager.h> // Dependency
|
||||
|
||||
#include "model/Stage.h"
|
||||
|
||||
// TODO: if QT moc ever supports nested classes, subclass these to the interface instead of namespacing
|
||||
namespace SceneScripting {
|
||||
class Location : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Location(model::SunSkyStagePointer skyStage) : _skyStage{ skyStage } {}
|
||||
|
||||
Q_PROPERTY(float longitude READ getLongitude WRITE setLongitude)
|
||||
Q_PROPERTY(float latitude READ getLatitude WRITE setLatitude)
|
||||
Q_PROPERTY(float altitude READ getAltitude WRITE setAltitude)
|
||||
|
||||
float getLongitude() const;
|
||||
float getLatitude() const;
|
||||
float getAltitude() const;
|
||||
void setLongitude(float longitude);
|
||||
void setLatitude(float latitude);
|
||||
void setAltitude(float altitude);
|
||||
|
||||
protected:
|
||||
model::SunSkyStagePointer _skyStage;
|
||||
};
|
||||
using LocationPointer = std::unique_ptr<Location>;
|
||||
|
||||
class Time : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Time(model::SunSkyStagePointer skyStage) : _skyStage{ skyStage } {}
|
||||
|
||||
Q_PROPERTY(float hour READ getHour WRITE setHour)
|
||||
Q_PROPERTY(int day READ getDay WRITE setDay)
|
||||
|
||||
float getHour() const;
|
||||
void setHour(float hour);
|
||||
int getDay() const;
|
||||
void setDay(int day);
|
||||
|
||||
protected:
|
||||
model::SunSkyStagePointer _skyStage;
|
||||
};
|
||||
using TimePointer = std::unique_ptr<Time>;
|
||||
|
||||
class KeyLight : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KeyLight(model::SunSkyStagePointer skyStage) : _skyStage{ skyStage } {}
|
||||
|
||||
Q_PROPERTY(glm::vec3 color READ getColor WRITE setColor)
|
||||
Q_PROPERTY(float intensity READ getIntensity WRITE setIntensity)
|
||||
Q_PROPERTY(float ambientIntensity READ getAmbientIntensity WRITE setAmbientIntensity)
|
||||
Q_PROPERTY(glm::vec3 direction READ getDirection WRITE setDirection)
|
||||
|
||||
glm::vec3 getColor() const;
|
||||
void setColor(const glm::vec3& color);
|
||||
float getIntensity() const;
|
||||
void setIntensity(float intensity);
|
||||
float getAmbientIntensity() const;
|
||||
void setAmbientIntensity(float intensity);
|
||||
glm::vec3 getDirection() const;
|
||||
// setDirection is only effective if stage Sun model is disabled
|
||||
void setDirection(const glm::vec3& direction);
|
||||
|
||||
// AmbientTexture is unscriptable - it must be set through the zone entity
|
||||
void setAmbientSphere(const gpu::SHPointer& sphere);
|
||||
void resetAmbientSphere() { setAmbientSphere(nullptr); }
|
||||
void setAmbientMap(const gpu::TexturePointer& map);
|
||||
|
||||
protected:
|
||||
model::SunSkyStagePointer _skyStage;
|
||||
};
|
||||
using KeyLightPointer = std::unique_ptr<KeyLight>;
|
||||
|
||||
class Stage : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Stage(model::SunSkyStagePointer skyStage)
|
||||
: _skyStage{ skyStage },
|
||||
_location{ new Location{ skyStage } }, _time{ new Time{ skyStage } }, _keyLight{ new KeyLight{ skyStage } }{}
|
||||
|
||||
Q_INVOKABLE void setOrientation(const glm::quat& orientation) const;
|
||||
|
||||
Q_PROPERTY(Location* location READ getLocation)
|
||||
Location* getLocation() const { return _location.get(); }
|
||||
Q_INVOKABLE void setLocation(float longitude, float latitude, float altitude);
|
||||
|
||||
Q_PROPERTY(Time* time READ getTime)
|
||||
Time* getTime() const { return _time.get(); }
|
||||
|
||||
Q_PROPERTY(KeyLight* keyLight READ getKeyLight)
|
||||
KeyLight* getKeyLight() const { return _keyLight.get(); }
|
||||
|
||||
// Enable/disable the stage sun model which uses the key light to simulate
|
||||
// the sun light based on the location of the stage relative to earth and the current time
|
||||
Q_PROPERTY(bool sunModel READ isSunModelEnabled WRITE setSunModelEnable)
|
||||
void setSunModelEnable(bool isEnabled);
|
||||
bool isSunModelEnabled() const;
|
||||
|
||||
Q_PROPERTY(QString backgroundMode READ getBackgroundMode WRITE setBackgroundMode)
|
||||
void setBackgroundMode(const QString& mode);
|
||||
QString getBackgroundMode() const;
|
||||
|
||||
protected:
|
||||
model::SunSkyStagePointer _skyStage;
|
||||
LocationPointer _location;
|
||||
TimePointer _time;
|
||||
KeyLightPointer _keyLight;
|
||||
};
|
||||
using StagePointer = std::unique_ptr<Stage>;
|
||||
};
|
||||
|
||||
class SceneScriptingInterface : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
|
||||
public:
|
||||
Q_PROPERTY(bool shouldRenderAvatars READ shouldRenderAvatars WRITE setShouldRenderAvatars)
|
||||
Q_PROPERTY(bool shouldRenderEntities READ shouldRenderEntities WRITE setShouldRenderEntities)
|
||||
bool shouldRenderAvatars() const { return _shouldRenderAvatars; }
|
||||
bool shouldRenderEntities() const { return _shouldRenderEntities; }
|
||||
void setShouldRenderAvatars(bool shouldRenderAvatars);
|
||||
void setShouldRenderEntities(bool shouldRenderEntities);
|
||||
|
||||
Q_PROPERTY(SceneScripting::Stage* stage READ getStage)
|
||||
SceneScripting::Stage* getStage() const { return _stage.get(); }
|
||||
|
||||
model::SunSkyStagePointer getSkyStage() const;
|
||||
|
||||
signals:
|
||||
void shouldRenderAvatarsChanged(bool shouldRenderAvatars);
|
||||
void shouldRenderEntitiesChanged(bool shouldRenderEntities);
|
||||
|
||||
protected:
|
||||
SceneScriptingInterface();
|
||||
~SceneScriptingInterface() {};
|
||||
|
||||
model::SunSkyStagePointer _skyStage = std::make_shared<model::SunSkyStage>();
|
||||
SceneScripting::StagePointer _stage;
|
||||
|
||||
bool _shouldRenderAvatars = true;
|
||||
bool _shouldRenderEntities = true;
|
||||
};
|
||||
|
||||
#endif // hifi_SceneScriptingInterface_h
|
Loading…
Reference in a new issue