mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:14:35 +02:00
wire up zone to environment atmosphere rendering
This commit is contained in:
parent
8c47736c3b
commit
4561c59203
9 changed files with 84 additions and 39 deletions
|
@ -3113,9 +3113,9 @@ 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;
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
|
||||||
|
// TODO: handle this correctly for zones
|
||||||
const EnvironmentData& closestData = _environment.getClosestData(theCamera.getPosition());
|
const EnvironmentData& closestData = _environment.getClosestData(theCamera.getPosition());
|
||||||
float height = glm::distance(theCamera.getPosition(),
|
float height = glm::distance(theCamera.getPosition(), closestData.getAtmosphereCenter());
|
||||||
closestData.getAtmosphereCenter(theCamera.getPosition()));
|
|
||||||
if (height < closestData.getAtmosphereInnerRadius()) {
|
if (height < closestData.getAtmosphereInnerRadius()) {
|
||||||
alpha = 0.0f;
|
alpha = 0.0f;
|
||||||
|
|
||||||
|
@ -3126,6 +3126,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally render the starfield
|
// finally render the starfield
|
||||||
|
//qDebug() << "stars alpha:" << alpha;
|
||||||
_stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);
|
_stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,6 +280,9 @@ public:
|
||||||
virtual int getBoundaryLevelAdjust() const;
|
virtual int getBoundaryLevelAdjust() const;
|
||||||
virtual PickRay computePickRay(float x, float y);
|
virtual PickRay computePickRay(float x, float y);
|
||||||
virtual const glm::vec3& getAvatarPosition() const { return _myAvatar->getPosition(); }
|
virtual const glm::vec3& getAvatarPosition() const { return _myAvatar->getPosition(); }
|
||||||
|
virtual void overrideEnvironmentData(const EnvironmentData& newData) { _environment.override(newData); }
|
||||||
|
virtual void endOverrideEnvironmentData() { _environment.endOverride(); }
|
||||||
|
|
||||||
|
|
||||||
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
|
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
|
||||||
|
|
||||||
|
|
|
@ -72,14 +72,45 @@ void Environment::renderAtmospheres(Camera& camera) {
|
||||||
// get the lock for the duration of the call
|
// get the lock for the duration of the call
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
|
|
||||||
foreach (const ServerData& serverData, _data) {
|
if (_environmentIsOverridden) {
|
||||||
// TODO: do something about EnvironmentData
|
renderAtmosphere(camera, _overrideData);
|
||||||
foreach (const EnvironmentData& environmentData, serverData) {
|
} else {
|
||||||
renderAtmosphere(camera, environmentData);
|
foreach (const ServerData& serverData, _data) {
|
||||||
|
// TODO: do something about EnvironmentData
|
||||||
|
foreach (const EnvironmentData& environmentData, serverData) {
|
||||||
|
renderAtmosphere(camera, environmentData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnvironmentData Environment::getClosestData(const glm::vec3& position) {
|
||||||
|
if (_environmentIsOverridden) {
|
||||||
|
return _overrideData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the lock for the duration of the call
|
||||||
|
QMutexLocker locker(&_mutex);
|
||||||
|
|
||||||
|
EnvironmentData closest;
|
||||||
|
float closestDistance = FLT_MAX;
|
||||||
|
foreach (const ServerData& serverData, _data) {
|
||||||
|
foreach (const EnvironmentData& environmentData, serverData) {
|
||||||
|
float distance = glm::distance(position, environmentData.getAtmosphereCenter(position)) -
|
||||||
|
environmentData.getAtmosphereOuterRadius();
|
||||||
|
if (distance < closestDistance) {
|
||||||
|
closest = environmentData;
|
||||||
|
closestDistance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return closest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: Deprecated - I'm leaving this in for now, but it's not actually used. I made it private
|
||||||
|
// so that if anyone wants to start using this in the future they will consider how to make it
|
||||||
|
// work with new physics systems.
|
||||||
glm::vec3 Environment::getGravity (const glm::vec3& position) {
|
glm::vec3 Environment::getGravity (const glm::vec3& position) {
|
||||||
//
|
//
|
||||||
// 'Default' gravity pulls you downward in Y when you are near the X/Z plane
|
// 'Default' gravity pulls you downward in Y when you are near the X/Z plane
|
||||||
|
@ -115,25 +146,6 @@ glm::vec3 Environment::getGravity (const glm::vec3& position) {
|
||||||
return gravity;
|
return gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EnvironmentData Environment::getClosestData(const glm::vec3& position) {
|
|
||||||
// get the lock for the duration of the call
|
|
||||||
QMutexLocker locker(&_mutex);
|
|
||||||
|
|
||||||
EnvironmentData closest;
|
|
||||||
float closestDistance = FLT_MAX;
|
|
||||||
foreach (const ServerData& serverData, _data) {
|
|
||||||
foreach (const EnvironmentData& environmentData, serverData) {
|
|
||||||
float distance = glm::distance(position, environmentData.getAtmosphereCenter(position)) -
|
|
||||||
environmentData.getAtmosphereOuterRadius();
|
|
||||||
if (distance < closestDistance) {
|
|
||||||
closest = environmentData;
|
|
||||||
closestDistance = distance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return closest;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Environment::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end,
|
bool Environment::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end,
|
||||||
float radius, glm::vec3& penetration) {
|
float radius, glm::vec3& penetration) {
|
||||||
// collide with the "floor"
|
// collide with the "floor"
|
||||||
|
@ -217,7 +229,7 @@ ProgramObject* Environment::createSkyProgram(const char* from, int* locations) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::renderAtmosphere(Camera& camera, const EnvironmentData& data) {
|
void Environment::renderAtmosphere(Camera& camera, const EnvironmentData& data) {
|
||||||
glm::vec3 center = data.getAtmosphereCenter(camera.getPosition());
|
glm::vec3 center = data.getAtmosphereCenter();
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(center.x, center.y, center.z);
|
glTranslatef(center.x, center.y, center.z);
|
||||||
|
|
|
@ -31,14 +31,18 @@ public:
|
||||||
void resetToDefault();
|
void resetToDefault();
|
||||||
void renderAtmospheres(Camera& camera);
|
void renderAtmospheres(Camera& camera);
|
||||||
|
|
||||||
glm::vec3 getGravity (const glm::vec3& position);
|
void override(const EnvironmentData& overrideData) { _overrideData = overrideData; _environmentIsOverridden = true; }
|
||||||
const EnvironmentData getClosestData(const glm::vec3& position);
|
void endOverride() { _environmentIsOverridden = false; }
|
||||||
|
|
||||||
|
EnvironmentData getClosestData(const glm::vec3& position);
|
||||||
|
|
||||||
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration);
|
|
||||||
|
|
||||||
int parseData(const HifiSockAddr& senderSockAddr, const QByteArray& packet);
|
int parseData(const HifiSockAddr& senderSockAddr, const QByteArray& packet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
glm::vec3 getGravity (const glm::vec3& position); // NOTE: Deprecated
|
||||||
|
bool findCapsulePenetration(const glm::vec3& start,
|
||||||
|
const glm::vec3& end, float radius, glm::vec3& penetration); // NOTE: Deprecated
|
||||||
|
|
||||||
ProgramObject* createSkyProgram(const char* from, int* locations);
|
ProgramObject* createSkyProgram(const char* from, int* locations);
|
||||||
|
|
||||||
|
@ -74,6 +78,8 @@ private:
|
||||||
typedef QHash<int, EnvironmentData> ServerData;
|
typedef QHash<int, EnvironmentData> ServerData;
|
||||||
|
|
||||||
QHash<HifiSockAddr, ServerData> _data;
|
QHash<HifiSockAddr, ServerData> _data;
|
||||||
|
EnvironmentData _overrideData;
|
||||||
|
bool _environmentIsOverridden = false;
|
||||||
|
|
||||||
QMutex _mutex;
|
QMutex _mutex;
|
||||||
};
|
};
|
||||||
|
|
|
@ -427,6 +427,8 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
||||||
_bestZone->getStageAltitude());
|
_bestZone->getStageAltitude());
|
||||||
scene->setStageDayTime(_bestZone->getStageHour());
|
scene->setStageDayTime(_bestZone->getStageHour());
|
||||||
scene->setStageYearTime(_bestZone->getStageDay());
|
scene->setStageYearTime(_bestZone->getStageDay());
|
||||||
|
|
||||||
|
_viewState->overrideEnvironmentData(_bestZone->getEnvironmentData());
|
||||||
} else {
|
} else {
|
||||||
if (_hasPreviousZone) {
|
if (_hasPreviousZone) {
|
||||||
scene->setKeyLightColor(_previousKeyLightColor);
|
scene->setKeyLightColor(_previousKeyLightColor);
|
||||||
|
@ -440,6 +442,7 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
||||||
scene->setStageYearTime(_previousStageDay);
|
scene->setStageYearTime(_previousStageDay);
|
||||||
_hasPreviousZone = false;
|
_hasPreviousZone = false;
|
||||||
}
|
}
|
||||||
|
_viewState->endOverrideEnvironmentData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
@ -66,6 +66,24 @@ ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID, const EntityIte
|
||||||
setProperties(properties);
|
setProperties(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EnvironmentData ZoneEntityItem::getEnvironmentData() const {
|
||||||
|
EnvironmentData result;
|
||||||
|
|
||||||
|
result.setAtmosphereCenter(_atmospherePropeties.getCenter());
|
||||||
|
result.setAtmosphereInnerRadius(_atmospherePropeties.getInnerRadius());
|
||||||
|
result.setAtmosphereOuterRadius(_atmospherePropeties.getOuterRadius());
|
||||||
|
result.setRayleighScattering(_atmospherePropeties.getRayleighScattering());
|
||||||
|
result.setMieScattering(_atmospherePropeties.getMieScattering());
|
||||||
|
result.setScatteringWavelengths(_atmospherePropeties.getScatteringWavelengths());
|
||||||
|
|
||||||
|
// defaults for now...
|
||||||
|
result.setSunLocation(glm::vec3(1000, 900, 1000));
|
||||||
|
result.setSunBrightness(20.0f);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
EntityItemProperties ZoneEntityItem::getProperties() const {
|
EntityItemProperties ZoneEntityItem::getProperties() const {
|
||||||
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class
|
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class
|
||||||
|
|
||||||
|
@ -123,9 +141,6 @@ bool ZoneEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
setLastEdited(properties._lastEdited);
|
setLastEdited(properties._lastEdited);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "ZoneEntityItem::setProperties()";
|
|
||||||
debugDump();
|
|
||||||
|
|
||||||
return somethingChanged;
|
return somethingChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,9 +170,6 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
propertyFlags, overwriteLocalData);
|
propertyFlags, overwriteLocalData);
|
||||||
|
|
||||||
|
|
||||||
qDebug() << "ZoneEntityItem::readEntitySubclassDataFromBuffer()";
|
|
||||||
debugDump();
|
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef hifi_ZoneEntityItem_h
|
#ifndef hifi_ZoneEntityItem_h
|
||||||
#define hifi_ZoneEntityItem_h
|
#define hifi_ZoneEntityItem_h
|
||||||
|
|
||||||
|
#include <EnvironmentData.h>
|
||||||
|
|
||||||
#include "AtmospherePropertyGroup.h"
|
#include "AtmospherePropertyGroup.h"
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
|
|
||||||
|
@ -104,6 +106,7 @@ public:
|
||||||
void setSkyboxMode(SkyboxMode value) { _skyboxMode = value; }
|
void setSkyboxMode(SkyboxMode value) { _skyboxMode = value; }
|
||||||
SkyboxMode getSkyboxMode() const { return _skyboxMode; }
|
SkyboxMode getSkyboxMode() const { return _skyboxMode; }
|
||||||
|
|
||||||
|
EnvironmentData getEnvironmentData() const;
|
||||||
|
|
||||||
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,
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Transform;
|
||||||
class QThread;
|
class QThread;
|
||||||
class ViewFrustum;
|
class ViewFrustum;
|
||||||
class PickRay;
|
class PickRay;
|
||||||
|
class EnvironmentData;
|
||||||
|
|
||||||
/// Interface provided by Application to other objects that need access to the current view state details
|
/// Interface provided by Application to other objects that need access to the current view state details
|
||||||
class AbstractViewStateInterface {
|
class AbstractViewStateInterface {
|
||||||
|
@ -33,6 +34,10 @@ public:
|
||||||
/// gets the current view frustum for rendering the view state
|
/// gets the current view frustum for rendering the view state
|
||||||
virtual ViewFrustum* getCurrentViewFrustum() = 0;
|
virtual ViewFrustum* getCurrentViewFrustum() = 0;
|
||||||
|
|
||||||
|
/// overrides environment data
|
||||||
|
virtual void overrideEnvironmentData(const EnvironmentData& newData) = 0;
|
||||||
|
virtual void endOverrideEnvironmentData() = 0;
|
||||||
|
|
||||||
/// gets the shadow view frustum for rendering the view state
|
/// gets the shadow view frustum for rendering the view state
|
||||||
virtual ViewFrustum* getShadowViewFrustum() = 0;
|
virtual ViewFrustum* getShadowViewFrustum() = 0;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,6 @@ set(TARGET_NAME octree-tests)
|
||||||
setup_hifi_project(Script Network)
|
setup_hifi_project(Script Network)
|
||||||
|
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(shared octree gpu model fbx networking entities avatars audio animation script-engine physics)
|
link_hifi_libraries(shared octree gpu model fbx networking environment entities avatars audio animation script-engine physics)
|
||||||
|
|
||||||
copy_dlls_beside_windows_executable()
|
copy_dlls_beside_windows_executable()
|
Loading…
Reference in a new issue