mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +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
|
||||
},
|
||||
skybox: {
|
||||
color: { red: 255, green: 0, blue: 0 },
|
||||
url: "http://google.com"
|
||||
color: { red: 255, green: 0, blue: 255 },
|
||||
url: ""
|
||||
},
|
||||
stageLatitude: 37.777,
|
||||
stageLongitude: 122.407,
|
||||
|
|
|
@ -445,7 +445,22 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
|||
data.setSunBrightness(sunBrightness);
|
||||
|
||||
_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 {
|
||||
if (_hasPreviousZone) {
|
||||
scene->setKeyLightColor(_previousKeyLightColor);
|
||||
|
@ -460,6 +475,7 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
|||
_hasPreviousZone = false;
|
||||
}
|
||||
_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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -249,7 +249,7 @@ void addBackgroundMode(BackgroundMode type) {
|
|||
void buildStringToBackgroundModeLookup() {
|
||||
addBackgroundMode(BACKGROUND_MODE_INHERIT);
|
||||
addBackgroundMode(BACKGROUND_MODE_ATMOSPHERE);
|
||||
addBackgroundMode(BACKGROUND_MODE_TEXTURE);
|
||||
addBackgroundMode(BACKGROUND_MODE_SKYBOX);
|
||||
}
|
||||
|
||||
QString EntityItemProperties::getBackgroundModeAsString() const {
|
||||
|
|
|
@ -118,12 +118,10 @@
|
|||
|
||||
#define READ_ENTITY_PROPERTY_XCOLOR(P,M) \
|
||||
if (propertyFlags.getHasProperty(P)) { \
|
||||
rgbColor temp; \
|
||||
if (overwriteLocalData) { \
|
||||
memcpy(temp, dataAt, sizeof(temp)); \
|
||||
M.red = temp[RED_INDEX]; \
|
||||
M.green = temp[GREEN_INDEX]; \
|
||||
M.blue = temp[BLUE_INDEX]; \
|
||||
M.red = dataAt[RED_INDEX]; \
|
||||
M.green = dataAt[GREEN_INDEX]; \
|
||||
M.blue = dataAt[BLUE_INDEX]; \
|
||||
} \
|
||||
dataAt += sizeof(rgbColor); \
|
||||
bytesRead += sizeof(rgbColor); \
|
||||
|
|
|
@ -160,7 +160,7 @@ extern EntityPropertyList PROP_LAST_ITEM;
|
|||
enum BackgroundMode {
|
||||
BACKGROUND_MODE_INHERIT,
|
||||
BACKGROUND_MODE_ATMOSPHERE,
|
||||
BACKGROUND_MODE_TEXTURE,
|
||||
BACKGROUND_MODE_SKYBOX,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,14 @@ public:
|
|||
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args,
|
||||
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);
|
||||
|
|
|
@ -167,11 +167,17 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
|||
READ_ENTITY_PROPERTY_SETTER(PROP_SHAPE_TYPE, ShapeType, updateShapeType);
|
||||
READ_ENTITY_PROPERTY_STRING(PROP_COMPOUND_SHAPE_URL, setCompoundShapeURL);
|
||||
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);
|
||||
bytesRead += bytesFromSkybox;
|
||||
dataAt += bytesFromSkybox;
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,8 @@ public:
|
|||
BackgroundMode getBackgroundMode() const { return _backgroundMode; }
|
||||
|
||||
EnvironmentData getEnvironmentData() const;
|
||||
const AtmospherePropertyGroup& getAtmosphereProperties() const { return _atmosphereProperties; }
|
||||
const SkyboxPropertyGroup& getSkyboxProperties() const { return _skyboxProperties; }
|
||||
|
||||
virtual bool supportsDetailedRayIntersection() const { return true; }
|
||||
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
|
|
|
@ -41,10 +41,13 @@ void Skybox::setCubemap(const gpu::TexturePointer& cubemap) {
|
|||
_cubemap = cubemap;
|
||||
}
|
||||
|
||||
void Skybox::clearCubemap() {
|
||||
_cubemap.reset();
|
||||
}
|
||||
|
||||
void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Skybox& skybox) {
|
||||
|
||||
if (skybox.getCubemap()) {
|
||||
|
||||
static gpu::PipelinePointer thePipeline;
|
||||
static gpu::BufferPointer theBuffer;
|
||||
static gpu::Stream::FormatPointer theFormat;
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
|
||||
void setCubemap(const gpu::TexturePointer& cubemap);
|
||||
const gpu::TexturePointer& getCubemap() const { return _cubemap; }
|
||||
void clearCubemap();
|
||||
|
||||
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_FLAGS = 1;
|
||||
typedef unsigned char rgbColor[BYTES_PER_COLOR];
|
||||
typedef unsigned char colorPart;
|
||||
typedef unsigned char nodeColor[BYTES_PER_COLOR + BYTES_PER_FLAGS];
|
||||
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 {
|
||||
unsigned char red;
|
||||
unsigned char green;
|
||||
|
|
Loading…
Reference in a new issue