Ignore:
Timestamp:
Aug 2, 2013, 5:50:39 PM (6 years ago)
Author:
sam
Message:

test: port the btphystest and meshviewer tests to the new input API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/btphystest.cpp

    r2816 r2838  
    3434#define USE_PLATFORM    1
    3535#define USE_ROPE        0
    36 #define USE_BODIES        1
     36#define USE_BODIES      1
    3737#define USE_ROTATION    0
    38 #define USE_CHARACTER    1
    39 #define USE_STAIRS        1
    40 
    41 #define    IPT_MOVE_FORWARD        "Move_Forward"
    42 #define    IPT_MOVE_BACKWARD        "Move_Backward"
    43 #define    IPT_MOVE_LEFT            "Move_Left"
    44 #define    IPT_MOVE_RIGHT            "Move_Right"
    45 #define    IPT_MOVE_UP                "Move_Up"
    46 #define    IPT_MOVE_DOWN            "Move_Down"
    47 #define    IPT_MOVE_JUMP            "Move_Jump"
     38#define USE_CHARACTER   1
     39#define USE_STAIRS      1
    4840
    4941BtPhysTest::BtPhysTest(bool editor)
    5042{
    5143    m_loop_value = .0f;
     44
     45    /* Register an input controller for the keyboard */
     46    m_controller = new Controller(KEY_MAX, 0);
     47    m_controller->GetKey(KEY_MOVE_FORWARD).Bind("Keyboard", "Up");
     48    m_controller->GetKey(KEY_MOVE_BACK).Bind("Keyboard", "Down");
     49    m_controller->GetKey(KEY_MOVE_LEFT).Bind("Keyboard", "Left");
     50    m_controller->GetKey(KEY_MOVE_RIGHT).Bind("Keyboard", "Right");
     51    m_controller->GetKey(KEY_MOVE_JUMP).Bind("Keyboard", "Space");
     52    m_controller->GetKey(KEY_MOVE_UP).Bind("Keyboard", "PageUp");
     53    m_controller->GetKey(KEY_MOVE_DOWN).Bind("Keyboard", "PageDown");
     54    m_controller->GetKey(KEY_QUIT).Bind("Keyboard", "Escape");
    5255
    5356    /* Create a camera that matches the settings of XNA BtPhysTest */
     
    196199        m_character_list << NewPhyobj;
    197200        Ticker::Ref(NewPhyobj);
    198 
    199 
    200         Input::LinkActionToKey(IPT_MOVE_FORWARD,        Key::Up);
    201         Input::LinkActionToKey(IPT_MOVE_BACKWARD,        Key::Down);
    202         Input::LinkActionToKey(IPT_MOVE_LEFT,            Key::Left);
    203         Input::LinkActionToKey(IPT_MOVE_RIGHT,            Key::Right);
    204         Input::LinkActionToKey(IPT_MOVE_JUMP,            Key::Space);
    205         Input::LinkActionToKey(IPT_MOVE_UP,                Key::PageUp);
    206         Input::LinkActionToKey(IPT_MOVE_DOWN,            Key::PageDown);
    207201
    208202        //NewPhyobj->GetCharacter()->AttachTo(BasePhyobj->GetPhysic(), true, true);
     
    259253    WorldEntity::TickGame(seconds);
    260254
    261     if (Input::WasReleased(Key::Escape))
     255    if (m_controller->GetKey(KEY_QUIT).IsReleased())
    262256        Ticker::Shutdown();
    263257
     
    345339            mat4 CtlrMx = Character->GetTransform();
    346340
    347             int HMovement = Input::GetStatus(IPT_MOVE_RIGHT) - Input::GetStatus(IPT_MOVE_LEFT);
    348             int VMovement = Input::GetStatus(IPT_MOVE_FORWARD) - Input::GetStatus(IPT_MOVE_BACKWARD);
    349             int RMovement = Input::GetStatus(IPT_MOVE_UP) - Input::GetStatus(IPT_MOVE_DOWN);
    350             vec3 CharMove = vec3((float)VMovement * seconds * 4.f, (float)RMovement * seconds * 10.f, (float)HMovement * seconds * 4.f);
    351 
    352             if (Input::WasReleased(IPT_MOVE_JUMP))
     341            vec3 movement(0.f);
     342            movement.z = (m_controller->GetKey(KEY_MOVE_RIGHT).IsDown() ? 1.f : 0.f)
     343                       - (m_controller->GetKey(KEY_MOVE_LEFT).IsDown() ? 1.f : 0.f);
     344            movement.x = (m_controller->GetKey(KEY_MOVE_FORWARD).IsDown() ? 1.f : 0.f)
     345                       - (m_controller->GetKey(KEY_MOVE_BACK).IsDown() ? 1.f : 0.f);
     346            movement.y = (m_controller->GetKey(KEY_MOVE_UP).IsDown() ? 1.f : 0.f)
     347                       - (m_controller->GetKey(KEY_MOVE_DOWN).IsDown() ? 1.f : 0.f);
     348            vec3 CharMove = movement * seconds * vec3(4.f, 10.f, 4.f);
     349
     350            if (m_controller->GetKey(KEY_MOVE_JUMP).IsReleased())
    353351                Character->Jump();
    354352            Character->SetMovementForFrame(CharMove);
Note: See TracChangeset for help on using the changeset viewer.