renderstack::frame Class Reference

holds transformation information

#include <frame.hpp>

Inherits renderstack::uniform_source.

Inherited by renderstack::camera.

Public Member Functions

 frame ()
void translate_in_world (vec3 const &v)
void rotate_in_world (vec3 const &axis, float angle_radians)
void set_hpb_xyz (vec3 const &hpb, vec3 const &xyz)
matrixlocal_to_world ()
matrixworld_to_local ()
matrix const & local_to_world () const
matrix const & world_to_local () const
vec3 position_in_world ()
bool connect (uniform_bindings &bindings, enum logical_uniform uniform, int slot)

Static Public Attributes

static class frame identity

Detailed Description

Definition at line 37 of file frame.hpp.


Constructor & Destructor Documentation

renderstack::frame::frame (  ) 

Definition at line 35 of file frame.cpp.

00036 {
00037     m_local_to_world = matrix::identity();
00038     m_world_to_local = matrix::identity();
00039 }


Member Function Documentation

void renderstack::frame::translate_in_world ( vec3 const &  v  ) 

Definition at line 51 of file frame.cpp.

00052 {
00053     m_local_to_world.m[3][0] += t.x;
00054     m_local_to_world.m[3][1] += t.y;
00055     m_local_to_world.m[3][2] += t.z;
00056     m_world_to_local = inverse(m_local_to_world);
00057 }

void renderstack::frame::rotate_in_world ( vec3 const &  axis,
float  angle_radians 
)

Definition at line 59 of file frame.cpp.

00060 {
00061     vec3    a = axis;
00062     float   half_angle     = 0.5f * angle;
00063     float   half_angle_sin = sinf(half_angle);
00064     float   half_angle_cos = cosf(half_angle);
00065     matrix  local_to_world;
00066 
00067     while(angle < 0)
00068     {
00069         angle += RS_TWO_PI;
00070     }
00071 
00072     while(angle >= RS_TWO_PI)
00073     {
00074         angle -= RS_TWO_PI;
00075     }
00076 
00077     quaternion q = quaternion(axis, half_angle_sin, half_angle_cos);
00078     m_local_to_world *= matrix(q);
00079     m_world_to_local = inverse(m_local_to_world);
00080 }

void renderstack::frame::set_hpb_xyz ( vec3 const &  hpb,
vec3 const &  xyz 
)

Definition at line 82 of file frame.cpp.

00086 {
00087     make_matrix_hpb_xyz(
00088         m_local_to_world, 
00089         m_world_to_local,
00090         hpb_mod_2pi(hpb),
00091         translation
00092     );
00093 }

matrix& renderstack::frame::local_to_world (  )  [inline]

Definition at line 47 of file frame.hpp.

00047 { return m_local_to_world; }

matrix& renderstack::frame::world_to_local (  )  [inline]

Definition at line 48 of file frame.hpp.

00048 { return m_world_to_local; } 

matrix const& renderstack::frame::local_to_world (  )  const [inline]

Definition at line 49 of file frame.hpp.

00049 { return m_local_to_world; }

matrix const& renderstack::frame::world_to_local (  )  const [inline]

Definition at line 50 of file frame.hpp.

00050 { return m_world_to_local; } 

vec3 renderstack::frame::position_in_world (  )  [inline]

Definition at line 52 of file frame.hpp.

00052 { return m_local_to_world.column3(3); }

bool renderstack::frame::connect ( uniform_bindings bindings,
enum logical_uniform  uniform,
int  slot 
) [virtual]

Implements renderstack::uniform_source.

Reimplemented in renderstack::camera.

Definition at line 41 of file frame.cpp.

00042 {
00043     switch(uniform)
00044     {
00045         case logical_uniform_local_to_world: return bindings.add(uniform_type_matrix_4, slot, 1, &m_local_to_world.m[0][0]);
00046         case logical_uniform_world_to_local: return bindings.add(uniform_type_matrix_4, slot, 1, &m_world_to_local.m[0][0]);
00047         default: return false;
00048     }
00049 }


Field Documentation

Definition at line 58 of file frame.hpp.


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