Changeset 1308 for trunk/orbital/orbital.cpp
 Timestamp:
 Apr 29, 2012, 8:41:43 PM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/orbital/orbital.cpp
r1304 r1308 92 92 vec3(0, 1, 0)); 93 93 94 m_angle = 0; 94 m_auto_cam_timer = 0.0f; 95 96 m_horizontal_angle = 0; 97 m_vertical_angle = 0; 98 m_roll_angle = 0; 99 100 m_horizontal_angle_speed = 0.0f; 101 m_vertical_angle_speed = 0.0f; 102 m_roll_angle_speed = 0.0f; 95 103 96 104 m_ready = false; … … 104 112 WorldEntity::TickGame(deltams); 105 113 106 m_angle += deltams / 50.0f; 107 108 mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0)); 114 //TEMP : Convert DT to seconds 115 deltams /= 1000.0f; 116 117 if (Input::GetButtonState(27 /*SDLK_ESCAPE*/)) 118 Ticker::Shutdown(); 119 120 if (m_auto_cam_timer > 0.0f) 121 m_auto_cam_timer = deltams; 122 123 //Doing the query with actual values, cause I want to stay SDLfree for now. 124 int HMovement = Input::GetButtonState(276 /*SDLK_LEFT*/)  Input::GetButtonState(275 /*SDLK_RIGHT*/); 125 int VMovement = Input::GetButtonState(273 /*SDLK_UP*/)  Input::GetButtonState(274 /*SDLK_DOWN*/); 126 int RMovement = Input::GetButtonState(256 /*SDLK_KP0*/)  Input::GetButtonState(305 /*SDLK_RCTRL*/); 127 128 float new_horizontal_angle_speed = 0.0f; 129 float new_vertical_angle_speed = 0.0f; 130 float new_roll_angle_speed = 0.0f; 131 132 if (HMovement != 0  VMovement != 0  RMovement != 0) 133 { 134 new_horizontal_angle_speed = ((float)HMovement) * 50.0f; 135 new_vertical_angle_speed = ((float)VMovement) * 50.0f; 136 new_roll_angle_speed = ((float)RMovement) * 50.0f; 137 m_auto_cam_timer = 2.0f; 138 } 139 else if (m_auto_cam_timer <= 0.0f) 140 { 141 new_horizontal_angle_speed = 40.0f; 142 new_vertical_angle_speed = max<float>(min<float>(m_vertical_angle, 20.0f), 20.0f); 143 new_roll_angle_speed = max<float>(min<float>(m_roll_angle, 40.0f), 40.0f); 144 } 145 146 m_horizontal_angle_speed += (new_horizontal_angle_speed  m_horizontal_angle_speed) * (deltams / (deltams + 0.3f)); 147 m_vertical_angle_speed += (new_vertical_angle_speed  m_vertical_angle_speed) * (deltams / (deltams + 0.3f)); 148 m_roll_angle_speed += (new_roll_angle_speed  m_roll_angle_speed) * (deltams / (deltams + 0.3f)); 149 150 m_horizontal_angle += m_horizontal_angle_speed * deltams; 151 m_vertical_angle += new_vertical_angle_speed * deltams; 152 m_roll_angle += new_roll_angle_speed * deltams; 153 154 if (m_horizontal_angle > 180.0f) 155 m_horizontal_angle = 360.0f; 156 else if (m_horizontal_angle < 180.0f) 157 m_horizontal_angle += 360.0f; 158 if (m_vertical_angle > 180.0f) 159 m_vertical_angle = 360.0f; 160 else if (m_vertical_angle < 180.0f) 161 m_vertical_angle += 360.0f; 162 if (m_roll_angle > 180.0f) 163 m_roll_angle = 360.0f; 164 else if (m_roll_angle < 180.0f) 165 m_roll_angle += 360.0f; 166 167 mat4 animH = mat4::rotate(m_horizontal_angle, vec3(0, 1, 0)); 168 mat4 animV = mat4::rotate(m_vertical_angle, vec3(1, 0, 0)); 169 mat4 animR = mat4::rotate(m_roll_angle, vec3(0, 0, 1)); 109 170 mat4 model = mat4::translate(vec3(0)); 110 171 111 m_modelview = m_camera>GetViewMatrix() * model * anim ;172 m_modelview = m_camera>GetViewMatrix() * model * animV * animR * animH; 112 173 m_proj = m_camera>GetProjMatrix(); 113 174 m_normalmat = transpose(inverse(mat3(m_modelview)));
Note: See TracChangeset
for help on using the changeset viewer.