From 60f0e6581db8d3d3a10bda361a5ee0ae85d24c29 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 22 Apr 2013 14:04:36 -0700 Subject: [PATCH 1/6] improved test sphere collision algorithm --- interface/src/Head.cpp | 57 +++++++++++++++++++++--------------------- interface/src/Head.h | 39 +++++++++++++---------------- 2 files changed, 45 insertions(+), 51 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 24d04b2c7b..be8a6680bd 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -115,8 +115,7 @@ Head::Head(bool isMine) { _head.noise = 0; _movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 ); -_usingBodySprings = true; -//_usingBodySprings = false; + _usingBodySprings = true; _springForce = 6.0f; _springVelocityDecay = 16.0f; _renderYaw = 0.0; @@ -168,11 +167,7 @@ Head::Head(const Head &otherAvatar) { _springForce = otherAvatar._springForce; _springVelocityDecay = otherAvatar._springVelocityDecay; _orientation.set( otherAvatar._orientation ); - - //for (int o=0;o 0.0) { - float amp = 1.0 - (distanceToBigSphereCenter / combinedRadius); - glm::vec3 collisionForce = vectorFromJointToBigSphere * amp; - _bone[b].springyVelocity += collisionForce * 8.0f * deltaTime; - _velocity += collisionForce * 18.0f * deltaTime; + glm::vec3 directionVector = vectorFromJointToBigSphereCenter / distanceToBigSphereCenter; + + float penetration = 1.0 - (distanceToBigSphereCenter / combinedRadius); + glm::vec3 collisionForce = vectorFromJointToBigSphereCenter * penetration; + + _bone[b].springyVelocity += collisionForce * 8.0f * deltaTime; + _velocity += collisionForce * 18.0f * deltaTime; + _bone[b].position = _TEST_bigSpherePosition + directionVector * combinedRadius; } } } @@ -874,7 +872,6 @@ void Head::renderHead(int faceToFace) { glPopMatrix(); } - void Head::startHandMovement() { if (!_usingBodySprings) { @@ -1136,7 +1133,7 @@ glm::vec3 Head::getHeadPosition() { } -glm::vec3 Head::getBonePosition( AvatarBones b ) { +glm::vec3 Head::getBonePosition( AvatarBoneID b ) { return _bone[b].position; } @@ -1246,18 +1243,8 @@ void Head::renderBody() { // Render bone positions as spheres //----------------------------------------- for (int b=0; b Date: Mon, 22 Apr 2013 15:39:31 -0700 Subject: [PATCH 2/6] Cleaned up some const values in Head.h, implemented avatar gravity and ground collision, improved test sphere collision, added _usingBodySprings test to getHeadPosition, improved camera settings in main.cpp, cleaned up commented-out code in main.cpp --- interface/src/Head.cpp | 58 +++++++++++++++++++++++------------------- interface/src/Head.h | 7 +++++ interface/src/main.cpp | 33 +++++++++--------------- 3 files changed, 51 insertions(+), 47 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index bf410eae94..f4dcdbee53 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -35,9 +35,7 @@ float browThickness = 0.16; bool usingBigSphereCollisionTest = true; -const float DECAY = 0.1; -const float THRUST_MAG = 10.0; -const float YAW_MAG = 300.0; + char iris_texture_file[] = "resources/images/green_eye.png"; @@ -380,7 +378,19 @@ void Head::simulate(float deltaTime) { //-------------------------------------------------------------- updateBigSphereCollisionTest(deltaTime); } - + + if ( AVATAR_GRAVITY ) { + if ( _bodyPosition.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) { + _velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime ); + } + else { + if ( _bodyPosition.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) { + _bodyPosition.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius; + _velocity.y = 0.0; + } + } + } + //------------------------ // update avatar skeleton //------------------------ @@ -460,7 +470,6 @@ void Head::simulate(float deltaTime) { //---------------------------------------------------------- // decay body yaw delta //---------------------------------------------------------- - const float TEST_YAW_DECAY = 5.0; _bodyYawDelta *= (1.0 - TEST_YAW_DECAY * deltaTime); //---------------------------------------------------------- @@ -476,7 +485,6 @@ void Head::simulate(float deltaTime) { //---------------------------------------------------------- // decay velocity //---------------------------------------------------------- - const float LIN_VEL_DECAY = 5.0; _velocity *= ( 1.0 - LIN_VEL_DECAY * deltaTime ); if (!_head.noise) { @@ -585,7 +593,7 @@ void Head::updateBigSphereCollisionTest( float deltaTime ) { { for (int b=0; b #include //looks like we might not need this +const bool AVATAR_GRAVITY = true; +const float DECAY = 0.1; +const float THRUST_MAG = 10.0; +const float YAW_MAG = 300.0; +const float TEST_YAW_DECAY = 5.0; +const float LIN_VEL_DECAY = 5.0; + enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH}; #define FWD 0 diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 749113f490..8d6fa06e8d 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -802,18 +802,16 @@ void display(void) //-------------------------------------------------------- // camera settings //-------------------------------------------------------- - myCamera.setTargetPosition( myAvatar.getBodyPosition() ); - if ( displayHead ) { //----------------------------------------------- // set the camera to looking at my own face //----------------------------------------------- - myCamera.setTargetPosition ( myAvatar.getBodyPosition() ); // XXXBHG - Shouldn't we use Head position here? + myCamera.setTargetPosition ( myAvatar.getHeadPosition() ); myCamera.setYaw ( - myAvatar.getBodyYaw() ); - myCamera.setPitch ( 0.0 ); - myCamera.setRoll ( 0.0 ); - myCamera.setUp ( 0.6 ); - myCamera.setDistance ( 0.3 ); + myCamera.setPitch ( 0.0 ); + myCamera.setRoll ( 0.0 ); + myCamera.setUp ( 0.0 ); + myCamera.setDistance ( 0.2 ); myCamera.setTightness ( 100.0f ); myCamera.update ( 1.f/FPS ); } else { @@ -822,12 +820,12 @@ void display(void) //---------------------------------------------------- myCamera.setTargetPosition ( myAvatar.getBodyPosition() ); myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() ); - myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju - myCamera.setRoll ( 0.0 ); - myCamera.setUp ( 0.45); - myCamera.setDistance ( 1.0 ); - myCamera.setTightness ( 10.0f ); - myCamera.update ( 1.f/FPS ); + myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju + myCamera.setRoll ( 0.0 ); + myCamera.setUp ( 0.45 ); + myCamera.setDistance ( 1.0 ); + myCamera.setTightness ( 8.0f ); + myCamera.update ( 1.f/FPS); } // Note: whichCamera is used to pick between the normal camera myCamera for our @@ -890,14 +888,12 @@ void display(void) float sphereRadius = 0.25f; glColor3f(1,0,0); glPushMatrix(); - //glTranslatef( 0.0f, sphereRadius, 0.0f ); glutSolidSphere( sphereRadius, 15, 15 ); glPopMatrix(); //draw a grid gound plane.... drawGroundPlaneGrid( 5.0f, 9 ); - // Draw cloud of dots if (!displayHead) cloud.render(); @@ -917,12 +913,7 @@ void display(void) agent++) { if (agent->getLinkedData() != NULL) { Head *avatar = (Head *)agent->getLinkedData(); - //glPushMatrix(); - -//printf( "rendering remote avatar\n" ); - avatar->render(0); - //glPopMatrix(); } } @@ -993,7 +984,7 @@ void display(void) int totalAgents = AgentList::getInstance()->getAgents().size(); int totalAvatars = 0, totalServers = 0; for (int i = 0; i < totalAgents; i++) { - (AgentList::getInstance()->getAgents()[i].getType() == AGENT_TYPE_INTERFACE) + (AgentList::getInstance()->getAgents()[i].getType() == AGENT_TYPE_AVATAR) ? totalAvatars++ : totalServers++; } sprintf(agents, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); From 3dc03f44a13d9d0881c265ae1bce8231cd79da94 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 22 Apr 2013 16:32:35 -0700 Subject: [PATCH 3/6] improved rendering of avatar --- interface/src/Head.cpp | 122 ++++++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 51 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index f4dcdbee53..fd054bd6f3 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -649,12 +649,7 @@ void Head::render(int faceToFace) { glutSolidSphere( 1, 20, 20 ); glPopMatrix(); } - - //--------------------------------------------------- - // show avatar orientation - //--------------------------------------------------- - renderOrientationDirections( _bone[ AVATAR_BONE_HEAD ].position, _bone[ AVATAR_BONE_HEAD ].orientation, 0.2f ); - + //--------------------------------------------------- // render body //--------------------------------------------------- @@ -708,6 +703,11 @@ void Head::renderHead(int faceToFace) { glEnable(GL_DEPTH_TEST); glEnable(GL_RESCALE_NORMAL); + //--------------------------------------------------- + // show head orientation + //--------------------------------------------------- + //renderOrientationDirections( _bone[ AVATAR_BONE_HEAD ].position, _bone[ AVATAR_BONE_HEAD ].orientation, 0.2f ); + glPushMatrix(); if (_usingBodySprings) { @@ -900,7 +900,7 @@ void Head::initializeSkeleton() { _bone[b].pitch = 0.0; _bone[b].roll = 0.0; _bone[b].length = 0.0; - _bone[b].radius = 0.02; //default + _bone[b].radius = 0.0; _bone[b].springBodyTightness = 4.0; _bone[b].orientation.setToIdentity(); } @@ -955,29 +955,54 @@ void Head::initializeSkeleton() { //---------------------------------------------------------- // specify the default pose position //---------------------------------------------------------- - _bone[ AVATAR_BONE_PELVIS_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.3, 0.0 ); - _bone[ AVATAR_BONE_MID_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.1, 0.0 ); - _bone[ AVATAR_BONE_CHEST_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.1, 0.0 ); - _bone[ AVATAR_BONE_NECK ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 ); - _bone[ AVATAR_BONE_HEAD ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 ); - _bone[ AVATAR_BONE_LEFT_CHEST ].defaultPosePosition = glm::vec3( -0.06, 0.06, 0.0 ); - _bone[ AVATAR_BONE_LEFT_SHOULDER ].defaultPosePosition = glm::vec3( -0.03, 0.0, 0.0 ); - _bone[ AVATAR_BONE_LEFT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.12, 0.0 ); - _bone[ AVATAR_BONE_LEFT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); - _bone[ AVATAR_BONE_LEFT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 ); - _bone[ AVATAR_BONE_RIGHT_CHEST ].defaultPosePosition = glm::vec3( 0.06, 0.06, 0.0 ); - _bone[ AVATAR_BONE_RIGHT_SHOULDER ].defaultPosePosition = glm::vec3( 0.03, 0.0, 0.0 ); - _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.12, 0.0 ); - _bone[ AVATAR_BONE_RIGHT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); - _bone[ AVATAR_BONE_RIGHT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 ); - _bone[ AVATAR_BONE_LEFT_PELVIS ].defaultPosePosition = glm::vec3( -0.05, 0.0, 0.0 ); - _bone[ AVATAR_BONE_LEFT_THIGH ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 ); - _bone[ AVATAR_BONE_LEFT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 ); - _bone[ AVATAR_BONE_LEFT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 ); - _bone[ AVATAR_BONE_RIGHT_PELVIS ].defaultPosePosition = glm::vec3( 0.05, 0.0, 0.0 ); - _bone[ AVATAR_BONE_RIGHT_THIGH ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 ); - _bone[ AVATAR_BONE_RIGHT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 ); - _bone[ AVATAR_BONE_RIGHT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 ); + _bone[ AVATAR_BONE_PELVIS_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.3, 0.0 ); + _bone[ AVATAR_BONE_MID_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.1, 0.0 ); + _bone[ AVATAR_BONE_CHEST_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 ); + _bone[ AVATAR_BONE_NECK ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 ); + _bone[ AVATAR_BONE_HEAD ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 ); + _bone[ AVATAR_BONE_LEFT_CHEST ].defaultPosePosition = glm::vec3( -0.06, 0.06, 0.0 ); + _bone[ AVATAR_BONE_LEFT_SHOULDER ].defaultPosePosition = glm::vec3( -0.03, 0.0, 0.0 ); + _bone[ AVATAR_BONE_LEFT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); + _bone[ AVATAR_BONE_LEFT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); + _bone[ AVATAR_BONE_LEFT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 ); + _bone[ AVATAR_BONE_RIGHT_CHEST ].defaultPosePosition = glm::vec3( 0.06, 0.06, 0.0 ); + _bone[ AVATAR_BONE_RIGHT_SHOULDER ].defaultPosePosition = glm::vec3( 0.03, 0.0, 0.0 ); + _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); + _bone[ AVATAR_BONE_RIGHT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); + _bone[ AVATAR_BONE_RIGHT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 ); + _bone[ AVATAR_BONE_LEFT_PELVIS ].defaultPosePosition = glm::vec3( -0.05, 0.0, 0.0 ); + _bone[ AVATAR_BONE_LEFT_THIGH ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 ); + _bone[ AVATAR_BONE_LEFT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 ); + _bone[ AVATAR_BONE_LEFT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 ); + _bone[ AVATAR_BONE_RIGHT_PELVIS ].defaultPosePosition = glm::vec3( 0.05, 0.0, 0.0 ); + _bone[ AVATAR_BONE_RIGHT_THIGH ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 ); + _bone[ AVATAR_BONE_RIGHT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 ); + _bone[ AVATAR_BONE_RIGHT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 ); + + + _bone[ AVATAR_BONE_PELVIS_SPINE ].radius = 0.05; + _bone[ AVATAR_BONE_MID_SPINE ].radius = 0.06; + _bone[ AVATAR_BONE_CHEST_SPINE ].radius = 0.03; + _bone[ AVATAR_BONE_NECK ].radius = 0.02; + _bone[ AVATAR_BONE_HEAD ].radius = 0.02; + _bone[ AVATAR_BONE_LEFT_CHEST ].radius = 0.025; + _bone[ AVATAR_BONE_LEFT_SHOULDER ].radius = 0.02; + _bone[ AVATAR_BONE_LEFT_UPPER_ARM ].radius = 0.02; + _bone[ AVATAR_BONE_LEFT_FOREARM ].radius = 0.015; + _bone[ AVATAR_BONE_LEFT_HAND ].radius = 0.01; + _bone[ AVATAR_BONE_RIGHT_CHEST ].radius = 0.025; + _bone[ AVATAR_BONE_RIGHT_SHOULDER ].radius = 0.02; + _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].radius = 0.02; + _bone[ AVATAR_BONE_RIGHT_FOREARM ].radius = 0.015; + _bone[ AVATAR_BONE_RIGHT_HAND ].radius = 0.01; + _bone[ AVATAR_BONE_LEFT_PELVIS ].radius = 0.02; + _bone[ AVATAR_BONE_LEFT_THIGH ].radius = 0.02; + _bone[ AVATAR_BONE_LEFT_SHIN ].radius = 0.015; + _bone[ AVATAR_BONE_LEFT_FOOT ].radius = 0.02; + _bone[ AVATAR_BONE_RIGHT_PELVIS ].radius = 0.02; + _bone[ AVATAR_BONE_RIGHT_THIGH ].radius = 0.02; + _bone[ AVATAR_BONE_RIGHT_SHIN ].radius = 0.015; + _bone[ AVATAR_BONE_RIGHT_FOOT ].radius = 0.02; //---------------------------------------------------------------------------- // calculate bone length @@ -1125,17 +1150,6 @@ glm::vec3 Head::getHeadPosition() { } return _bone[ AVATAR_BONE_HEAD ].position; - - -/* - return glm::vec3 - ( - _bone[ AVATAR_BONE_HEAD ].position.x, - _bone[ AVATAR_BONE_HEAD ].position.y, - _bone[ AVATAR_BONE_HEAD ].position.z - ); -*/ - } @@ -1251,18 +1265,21 @@ void Head::renderBody() { for (int b=0; b Date: Mon, 22 Apr 2013 17:21:47 -0700 Subject: [PATCH 4/6] switch to boxInFrustum() instead of pointInFrustum() for more accuracy --- interface/src/VoxelSystem.cpp | 2 +- libraries/voxels/src/VoxelTree.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index b2bcc701e0..fb7a11aef2 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -465,7 +465,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, bool down, void* voxelBox.getSize().x); // If the voxel is outside of the view frustum, then false color it red - if (ViewFrustum::OUTSIDE == viewFrustum->pointInFrustum(voxelBox.getCorner())) { + if (ViewFrustum::OUTSIDE == viewFrustum->boxInFrustum(voxelBox)) { // Out of view voxels are colored RED unsigned char newR = 255; unsigned char newG = 0; diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 3e75f76184..db69535e14 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -392,7 +392,7 @@ unsigned char * VoxelTree::loadBitstreamBuffer(unsigned char *& bitstreamBuffer, bool childIsClose = true; // for now, assume we're close enough bool childInView = !viewFrustumCulling || - (ViewFrustum::OUTSIDE != viewFrustum.pointInFrustum(childBox.getCorner())); + (ViewFrustum::OUTSIDE != viewFrustum.boxInFrustum(childBox)); /// XXXBHG - debug code, switch this to true, and we'll send everything but include false coloring // on voxels based on whether or not they match these rules. From 602fd94af26b021964872b7b9e8258988bff606f Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 22 Apr 2013 17:41:12 -0700 Subject: [PATCH 5/6] a few cleanups --- interface/src/Head.cpp | 46 ++++++++++-------------------------------- interface/src/main.cpp | 7 +------ 2 files changed, 12 insertions(+), 41 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index f3b0d4cb65..d1bbf5e65b 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -149,7 +149,7 @@ Head::Head(const Head &otherAvatar) { _bodyPitch = otherAvatar._bodyPitch; _bodyRoll = otherAvatar._bodyRoll; _bodyYawDelta = otherAvatar._bodyYawDelta; - _mousePressed = otherAvatar._mousePressed; + _mousePressed = otherAvatar._mousePressed; _mode = otherAvatar._mode; _isMine = otherAvatar._isMine; _renderYaw = otherAvatar._renderYaw; @@ -892,45 +892,25 @@ void Head::initializeSkeleton() { //---------------------------------------------------------------------------- // parental hierarchy //---------------------------------------------------------------------------- - - //---------------------------------------------------------------------------- - // spine and head - //---------------------------------------------------------------------------- _bone[ AVATAR_BONE_PELVIS_SPINE ].parent = AVATAR_BONE_NULL; _bone[ AVATAR_BONE_MID_SPINE ].parent = AVATAR_BONE_PELVIS_SPINE; _bone[ AVATAR_BONE_CHEST_SPINE ].parent = AVATAR_BONE_MID_SPINE; _bone[ AVATAR_BONE_NECK ].parent = AVATAR_BONE_CHEST_SPINE; _bone[ AVATAR_BONE_HEAD ].parent = AVATAR_BONE_NECK; - - //---------------------------------------------------------------------------- - // left chest and arm - //---------------------------------------------------------------------------- _bone[ AVATAR_BONE_LEFT_CHEST ].parent = AVATAR_BONE_MID_SPINE; _bone[ AVATAR_BONE_LEFT_SHOULDER ].parent = AVATAR_BONE_LEFT_CHEST; _bone[ AVATAR_BONE_LEFT_UPPER_ARM ].parent = AVATAR_BONE_LEFT_SHOULDER; _bone[ AVATAR_BONE_LEFT_FOREARM ].parent = AVATAR_BONE_LEFT_UPPER_ARM; _bone[ AVATAR_BONE_LEFT_HAND ].parent = AVATAR_BONE_LEFT_FOREARM; - - //---------------------------------------------------------------------------- - // right chest and arm - //---------------------------------------------------------------------------- _bone[ AVATAR_BONE_RIGHT_CHEST ].parent = AVATAR_BONE_MID_SPINE; _bone[ AVATAR_BONE_RIGHT_SHOULDER ].parent = AVATAR_BONE_RIGHT_CHEST; _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].parent = AVATAR_BONE_RIGHT_SHOULDER; _bone[ AVATAR_BONE_RIGHT_FOREARM ].parent = AVATAR_BONE_RIGHT_UPPER_ARM; _bone[ AVATAR_BONE_RIGHT_HAND ].parent = AVATAR_BONE_RIGHT_FOREARM; - - //---------------------------------------------------------------------------- - // left pelvis and leg - //---------------------------------------------------------------------------- _bone[ AVATAR_BONE_LEFT_PELVIS ].parent = AVATAR_BONE_PELVIS_SPINE; _bone[ AVATAR_BONE_LEFT_THIGH ].parent = AVATAR_BONE_LEFT_PELVIS; _bone[ AVATAR_BONE_LEFT_SHIN ].parent = AVATAR_BONE_LEFT_THIGH; _bone[ AVATAR_BONE_LEFT_FOOT ].parent = AVATAR_BONE_LEFT_SHIN; - - //---------------------------------------------------------------------------- - // right pelvis and leg - //---------------------------------------------------------------------------- _bone[ AVATAR_BONE_RIGHT_PELVIS ].parent = AVATAR_BONE_PELVIS_SPINE; _bone[ AVATAR_BONE_RIGHT_THIGH ].parent = AVATAR_BONE_RIGHT_PELVIS; _bone[ AVATAR_BONE_RIGHT_SHIN ].parent = AVATAR_BONE_RIGHT_THIGH; @@ -944,12 +924,12 @@ void Head::initializeSkeleton() { _bone[ AVATAR_BONE_CHEST_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 ); _bone[ AVATAR_BONE_NECK ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 ); _bone[ AVATAR_BONE_HEAD ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 ); - _bone[ AVATAR_BONE_LEFT_CHEST ].defaultPosePosition = glm::vec3( -0.06, 0.06, 0.0 ); + _bone[ AVATAR_BONE_LEFT_CHEST ].defaultPosePosition = glm::vec3( -0.05, 0.05, 0.0 ); _bone[ AVATAR_BONE_LEFT_SHOULDER ].defaultPosePosition = glm::vec3( -0.03, 0.0, 0.0 ); _bone[ AVATAR_BONE_LEFT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); _bone[ AVATAR_BONE_LEFT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); _bone[ AVATAR_BONE_LEFT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 ); - _bone[ AVATAR_BONE_RIGHT_CHEST ].defaultPosePosition = glm::vec3( 0.06, 0.06, 0.0 ); + _bone[ AVATAR_BONE_RIGHT_CHEST ].defaultPosePosition = glm::vec3( 0.05, 0.05, 0.0 ); _bone[ AVATAR_BONE_RIGHT_SHOULDER ].defaultPosePosition = glm::vec3( 0.03, 0.0, 0.0 ); _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); _bone[ AVATAR_BONE_RIGHT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 ); @@ -971,12 +951,12 @@ void Head::initializeSkeleton() { _bone[ AVATAR_BONE_HEAD ].radius = 0.02; _bone[ AVATAR_BONE_LEFT_CHEST ].radius = 0.025; _bone[ AVATAR_BONE_LEFT_SHOULDER ].radius = 0.02; - _bone[ AVATAR_BONE_LEFT_UPPER_ARM ].radius = 0.02; + _bone[ AVATAR_BONE_LEFT_UPPER_ARM ].radius = 0.015; _bone[ AVATAR_BONE_LEFT_FOREARM ].radius = 0.015; _bone[ AVATAR_BONE_LEFT_HAND ].radius = 0.01; _bone[ AVATAR_BONE_RIGHT_CHEST ].radius = 0.025; _bone[ AVATAR_BONE_RIGHT_SHOULDER ].radius = 0.02; - _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].radius = 0.02; + _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].radius = 0.015; _bone[ AVATAR_BONE_RIGHT_FOREARM ].radius = 0.015; _bone[ AVATAR_BONE_RIGHT_HAND ].radius = 0.01; _bone[ AVATAR_BONE_LEFT_PELVIS ].radius = 0.02; @@ -1157,16 +1137,12 @@ void Head::updateHandMovement() { if ( _usingBodySprings ) { if ( _closestOtherAvatar != -1 ) { if ( _mousePressed ) { + + + glm::vec3 handToHandVector( _otherAvatarHandPosition[ _closestOtherAvatar ]); + handToHandVector -= _bone[ AVATAR_BONE_RIGHT_HAND ].position; - /* - glm::vec3 handShakePull( DEBUG_otherAvatarListPosition[ closestOtherAvatar ]); - handShakePull -= _bone[ AVATAR_BONE_RIGHT_HAND ].position; - - handShakePull *= 1.0; - - transformedHandMovement += handShakePull; - */ - + //_bone[ AVATAR_BONE_RIGHT_HAND ].springyVelocity -= handPull; _bone[ AVATAR_BONE_RIGHT_HAND ].position = _otherAvatarHandPosition[ _closestOtherAvatar ]; } } @@ -1250,7 +1226,7 @@ void Head::renderBody() { //renderBoneAsBlock( (AvatarBoneID)b); //render bone orientation - //renderOrientationDirections( _bone[b].position, _bone[b].orientation, 0.05f ); + renderOrientationDirections( _bone[b].springyPosition, _bone[b].orientation, _bone[b].radius * 2.0 ); if ( _usingBodySprings ) { glColor3fv( skinColor ); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index c71a94da9a..b3883f6e97 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -1500,7 +1500,7 @@ void idle(void) { // // Sample hardware, update view frustum if needed, Lsend avatar data to mixer/agents // - updateAvatar( 1.f/FPS ); + updateAvatar(deltaTime); //loop through all the other avatars and simulate them. AgentList * agentList = AgentList::getInstance(); @@ -1509,14 +1509,9 @@ void idle(void) { if (agent->getLinkedData() != NULL) { Head *avatar = (Head *)agent->getLinkedData(); - -//printf( "simulating remote avatar\n" ); - avatar->simulate(deltaTime); } } - - //updateAvatarHand(1.f/FPS); field.simulate (deltaTime); myAvatar.simulate(deltaTime); From 9d17dc0387fe7a75303d9341e622876189df4a58 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 22 Apr 2013 17:43:28 -0700 Subject: [PATCH 6/6] make view frustum culling default behavior, removed soem debug printf()s for now --- libraries/voxels/src/ViewFrustum.cpp | 26 ++++++++++++-------------- voxel-server/src/main.cpp | 6 +++--- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index 5c9022c27e..8bdb2d97cb 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -192,16 +192,16 @@ int ViewFrustum::sphereInFrustum(const glm::vec3& center, float radius) const { int ViewFrustum::boxInFrustum(const AABox& box) const { - printf("ViewFrustum::boxInFrustum() box.corner=%f,%f,%f x=%f\n", - box.getCorner().x,box.getCorner().y,box.getCorner().z,box.getSize().x); + //printf("ViewFrustum::boxInFrustum() box.corner=%f,%f,%f x=%f\n", + // box.getCorner().x,box.getCorner().y,box.getCorner().z,box.getSize().x); int result = INSIDE; for(int i=0; i < 6; i++) { - printf("plane[%d] -- point(%f,%f,%f) normal(%f,%f,%f) d=%f \n",i, - _planes[i].getPoint().x, _planes[i].getPoint().y, _planes[i].getPoint().z, - _planes[i].getNormal().x, _planes[i].getNormal().y, _planes[i].getNormal().z, - _planes[i].getDCoefficient() - ); + //printf("plane[%d] -- point(%f,%f,%f) normal(%f,%f,%f) d=%f \n",i, + // _planes[i].getPoint().x, _planes[i].getPoint().y, _planes[i].getPoint().z, + // _planes[i].getNormal().x, _planes[i].getNormal().y, _planes[i].getNormal().z, + // _planes[i].getDCoefficient() + //); glm::vec3 normal = _planes[i].getNormal(); glm::vec3 boxVertexP = box.getVertexP(normal); @@ -210,13 +210,11 @@ int ViewFrustum::boxInFrustum(const AABox& box) const { glm::vec3 boxVertexN = box.getVertexN(normal); float planeToBoxVertexNDistance = _planes[i].distance(boxVertexN); - - - printf("plane[%d] normal=(%f,%f,%f) bVertexP=(%f,%f,%f) planeToBoxVertexPDistance=%f boxVertexN=(%f,%f,%f) planeToBoxVertexNDistance=%f\n",i, - normal.x,normal.y,normal.z, - boxVertexP.x,boxVertexP.y,boxVertexP.z,planeToBoxVertexPDistance, - boxVertexN.x,boxVertexN.y,boxVertexN.z,planeToBoxVertexNDistance - ); + //printf("plane[%d] normal=(%f,%f,%f) bVertexP=(%f,%f,%f) planeToBoxVertexPDistance=%f boxVertexN=(%f,%f,%f) planeToBoxVertexNDistance=%f\n",i, + // normal.x,normal.y,normal.z, + // boxVertexP.x,boxVertexP.y,boxVertexP.z,planeToBoxVertexPDistance, + // boxVertexN.x,boxVertexN.y,boxVertexN.z,planeToBoxVertexNDistance + // ); if (planeToBoxVertexPDistance < 0) { return OUTSIDE; diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index d85154abc5..91fa2fd596 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -49,7 +49,7 @@ VoxelTree randomTree; bool wantColorRandomizer = false; bool debugViewFrustum = false; -bool viewFrustumCulling = false; // for now +bool viewFrustumCulling = true; // for now void addSphere(VoxelTree * tree,bool random, bool wantColorRandomizer) { float r = random ? randFloatInRange(0.05,0.1) : 0.25; @@ -276,8 +276,8 @@ int main(int argc, const char * argv[]) ::debugViewFrustum = cmdOptionExists(argc, argv, DEBUG_VIEW_FRUSTUM); printf("debugViewFrustum=%s\n", (::debugViewFrustum ? "yes" : "no")); - const char* VIEW_FRUSTUM_CULLING = "--ViewFrustumCulling"; - ::viewFrustumCulling = cmdOptionExists(argc, argv, VIEW_FRUSTUM_CULLING); + const char* NO_VIEW_FRUSTUM_CULLING = "--NoViewFrustumCulling"; + ::viewFrustumCulling = !cmdOptionExists(argc, argv, NO_VIEW_FRUSTUM_CULLING); printf("viewFrustumCulling=%s\n", (::viewFrustumCulling ? "yes" : "no")); const char* WANT_COLOR_RANDOMIZER = "--WantColorRandomizer";