mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:30:42 +02:00
wire up the skybox color property to the new skybox renderer
This commit is contained in:
parent
af2c3d91cf
commit
496da6fcd5
11 changed files with 57 additions and 15 deletions
|
@ -34,8 +34,8 @@ var zoneEntityA = Entities.addEntity({
|
||||||
hasStars: false
|
hasStars: false
|
||||||
},
|
},
|
||||||
skybox: {
|
skybox: {
|
||||||
color: { red: 255, green: 0, blue: 0 },
|
color: { red: 255, green: 0, blue: 255 },
|
||||||
url: "http://google.com"
|
url: ""
|
||||||
},
|
},
|
||||||
stageLatitude: 37.777,
|
stageLatitude: 37.777,
|
||||||
stageLongitude: 122.407,
|
stageLongitude: 122.407,
|
||||||
|
|
|
@ -445,7 +445,22 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
||||||
data.setSunBrightness(sunBrightness);
|
data.setSunBrightness(sunBrightness);
|
||||||
|
|
||||||
_viewState->overrideEnvironmentData(data);
|
_viewState->overrideEnvironmentData(data);
|
||||||
|
scene->getSkyStage()->setBackgroundMode(model::SunSkyStage::SKY_DOME);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_viewState->endOverrideEnvironmentData();
|
||||||
|
if (_bestZone->getBackgroundMode() == BACKGROUND_MODE_SKYBOX) {
|
||||||
|
auto stage = scene->getSkyStage();
|
||||||
|
stage->getSkybox()->setColor(_bestZone->getSkyboxProperties().getColorVec3());
|
||||||
|
if (_bestZone->getSkyboxProperties().getURL().isEmpty()) {
|
||||||
|
stage->getSkybox()->clearCubemap();
|
||||||
|
} else {
|
||||||
|
stage->getSkybox()->clearCubemap(); // NOTE: this should be changed to do something to set the cubemap
|
||||||
|
}
|
||||||
|
stage->setBackgroundMode(model::SunSkyStage::SKY_BOX);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (_hasPreviousZone) {
|
if (_hasPreviousZone) {
|
||||||
scene->setKeyLightColor(_previousKeyLightColor);
|
scene->setKeyLightColor(_previousKeyLightColor);
|
||||||
|
@ -460,6 +475,7 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
||||||
_hasPreviousZone = false;
|
_hasPreviousZone = false;
|
||||||
}
|
}
|
||||||
_viewState->endOverrideEnvironmentData();
|
_viewState->endOverrideEnvironmentData();
|
||||||
|
scene->getSkyStage()->setBackgroundMode(model::SunSkyStage::SKY_DOME);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we must call endScene while we still have the tree locked so that no one deletes a model
|
// we must call endScene while we still have the tree locked so that no one deletes a model
|
||||||
|
|
|
@ -238,7 +238,7 @@ void EntityItemProperties::setShapeTypeFromString(const QString& shapeName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* backgroundModeNames[] = {"inherit", "atmosphere", "texture" };
|
const char* backgroundModeNames[] = {"inherit", "atmosphere", "skybox" };
|
||||||
|
|
||||||
QHash<QString, BackgroundMode> stringToBackgroundModeLookup;
|
QHash<QString, BackgroundMode> stringToBackgroundModeLookup;
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ void addBackgroundMode(BackgroundMode type) {
|
||||||
void buildStringToBackgroundModeLookup() {
|
void buildStringToBackgroundModeLookup() {
|
||||||
addBackgroundMode(BACKGROUND_MODE_INHERIT);
|
addBackgroundMode(BACKGROUND_MODE_INHERIT);
|
||||||
addBackgroundMode(BACKGROUND_MODE_ATMOSPHERE);
|
addBackgroundMode(BACKGROUND_MODE_ATMOSPHERE);
|
||||||
addBackgroundMode(BACKGROUND_MODE_TEXTURE);
|
addBackgroundMode(BACKGROUND_MODE_SKYBOX);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EntityItemProperties::getBackgroundModeAsString() const {
|
QString EntityItemProperties::getBackgroundModeAsString() const {
|
||||||
|
|
|
@ -118,12 +118,10 @@
|
||||||
|
|
||||||
#define READ_ENTITY_PROPERTY_XCOLOR(P,M) \
|
#define READ_ENTITY_PROPERTY_XCOLOR(P,M) \
|
||||||
if (propertyFlags.getHasProperty(P)) { \
|
if (propertyFlags.getHasProperty(P)) { \
|
||||||
rgbColor temp; \
|
|
||||||
if (overwriteLocalData) { \
|
if (overwriteLocalData) { \
|
||||||
memcpy(temp, dataAt, sizeof(temp)); \
|
M.red = dataAt[RED_INDEX]; \
|
||||||
M.red = temp[RED_INDEX]; \
|
M.green = dataAt[GREEN_INDEX]; \
|
||||||
M.green = temp[GREEN_INDEX]; \
|
M.blue = dataAt[BLUE_INDEX]; \
|
||||||
M.blue = temp[BLUE_INDEX]; \
|
|
||||||
} \
|
} \
|
||||||
dataAt += sizeof(rgbColor); \
|
dataAt += sizeof(rgbColor); \
|
||||||
bytesRead += sizeof(rgbColor); \
|
bytesRead += sizeof(rgbColor); \
|
||||||
|
|
|
@ -160,7 +160,7 @@ extern EntityPropertyList PROP_LAST_ITEM;
|
||||||
enum BackgroundMode {
|
enum BackgroundMode {
|
||||||
BACKGROUND_MODE_INHERIT,
|
BACKGROUND_MODE_INHERIT,
|
||||||
BACKGROUND_MODE_ATMOSPHERE,
|
BACKGROUND_MODE_ATMOSPHERE,
|
||||||
BACKGROUND_MODE_TEXTURE,
|
BACKGROUND_MODE_SKYBOX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,14 @@ public:
|
||||||
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||||
ReadBitstreamToTreeParams& args,
|
ReadBitstreamToTreeParams& args,
|
||||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData);
|
EntityPropertyFlags& propertyFlags, bool overwriteLocalData);
|
||||||
|
|
||||||
|
glm::vec3 getColorVec3() const {
|
||||||
|
const quint8 MAX_COLOR = 255;
|
||||||
|
glm::vec3 color = { (float)_color.red / (float)MAX_COLOR,
|
||||||
|
(float)_color.green / (float)MAX_COLOR,
|
||||||
|
(float)_color.blue / (float)MAX_COLOR };
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DEFINE_PROPERTY_REF(PROP_SKYBOX_COLOR, Color, color, xColor);
|
DEFINE_PROPERTY_REF(PROP_SKYBOX_COLOR, Color, color, xColor);
|
||||||
|
|
|
@ -167,11 +167,17 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
READ_ENTITY_PROPERTY_SETTER(PROP_SHAPE_TYPE, ShapeType, updateShapeType);
|
READ_ENTITY_PROPERTY_SETTER(PROP_SHAPE_TYPE, ShapeType, updateShapeType);
|
||||||
READ_ENTITY_PROPERTY_STRING(PROP_COMPOUND_SHAPE_URL, setCompoundShapeURL);
|
READ_ENTITY_PROPERTY_STRING(PROP_COMPOUND_SHAPE_URL, setCompoundShapeURL);
|
||||||
READ_ENTITY_PROPERTY_SETTER(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode);
|
READ_ENTITY_PROPERTY_SETTER(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode);
|
||||||
bytesRead += _atmosphereProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
|
||||||
propertyFlags, overwriteLocalData);
|
|
||||||
|
|
||||||
bytesRead += _skyboxProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
int bytesFromAtmosphere = _atmosphereProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
|
propertyFlags, overwriteLocalData);
|
||||||
|
|
||||||
|
bytesRead += bytesFromAtmosphere;
|
||||||
|
dataAt += bytesFromAtmosphere;
|
||||||
|
|
||||||
|
int bytesFromSkybox = _skyboxProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
propertyFlags, overwriteLocalData);
|
propertyFlags, overwriteLocalData);
|
||||||
|
bytesRead += bytesFromSkybox;
|
||||||
|
dataAt += bytesFromSkybox;
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,8 @@ public:
|
||||||
BackgroundMode getBackgroundMode() const { return _backgroundMode; }
|
BackgroundMode getBackgroundMode() const { return _backgroundMode; }
|
||||||
|
|
||||||
EnvironmentData getEnvironmentData() const;
|
EnvironmentData getEnvironmentData() const;
|
||||||
|
const AtmospherePropertyGroup& getAtmosphereProperties() const { return _atmosphereProperties; }
|
||||||
|
const SkyboxPropertyGroup& getSkyboxProperties() const { return _skyboxProperties; }
|
||||||
|
|
||||||
virtual bool supportsDetailedRayIntersection() const { return true; }
|
virtual bool supportsDetailedRayIntersection() const { return true; }
|
||||||
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
|
|
|
@ -41,10 +41,13 @@ void Skybox::setCubemap(const gpu::TexturePointer& cubemap) {
|
||||||
_cubemap = cubemap;
|
_cubemap = cubemap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Skybox::clearCubemap() {
|
||||||
|
_cubemap.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Skybox& skybox) {
|
void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Skybox& skybox) {
|
||||||
|
|
||||||
if (skybox.getCubemap()) {
|
if (skybox.getCubemap()) {
|
||||||
|
|
||||||
static gpu::PipelinePointer thePipeline;
|
static gpu::PipelinePointer thePipeline;
|
||||||
static gpu::BufferPointer theBuffer;
|
static gpu::BufferPointer theBuffer;
|
||||||
static gpu::Stream::FormatPointer theFormat;
|
static gpu::Stream::FormatPointer theFormat;
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
|
|
||||||
void setCubemap(const gpu::TexturePointer& cubemap);
|
void setCubemap(const gpu::TexturePointer& cubemap);
|
||||||
const gpu::TexturePointer& getCubemap() const { return _cubemap; }
|
const gpu::TexturePointer& getCubemap() const { return _cubemap; }
|
||||||
|
void clearCubemap();
|
||||||
|
|
||||||
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox);
|
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox);
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,19 @@
|
||||||
|
|
||||||
const int BYTES_PER_COLOR = 3;
|
const int BYTES_PER_COLOR = 3;
|
||||||
const int BYTES_PER_FLAGS = 1;
|
const int BYTES_PER_FLAGS = 1;
|
||||||
typedef unsigned char rgbColor[BYTES_PER_COLOR];
|
|
||||||
typedef unsigned char colorPart;
|
typedef unsigned char colorPart;
|
||||||
typedef unsigned char nodeColor[BYTES_PER_COLOR + BYTES_PER_FLAGS];
|
typedef unsigned char nodeColor[BYTES_PER_COLOR + BYTES_PER_FLAGS];
|
||||||
typedef unsigned char rgbColor[BYTES_PER_COLOR];
|
typedef unsigned char rgbColor[BYTES_PER_COLOR];
|
||||||
|
|
||||||
|
inline QDebug& operator<<(QDebug& dbg, const rgbColor& c) {
|
||||||
|
dbg.nospace() << "{type='rgbColor'"
|
||||||
|
", red=" << c[0] <<
|
||||||
|
", green=" << c[1] <<
|
||||||
|
", blue=" << c[2] <<
|
||||||
|
"}";
|
||||||
|
return dbg;
|
||||||
|
}
|
||||||
|
|
||||||
struct xColor {
|
struct xColor {
|
||||||
unsigned char red;
|
unsigned char red;
|
||||||
unsigned char green;
|
unsigned char green;
|
||||||
|
|
Loading…
Reference in a new issue