From fbeaa0524f855d05863287d7f1cdb11854ad0764 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Wed, 24 Feb 2010 05:23:00 +0000 Subject: [PATCH] More fixes to swap the bullet axis. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/switch_coordinate_system@4822 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/graphics/camera.cpp | 6 +++++- src/karts/kart.cpp | 1 - src/karts/moveable.cpp | 11 +++++++++++ src/modes/world.cpp | 2 +- src/physics/physics.cpp | 2 +- src/states_screens/kart_selection.cpp | 2 +- src/tracks/track.cpp | 2 +- 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp index 8eb76fbda..24d7fb68b 100644 --- a/src/graphics/camera.cpp +++ b/src/graphics/camera.cpp @@ -269,7 +269,11 @@ void Camera::update(float dt) { Vec3 wanted_position; Vec3 wanted_target = m_kart->getXYZ(); - + Vec3 rotated_forw=m_kart->getTrans().getBasis()*Vec3(0,0,1); + float heading=atan2f(-rotated_forw.getX(), rotated_forw.getZ()); + printf("kart hpr %f (%f) %f %f\n", + m_kart->getHPR().getX(),heading, m_kart->getHPR().getY(), + m_kart->getHPR().getZ()); // Each case should set wanted_position and wanted_target according to // what is needed for that mode. Yes, there is a lot of duplicate code // but it is (IMHO) much easier to follow this way. diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 71b907d28..9f3d4a5d7 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -645,7 +645,6 @@ void Kart::update(float dt) else m_uprightConstraint->setLimit(m_kart_properties->getUprightTolerance()); - m_zipper_time_left = m_zipper_time_left>0.0f ? m_zipper_time_left-dt : 0.0f; //m_wheel_rotation gives the rotation around the X-axis, and since velocity's diff --git a/src/karts/moveable.cpp b/src/karts/moveable.cpp index 2622aa976..433625e9d 100644 --- a/src/karts/moveable.cpp +++ b/src/karts/moveable.cpp @@ -136,6 +136,17 @@ void Moveable::update(float dt) //Vec3 roll_vec = m_transform.getBasis()*up; //float roll = atan2(roll_vec.getX(), roll_vec.getY()); //m_hpr.setRoll(roll); + Vec3 up(0, 1, 0); + Vec3 pitch_vec = m_transform.getBasis()*up; + float p = atan2f(pitch_vec.getZ(), pitch_vec.getY()); + float r = atan2f(pitch_vec.getX(), pitch_vec.getY()); + Vec3 forw(0,0,1); + Vec3 forw_vec = m_transform.getBasis()*forw; + float h = atan2f(forw_vec.getX(), forw_vec.getZ()); + printf("orig: %f %f %f now %f %f %f\n", + m_hpr.getX(), m_hpr.getY(), m_hpr.getZ(), h, p, r); + //m_hpr = Vec3(h, p, r); + //m_hpr.setPitch(p); updateGraphics(Vec3(0,0,0), Vec3(0,0,0)); m_first_time = false ; diff --git a/src/modes/world.cpp b/src/modes/world.cpp index b15be752d..43ab70e35 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -304,7 +304,7 @@ void World::resetAllKarts() for ( KartList::iterator i=m_karts.begin(); i!=m_karts.end(); i++) { ///start projection from top of kart - btVector3 up_offset(0, 0, 0.5f * ((*i)->getKartHeight())); + btVector3 up_offset(0, 0.5f * ((*i)->getKartHeight()), 0); (*i)->getVehicle()->getRigidBody()->translate (up_offset); bool kart_over_ground = m_physics->projectKartDownwards(*i); diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 618f45ef3..176971c82 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -154,7 +154,7 @@ void Physics::update(float dt) bool Physics::projectKartDownwards(const Kart *k) { - btVector3 hell(0, 0, -10000); + btVector3 hell(0, -10000, 0); return k->getVehicle()->projectVehicleToSurface(hell, true /*allow translation*/); } //projectKartsDownwards diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index 3ef8be671..fa716fd5a 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -664,7 +664,7 @@ public: // Random kart scene::IMesh* model = item_manager->getItemModel(Item::ITEM_BONUS_BOX); w3->clearModels(); - w3->addModel( model, Vec3(0.0f, 0.0f, -12.0f) ); + w3->addModel( model, Vec3(0.0f, -12.0f, 0.0f) ); w3->update(0); m_parent->m_kart_widgets[playerID].kartName->setText( _("Random Kart") ); } diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index c09c00e0a..725d29047 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -918,7 +918,7 @@ void Track::getTerrainInfo(const Vec3 &pos, float *hot, Vec3 *normal, const Material **material) const { btVector3 to_pos(pos); - to_pos.setZ(-100000.f); + to_pos.setY(-100000.f); class MaterialCollision : public btCollisionWorld::ClosestRayResultCallback {