mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:24:24 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into metavoxels
This commit is contained in:
commit
c423205709
5 changed files with 76 additions and 48 deletions
|
@ -79,8 +79,10 @@ const int MIRROR_VIEW_TOP_PADDING = 5;
|
||||||
const int MIRROR_VIEW_LEFT_PADDING = 10;
|
const int MIRROR_VIEW_LEFT_PADDING = 10;
|
||||||
const int MIRROR_VIEW_WIDTH = 265;
|
const int MIRROR_VIEW_WIDTH = 265;
|
||||||
const int MIRROR_VIEW_HEIGHT = 215;
|
const int MIRROR_VIEW_HEIGHT = 215;
|
||||||
const float MAX_ZOOM_DISTANCE = 0.3f;
|
const float MIRROR_FULLSCREEN_DISTANCE = 0.2f;
|
||||||
const float MIN_ZOOM_DISTANCE = 2.0f;
|
const float MIRROR_REARVIEW_DISTANCE = 0.3f;
|
||||||
|
const float MIRROR_REARVIEW_BODY_DISTANCE = 1.f;
|
||||||
|
|
||||||
|
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
|
||||||
fprintf(stdout, "%s", message.toLocal8Bit().constData());
|
fprintf(stdout, "%s", message.toLocal8Bit().constData());
|
||||||
|
@ -376,11 +378,12 @@ void Application::paintGL() {
|
||||||
|
|
||||||
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
_myCamera.setTightness(0.0f);
|
_myCamera.setTightness(0.0f);
|
||||||
_myCamera.setDistance(MAX_ZOOM_DISTANCE);
|
float headHeight = _myAvatar.getHead().calculateAverageEyePosition().y - _myAvatar.getPosition().y;
|
||||||
_myCamera.setTargetPosition(_myAvatar.getHead().calculateAverageEyePosition());
|
_myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar.getScale());
|
||||||
|
_myCamera.setTargetPosition(_myAvatar.getPosition() + glm::vec3(0, headHeight, 0));
|
||||||
_myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
|
_myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update camera position
|
// Update camera position
|
||||||
_myCamera.update( 1.f/_fps );
|
_myCamera.update( 1.f/_fps );
|
||||||
|
|
||||||
|
@ -432,10 +435,10 @@ void Application::paintGL() {
|
||||||
|
|
||||||
bool eyeRelativeCamera = false;
|
bool eyeRelativeCamera = false;
|
||||||
if (_rearMirrorTools->getZoomLevel() == BODY) {
|
if (_rearMirrorTools->getZoomLevel() == BODY) {
|
||||||
_mirrorCamera.setDistance(MIN_ZOOM_DISTANCE);
|
_mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar.getScale());
|
||||||
_mirrorCamera.setTargetPosition(_myAvatar.getChestJointPosition());
|
_mirrorCamera.setTargetPosition(_myAvatar.getChestJointPosition());
|
||||||
} else { // HEAD zoom level
|
} else { // HEAD zoom level
|
||||||
_mirrorCamera.setDistance(MAX_ZOOM_DISTANCE);
|
_mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar.getScale());
|
||||||
if (_myAvatar.getSkeletonModel().isActive() && _myAvatar.getHead().getFaceModel().isActive()) {
|
if (_myAvatar.getSkeletonModel().isActive() && _myAvatar.getHead().getFaceModel().isActive()) {
|
||||||
// as a hack until we have a better way of dealing with coordinate precision issues, reposition the
|
// as a hack until we have a better way of dealing with coordinate precision issues, reposition the
|
||||||
// face/body so that the average eye position lies at the origin
|
// face/body so that the average eye position lies at the origin
|
||||||
|
@ -1412,9 +1415,16 @@ void Application::processAvatarURLsMessage(unsigned char* packetData, size_t dat
|
||||||
if (!avatar) {
|
if (!avatar) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QDataStream in(QByteArray((char*)packetData, dataBytes));
|
// PER Note: message is no longer processed but used to trigger
|
||||||
QUrl voxelURL;
|
// Dataserver lookup - redesign this to instantly ask the
|
||||||
in >> voxelURL;
|
// dataserver on first receipt of other avatar UUID, and also
|
||||||
|
// don't ask over and over again. Instead use this message to
|
||||||
|
// Tell the other avatars that your dataserver data has
|
||||||
|
// changed.
|
||||||
|
|
||||||
|
//QDataStream in(QByteArray((char*)packetData, dataBytes));
|
||||||
|
//QUrl voxelURL;
|
||||||
|
//in >> voxelURL;
|
||||||
|
|
||||||
// use this timing to as the data-server for an updated mesh for this avatar (if we have UUID)
|
// use this timing to as the data-server for an updated mesh for this avatar (if we have UUID)
|
||||||
DataServerClient::getValuesForKeysAndUUID(QStringList() << DataServerKey::FaceMeshURL << DataServerKey::SkeletonURL,
|
DataServerClient::getValuesForKeysAndUUID(QStringList() << DataServerKey::FaceMeshURL << DataServerKey::SkeletonURL,
|
||||||
|
@ -2553,6 +2563,11 @@ void Application::updateAvatar(float deltaTime) {
|
||||||
controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,
|
controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,
|
||||||
nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
|
nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
|
||||||
|
|
||||||
|
const float AVATAR_URLS_SEND_INTERVAL = 1.0f;
|
||||||
|
if (shouldDo(AVATAR_URLS_SEND_INTERVAL, deltaTime)) {
|
||||||
|
QUrl empty;
|
||||||
|
Avatar::sendAvatarURLsMessage(empty);
|
||||||
|
}
|
||||||
// Update _viewFrustum with latest camera and view frustum data...
|
// Update _viewFrustum with latest camera and view frustum data...
|
||||||
// NOTE: we get this from the view frustum, to make it simpler, since the
|
// NOTE: we get this from the view frustum, to make it simpler, since the
|
||||||
// loadViewFrumstum() method will get the correct details from the camera
|
// loadViewFrumstum() method will get the correct details from the camera
|
||||||
|
@ -2980,6 +2995,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// render the ambient occlusion effect if enabled
|
||||||
|
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
|
||||||
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
"Application::displaySide() ... AmbientOcclusion...");
|
||||||
|
_ambientOcclusionEffect.render();
|
||||||
|
}
|
||||||
|
|
||||||
// restore default, white specular
|
// restore default, white specular
|
||||||
glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
|
glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
|
||||||
|
|
||||||
|
@ -3063,13 +3085,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
|
||||||
renderWorldBox();
|
renderWorldBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the ambient occlusion effect if enabled
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
|
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
|
||||||
"Application::displaySide() ... AmbientOcclusion...");
|
|
||||||
_ambientOcclusionEffect.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
// brad's frustum for debugging
|
// brad's frustum for debugging
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
|
|
@ -168,18 +168,18 @@ void Avatar::follow(Avatar* leadingAvatar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
|
|
||||||
if (_leadingAvatar && !_leadingAvatar->getOwningNode()->isAlive()) {
|
if (_leadingAvatar && !_leadingAvatar->getOwningNode()->isAlive()) {
|
||||||
follow(NULL);
|
follow(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_scale != _newScale) {
|
if (_scale != _newScale) {
|
||||||
setScale(_newScale);
|
setScale(_newScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy velocity so we can use it later for acceleration
|
// copy velocity so we can use it later for acceleration
|
||||||
glm::vec3 oldVelocity = getVelocity();
|
glm::vec3 oldVelocity = getVelocity();
|
||||||
|
|
||||||
// update balls
|
// update balls
|
||||||
if (_balls) {
|
if (_balls) {
|
||||||
_balls->moveOrigin(_position);
|
_balls->moveOrigin(_position);
|
||||||
|
@ -194,7 +194,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
|
|
||||||
// update torso rotation based on head lean
|
// update torso rotation based on head lean
|
||||||
_skeleton.joint[AVATAR_JOINT_TORSO].rotation = glm::quat(glm::radians(glm::vec3(
|
_skeleton.joint[AVATAR_JOINT_TORSO].rotation = glm::quat(glm::radians(glm::vec3(
|
||||||
_head.getLeanForward(), 0.0f, _head.getLeanSideways())));
|
_head.getLeanForward(), 0.0f, _head.getLeanSideways())));
|
||||||
|
|
||||||
// apply joint data (if any) to skeleton
|
// apply joint data (if any) to skeleton
|
||||||
bool enableHandMovement = true;
|
bool enableHandMovement = true;
|
||||||
|
@ -205,25 +205,16 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
enableHandMovement &= (it->jointID != AVATAR_JOINT_RIGHT_WRIST);
|
enableHandMovement &= (it->jointID != AVATAR_JOINT_RIGHT_WRIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update avatar skeleton
|
||||||
|
_skeleton.update(deltaTime, getOrientation(), _position);
|
||||||
|
|
||||||
|
|
||||||
|
// if this is not my avatar, then hand position comes from transmitted data
|
||||||
|
_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = _handPosition;
|
||||||
|
|
||||||
//update the movement of the hand and process handshaking with other avatars...
|
//update the movement of the hand and process handshaking with other avatars...
|
||||||
updateHandMovementAndTouching(deltaTime, enableHandMovement);
|
updateHandMovementAndTouching(deltaTime, enableHandMovement);
|
||||||
|
|
||||||
// use speed and angular velocity to determine walking vs. standing
|
|
||||||
if (_speed + fabs(_bodyYawDelta) > 0.2) {
|
|
||||||
_mode = AVATAR_MODE_WALKING;
|
|
||||||
} else {
|
|
||||||
_mode = AVATAR_MODE_INTERACTING;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update position by velocity, and subtract the change added earlier for gravity
|
|
||||||
_position += _velocity * deltaTime;
|
|
||||||
|
|
||||||
// update avatar skeleton
|
|
||||||
_skeleton.update(deltaTime, getOrientation(), _position);
|
|
||||||
|
|
||||||
// if this is not my avatar, then hand position comes from transmitted data
|
|
||||||
_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = _handPosition;
|
|
||||||
|
|
||||||
_hand.simulate(deltaTime, false);
|
_hand.simulate(deltaTime, false);
|
||||||
_skeletonModel.simulate(deltaTime);
|
_skeletonModel.simulate(deltaTime);
|
||||||
_head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
_head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
||||||
|
@ -233,11 +224,20 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
_head.setScale(_scale);
|
_head.setScale(_scale);
|
||||||
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
||||||
_head.simulate(deltaTime, false);
|
_head.simulate(deltaTime, false);
|
||||||
|
|
||||||
|
// use speed and angular velocity to determine walking vs. standing
|
||||||
|
if (_speed + fabs(_bodyYawDelta) > 0.2) {
|
||||||
|
_mode = AVATAR_MODE_WALKING;
|
||||||
|
} else {
|
||||||
|
_mode = AVATAR_MODE_INTERACTING;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update position by velocity, and subtract the change added earlier for gravity
|
||||||
|
_position += _velocity * deltaTime;
|
||||||
|
|
||||||
// Zero thrust out now that we've added it to velocity in this frame
|
// Zero thrust out now that we've added it to velocity in this frame
|
||||||
_thrust = glm::vec3(0, 0, 0);
|
_thrust = glm::vec3(0, 0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::setMouseRay(const glm::vec3 &origin, const glm::vec3 &direction) {
|
void Avatar::setMouseRay(const glm::vec3 &origin, const glm::vec3 &direction) {
|
||||||
|
@ -452,6 +452,8 @@ void Avatar::renderBody(bool forceRenderHead) {
|
||||||
_head.getVideoFace().render(1.0f);
|
_head.getVideoFace().render(1.0f);
|
||||||
} else {
|
} else {
|
||||||
// Render the body's voxels and head
|
// Render the body's voxels and head
|
||||||
|
glm::vec3 pos = getPosition();
|
||||||
|
//printf("Render other at %.3f, %.2f, %.2f\n", pos.x, pos.y, pos.z);
|
||||||
_skeletonModel.render(1.0f);
|
_skeletonModel.render(1.0f);
|
||||||
_head.render(1.0f, false);
|
_head.render(1.0f, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ void SkeletonModel::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkeletonModel::render(float alpha) {
|
bool SkeletonModel::render(float alpha) {
|
||||||
|
|
||||||
if (_jointStates.isEmpty()) {
|
if (_jointStates.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ GlowEffect::GlowEffect()
|
||||||
: _initialized(false),
|
: _initialized(false),
|
||||||
_renderMode(DIFFUSE_ADD_MODE),
|
_renderMode(DIFFUSE_ADD_MODE),
|
||||||
_isOddFrame(false),
|
_isOddFrame(false),
|
||||||
|
_isFirstFrame(true),
|
||||||
_intensity(0.0f) {
|
_intensity(0.0f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,16 +167,21 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
}
|
}
|
||||||
newDiffusedFBO->bind();
|
newDiffusedFBO->bind();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
if (_isFirstFrame) {
|
||||||
glBindTexture(GL_TEXTURE_2D, oldDiffusedFBO->texture());
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
_diffuseProgram->bind();
|
} else {
|
||||||
QSize size = Application::getInstance()->getGLWidget()->size();
|
glActiveTexture(GL_TEXTURE1);
|
||||||
_diffuseProgram->setUniformValue(_diffusionScaleLocation, 1.0f / size.width(), 1.0f / size.height());
|
glBindTexture(GL_TEXTURE_2D, oldDiffusedFBO->texture());
|
||||||
|
|
||||||
|
_diffuseProgram->bind();
|
||||||
|
QSize size = Application::getInstance()->getGLWidget()->size();
|
||||||
|
_diffuseProgram->setUniformValue(_diffusionScaleLocation, 1.0f / size.width(), 1.0f / size.height());
|
||||||
|
|
||||||
renderFullscreenQuad();
|
renderFullscreenQuad();
|
||||||
|
|
||||||
_diffuseProgram->release();
|
_diffuseProgram->release();
|
||||||
|
}
|
||||||
|
|
||||||
newDiffusedFBO->release();
|
newDiffusedFBO->release();
|
||||||
|
|
||||||
|
@ -221,7 +227,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
maybeRelease(destFBO);
|
maybeRelease(destFBO);
|
||||||
|
|
||||||
} else { // _renderMode == BLUR_PERSIST_ADD_MODE
|
} else { // _renderMode == BLUR_PERSIST_ADD_MODE
|
||||||
// render the secondary to the tertiary with horizontal blur and persistence
|
// render the secondary to the tertiary with vertical blur and persistence
|
||||||
QOpenGLFramebufferObject* tertiaryFBO =
|
QOpenGLFramebufferObject* tertiaryFBO =
|
||||||
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject();
|
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject();
|
||||||
tertiaryFBO->bind();
|
tertiaryFBO->bind();
|
||||||
|
@ -229,7 +235,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_ONE_MINUS_CONSTANT_ALPHA, GL_CONSTANT_ALPHA);
|
glBlendFunc(GL_ONE_MINUS_CONSTANT_ALPHA, GL_CONSTANT_ALPHA);
|
||||||
const float PERSISTENCE_SMOOTHING = 0.9f;
|
const float PERSISTENCE_SMOOTHING = 0.9f;
|
||||||
glBlendColor(0.0f, 0.0f, 0.0f, PERSISTENCE_SMOOTHING);
|
glBlendColor(0.0f, 0.0f, 0.0f, _isFirstFrame ? 0.0f : PERSISTENCE_SMOOTHING);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture());
|
glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture());
|
||||||
|
|
||||||
|
@ -270,6 +276,8 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
_isFirstFrame = false;
|
||||||
|
|
||||||
return destFBO;
|
return destFBO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,6 +300,7 @@ void GlowEffect::cycleRenderMode() {
|
||||||
qDebug() << "Glow mode: Diffuse/add\n";
|
qDebug() << "Glow mode: Diffuse/add\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
_isFirstFrame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glower::Glower(float amount) {
|
Glower::Glower(float amount) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ private:
|
||||||
|
|
||||||
bool _isEmpty; ///< set when nothing in the scene is currently glowing
|
bool _isEmpty; ///< set when nothing in the scene is currently glowing
|
||||||
bool _isOddFrame; ///< controls the alternation between texture targets in diffuse add mode
|
bool _isOddFrame; ///< controls the alternation between texture targets in diffuse add mode
|
||||||
|
bool _isFirstFrame; ///< for persistent modes, notes whether this is the first frame rendered
|
||||||
|
|
||||||
float _intensity;
|
float _intensity;
|
||||||
QStack<float> _intensityStack;
|
QStack<float> _intensityStack;
|
||||||
|
|
Loading…
Reference in a new issue