renderstack::frame_controls Class Reference

translation and rotation controls for all axes, for frame

#include <control.hpp>

Public Member Functions

 frame_controls (frame &slave_frame)
controlrotate_x ()
controlrotate_y ()
controlrotate_z ()
controltranslate_x ()
controltranslate_y ()
controltranslate_z ()
void fixed_update ()
void once_per_frame_update ()

Detailed Description

Definition at line 80 of file control.hpp.


Constructor & Destructor Documentation

renderstack::frame_controls::frame_controls ( frame slave_frame  ) 

Definition at line 211 of file control.cpp.

00212 :   m_frame(slave_frame)
00213 {
00214     m_translate_x.clear();
00215     m_translate_y.clear();
00216     m_translate_z.clear();
00217     m_rotate_x.clear();
00218     m_rotate_y.clear();
00219     m_rotate_z.clear();
00220 
00221     m_rotate_x.set_damp     (0.900f);
00222     m_rotate_y.set_damp     (0.900f);
00223     m_rotate_y.set_max_delta(0.002f);
00224     m_rotate_z.set_damp     (0.900f);
00225     m_rotate_z.set_max_delta(0.001f);
00226 
00227     m_translate_x.set_damp     (0.9700f);
00228     m_translate_y.set_damp     (0.9700f);
00229     m_translate_z.set_damp     (0.9700f);
00230     m_translate_x.set_max_delta(0.0040f);
00231     m_translate_y.set_max_delta(0.0040f);
00232     m_translate_z.set_max_delta(0.0040f);
00233 
00234     m_rotation = quaternion(m_frame.local_to_world());
00235 
00236     m_position_in_world = m_frame.position_in_world();
00237 }


Member Function Documentation

control& renderstack::frame_controls::rotate_x (  )  [inline]

Definition at line 90 of file control.hpp.

00090 { return m_rotate_x; }

control& renderstack::frame_controls::rotate_y (  )  [inline]

Definition at line 91 of file control.hpp.

00091 { return m_rotate_y; }

control& renderstack::frame_controls::rotate_z (  )  [inline]

Definition at line 92 of file control.hpp.

00092 { return m_rotate_z; }

control& renderstack::frame_controls::translate_x (  )  [inline]

Definition at line 93 of file control.hpp.

00093 { return m_translate_x; }

control& renderstack::frame_controls::translate_y (  )  [inline]

Definition at line 94 of file control.hpp.

00094 { return m_translate_y; }

control& renderstack::frame_controls::translate_z (  )  [inline]

Definition at line 95 of file control.hpp.

00095 { return m_translate_z; }

void renderstack::frame_controls::fixed_update (  ) 

Definition at line 240 of file control.cpp.

00241 {
00242     float       rotation_delta;
00243     float       half_angle_sin;
00244     float       half_angle_cos;
00245     quaternion  rotq;
00246     vec3        axis;
00247 
00248     m_translate_x.update();
00249     m_translate_y.update();
00250     m_translate_z.update();
00251     m_rotate_x.update();
00252     m_rotate_y.update();
00253     m_rotate_z.update();
00254 
00255     if(m_translate_x.current_value() != 0.0f)
00256     {
00257         float value = m_translate_x.current_value();
00258 
00259         axis = m_rotation.right_axis();
00260         m_position_in_world += axis * value;
00261     }
00262 
00263     if(m_translate_z.current_value() != 0.0f)
00264     {
00265         float value = m_translate_z.current_value();
00266 
00267         axis = m_rotation.view_axis();
00268         m_position_in_world += axis * value;
00269     }
00270 
00271     if(m_translate_y.current_value() != 0.0f)
00272     {
00273         float value = m_translate_y.current_value();
00274 
00275         axis = m_rotation.up_axis();
00276         m_position_in_world += axis * value;
00277     }
00278 
00279     if(m_rotate_y.current_value() != 0.0f)
00280     {
00281         rotation_delta = radian_mod_2pi(m_rotate_y.current_value());
00282 
00283         half_angle_sin = sinf(rotation_delta);
00284         half_angle_cos = cosf(rotation_delta);
00285 
00286         axis = m_rotation.up_axis();
00287         rotq = quaternion(axis, half_angle_sin, half_angle_cos);
00288         m_rotation = rotq * m_rotation;
00289         m_rotation = normalize(m_rotation);
00290     }
00291 
00292     if(m_rotate_x.current_value() != 0.0f)
00293     {
00294         rotation_delta = radian_mod_2pi(m_rotate_x.current_value());
00295 
00296         half_angle_sin = sinf(rotation_delta);
00297         half_angle_cos = cosf(rotation_delta);
00298 
00299         axis = m_rotation.right_axis();
00300         rotq = quaternion(axis, half_angle_sin, half_angle_cos);
00301         m_rotation = rotq * m_rotation;
00302         m_rotation = normalize(m_rotation);
00303     }
00304 
00305     if(m_rotate_z.current_value() != 0.0f)
00306     {
00307         rotation_delta = radian_mod_2pi(m_rotate_z.current_value());
00308 
00309         half_angle_sin = sinf(rotation_delta);
00310         half_angle_cos = cosf(rotation_delta);
00311 
00312         axis = m_rotation.view_axis();
00313         rotq = quaternion(axis, half_angle_sin, half_angle_cos);
00314         //m_rotation *= rotq;
00315         m_rotation = rotq * m_rotation;
00316         m_rotation = normalize(m_rotation);
00317     }
00318 }

void renderstack::frame_controls::once_per_frame_update (  ) 

Definition at line 320 of file control.cpp.

00321 {
00322     make_matrix_quaternion_xyz(
00323         m_frame.local_to_world(),
00324         m_frame.world_to_local(),
00325         m_rotation,
00326         m_position_in_world
00327     );
00328 }


The documentation for this class was generated from the following files:
Generated on Sun Apr 11 12:23:11 2010 for RenderStack by  doxygen 1.6.3