renderstack Namespace Reference
[RenderStack]

Namespaces

namespace  shapes

Data Structures

struct  attribute_mapping
 holds necessary information to map shader attribute to data in vertex buffer More...
class  attribute_mappings
 attribute_mapping collection More...
struct  attribute_binding
 holds necessary information to feed shader attribute with data More...
class  attribute_bindings
 attribute_binding collection More...
class  index_out_of_range_exception
class  invalid_buffer_stride_exception
class  invalid_buffer_gl_target_exception
class  buffer
 wrapper for gl vertex and index buffers More...
class  invalid_camera_projection_exception
class  camera
 holds necessary information to produce projection matrix More...
class  color
 simple rgb triplet More...
class  control
 value control that can be updated over time More...
class  frame_controls
 translation and rotation controls for all axes, for frame More...
class  dynamic_rectangle
 mesh for 2D rectangle that can resize More...
class  frame
 holds transformation information More...
class  grid
 basic grid mesh (low level) More...
class  matrix_not_invertible_exception
class  matrix
 4 x 4 float matrix, column major More...
class  index_buffer_not_found_exception
class  mesh
 holds vertex buffer and a number of index buffers More...
class  program_attribute_not_found_exception
class  uniform_not_found_exception
class  uniform
 wrapper for gl uniform More...
class  program_attribute
 wrapper for gl program attribute More...
class  shader
 wrapper for gl shader More...
class  program
 wrapper for gl program More...
class  quaternion
 quaternion for 3d rotations and attitude More...
class  rectangle
 simple 2D integer rectangle with x, y, width and height More...
class  render_buffer
class  framebuffer_attachment
 holds either renderbuffer or texture More...
class  render_target
 abstraction for gl framebuffer object More...
class  default_render_target
class  renderbuffer
 can be attached to render_target More...
class  texture
 can be used as texture, can be rendered to if attached to render_target More...
struct  texture_binding
struct  uniform_binding
 contains information necessary to feed uniform to gl More...
class  uniform_bindings
 uniform_binding collection More...
struct  uniform_mapping
 contains information how to map a shader uniform to a parameter based on name and type More...
class  uniform_mappings
 uniform mapping collection More...
class  uniform_source
 pure virtual interface for objects that can act bind data to uniforms More...
struct  uint_parameter
struct  float_parameter
struct  vec2_parameter
struct  vec3_parameter
struct  vec4_parameter
struct  matrix_parameter
struct  texture_parameter
class  uniform_parameter_source
 container for parameters More...
class  vec2
 simple two component float vector More...
class  vec3
 simple three component float vector More...
class  vec4
 simple four component float vector More...
class  vertex_attribute_not_found_exception
class  vertex_attribute
 specifies one vertex attribute such as vertex position or normal More...
class  vertex_format
 collection of vertex attributes More...
class  viewport
 simple rectangle used to specify gl viewport More...
class  realize_failed_exception
class  make_current_failed_exception
class  window
 native window system window with rendering context More...

Enumerations

enum  camera_projection {
  camera_projection_perspective_horizontal = 1, camera_projection_perspective_vertical, camera_projection_orthogonal_horizontal, camera_projection_orthogonal_vertical,
  camera_projection_orthogonal
}
enum  mesh_mode {
  mesh_mode_not_set = 0, mesh_mode_polygon_fill, mesh_mode_edge_lines, mesh_mode_corner_points,
  mesh_mode_corner_normals, mesh_mode_polygon_centroids, mesh_mode_count
}
enum  attachment_type { attachment_renderbuffer, attachment_texture }
enum  uniform_type {
  uniform_type_matrix_4, uniform_type_float, uniform_type_vec2, uniform_type_vec3,
  uniform_type_vec4, uniform_type_int, uniform_type_uint, uniform_type_texture_2d,
  uniform_type_texture_cube
}
enum  logical_uniform {
  logical_uniform_local_to_world, logical_uniform_world_to_local, logical_uniform_local_to_clip, logical_uniform_clip_to_local,
  logical_uniform_world_to_clip, logical_uniform_clip_to_world, logical_uniform_view_position_in_world, logical_uniform_generic_uniform
}
enum  vertex_attribute_usage {
  vertex_attribute_usage_none, vertex_attribute_usage_position, vertex_attribute_usage_normal, vertex_attribute_usage_tangent,
  vertex_attribute_usage_bitangent, vertex_attribute_usage_color, vertex_attribute_usage_weights, vertex_attribute_usage_matrix_indices,
  vertex_attribute_usage_texcoord, vertex_attribute_usage_id
}

Functions

color make_color_from_hsv (vec3 const &hsv)
float srgb_to_linear (float cs)
float linear_to_srgb (float cl)
void make_matrix_quaternion_xyz (matrix &m, matrix &mi, quaternion const &q, vec3 const &xyz)
void make_matrix_quaternion_xyz_scale (matrix &m, matrix &mi, quaternion const &q, vec3 const &xyz, vec3 const &scaling)
matrix transpose (matrix const &m)
matrix inverse (matrix const &m)
matrix make_matrix_frustum_centered (float width, float height, float nearv, float farv)
matrix make_matrix_frustum (float left, float right, float bottom, float top, float nearv, float farv)
matrix make_matrix_perspective_vertical (float fovy, float aspect, float near_val, float far_val)
matrix make_matrix_perspective_horizontal (float fovx, float aspect, float near_val, float far_val)
matrix make_matrix_orthogonal_centered (float width, float height, float near_val, float far_val)
matrix make_matrix_orthogonal (float left, float right, float bottom, float top, float near_val, float far_val)
matrix make_matrix_translate (vec3 const &translation)
matrix make_matrix_scale (vec3 const &scaling)
matrix make_matrix_translate_scale (vec3 const &translation, vec3 const &scaling)
void make_matrix_hpb_xyz (matrix &m, matrix &mi, vec3 const &hpb, vec3 const &translation)
void make_matrix_hpb_xyz_scale (matrix &m, matrix &mi, vec3 const &hpb, vec3 const &translation, vec3 const &scaling)
quaternion normalize (quaternion const &q)
float dot (vec2 const &v1, vec2 const &v2)
vec2 normalize (vec2 const &v)
float dot (vec3 const &v1, vec3 const &v2)
vec3 cross (vec3 const &v1, vec3 const &v2)
vec3 normalize (vec3 const &v)
float radian_mod_2pi (float angle_radians)
vec3 hpb_mod_2pi (vec3 const &hpb)
float dot (vec4 const &v1, vec4 const &v2)
vec4 normalize (vec4 const &v)
vec3 homogenize (vec4 const &v)
vec4 cross (vec4 const &r, vec4 const &s, vec4 const &t)
int gl_size_of_type (int type_code)
void make_matrix_quaternion_xyz (matrix &m, matrix &mi, quaternion const &q, vec3 const &t, vec3 const &s)
matrix matrix_make_translate_scale (vec3 const &t, vec3 const &s)
matrix matrix_make_scale (vec3 const &s)
matrix matrix_make_translate (vec3 const &t)

Enumeration Type Documentation

Enumerator:
camera_projection_perspective_horizontal 
camera_projection_perspective_vertical 
camera_projection_orthogonal_horizontal 
camera_projection_orthogonal_vertical 
camera_projection_orthogonal 

Definition at line 43 of file camera.hpp.

Enumerator:
mesh_mode_not_set 
mesh_mode_polygon_fill 
mesh_mode_edge_lines 
mesh_mode_corner_points 
mesh_mode_corner_normals 
mesh_mode_polygon_centroids 
mesh_mode_count 

Definition at line 39 of file mesh.hpp.

Enumerator:
attachment_renderbuffer 
attachment_texture 

Definition at line 36 of file render_target.hpp.

00037 {
00038     attachment_renderbuffer,
00039     attachment_texture
00040 };

Enumerator:
uniform_type_matrix_4 
uniform_type_float 
uniform_type_vec2 
uniform_type_vec3 
uniform_type_vec4 
uniform_type_int 
uniform_type_uint 
uniform_type_texture_2d 
uniform_type_texture_cube 

Definition at line 43 of file uniform_bindings.hpp.

Enumerator:
logical_uniform_local_to_world 
logical_uniform_world_to_local 
logical_uniform_local_to_clip 
logical_uniform_clip_to_local 
logical_uniform_world_to_clip 
logical_uniform_clip_to_world 
logical_uniform_view_position_in_world 
logical_uniform_generic_uniform 

Definition at line 56 of file uniform_bindings.hpp.

Enumerator:
vertex_attribute_usage_none 
vertex_attribute_usage_position 
vertex_attribute_usage_normal 
vertex_attribute_usage_tangent 
vertex_attribute_usage_bitangent 
vertex_attribute_usage_color 
vertex_attribute_usage_weights 
vertex_attribute_usage_matrix_indices 
vertex_attribute_usage_texcoord 
vertex_attribute_usage_id 

Definition at line 37 of file vertex_format.hpp.


Function Documentation

color renderstack::make_color_from_hsv ( vec3 const &  hsv  ) 

Definition at line 184 of file color.cpp.

00185 {
00186     float h = hsv.x;
00187     float s = hsv.y;
00188     float v = hsv.z;
00189     float r = 0.0f;
00190     float g = 0.0f;
00191     float b = 0.0f;
00192     float f;
00193     float p;
00194     float q;
00195     float t;
00196     int   i;
00197 
00198     if(s == 0.0f)
00199     {
00200         r = v;
00201         g = v;
00202         b = v;
00203     }
00204     else
00205     {
00206         if(h == 360.0f)
00207         {
00208             h = 0.0;
00209         }
00210         h = h / 60.0f;
00211         i = (int)(h);
00212         f = h - i;
00213         p = v * (1.0f -  s             );
00214         q = v * (1.0f - (s *         f ));
00215         t = v * (1.0f - (s * (1.0f - f)));
00216         switch(i)
00217         {
00218             case 0:
00219             {
00220                 r = v;
00221                 g = t;
00222                 b = p;
00223                 break;
00224             }
00225             case 1:
00226             {
00227                 r = q;
00228                 g = v;
00229                 b = p;
00230                 break;
00231             }
00232             case 2:
00233             {
00234                 r = p;
00235                 g = v;
00236                 b = t;
00237                 break;
00238             }
00239             case 3:
00240             {
00241                 r = p;
00242                 g = q;
00243                 b = v;
00244                 break;
00245             }
00246             case 4:
00247             {
00248                 r = t;
00249                 g = p;
00250                 b = v;
00251                 break;
00252             }
00253             case 5:
00254             {
00255                 r = v;
00256                 g = p;
00257                 b = q;
00258                 break;
00259             }
00260             default:
00261             {
00262                 r = 1.0f;
00263                 b = 1.0f;
00264                 b = 1.0f;
00265                 break;
00266             }
00267         }
00268     }
00269     return color(r, g, b);
00270 }

float renderstack::srgb_to_linear ( float  cs  ) 

Definition at line 36 of file color.cpp.

00037 {
00038     float cl = 0.0f;
00039 
00040     RS_ASSERT(cs >= 0.0f);
00041     RS_ASSERT(cs <= 1.0f);
00042 
00043     if(cs <= 0.04045f)
00044     {
00045         cl = cs / 12.92f;
00046     }
00047     else
00048     {
00049         cl = powf(
00050             (cs + 0.055f) / 1.055f, 
00051             2.4f
00052         );
00053     }
00054 
00055     return cl;
00056 }

float renderstack::linear_to_srgb ( float  cl  ) 

Definition at line 58 of file color.cpp.

00059 {
00060     if(cl > 1.0f)
00061     {
00062         return 1.0f;
00063     }
00064     else if(cl < 0.0)
00065     {
00066         return 0.0f;
00067     }
00068     else if(cl < 0.0031308f)
00069     {
00070         return 12.92f * cl;
00071     }
00072     else
00073     {
00074         return 1.055f * powf(cl, 0.41666f) - 0.055f;
00075     }
00076 }

void renderstack::make_matrix_quaternion_xyz ( matrix &  m,
matrix &  mi,
quaternion const &  q,
vec3 const &  xyz 
)

Definition at line 327 of file matrix.cpp.

00333 {
00334     float x2 = 2.0f * q.x;
00335     float y2 = 2.0f * q.y;
00336     float z2 = 2.0f * q.z;
00337     float xx = q.x * x2;
00338     float xy = q.x * y2;
00339     float xz = q.x * z2;
00340     float yy = q.y * y2;
00341     float yz = q.y * z2;
00342     float zz = q.z * z2;
00343     float wx = q.w * x2;
00344     float wy = q.w * y2;
00345     float wz = q.w * z2;
00346 
00347     mi.m[0][0] = m.m[0][0] = 1.0f - yy - zz;
00348     mi.m[0][1] = m.m[1][0] = xy - wz;
00349     mi.m[0][2] = m.m[2][0] = xz + wy;
00350                  m.m[3][0] = t.x;
00351 
00352     mi.m[1][0] = m.m[0][1] = xy + wz;
00353     mi.m[1][1] = m.m[1][1] = 1.0f - xx - zz;
00354     mi.m[1][2] = m.m[2][1] = yz - wx;
00355                  m.m[3][1] = t.y;
00356 
00357     mi.m[2][0] = m.m[0][2] = xz - wy;
00358     mi.m[2][1] = m.m[1][2] = yz + wx;
00359     mi.m[2][2] = m.m[2][2] = 1.0f - xx - yy;
00360                  m.m[3][2] = t.z;
00361 
00362     mi.m[3][0] = mi.m[0][0] * -t.x + mi.m[1][0] * -t.y + mi.m[2][0] * -t.z;
00363     mi.m[3][1] = mi.m[0][1] * -t.x + mi.m[1][1] * -t.y + mi.m[2][1] * -t.z;
00364     mi.m[3][2] = mi.m[0][2] * -t.x + mi.m[1][2] * -t.y + mi.m[2][2] * -t.z;
00365 
00366     mi.m[3][3] = m.m[3][3] = 1.0f;
00367 }

void renderstack::make_matrix_quaternion_xyz_scale ( matrix &  m,
matrix &  mi,
quaternion const &  q,
vec3 const &  xyz,
vec3 const &  scaling 
)
matrix renderstack::transpose ( matrix const &  m  ) 
matrix renderstack::inverse ( matrix const &  m  ) 

Definition at line 157 of file matrix.cpp.

00158 {
00159     vec4  x  = m.column(0);
00160     vec4  y  = m.column(1);
00161     vec4  z  = m.column(2);
00162     vec4  w  = m.column(3);
00163     vec4  x1 = cross(y, z, w);
00164     vec4  y1 = cross(z, w, x);
00165     vec4  z1 = cross(w, x, y);
00166     vec4  w1 = cross(x, y, z);
00167     float lx = dot(x, x1);
00168     float ly = dot(y, y1);
00169     float lz = dot(z, z1);
00170     float lw = dot(w, w1);
00171 
00172     if(
00173         RS_NEAR_ZERO(lx) ||
00174         RS_NEAR_ZERO(ly) ||
00175         RS_NEAR_ZERO(lz) ||
00176         RS_NEAR_ZERO(lw)
00177     )
00178     {
00179         throw matrix_not_invertible_exception();
00180     }
00181 
00182     x1[0] /= lx; 
00183     y1[0] /= ly; 
00184     z1[0] /= lz; 
00185     w1[0] /= lw; 
00186 
00187     return matrix(x1, y1, z1, w1);
00188 }

matrix renderstack::make_matrix_frustum_centered ( float  width,
float  height,
float  nearv,
float  farv 
)

Definition at line 191 of file matrix.cpp.

00197 {
00198     float far_plus_near  = farv + nearv;
00199     float far_minus_near = farv - nearv;
00200     float far_times_near = farv * nearv;
00201 
00202     float x = RS_NEAR_ZERO(width         ) ? 1.0f : ( 2.0f *  nearv          / width);
00203     float y = RS_NEAR_ZERO(height        ) ? 1.0f : ( 2.0f *  nearv          / height);
00204     float c = RS_NEAR_ZERO(far_minus_near) ? 1.0f : (        -far_plus_near  / far_minus_near);
00205     float d = RS_NEAR_ZERO(far_minus_near) ? 1.0f : (-2.0f *  far_times_near / far_minus_near);
00206 
00207     return matrix(
00208         x,     0.0f,   0.0f,  0.0f,
00209         0.0f,  y,      0.0f,  0.0f,
00210         0.0f,  0.0f,   c,     d,
00211         0.0f,  0.0f,  -1.0f,  0.0f
00212     );
00213 }

matrix renderstack::make_matrix_frustum ( float  left,
float  right,
float  bottom,
float  top,
float  nearv,
float  farv 
)

Definition at line 216 of file matrix.cpp.

00224 {
00225     float right_plus_left  = right + left;
00226     float top_plus_bottom  = top   + bottom;
00227     float far_plus_near    = farv  + nearv;
00228     float right_minus_left = right - left;
00229     float top_minus_bottom = top   - bottom;
00230     float far_minus_near   = farv  - nearv;
00231     float far_times_near   = farv  * nearv;
00232 
00233     float x = RS_NEAR_ZERO(right_minus_left) ? 1.0f : ( 2.0f * nearv          / right_minus_left);
00234     float y = RS_NEAR_ZERO(top_minus_bottom) ? 1.0f : ( 2.0f * nearv          / top_minus_bottom);
00235     float a = RS_NEAR_ZERO(right_minus_left) ? 1.0f : ( right_plus_left       / right_minus_left);
00236     float b = RS_NEAR_ZERO(top_minus_bottom) ? 1.0f : ( top_plus_bottom       / top_minus_bottom);
00237     float c = RS_NEAR_ZERO(far_minus_near  ) ? 1.0f : (-far_plus_near         / far_minus_near);
00238     float d = RS_NEAR_ZERO(far_minus_near  ) ? 1.0f : (-2.0f * far_times_near / far_minus_near);
00239 
00240     return matrix(
00241         x,     0.0f,   a,     0.0f,
00242         0.0f,  y,      b,     0.0f,
00243         0.0f,  0.0f,   c,     d,
00244         0.0f,  0.0f,  -1.0f,  0.0f
00245     );
00246 }

matrix renderstack::make_matrix_perspective_vertical ( float  fovy,
float  aspect,
float  near_val,
float  far_val 
)

Definition at line 249 of file matrix.cpp.

00255 {
00256     float fov_tangent = tanf(fov_y_radians * 0.5f);
00257     float height      = 2.0f * near_val * fov_tangent;
00258     float width       = height * aspect;
00259 
00260     return make_matrix_frustum_centered(width, height, near_val, far_val);
00261 }

matrix renderstack::make_matrix_perspective_horizontal ( float  fovx,
float  aspect,
float  near_val,
float  far_val 
)

Definition at line 263 of file matrix.cpp.

00269 {
00270     float fov_tangent = tanf(fov_x_radians * 0.5f);
00271     float width       = 2.0f * near_val * fov_tangent;
00272     float height      = width / aspect;
00273 
00274     return make_matrix_frustum_centered(width, height, near_val, far_val);
00275 }

matrix renderstack::make_matrix_orthogonal_centered ( float  width,
float  height,
float  near_val,
float  far_val 
)

Definition at line 277 of file matrix.cpp.

00283 {
00284     float x = RS_NEAR_ZERO(width            ) ? 1.0f : ( 2.0f / (float)(width)             );
00285     float y = RS_NEAR_ZERO(height           ) ? 1.0f : ( 2.0f / (float)(height)            );
00286     float z = RS_TOLERANCE(near_val, far_val) ? 1.0f : (-2.0f / (float)(far_val - near_val));
00287 
00288     return matrix(
00289         x,     0.0f,  0.0f,  0.0f,
00290         0.0f,  y,     0.0f,  0.0f,
00291         0.0f,  0.0f,  z,     0.0f,
00292         0.0f,  0.0f,  0.0f,  1.0f
00293     );
00294 }

matrix renderstack::make_matrix_orthogonal ( float  left,
float  right,
float  bottom,
float  top,
float  near_val,
float  far_val 
)

Definition at line 296 of file matrix.cpp.

00304 {
00305     float r_plus_l  = right   + left;
00306     float t_plus_b  = top     + bottom;
00307     float f_plus_n  = far_val + near_val;
00308     float r_minus_l = right   - left;
00309     float t_minus_b = top     - bottom;
00310     float f_minus_n = far_val - near_val;
00311 
00312     float x  = RS_NEAR_ZERO(r_minus_l) ? 1.0f : ( 2.0f     / r_minus_l);
00313     float y  = RS_NEAR_ZERO(t_minus_b) ? 1.0f : ( 2.0f     / t_minus_b);
00314     float z  = RS_NEAR_ZERO(f_minus_n) ? 1.0f : (-2.0f     / f_minus_n);
00315     float tx = RS_NEAR_ZERO(r_minus_l) ? 0.0f : (-r_plus_l / r_minus_l);
00316     float ty = RS_NEAR_ZERO(t_minus_b) ? 0.0f : (-t_plus_b / t_minus_b);
00317     float tz = RS_NEAR_ZERO(f_minus_n) ? 0.0f : (-f_plus_n / f_minus_n);
00318 
00319     return matrix(
00320         x,     0.0f,  0,     tx,
00321         0.0f,  y,     0,     ty,
00322         0.0f,  0.0f,  z,     tz,
00323         0.0f,  0.0f,  0.0f,  1.0f
00324     );
00325 }

matrix renderstack::make_matrix_translate ( vec3 const &  translation  ) 
matrix renderstack::make_matrix_scale ( vec3 const &  scaling  ) 
matrix renderstack::make_matrix_translate_scale ( vec3 const &  translation,
vec3 const &  scaling 
)
void renderstack::make_matrix_hpb_xyz ( matrix &  m,
matrix &  mi,
vec3 const &  hpb,
vec3 const &  translation 
)

Definition at line 481 of file matrix.cpp.

00487 {
00488     float A = cosf(hpb.y);
00489     float B = sinf(hpb.y);
00490     float C = cosf(hpb.x);
00491     float D = sinf(hpb.x);
00492     float E = cosf(hpb.z);
00493     float F = sinf(hpb.z);
00494 
00495     {
00496         float DB = D * B;
00497 
00498         mi.m[0][0] = m.m[0][0] =  C *  E + -DB * F;
00499         mi.m[0][1] = m.m[1][0] =  C * -F + -DB * E;
00500         mi.m[0][2] = m.m[2][0] = -D *  A;
00501                      m.m[3][0] =  t.x;
00502     }
00503 
00504     {
00505         mi.m[1][0] = m.m[0][1] =  A * F;
00506         mi.m[1][1] = m.m[1][1] =  A * E;
00507         mi.m[1][2] = m.m[2][1] = -B;
00508                      m.m[3][1] =  t.y;
00509     }
00510 
00511     {
00512         float CB = C * B;
00513 
00514         mi.m[2][0] = m.m[0][2] =  D *  E + CB * F;
00515         mi.m[2][1] = m.m[1][2] =  D * -F + CB * E;
00516         mi.m[2][2] = m.m[2][2] =  C *  A;
00517                      m.m[3][2] =  t.z;
00518     }
00519 
00520     mi.m[3][0] = mi.m[0][0] * -t.x + mi.m[1][0] * -t.y + mi.m[2][0] * -t.z;
00521     mi.m[3][1] = mi.m[0][1] * -t.x + mi.m[1][1] * -t.y + mi.m[2][1] * -t.z;
00522     mi.m[3][2] = mi.m[0][2] * -t.x + mi.m[1][2] * -t.y + mi.m[2][2] * -t.z;
00523     mi.m[3][3] = 1.0f;
00524     m.m[0][3] = 0.0f;
00525     m.m[1][3] = 0.0f;
00526     m.m[2][3] = 0.0f;
00527     m.m[3][3] = 1.0f;
00528 }

void renderstack::make_matrix_hpb_xyz_scale ( matrix &  m,
matrix &  mi,
vec3 const &  hpb,
vec3 const &  translation,
vec3 const &  scaling 
)

Definition at line 530 of file matrix.cpp.

00537 {
00538     float A = cosf(hpb.y);
00539     float B = sinf(hpb.y);
00540     float C = cosf(hpb.x);
00541     float D = sinf(hpb.x);
00542     float E = cosf(hpb.z);
00543     float F = sinf(hpb.z);
00544 
00545     {
00546         float DB = D * B;
00547 
00548         mi.m[0][0] = m.m[0][0] =  C *  E + -DB * F;
00549         mi.m[0][1] = m.m[1][0] =  C * -F + -DB * E;
00550         mi.m[0][2] = m.m[2][0] = -D *  A;
00551                      m.m[3][0] =  t.x;
00552     }
00553 
00554     {
00555         mi.m[1][0] = m.m[0][1] =  A * F;
00556         mi.m[1][1] = m.m[1][1] =  A * E;
00557         mi.m[1][2] = m.m[2][1] = -B;
00558                      m.m[3][1] =  t.y;
00559     }
00560 
00561     {
00562         float CB = C * B;
00563 
00564         mi.m[2][0] = m.m[0][2] =  D *  E + CB * F;
00565         mi.m[2][1] = m.m[1][2] =  D * -F + CB * E;
00566         mi.m[2][2] = m.m[2][2] =  C *  A;
00567                      m.m[3][2] =  t.z;
00568     }
00569 
00570     mi.m[3][0] = mi.m[0][0] * -t.x + mi.m[1][0] * -t.y + mi.m[2][0] * -t.z;
00571     mi.m[3][1] = mi.m[0][1] * -t.x + mi.m[1][1] * -t.y + mi.m[2][1] * -t.z;
00572     mi.m[3][2] = mi.m[0][2] * -t.x + mi.m[1][2] * -t.y + mi.m[2][2] * -t.z;
00573 
00574     m.m[0][0] = m.m[0][0] * s.x;
00575     m.m[1][0] = m.m[1][0] * s.y;
00576     m.m[2][0] = m.m[2][0] * s.z;
00577 
00578     m.m[0][1] = m.m[0][1] * s.x;
00579     m.m[1][1] = m.m[1][1] * s.y;
00580     m.m[2][1] = m.m[2][1] * s.z;
00581 
00582     m.m[0][2] = m.m[0][2] * s.x;
00583     m.m[1][2] = m.m[1][2] * s.y;
00584     m.m[2][2] = m.m[2][2] * s.z;
00585 
00586     {
00587         float isx = RS_NEAR_ZERO(s.x) ? 0.0f : 1.0f / s.x; 
00588         float isy = RS_NEAR_ZERO(s.y) ? 0.0f : 1.0f / s.y;
00589         float isz = RS_NEAR_ZERO(s.z) ? 0.0f : 1.0f / s.z;
00590 
00591         mi.m[0][0] = mi.m[0][0] * isx;
00592         mi.m[1][0] = mi.m[1][0] * isy;
00593         mi.m[2][0] = mi.m[2][0] * isz;
00594         mi.m[3][0] = mi.m[3][0] * isz;
00595 
00596         mi.m[0][1] = mi.m[0][1] * isx;
00597         mi.m[1][1] = mi.m[1][1] * isy;
00598         mi.m[2][1] = mi.m[2][1] * isz;
00599         mi.m[3][1] = mi.m[3][1] * isz;
00600 
00601         mi.m[0][2] = mi.m[0][2] * isx;
00602         mi.m[1][2] = mi.m[1][2] * isy;
00603         mi.m[2][2] = mi.m[2][2] * isz;
00604         mi.m[3][2] = mi.m[3][2] * isz;
00605     }
00606 
00607     mi.m[3][3] = 1.0f;
00608     m.m[3][3] = 1.0f;
00609 }

quaternion renderstack::normalize ( quaternion const &  q  )  [inline]

Definition at line 86 of file quaternion.hpp.

00087 {
00088     float dot   = q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;
00089     float t     = 1.5f - 0.5f * dot;
00090     return quaternion(q.x * t, q.y * t, q.z * t, q.w * t);
00091 }

float renderstack::dot ( vec2 const &  v1,
vec2 const &  v2 
) [inline]

Definition at line 122 of file vec2.hpp.

00123 {
00124     return v1.x * v2.x + v1.y * v2.y;
00125 }

vec2 renderstack::normalize ( vec2 const &  v  )  [inline]

Definition at line 127 of file vec2.hpp.

00128 {
00129     return v / v.length();
00130 }

float renderstack::dot ( vec3 const &  v1,
vec3 const &  v2 
) [inline]

Definition at line 129 of file vec3.hpp.

00130 {
00131     return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
00132 }

vec3 renderstack::cross ( vec3 const &  v1,
vec3 const &  v2 
) [inline]

Definition at line 134 of file vec3.hpp.

00135 {
00136     return vec3(
00137         (v1.y * v2.z) - (v1.z * v2.y),
00138         (v1.z * v2.x) - (v1.x * v2.z),
00139         (v1.x * v2.y) - (v1.y * v2.x)
00140     );
00141 }

vec3 renderstack::normalize ( vec3 const &  v  )  [inline]

Definition at line 143 of file vec3.hpp.

00144 {
00145     return v / v.length();
00146 }

float renderstack::radian_mod_2pi ( float  angle_radians  )  [inline]

Definition at line 148 of file vec3.hpp.

00149 {
00150     while(angle_radians > RS_TWO_PI) angle_radians -= RS_TWO_PI;
00151     while(angle_radians < 0        ) angle_radians += RS_TWO_PI;
00152 
00153     return angle_radians;
00154 }

vec3 renderstack::hpb_mod_2pi ( vec3 const &  hpb  )  [inline]

Definition at line 156 of file vec3.hpp.

00157 {
00158     float h = hpb.x;
00159     float p = hpb.y;
00160     float b = hpb.z;
00161 
00162     while(h > RS_TWO_PI) h -= RS_TWO_PI;
00163     while(h < 0        ) h += RS_TWO_PI;
00164     while(p > RS_TWO_PI) p -= RS_TWO_PI;
00165     while(p < 0        ) p += RS_TWO_PI;
00166     while(b > RS_TWO_PI) b -= RS_TWO_PI;
00167     while(b < 0        ) b += RS_TWO_PI;
00168 
00169     return vec3(h, p, b);
00170 }

float renderstack::dot ( vec4 const &  v1,
vec4 const &  v2 
) [inline]

Definition at line 144 of file vec4.hpp.

00145 {
00146     return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v2.w;
00147 }

vec4 renderstack::normalize ( vec4 const &  v  )  [inline]

Definition at line 149 of file vec4.hpp.

00150 {
00151     return v / v.length();
00152 }

vec3 renderstack::homogenize ( vec4 const &  v  )  [inline]

Definition at line 154 of file vec4.hpp.

00155 {
00156     return vec3(v.x / v.w, v.y / v.w, v.z / v.w);
00157 }

vec4 renderstack::cross ( vec4 const &  r,
vec4 const &  s,
vec4 const &  t 
) [inline]

Definition at line 159 of file vec4.hpp.

00160 {
00161     return vec4(
00162         r.y * s.z * t.w + r.z * s.w * t.y + r.w * s.y * t.z - r.y * s.w * t.z - r.z * s.y * t.w - r.w * s.z * t.y,
00163         r.x * s.w * t.z + r.z * s.x * t.w + r.w * s.z * t.x - r.x * s.z * t.w - r.z * s.w * t.x - r.w * s.x * t.z,
00164         r.x * s.y * t.w + r.y * s.w * t.x + r.w * s.x * t.y - r.x * s.w * t.y - r.y * s.x * t.w - r.w * s.y * t.x,
00165         r.x * s.z * t.y + r.y * s.x * t.z + r.z * s.y * t.x - r.x * s.y * t.z - r.y * s.z * t.x - r.z * s.x * t.y
00166     );
00167 }

int renderstack::gl_size_of_type ( int  type_code  ) 

Definition at line 32 of file vertex_format.cpp.

00033 {
00034     switch(gl_type_code)
00035     {
00036         case GL_UNSIGNED_BYTE:  return 1;
00037         case GL_BYTE:           return 1;
00038         case GL_UNSIGNED_SHORT: return 2;
00039         case GL_SHORT:          return 2;
00040         case GL_UNSIGNED_INT:   return 4;
00041         case GL_INT:            return 4;
00042         case GL_FLOAT:          return 4;
00043         default: throw false;
00044     }
00045 }

void renderstack::make_matrix_quaternion_xyz ( matrix &  m,
matrix &  mi,
quaternion const &  q,
vec3 const &  t,
vec3 const &  s 
)

Definition at line 369 of file matrix.cpp.

00376 {
00377     float x2 = 2.0f * q.x;
00378     float y2 = 2.0f * q.y;
00379     float z2 = 2.0f * q.z;
00380     float xx = q.x * x2;
00381     float xy = q.x * y2;
00382     float xz = q.x * z2;
00383     float yy = q.y * y2;
00384     float yz = q.y * z2;
00385     float zz = q.z * z2;
00386     float wx = q.w * x2;
00387     float wy = q.w * y2;
00388     float wz = q.w * z2;
00389 
00390     mi.m[0][0] = m.m[0][0] = 1.0f - yy - zz;
00391     mi.m[0][1] = m.m[1][0] = xy - wz;
00392     mi.m[0][2] = m.m[2][0] = xz + wy;
00393                  m.m[3][0] = t.x;
00394 
00395     mi.m[1][0] = m.m[0][1] = xy + wz;
00396     mi.m[1][1] = m.m[1][1] = 1.0f - xx - zz;
00397     mi.m[1][2] = m.m[2][1] = yz - wx;
00398                  m.m[3][1] = t.y;
00399 
00400     mi.m[2][0] = m.m[0][2] = xz - wy;
00401     mi.m[2][1] = m.m[1][2] = yz + wx;
00402     mi.m[2][2] = m.m[2][2] = 1.0f - xx - yy;
00403                  m.m[3][2] = t.z;
00404 
00405     mi.m[3][0] = mi.m[0][0] * -t.x + mi.m[1][0] * -t.y + mi.m[2][0] * -t.z;
00406     mi.m[3][1] = mi.m[0][1] * -t.x + mi.m[1][1] * -t.y + mi.m[2][1] * -t.z;
00407     mi.m[3][2] = mi.m[0][2] * -t.x + mi.m[1][2] * -t.y + mi.m[2][2] * -t.z;
00408 
00409     m.m[0][0] = m.m[0][0] * s.x;
00410     m.m[1][0] = m.m[1][0] * s.y;
00411     m.m[2][0] = m.m[2][0] * s.z;
00412 
00413     m.m[0][1] = m.m[0][1] * s.x;
00414     m.m[1][1] = m.m[1][1] * s.y;
00415     m.m[2][1] = m.m[2][1] * s.z;
00416 
00417     m.m[0][2] = m.m[0][2] * s.x;
00418     m.m[1][2] = m.m[1][2] * s.y;
00419     m.m[2][2] = m.m[2][2] * s.z;
00420 
00421     {
00422         float isx = RS_NEAR_ZERO(s.x) ? 0.0f : 1.0f / s.x;
00423         float isy = RS_NEAR_ZERO(s.y) ? 0.0f : 1.0f / s.y;
00424         float isz = RS_NEAR_ZERO(s.z) ? 0.0f : 1.0f / s.z;
00425 
00426         mi.m[0][0] = mi.m[0][0] * isx;
00427         mi.m[1][0] = mi.m[1][0] * isy;
00428         mi.m[2][0] = mi.m[2][0] * isz;
00429 
00430         mi.m[0][1] = mi.m[0][1] * isx;
00431         mi.m[1][1] = mi.m[1][1] * isy;
00432         mi.m[2][1] = mi.m[2][1] * isz;
00433 
00434         mi.m[0][2] = mi.m[0][2] * isx;
00435         mi.m[1][2] = mi.m[1][2] * isy;
00436         mi.m[2][2] = mi.m[2][2] * isz;
00437     }
00438     m.m[0][3] = mi.m[0][3] = 0.0f;
00439     m.m[1][3] = mi.m[1][3] = 0.0f;
00440     m.m[2][3] = mi.m[2][3] = 0.0f;
00441     m.m[3][3] = mi.m[3][3] = 1.0f;
00442 }

matrix renderstack::matrix_make_translate_scale ( vec3 const &  t,
vec3 const &  s 
)

Definition at line 444 of file matrix.cpp.

00448 {
00449     return matrix(
00450         s.x,  0.0f, 0.0f, t.x,
00451         0.0f, s.y,  0.0f, t.y,
00452         0.0f, 0.0f, s.z,  t.z,
00453         0.0f, 0.0f, 0.0f, 1.0f
00454     );
00455 }

matrix renderstack::matrix_make_scale ( vec3 const &  s  ) 

Definition at line 457 of file matrix.cpp.

00460 {
00461     return matrix(
00462         s.x,  0.0f, 0.0f, 0.0f,
00463         0.0f, s.y,  0.0f, 0.0f,
00464         0.0f, 0.0f, s.z,  0.0f,
00465         0.0f, 0.0f, 0.0f, 1.0f
00466     );
00467 }

matrix renderstack::matrix_make_translate ( vec3 const &  t  ) 

Definition at line 469 of file matrix.cpp.

00472 {
00473     return matrix(
00474         1.0f, 0.0f, 0.0f, t.x,
00475         0.0f, 1.0f, 0.0f, t.y,
00476         0.0f, 0.0f, 1.0f, t.z,
00477         0.0f, 0.0f, 0.0f, 1.0f
00478     );
00479 }

Generated on Sun Apr 11 12:23:11 2010 for RenderStack by  doxygen 1.6.3