From 496894ecced1b0a4ae5ab176902bbd0f43a31ed1 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Fri, 24 Oct 2014 12:56:30 -0700 Subject: Updating to 0.4.3 SDK --- Samples/OculusWorldDemo/Player.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'Samples/OculusWorldDemo/Player.cpp') diff --git a/Samples/OculusWorldDemo/Player.cpp b/Samples/OculusWorldDemo/Player.cpp index 53ad2a6..fc90956 100644 --- a/Samples/OculusWorldDemo/Player.cpp +++ b/Samples/OculusWorldDemo/Player.cpp @@ -23,14 +23,21 @@ limitations under the License. #include "Player.h" #include -Player::Player() - : UserEyeHeight(1.76f - 0.15f), // 1.76 meters height (ave US male, Wikipedia), less 15 centimeters (TomF's top-of-head-to-eye distance). + +Player::Player() : + UserEyeHeight(1.76f - 0.15f), // 1.76 meters height (ave US male, Wikipedia), less 15 centimeters (TomF's top-of-head-to-eye distance). + HeightScale(1.0f), BodyPos(7.7f, 1.76f - 0.15f, -1.0f), - BodyYaw(YawInitial) + BodyYaw(YawInitial), + HeadPose(), + MoveForward(0), + MoveBack(0), + MoveLeft(0), + MoveRight(0), + GamepadMove(), + GamepadRotate(), + bMotionRelativeToBody(false) { - MoveForward = MoveBack = MoveLeft = MoveRight = 0; - GamepadMove = Vector3f(0); - GamepadRotate = Vector3f(0); } Player::~Player() @@ -56,7 +63,6 @@ Posef Player::VirtualWorldTransformfromRealPose(const Posef &sensorHeadPose) BodyPos + baseQ.Rotate(sensorHeadPose.Translation)); } - void Player::HandleMovement(double dt, Array >* collisionModels, Array >* groundCollisionModels, bool shiftDown) { @@ -145,14 +151,14 @@ void Player::HandleMovement(double dt, Array >* collisionMod BodyPos += orientationVector; Planef collisionPlaneDown; - float finalDistanceDown = 10; + float finalDistanceDown = GetScaledEyeHeight() + 10.0f; // Only apply down if there is collision model (otherwise we get jitter). if (groundCollisionModels->GetSize()) { for(unsigned int i = 0; i < groundCollisionModels->GetSize(); ++i) { - float checkLengthDown = 10; + float checkLengthDown = GetScaledEyeHeight() + 10; if (groundCollisionModels->At(i)->TestRay(BodyPos, Vector3f(0.0f, -1.0f, 0.0f), checkLengthDown, &collisionPlaneDown)) { @@ -161,16 +167,14 @@ void Player::HandleMovement(double dt, Array >* collisionMod } // Maintain the minimum camera height - if (UserEyeHeight - finalDistanceDown < 1.0f) + if (GetScaledEyeHeight() - finalDistanceDown < 1.0f) { - BodyPos.y += UserEyeHeight - finalDistanceDown; + BodyPos.y += GetScaledEyeHeight() - finalDistanceDown; } } } - - // Handle directional movement. Returns 'true' if movement was processed. bool Player::HandleMoveKey(OVR::KeyCode key, bool down) { @@ -190,5 +194,3 @@ bool Player::HandleMoveKey(OVR::KeyCode key, bool down) default: return false; } } - - -- cgit v1.2.3