Ignore:
Timestamp:
Aug 12, 2012, 11:07:23 PM (10 years ago)
Author:
touky
Message:

So Character Controller works with a lazy camera logic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/BtPhysTest.cpp

    r1722 r1724  
    5252#define USE_WALL                1
    5353#define USE_PLATFORM    1
    54 #define USE_ROPE                0
    55 #define USE_BODIES              0
     54#define USE_ROPE                1
     55#define USE_BODIES              1
    5656#define USE_ROTATION    0
    5757#define USE_CHARACTER   1
     
    7171
    7272        m_simulation = new Simulation();
     73        m_simulation->SetWorldLimit(vec3(-1000.0f, -1000.0f, -1000.0f), vec3(1000.0f, 1000.0f, 1000.0f));
    7374        m_simulation->Init();
    7475        vec3 NewGravity = vec3(.0f, -10.0f, .0f);
     
    110111        {
    111112                quat NewRotation = quat::fromeuler_xyz(5.f, 0.f, 0.f);
    112                 vec3 NewPosition = pos_offset + vec3(5.0f, -20.0f, -15.0f);
     113                vec3 NewPosition = pos_offset + vec3(5.0f, -25.0f, -15.0f);
    113114
    114115                PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 1);
     
    128129        {
    129130                quat NewRotation = quat::fromeuler_xyz(0.f, 0.f, 0.f);
    130                 vec3 NewPosition = pos_offset + vec3(.0f, 40.0f, .0f);
     131                vec3 NewPosition = pos_offset + vec3(.0f, 20.0f, .0f);
    131132
    132133                PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 2);
     
    410411                {
    411412                        PhysicsObject* PhysObj = m_character_list[i];
     413                        EasyCharacterController* Character = (EasyCharacterController*)PhysObj->GetCharacter();
     414
     415                        int HMovement = Input::GetButtonState(275 /*SDLK_RIGHT*/) - Input::GetButtonState(276 /*SDLK_LEFT*/);
     416                        int VMovement = Input::GetButtonState(273 /*SDLK_UP*/) - Input::GetButtonState(274 /*SDLK_DOWN*/);
     417
     418                        Character->SetMovementForFrame(vec3((float)VMovement * seconds * 4.f, .0f, (float)HMovement * seconds * 4.f));
     419                }
     420        }
     421
     422        if (USE_CHARACTER)
     423        {
     424                PhysObjBarycenter = vec3(.0f);
     425                factor = .0f;
     426
     427                for (int i = 0; i < m_character_list.Count(); i++)
     428                {
     429                        PhysicsObject* PhysObj = m_character_list[i];
    412430                        mat4 GroundMat = PhysObj->GetTransform();
    413431
     
    418436                PhysObjBarycenter /= factor;
    419437
    420                 m_camera->SetTarget(PhysObjBarycenter);
    421                 m_camera->SetPosition(PhysObjBarycenter + vec3(-80.0f, 80.0f, .0f));
     438                m_camera->SetTarget(m_camera->GetTarget() + (seconds / (seconds + 0.18f)) * (PhysObjBarycenter - m_camera->GetTarget()));
     439                vec3 CamPosCenter = m_camera->GetTarget() + vec3(.0f, 20.0f, .0f);
     440                m_camera->SetPosition(CamPosCenter + normalize(m_camera->GetPosition() - CamPosCenter) * 5.0f);
    422441        }
    423442        else
Note: See TracChangeset for help on using the changeset viewer.