Changeset 1378


Ignore:
Timestamp:
May 12, 2012, 9:56:02 PM (11 years ago)
Author:
touky
Message:

Tweaked Player movement.
Camera follows player : mostly debug.

Location:
trunk/orbital
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/orbital/orbital.cpp

    r1376 r1378  
    187187#endif
    188188
     189        vec3 new_camera_pos = vec3(0,0,0);
     190        for (int i = 0; i < m_players.Count(); i++)
     191                new_camera_pos += m_players[i]->m_position;
     192        new_camera_pos /= (float)m_players.Count();
     193        new_camera_pos += vec3(0.f, 0.f, -50.f);
     194
     195        new_camera_pos = m_camera->GetTarget() + (new_camera_pos - m_camera->GetTarget()) * (seconds / (seconds + 0.15f));
     196        m_camera->SetPosition(new_camera_pos + vec3(0.f, 600.f, 0.f));
     197        m_camera->SetTarget(new_camera_pos);
     198
    189199    m_model = mat4(1.f);
    190200}
  • trunk/orbital/player.h

    r1377 r1378  
    2121                          vec4(0.1f,0.1f,0.6f,1.0f) };
    2222
     23                //Red Mesh
    2324        if (type == 0)
    2425        {
     
    2930            m_ship_mesh.SendCommand("scb1,1,1,1,ac4,15,.2,.6,1,1,tz-2,ac4,15,.2,.6,1,1,rx90,t0,-2,-7,fl");
    3031
    31             m_exhaust_mesh.SendCommand("sc0,1,1,1,scb0,0,0,1,ac5,15,0,1.5,0,1,ac7,35,1.1,4,0,1,rx90,t-3,0,27,mx,fl");
    32         }
     32            m_exhaust_mesh.SendCommand("sc0,1,1,1,scb0,0,0,1,ac5,15,0,1.5,0,1,ac7,35,1.1,4,0,1,rx90,t0,0,27,fl");
     33        }
     34                //Blue Mesh
    3335        else
    3436        {
     
    3739            m_ship_mesh.SendCommand("afcb3,4,7,.4,t4,0,0,mx,fl,afcb3,6,5,.4,sc1,1,1,1,afcb2,3,9,.4");
    3840
    39             m_exhaust_mesh.SendCommand("sc0,1,1,1,scb0,0,0,1,ac5,10,0,1.5,0,1,ac7,25,1.1,4,0,1,rx90,t0,0,25");
     41            m_exhaust_mesh.SendCommand("sc0,1,1,1,scb0,0,0,1,ac5,10,0,1.5,0,1,ac7,25,1.1,4,0,1,rx90,t0,0,19");
    4042        }
    4143
     
    4951        m_options.Push(m_position, vec3(0.f, 0.f, 0.f));
    5052        m_options.Push(m_position, vec3(0.f, 0.f, 0.f));
     53
     54                move_rotation_timer = 0.0f;
    5155    }
    5256
     
    120124                        m_options[i].m2[0] = rot[i][0] + (((damped_stick.x < 0.0f)?(20.0f):(-20.0f)) - rot[i][0]) * abs(damped_stick.x);
    121125
    122                         if (damped_stick.x < 0.00001f && damped_stick.x > -0.00001f)
     126                        if (damped_stick.x < 0.3f && damped_stick.x > -0.3f)
    123127                                m_options[i].m2[2] += seconds * (i & 1 ? 600.f : -600.f);
    124128                        else
     
    126130        }
    127131
     132                if (damped_stick.x > 0.5f || damped_stick.x < -0.5f)
     133                {
     134                        if (move_rotation_timer > 0.8f)
     135                                move_rotation.z += damped_stick.x * -220.f * seconds;
     136                        else
     137                                move_rotation_timer += seconds;
     138                }
     139                else
     140                {
     141                        move_rotation_timer = 0.0f;
     142                        move_rotation.z -= move_rotation.z * (seconds / (seconds + 0.2f));
     143                }
     144
     145                exhaust_rotation.z += 600.0f * seconds;
     146
     147                if (move_rotation.z > 180.f)
     148                        move_rotation.z -= 360.f;
     149                else if (move_rotation.z < -180.f)
     150                        move_rotation.z += 360.f;
     151
     152                if (exhaust_rotation.z > 180.f)
     153                        exhaust_rotation.z -= 360.f;
     154                else if (exhaust_rotation.z < -180.f)
     155                        exhaust_rotation.z += 360.f;
     156
     157                m_rotation = quat::fromeuler_xyz(vec3(((damped_stick.z <= 0.0f)?(damped_stick.z):(0.0f)) * -60.0f, 0.f, damped_stick.x * -50.0f) + move_rotation);
    128158        m_position += vec3(rightleft, 0.f, -updown) * 200.f * seconds;
    129159    }
     
    142172
    143173        mat4 model = mat4::translate(m_position) * mat4(m_rotation);
    144         m_ship_mesh.Render(model);
    145         m_exhaust_mesh.Render(model);
     174
     175                m_ship_mesh.Render(model);
     176
     177                if (m_type == 0)
     178                {
     179                        m_exhaust_mesh.Render(model * mat4::translate(vec3(-4.f,0.f,0.f)) * mat4::fromeuler_xyz(exhaust_rotation * -1.0f));
     180                        m_exhaust_mesh.Render(model * mat4::translate(vec3( 4.f,0.f,0.f)) * mat4::fromeuler_xyz(exhaust_rotation));
     181                }
     182                else
     183                        m_exhaust_mesh.Render(model * mat4::fromeuler_xyz(exhaust_rotation));
    146184
    147185        for (int i = 0; i < m_options.Count(); i++)
     
    162200
    163201        vec3 damped_stick;
     202        vec3 move_rotation;
     203        vec3 exhaust_rotation;
     204        float move_rotation_timer;
    164205
    165206    bool m_ready;
Note: See TracChangeset for help on using the changeset viewer.