Changeset 1314
- Timestamp:
- Apr 30, 2012, 12:23:11 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/orbital/orbital.cpp
r1312 r1314 114 114 115 115 //Doing the query with actual values, cause I want to stay SDL-free for now. 116 int HMovement = Input::GetButtonState(276 /*SDLK_LEFT*/) - Input::GetButtonState(275 /*SDLK_RIGHT*/);117 int VMovement = Input::GetButtonState(273 /*SDLK_UP*/) - Input::GetButtonState(274 /*SDLK_DOWN*/);118 int RMovement = Input::GetButtonState( 256 /*SDLK_KP0*/) - Input::GetButtonState(305 /*SDLK_RCTRL*/);116 int VMovement = Input::GetButtonState(274 /*SDLK_DOWN*/) - Input::GetButtonState(273 /*SDLK_UP*/); 117 int HMovement = Input::GetButtonState(275 /*SDLK_RIGHT*/) - Input::GetButtonState(276 /*SDLK_LEFT*/); 118 int RMovement = Input::GetButtonState(305 /*SDLK_RCTRL*/) - Input::GetButtonState(256 /*SDLK_KP0*/); 119 119 120 120 vec3 new_angular_velocity = vec3(0.0f); 121 121 122 if ( HMovement != 0 || VMovement != 0 || RMovement != 0)122 if (VMovement != 0 || HMovement != 0 || RMovement != 0) 123 123 { 124 new_angular_velocity = vec3( HMovement, VMovement, RMovement) * 50.0f;124 new_angular_velocity = vec3(VMovement, HMovement, RMovement) * 50.0f; 125 125 m_auto_cam_timer = 2.0f; 126 126 } … … 128 128 { 129 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));130 new_angular_velocity = clamp(-m_angle, vec3(-20.f, 40.f, -40.f), 131 vec3( 20.f, 40.f, 40.f)); 132 132 } 133 133 … … 145 145 } 146 146 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)); 147 mat4 anim = mat4::rotate(quat::fromeuler(m_angle)); 150 148 mat4 model = mat4::translate(vec3(0)); 151 149 152 m_modelview = m_camera->GetViewMatrix() * model * anim V * animR * animH;150 m_modelview = m_camera->GetViewMatrix() * model * anim; 153 151 m_proj = m_camera->GetProjMatrix(); 154 152 m_normalmat = transpose(inverse(mat3(m_modelview))); -
trunk/src/lol/math/vector.h
r1313 r1314 924 924 static Quat<T> rotate(T angle, T x, T y, T z); 925 925 static Quat<T> rotate(T angle, Vec3<T> const &v); 926 static Quat<T> fromeuler(T x, T y, T z); 927 static Quat<T> fromeuler(Vec3<T> const &v); 926 928 927 929 inline Quat<T> operator *(Quat<T> const &val) const -
trunk/src/math/vector.cpp
r1305 r1314 471 471 } 472 472 473 template<> quat quat::fromeuler(vec3 const &v) 474 { 475 using std::sin; 476 using std::cos; 477 478 vec3 half_angles = (M_PI / 360.0f) * v; 479 float sx = sin(half_angles.x), cx = cos(half_angles.x); 480 float sy = sin(half_angles.y), cy = cos(half_angles.y); 481 float sz = sin(half_angles.z), cz = cos(half_angles.z); 482 483 return quat(cx * cy * cz + sx * sy * sz, 484 sx * cy * cz - cx * sy * sz, 485 cx * sy * cz + sx * cy * sz, 486 cx * cy * sz - sx * sy * cz); 487 } 488 489 template<> quat quat::fromeuler(float x, float y, float z) 490 { 491 return quat::fromeuler(vec3(x, y, z)); 492 } 493 473 494 template<> mat4 mat4::lookat(vec3 eye, vec3 center, vec3 up) 474 495 {
Note: See TracChangeset
for help on using the changeset viewer.