This commit is contained in:
Philip Rosedale 2013-08-07 14:43:49 -07:00
commit a4d1bc5b6e
11 changed files with 112 additions and 22 deletions

View file

@ -471,7 +471,7 @@ void Application::resizeGL(int width, int height) {
float aspectRatio = ((float)width/(float)height); // based on screen resize
// reset the camera FOV to our preference...
_myCamera.setFieldOfView(_horizontalFieldOfView);
_myCamera.setFieldOfView(_fieldOfView);
// get the lens details from the current camera
Camera& camera = _viewFrustumFromOffset->isChecked() ? _viewFrustumOffsetCamera : _myCamera;
@ -492,7 +492,7 @@ void Application::resizeGL(int width, int height) {
}
} else {
camera.setAspectRatio(aspectRatio);
camera.setFieldOfView(fov = _horizontalFieldOfView);
camera.setFieldOfView(fov = _fieldOfView);
}
// Tell our viewFrustum about this change
@ -1295,11 +1295,11 @@ void Application::editPreferences() {
avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
form->addRow("Avatar URL:", avatarURL);
QSpinBox* horizontalFieldOfView = new QSpinBox();
horizontalFieldOfView->setMaximum(180);
horizontalFieldOfView->setMinimum(1);
horizontalFieldOfView->setValue(_horizontalFieldOfView);
form->addRow("Horizontal field of view (degrees):", horizontalFieldOfView);
QSpinBox* fieldOfView = new QSpinBox();
fieldOfView->setMaximum(180);
fieldOfView->setMinimum(1);
fieldOfView->setValue(_fieldOfView);
form->addRow("Vertical Field of View (Degrees):", fieldOfView);
QDoubleSpinBox* gyroCameraSensitivity = new QDoubleSpinBox();
gyroCameraSensitivity->setValue(_gyroCameraSensitivity);
@ -1359,7 +1359,7 @@ void Application::editPreferences() {
if (!shouldDynamicallySetJitterBuffer()) {
_audio.setJitterBufferSamples(_audioJitterBufferSamples);
}
_horizontalFieldOfView = horizontalFieldOfView->value();
_fieldOfView = fieldOfView->value();
resizeGL(_glWidget->width(), _glWidget->height());
}
@ -1389,6 +1389,8 @@ void Application::setRenderFirstPerson(bool firstPerson) {
if (firstPerson) {
_lookingInMirror->setChecked(false);
_manualThirdPerson->setChecked(false);
} else {
_manualThirdPerson->trigger();
}
}
@ -3811,7 +3813,7 @@ bool Application::maybeEditVoxelUnderCursor() {
}
} else if (_deleteVoxelMode->isChecked()) {
deleteVoxelUnderCursor();
VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f);
const float VOXEL_BOUNDS_ADJUST = 0.01f;
float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST;
fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger;
@ -4144,7 +4146,7 @@ void Application::loadSettings(QSettings* settings) {
_gyroCameraSensitivity = loadSetting(settings, "gyroCameraSensitivity", 0.5f);
_audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0);
_horizontalFieldOfView = loadSetting(settings, "horizontalFieldOfView", HORIZONTAL_FIELD_OF_VIEW_DEGREES);
_fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES);
settings->beginGroup("View Frustum Offset Camera");
// in case settings is corrupt or missing loadSetting() will check for NaN
@ -4168,7 +4170,7 @@ void Application::saveSettings(QSettings* settings) {
settings->setValue("gyroCameraSensitivity", _gyroCameraSensitivity);
settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples);
settings->setValue("horizontalFieldOfView", _horizontalFieldOfView);
settings->setValue("fieldOfView", _fieldOfView);
settings->beginGroup("View Frustum Offset Camera");
settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffsetYaw);
settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffsetPitch);

View file

@ -383,7 +383,7 @@ private:
int _audioJitterBufferSamples; // Number of extra samples to wait before starting audio playback
float _horizontalFieldOfView; // In Degrees, doesn't apply to HMD like Oculus
float _fieldOfView; // In Degrees, doesn't apply to HMD like Oculus
HandControl _handControl;

View file

@ -37,7 +37,8 @@ Camera::Camera() {
_linearModeShift = 0.0f;
_mode = CAMERA_MODE_THIRD_PERSON;
_tightness = 10.0f; // default
_fieldOfView = HORIZONTAL_FIELD_OF_VIEW_DEGREES;
_fieldOfView = DEFAULT_FIELD_OF_VIEW_DEGREES;
_aspectRatio = 16.f/9.f;
_nearClip = 0.08f; // default
_farClip = 50.0f * TREE_SCALE; // default
_upShift = 0.0f;

View file

@ -11,7 +11,7 @@
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
const float HORIZONTAL_FIELD_OF_VIEW_DEGREES = 90.0f;
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 90.0f;
enum CameraMode
{

View file

@ -130,6 +130,8 @@ Avatar::Avatar(Node* owningNode) :
} else {
_balls = NULL;
}
_collisionRadius = _height * 0.125f;
}
@ -633,6 +635,10 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter, float gyroCamer
}
if (_isCollisionsOn) {
Camera* myCamera = Application::getInstance()->getCamera();
_collisionRadius = myCamera->getAspectRatio() * (myCamera->getNearClip() / cos(myCamera->getFieldOfView() / 2.f));
_collisionRadius *= COLLISION_RADIUS_SCALAR;
updateCollisionWithEnvironment(deltaTime);
updateCollisionWithVoxels(deltaTime);
updateAvatarCollisions(deltaTime);
@ -984,14 +990,14 @@ void Avatar::updateCollisionWithSphere(glm::vec3 position, float radius, float d
void Avatar::updateCollisionWithEnvironment(float deltaTime) {
glm::vec3 up = getBodyUpDirection();
float radius = _height * 0.125f;
float radius = _collisionRadius;
const float ENVIRONMENT_SURFACE_ELASTICITY = 1.0f;
const float ENVIRONMENT_SURFACE_DAMPING = 0.01;
const float ENVIRONMENT_COLLISION_FREQUENCY = 0.05f;
glm::vec3 penetration;
if (Application::getInstance()->getEnvironment()->findCapsulePenetration(
_position - up * (_pelvisFloatingHeight - radius),
_position + up * (_height - _pelvisFloatingHeight - radius), radius, penetration)) {
_position + up * (_height - _pelvisFloatingHeight + radius), radius, penetration)) {
_lastCollisionPosition = _position;
updateCollisionSound(penetration, deltaTime, ENVIRONMENT_COLLISION_FREQUENCY);
applyHardCollision(penetration, ENVIRONMENT_SURFACE_ELASTICITY, ENVIRONMENT_SURFACE_DAMPING);
@ -1000,14 +1006,14 @@ void Avatar::updateCollisionWithEnvironment(float deltaTime) {
void Avatar::updateCollisionWithVoxels(float deltaTime) {
float radius = _height * 0.125f;
float radius = _collisionRadius;
const float VOXEL_ELASTICITY = 1.4f;
const float VOXEL_DAMPING = 0.0;
const float VOXEL_COLLISION_FREQUENCY = 0.5f;
glm::vec3 penetration;
if (Application::getInstance()->getVoxels()->findCapsulePenetration(
_position - glm::vec3(0.0f, _pelvisFloatingHeight - radius, 0.0f),
_position + glm::vec3(0.0f, _height - _pelvisFloatingHeight - radius, 0.0f), radius, penetration)) {
_position + glm::vec3(0.0f, _height - _pelvisFloatingHeight + radius, 0.0f), radius, penetration)) {
_lastCollisionPosition = _position;
updateCollisionSound(penetration, deltaTime, VOXEL_COLLISION_FREQUENCY);
applyHardCollision(penetration, VOXEL_ELASTICITY, VOXEL_DAMPING);

View file

@ -273,6 +273,7 @@ private:
bool _speedBrakes;
bool _isThrustOn;
bool _isCollisionsOn;
float _collisionRadius;
Avatar* _leadingAvatar;
float _stringLength;

View file

@ -63,7 +63,6 @@ void Face::setFrameFromWebcam() {
_textureSize = webcam->getTextureSize();
_textureRect = webcam->getFaceRect();
_aspectRatio = webcam->getAspectRatio();
} else {
clearFrame();
}
@ -262,6 +261,11 @@ bool Face::render(float alpha) {
xScale = FULL_FRAME_SCALE * _owningHead->getScale();
zScale = xScale * 0.3f;
glPushMatrix();
glColor4f(1.0f, 1.0f, 1.0f, alpha);
glScalef(xScale / 12, xScale / (aspect * 3), zScale / 2);
Application::getInstance()->getGeometryCache()->renderHalfCylinder(25, 20);
glPopMatrix();
} else {
aspect = _aspectRatio;
xScale = BODY_BALL_RADIUS_HEAD_BASE * _owningHead->getScale();
@ -308,7 +312,7 @@ bool Face::render(float alpha) {
glGenBuffers(1, &_iboID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iboID);
int* indices = new int[INDEX_COUNT];
int* indexPosition = indices;
int* indexPosition = indices;
for (int i = 0; i < QUAD_HEIGHT; i++) {
for (int j = 0; j < QUAD_WIDTH; j++) {
*indexPosition++ = i * VERTEX_WIDTH + j;

View file

@ -61,7 +61,7 @@ private:
cv::Size2f _textureSize;
cv::RotatedRect _textureRect;
float _aspectRatio;
vpx_codec_ctx_t _colorCodec;
vpx_codec_ctx_t _depthCodec;
bool _lastFullFrame;

View file

@ -163,3 +163,77 @@ void GeometryCache::renderSquare(int xDivisions, int yDivisions) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void GeometryCache::renderHalfCylinder(int slices, int stacks) {
VerticesIndices& vbo = _halfCylinderVBOs[IntPair(slices, stacks)];
int vertices = (slices + 1) * stacks;
int indices = 2 * 3 * slices * (stacks - 1);
if (vbo.first == 0) {
GLfloat* vertexData = new GLfloat[vertices * 2 * 3];
GLfloat* vertex = vertexData;
for (int i = 0; i <= (stacks - 1); i++) {
float y = (float)i / (stacks - 1);
for (int j = 0; j <= slices; j++) {
float theta = 3 * PIf / 2 + PIf * j / slices;
//normals
*(vertex++) = sinf(theta);
*(vertex++) = 0;
*(vertex++) = cosf(theta);
// vertices
*(vertex++) = sinf(theta);
*(vertex++) = y;
*(vertex++) = cosf(theta);
}
}
glGenBuffers(1, &vbo.first);
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
const int BYTES_PER_VERTEX = 3 * sizeof(GLfloat);
glBufferData(GL_ARRAY_BUFFER, 2 * vertices * BYTES_PER_VERTEX, vertexData, GL_STATIC_DRAW);
delete[] vertexData;
GLushort* indexData = new GLushort[indices];
GLushort* index = indexData;
for (int i = 0; i < stacks - 1; i++) {
GLushort bottom = i * (slices + 1);
GLushort top = bottom + slices + 1;
for (int j = 0; j < slices; j++) {
int next = j + 1;
*(index++) = bottom + j;
*(index++) = top + next;
*(index++) = top + j;
*(index++) = bottom + j;
*(index++) = bottom + next;
*(index++) = top + next;
}
}
glGenBuffers(1, &vbo.second);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
const int BYTES_PER_INDEX = sizeof(GLushort);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
delete[] indexData;
} else {
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
}
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 6 * sizeof(float), 0);
glVertexPointer(3, GL_FLOAT, (6 * sizeof(float)), (const void *)(3 * sizeof(float)));
glDrawRangeElementsEXT(GL_TRIANGLES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}

View file

@ -20,6 +20,7 @@ public:
void renderHemisphere(int slices, int stacks);
void renderSquare(int xDivisions, int yDivisions);
void renderHalfCylinder(int slices, int stacks);
private:
@ -28,6 +29,7 @@ private:
QHash<IntPair, VerticesIndices> _hemisphereVBOs;
QHash<IntPair, VerticesIndices> _squareVBOs;
QHash<IntPair, VerticesIndices> _halfCylinderVBOs;
};
#endif /* defined(__interface__GeometryCache__) */

View file

@ -42,7 +42,7 @@ def hifiJob(String targetName, Boolean deploy) {
if (deploy) {
publishers {
publishScp("${ARTIFACT_DESTINATION}") {
entry("**/build/${targetName}", "deploy/${targetName}")
entry("**/build/${targetName}/${targetName}", "deploy/${targetName}")
}
}
}