diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index e7bf3d751b..1481456361 100755 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -33,5 +33,11 @@ void Camera::update() position = glm::dvec3( targetPosition ); position += glm::dvec3( x, y, z ); + + //geterate the ortho-normals for the orientation based on the Euler angles + orientation.setToIdentity(); + orientation.yaw ( yaw ); + orientation.pitch ( pitch ); + orientation.roll ( roll ); } diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 2b1222c09d..c6df7de2e9 100755 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -190,7 +190,7 @@ void Head::reset() - +//this pertains to moving the head with the glasses //--------------------------------------------------- void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity) // Using serial data, update avatar/render position and angles @@ -285,10 +285,7 @@ void Head::simulate(float deltaTime) sin( avatar.pitch * PI_OVER_180 ), cos( avatar.roll * PI_OVER_180 ) ); - */ - - - /* + glm::vec3 forward(-sinf(getRenderYaw()*PI/180), sinf(getRenderPitch()*PI/180), cosf(getRenderYaw()*PI/180)); @@ -296,93 +293,54 @@ void Head::simulate(float deltaTime) thrust = glm::vec3(0); */ - const float THRUST_MAG = 10.0; - - /* - const float THRUST_LATERAL_MAG = 10.0; - const float THRUST_VERTICAL_MAG = 10.0; - */ - + const float THRUST_MAG = 10.0; + const float THRUST_LATERAL_MAG = 10.0; + const float THRUST_VERTICAL_MAG = 10.0; avatar.thrust = glm::dvec3( 0.0, 0.0, 0.0 ); if (driveKeys[FWD]) { - //position.x += avatar.orientation.getFront().getX() * 0.01; - //position.y += avatar.orientation.getFront().getY() * 0.01; - //position.z -= avatar.orientation.getFront().getZ() * 0.01; - avatar.thrust.x += avatar.orientation.getFront().getX() * THRUST_MAG; avatar.thrust.y += avatar.orientation.getFront().getY() * THRUST_MAG; avatar.thrust.z -= avatar.orientation.getFront().getZ() * THRUST_MAG; - //thrust += THRUST_MAG*forward; } - if (driveKeys[BACK]) { - //position.x -= avatar.orientation.getFront().getX() * 0.01; - //position.y -= avatar.orientation.getFront().getY() * 0.01; - //position.z += avatar.orientation.getFront().getZ() * 0.01; - avatar.thrust.x -= avatar.orientation.getFront().getX() * THRUST_MAG; avatar.thrust.y -= avatar.orientation.getFront().getY() * THRUST_MAG; avatar.thrust.z += avatar.orientation.getFront().getZ() * THRUST_MAG; - //thrust += -THRUST_MAG*forward; } - - if (driveKeys[RIGHT]) { - //position.x += avatar.orientation.getRight().getX() * 0.01; - //position.y += avatar.orientation.getRight().getY() * 0.01; - //position.z -= avatar.orientation.getRight().getZ() * 0.01; - - avatar.thrust.x += avatar.orientation.getRight().getX() * THRUST_MAG; - avatar.thrust.y += avatar.orientation.getRight().getY() * THRUST_MAG; - avatar.thrust.z -= avatar.orientation.getRight().getZ() * THRUST_MAG; - + avatar.thrust.x += avatar.orientation.getRight().getX() * THRUST_LATERAL_MAG; + avatar.thrust.y += avatar.orientation.getRight().getY() * THRUST_LATERAL_MAG; + avatar.thrust.z -= avatar.orientation.getRight().getZ() * THRUST_LATERAL_MAG; //thrust.x += forward.z*-THRUST_LATERAL_MAG; //thrust.z += forward.x*THRUST_LATERAL_MAG; } if (driveKeys[LEFT]) { - //position.x -= avatar.orientation.getRight().getX() * 0.01; - //position.y -= avatar.orientation.getRight().getY() * 0.01; - //position.z += avatar.orientation.getRight().getZ() * 0.01; - - avatar.thrust.x -= avatar.orientation.getRight().getX() * THRUST_MAG; - avatar.thrust.y -= avatar.orientation.getRight().getY() * THRUST_MAG; - avatar.thrust.z += avatar.orientation.getRight().getZ() * THRUST_MAG; - + avatar.thrust.x -= avatar.orientation.getRight().getX() * THRUST_LATERAL_MAG; + avatar.thrust.y -= avatar.orientation.getRight().getY() * THRUST_LATERAL_MAG; + avatar.thrust.z += avatar.orientation.getRight().getZ() * THRUST_LATERAL_MAG; //thrust.x += forward.z*THRUST_LATERAL_MAG; //thrust.z += forward.x*-THRUST_LATERAL_MAG; } - - if (driveKeys[UP]) { - //position.x -= avatar.orientation.getUp().getX() * 0.01; - //position.y -= avatar.orientation.getUp().getY() * 0.01; - //position.z += avatar.orientation.getUp().getZ() * 0.01; - - avatar.thrust.x -= avatar.orientation.getUp().getX() * THRUST_MAG; - avatar.thrust.y -= avatar.orientation.getUp().getY() * THRUST_MAG; - avatar.thrust.z += avatar.orientation.getUp().getZ() * THRUST_MAG; - + avatar.thrust.x -= avatar.orientation.getUp().getX() * THRUST_VERTICAL_MAG; + avatar.thrust.y -= avatar.orientation.getUp().getY() * THRUST_VERTICAL_MAG; + avatar.thrust.z += avatar.orientation.getUp().getZ() * THRUST_VERTICAL_MAG; //thrust.y += -THRUST_VERTICAL_MAG; } if (driveKeys[DOWN]) { - //position.x += avatar.orientation.getUp().getX() * 0.01; - //position.y += avatar.orientation.getUp().getY() * 0.01; - //position.z -= avatar.orientation.getUp().getZ() * 0.01; - - avatar.thrust.x += avatar.orientation.getUp().getX() * THRUST_MAG; - avatar.thrust.y += avatar.orientation.getUp().getY() * THRUST_MAG; - avatar.thrust.z -= avatar.orientation.getUp().getZ() * THRUST_MAG; - + avatar.thrust.x += avatar.orientation.getUp().getX() * THRUST_VERTICAL_MAG; + avatar.thrust.y += avatar.orientation.getUp().getY() * THRUST_VERTICAL_MAG; + avatar.thrust.z -= avatar.orientation.getUp().getZ() * THRUST_VERTICAL_MAG; //thrust.y += THRUST_VERTICAL_MAG; } @@ -1055,7 +1013,9 @@ void Head::parseData(void *data, int size) &Pitch, &Yaw, &Roll, &position.x, &position.y, &position.z, &loudness, &averageLoudness, - &handPos.x, &handPos.y, &handPos.z + &avatar.bone[ AVATAR_BONE_RIGHT_HAND ].worldPosition.x, + &avatar.bone[ AVATAR_BONE_RIGHT_HAND ].worldPosition.y, + &avatar.bone[ AVATAR_BONE_RIGHT_HAND ].worldPosition.z ); if (glm::length(handPos) > 0.0) hand->setPos(handPos); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 64d4e774c5..edaee1095a 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -608,7 +608,7 @@ void display(void) { myCamera.setYaw ( - myHead.getAvatarYaw() ); myCamera.setUp ( 0.4 ); - myCamera.setDistance( 0.08 ); + myCamera.setDistance( 0.5 ); myCamera.update(); } else @@ -618,7 +618,7 @@ void display(void) { myCamera.setYaw ( 180.0 - myHead.getAvatarYaw() ); myCamera.setUp ( 0.15 ); - myCamera.setDistance( 0.08 ); + myCamera.setDistance( 1.0 ); myCamera.update(); } @@ -653,14 +653,16 @@ void display(void) // if (!display_head) cloud.render(); // Draw voxels - voxels.render(); +//voxels.render(); // Draw field vectors if (display_field) field.render(); // Render heads of other agents - for(std::vector::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++) { - if (agent->getLinkedData() != NULL) { + for(std::vector::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++) + { + if (agent->getLinkedData() != NULL) + { Head *agentHead = (Head *)agent->getLinkedData(); glPushMatrix(); glm::vec3 pos = agentHead->getPos(); @@ -670,7 +672,7 @@ void display(void) } } - if (!display_head) balls.render(); + if ( !display_head ) balls.render(); // Render the world box if (!display_head && stats_on) render_world_box(); @@ -1046,6 +1048,21 @@ void idle(void) // Simulation simulateHead(1.f/FPS); + + + //test + /* + // simulate the other agents + for(std::vector::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++) + { + if (agent->getLinkedData() != NULL) + { + Head *agentHead = (Head *)agent->getLinkedData(); + agentHead->simulate(1.f/FPS); + } + } + */ + simulateHand(1.f/FPS); if (simulate_on) { @@ -1078,7 +1095,7 @@ void reshape(int width, int height) glMatrixMode(GL_PROJECTION); //hello fov.setResolution(width, height) .setBounds(glm::vec3(-0.5f,-0.5f,-500.0f), glm::vec3(0.5f, 0.5f, 0.1f) ) - .setPerspective(0.7854f); + .setPerspective(0.7854f); glLoadMatrixf(glm::value_ptr(fov.getViewerScreenXform())); glMatrixMode(GL_MODELVIEW);