Changeset 1312
 Timestamp:
 Apr 30, 2012, 3:12:47 AM (11 years ago)
 Location:
 trunk/orbital
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/orbital/orbital.cpp
r1310 r1312 94 94 m_auto_cam_timer = 0.0f; 95 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; 96 m_angle = vec3(0.f); 97 m_angular_velocity = vec3(0.f); 103 98 104 99 m_ready = false; … … 123 118 int RMovement = Input::GetButtonState(256 /*SDLK_KP0*/)  Input::GetButtonState(305 /*SDLK_RCTRL*/); 124 119 125 float new_horizontal_angle_speed = 0.0f; 126 float new_vertical_angle_speed = 0.0f; 127 float new_roll_angle_speed = 0.0f; 120 vec3 new_angular_velocity = vec3(0.0f); 128 121 129 122 if (HMovement != 0  VMovement != 0  RMovement != 0) 130 123 { 131 new_horizontal_angle_speed = ((float)HMovement) * 50.0f; 132 new_vertical_angle_speed = ((float)VMovement) * 50.0f; 133 new_roll_angle_speed = ((float)RMovement) * 50.0f; 124 new_angular_velocity = vec3(HMovement, VMovement, RMovement) * 50.0f; 134 125 m_auto_cam_timer = 2.0f; 135 126 } 136 127 else if (m_auto_cam_timer <= 0.0f) 137 128 { 138 new_horizontal_angle_speed = 40.0f;139 new_ vertical_angle_speed = max<float>(min<float>(m_vertical_angle, 20.0f), 20.0f);140 new_roll_angle_speed = max<float>(min<float>(m_roll_angle, 40.0f), 40.0f);129 /* Order is yaw, pitch, roll */ 130 new_angular_velocity = clamp(m_angle, vec3(40.f, 20.f, 40.f), 131 vec3(40.f, 20.f, 40.f)); 141 132 } 142 133 143 m_ horizontal_angle_speed += (new_horizontal_angle_speed  m_horizontal_angle_speed) * (seconds / (seconds + 0.3f));144 m_vertical_angle_speed += (new_vertical_angle_speed  m_vertical_angle_speed)* (seconds / (seconds + 0.3f));145 m_ roll_angle_speed += (new_roll_angle_speed  m_roll_angle_speed) * (seconds / (seconds + 0.3f));134 m_angular_velocity += (new_angular_velocity  m_angular_velocity) 135 * (seconds / (seconds + 0.3f)); 136 m_angle += m_angular_velocity * seconds; 146 137 147 m_horizontal_angle += m_horizontal_angle_speed * seconds; 148 m_vertical_angle += new_vertical_angle_speed * seconds; 149 m_roll_angle += new_roll_angle_speed * seconds; 138 /* TODO: implement "vec3 % float" or "fmod(vec3, float)" */ 139 for (int n = 0; n < 3; n++) 140 { 141 if (m_angle[n] > 180.f) 142 m_angle[n] = 360.f; 143 else if (m_angle[n] < 180.f) 144 m_angle[n] += 360.f; 145 } 150 146 151 if (m_horizontal_angle > 180.0f) 152 m_horizontal_angle = 360.0f; 153 else if (m_horizontal_angle < 180.0f) 154 m_horizontal_angle += 360.0f; 155 if (m_vertical_angle > 180.0f) 156 m_vertical_angle = 360.0f; 157 else if (m_vertical_angle < 180.0f) 158 m_vertical_angle += 360.0f; 159 if (m_roll_angle > 180.0f) 160 m_roll_angle = 360.0f; 161 else if (m_roll_angle < 180.0f) 162 m_roll_angle += 360.0f; 163 164 mat4 animH = mat4::rotate(m_horizontal_angle, vec3(0, 1, 0)); 165 mat4 animV = mat4::rotate(m_vertical_angle, vec3(1, 0, 0)); 166 mat4 animR = mat4::rotate(m_roll_angle, vec3(0, 0, 1)); 147 mat4 animH = mat4::rotate(m_angle[0], vec3(0, 1, 0)); 148 mat4 animV = mat4::rotate(m_angle[1], vec3(1, 0, 0)); 149 mat4 animR = mat4::rotate(m_angle[2], vec3(0, 0, 1)); 167 150 mat4 model = mat4::translate(vec3(0)); 168 151 
trunk/orbital/orbital.h
r1310 r1312 27 27 Mesh m; 28 28 float m_auto_cam_timer; 29 float m_horizontal_angle_speed; 30 float m_vertical_angle_speed; 31 float m_roll_angle_speed; 32 33 float m_horizontal_angle; 34 float m_vertical_angle; 35 float m_roll_angle; 29 vec3 m_angle, m_angular_velocity; 36 30 37 31 mat4 m_modelview, m_proj;
Note: See TracChangeset
for help on using the changeset viewer.