HydroSDL/oGL_graphics/solid_objects.h File Reference

#include "../hydro_source/Datas.h"
#include "graphics_relative.h"
#include "math.h"
#include "mex.h"

Include dependency graph for solid_objects.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SolidObject
 3D object description More...

Functions

void SolidObject_create (SolidObject *so, int N, int M)
 Creates a solid object.
void SolidObject_delete (SolidObject *so)
 Deletes a solid object.
void cross_product (float *va, float *vb, float *vc)
 Computes the cross-product.
void one_normal (float *v1, float *v2, float *v3, float *v4, float *vn)
 Computes normal vector for one vertex.
void Boat_delete ()
 Deletes the boat.
void SolidObject_compute_normals (SolidObject *so)
 Computes the normals for a SolidObject.
void Boat_create (datas *d)
 Creates and defines all boat related SolidObject objects.
void Sail_create_and_draw (datas *d)
 Create and draw the sail.
void RelativeWind_draw (datas *d)
 Draws relative wind vector.
void Target_draw (float x, float y)
 Draws a "target instrument" on the screen.
void VSlider_draw (float x)
 Draws a "vertical slider instrument" on the screen.
void HSlider_draw (float x)
 Draws a "horizontal slider instrument" on the screen.
void Girouette_draw (datas *d)
 Draws a girouette on the screen.
void Boat_draw ()
 Draws the boat.


Detailed Description

Author:
basile.graf@epfl.ch
This file relates to all graphical objects. SolidObject is the 3D desription of an object like a boat hull. This file contains also functions to draw navigation instruments on the screen.

Definition in file solid_objects.h.


Function Documentation

void Boat_create ( datas d  ) 

Creates and defines all boat related SolidObject objects.

Create and fill all boat informations (coordinates,...)
All hull coordinates are computed/defined herein. Have a look to the code!

Parameters:
*d : pointer to the datas data-structure

Definition at line 552 of file solid_objects.cpp.

References datas::alpha_left, datas::alpha_right, SolidObject::B, bridge2, bridgeMain, datas::Chord_max, datas::Chord_min, datas::Chord_pitch, datas::Chord_yaw, datas::E_foils, datas::E_yaw, datas::Env_pitch, foill, foilr, SolidObject::G, hull, datas::L_mast, datas::Long, lSwimm, mast, SolidObject::nX, SolidObject::nY, SolidObject::nZ, pitch, SolidObject::R, rSwimm, SolidObject_compute_normals(), SolidObject_create(), SolidObject::X, datas::x_foils, datas::x_pitch, datas::x_sail, datas::x_yaw, SolidObject::Y, datas::y_foil_left, datas::y_foil_right, datas::y_pitch, datas::y_sail, datas::y_yaw, yaw, SolidObject::Z, datas::z_foils, datas::z_pitch, and datas::z_yaw.

Referenced by main().

void Boat_delete (  ) 

Deletes the boat.

Deletes all SolidObject objects used in drawing the boat using SolidObject_delete()

Definition at line 528 of file solid_objects.cpp.

References bridge2, bridgeMain, foill, foilr, hull, lSwimm, mast, pitch, rSwimm, SolidObject_delete(), and yaw.

Referenced by quit_tutorial().

void Boat_draw (  ) 

Draws the boat.

Draws the boat once it has been created and defined by Boat_create(). This function uses calls to SolidObject_draw(). The code of this function contains OpenGL code.

Definition at line 508 of file solid_objects.cpp.

References bridge2, bridgeMain, foill, foilr, hull, lSwimm, mast, pitch, rSwimm, SolidObject_draw(), and yaw.

Referenced by DrawGLScene().

void cross_product ( float *  va,
float *  vb,
float *  vc 
)

Computes the cross-product.

$ v_c = v_a \times v_b $

Parameters:
*va : pointer to float array of 3 elements ($ v_a $)
*vb : pointer to float array of 3 elements ($ v_b $)
*vc : pointer to float array of 3 elements ($ v_c $)

Definition at line 118 of file solid_objects.cpp.

Referenced by Girouette_draw(), one_normal(), and Sail_create_and_draw().

void Girouette_draw ( datas d  ) 

Draws a girouette on the screen.

Draws a girouette instrument indicating relative wind direction as an on screen instrument. The code of this function contains OpenGL code.

Parameters:
*d : pointer to the datas data-structure

Definition at line 415 of file solid_objects.cpp.

References datas::angle_girouette, cross_product(), datas::dx, datas::dy, f(), datas::tanAngle_sail, datas::Wind_x, and datas::Wind_y.

Referenced by DrawGLScene().

void HSlider_draw ( float  x  ) 

Draws a "horizontal slider instrument" on the screen.

Draws a horizontal slider. The code of this function contains OpenGL code.

Parameters:
x,: slider position, $ -1.0 \leq x \leq 1.0$, clipped outside this range

Definition at line 385 of file solid_objects.cpp.

References f().

Referenced by DrawGLScene().

void one_normal ( float *  v1,
float *  v2,
float *  v3,
float *  v4,
float *  vn 
)

Computes normal vector for one vertex.

$ v_n = \frac{c}{|c|}$
$ c = v_1 \times v_2 + v_2 \times v_3 + v_3 \times v_4 + v_4 \times v_1$

Parameters:
*v1 : pointer to float array of 3 elements ($ v_1 $)
*v2 : pointer to float array of 3 elements ($ v_2 $)
*v3 : pointer to float array of 3 elements ($ v_3 $)
*v4 : pointer to float array of 3 elements ($ v_4 $)
*vn : pointer to float array of 3 elements ($ v_n $)

Definition at line 125 of file solid_objects.cpp.

References cross_product(), and f().

Referenced by SolidObject_compute_normals().

void RelativeWind_draw ( datas d  ) 

Draws relative wind vector.

Draws a relative wind vector at the top of the mast. The code of this function contains OpenGL code.

Parameters:
*d : pointer to the datas data-structure

Definition at line 305 of file solid_objects.cpp.

References datas::dx, datas::dy, f(), datas::L_mast, datas::phi, datas::psi, datas::theta, datas::Wind_x, datas::Wind_y, datas::x_sail, datas::y_sail, and datas::z_foils.

Referenced by DrawGLScene().

void Sail_create_and_draw ( datas d  ) 

Create and draw the sail.

The sail is not a SolidObject. It is redefined each time it is drawn (its position relative to the boat can change). The code of this function contains OpenGL code.

Parameters:
*d : pointer to the datas data-structure

Definition at line 261 of file solid_objects.cpp.

References datas::Baume, cross_product(), f(), get_texture(), datas::L_mast, datas::tanAngle_sail, texture, datas::x_sail, datas::y_sail, and datas::z_foils.

Referenced by DrawGLScene().

void SolidObject_compute_normals ( SolidObject so  ) 

Computes the normals for a SolidObject.

Once all X-, Y- Z- coordinates of a SolidObjects have been defined, the vertex-normal vectors in the SolidObject can be automatically filled by calling this function.

Parameters:
*so,: pointer to the SolidObject

Definition at line 155 of file solid_objects.cpp.

References SolidObject::M, SolidObject::N, SolidObject::nX, SolidObject::nY, SolidObject::nZ, one_normal(), SolidObject::X, SolidObject::Y, and SolidObject::Z.

Referenced by Boat_create().

void SolidObject_create ( SolidObject so,
int  N,
int  M 
)

Creates a solid object.

Initializes memory for a 3D object
Do not forget to call SolidObject_delete() for each object created once finished!!

Parameters:
*so pointer to a SolidObject to be initialized
N length of mesh 2D arrays (coordinates, normals, color)
M height of mesh 2D arrays (coordinates, normals, color)

Definition at line 46 of file solid_objects.cpp.

References SolidObject::B, SolidObject::G, SolidObject::M, SolidObject::N, SolidObject::nX, SolidObject::nY, SolidObject::nZ, SolidObject::R, SolidObject::X, SolidObject::Y, and SolidObject::Z.

Referenced by Boat_create().

void SolidObject_delete ( SolidObject so  ) 

Deletes a solid object.

Free memory used by a 3D object
To be used after every creation with SolidObject_create()

Definition at line 82 of file solid_objects.cpp.

References SolidObject::B, SolidObject::G, SolidObject::N, SolidObject::nX, SolidObject::nY, SolidObject::nZ, SolidObject::R, SolidObject::X, SolidObject::Y, and SolidObject::Z.

Referenced by Boat_delete().

void Target_draw ( float  x,
float  y 
)

Draws a "target instrument" on the screen.

Draws a circular target with a cross inside. The code of this function contains OpenGL code.

Parameters:
x,: cross position, $ -1.0 \leq x \leq 1.0$, clipped outside this range
y,: cross position, $ -1.0 \leq y \leq 1.0$, clipped outside this range

Definition at line 322 of file solid_objects.cpp.

References f().

Referenced by DrawGLScene().

void VSlider_draw ( float  x  ) 

Draws a "vertical slider instrument" on the screen.

Draws a vertical slider. The code of this function contains OpenGL code.

Parameters:
x,: slider position, $ -1.0 \leq x \leq 1.0$, clipped outside this range

Definition at line 356 of file solid_objects.cpp.

References f().

Referenced by DrawGLScene().


Generated on Wed Sep 20 14:30:04 2006 for hydroSDL by  doxygen 1.4.7