representation de la camera, type orbiter, placee sur une sphere autour du centre de l'objet.
More...
#include <orbiter.h>
|
| Orbiter () |
| cree une camera par defaut. observe le centre (0, 0, 0) a une distance 5. More...
|
|
| Orbiter (const Point ¢er, const float size) |
| cree une camera. observe le point center a une distance size. More...
|
|
| Orbiter (const Point &pmin, const Point &pmax) |
| cree une camera. observe une boite alignee sur les axes. More...
|
|
void | lookat (const Point ¢er, const float size) |
| observe le point center a une distance size. More...
|
|
void | lookat (const Point &pmin, const Point &pmax) |
| observe le centre d'une boite englobante. More...
|
|
void | rotation (const float x, const float y) |
| change le point de vue / la direction d'observation. More...
|
|
void | translation (const float x, const float y) |
| deplace le centre / le point observe. More...
|
|
void | move (const float z) |
| rapproche / eloigne la camera du centre. More...
|
|
Transform | view () const |
| renvoie la transformation vue. More...
|
|
Transform | projection (const float width, const float height, const float fov) const |
| renvoie la projection reglee pour une image d'aspect width / height, et une ouverture de fov degres. More...
|
|
void | frame (const float width, const float height, const float z, const float fov, Point &dO, Vector &dx, Vector &dy) const |
|
Point | position () |
| renvoie la position de la camera dans le repere du monde. More...
|
|
int | read_orbiter (const char *filename) |
| relit la position de l'orbiter depuis un fichier texte. More...
|
|
int | write_orbiter (const char *filename) |
| enregistre la position de l'orbiter dans un fichier texte. More...
|
|
|
Point | m_center |
|
vec2 | m_position |
|
vec2 | m_rotation |
|
float | m_size |
|
float | m_radius |
|
representation de la camera, type orbiter, placee sur une sphere autour du centre de l'objet.
Definition at line 16 of file orbiter.h.
cree une camera par defaut. observe le centre (0, 0, 0) a une distance 5.
Definition at line 20 of file orbiter.h.
20 : m_center(), m_position(), m_rotation(), m_size(5.f), m_radius(5.f) {}
Orbiter::Orbiter |
( |
const Point & |
center, |
|
|
const float |
size |
|
) |
| |
|
inline |
cree une camera. observe le point center a une distance size.
Definition at line 22 of file orbiter.h.
22 : m_center(center), m_position(), m_rotation(), m_size(size), m_radius(size) {}
Orbiter::Orbiter |
( |
const Point & |
pmin, |
|
|
const Point & |
pmax |
|
) |
| |
|
inline |
cree une camera. observe une boite alignee sur les axes.
Definition at line 24 of file orbiter.h.
24 : m_center(
center(pmin, pmax)), m_position(), m_rotation(), m_size(
distance(pmin, pmax)) {}
float distance(const Point &a, const Point &b)
renvoie la distance etre 2 points.
Point center(const Point &a, const Point &b)
renvoie le milieu du segment ab.
void Orbiter::lookat |
( |
const Point & |
center, |
|
|
const float |
size |
|
) |
| |
observe le point center a une distance size.
Definition at line 7 of file orbiter.cpp.
10 m_position=
vec2(0, 0);
11 m_rotation=
vec2(0, 0);
vecteur generique, utilitaire.
Point center(const Point &a, const Point &b)
renvoie le milieu du segment ab.
void Orbiter::lookat |
( |
const Point & |
pmin, |
|
|
const Point & |
pmax |
|
) |
| |
observe le centre d'une boite englobante.
Definition at line 16 of file orbiter.cpp.
void lookat(const Point ¢er, const float size)
observe le point center a une distance size.
float distance(const Point &a, const Point &b)
renvoie la distance etre 2 points.
Point center(const Point &a, const Point &b)
renvoie le milieu du segment ab.
void Orbiter::rotation |
( |
const float |
x, |
|
|
const float |
y |
|
) |
| |
change le point de vue / la direction d'observation.
Definition at line 21 of file orbiter.cpp.
23 m_rotation.x= m_rotation.x + y;
24 m_rotation.y= m_rotation.y + x;
void Orbiter::translation |
( |
const float |
x, |
|
|
const float |
y |
|
) |
| |
deplace le centre / le point observe.
Definition at line 27 of file orbiter.cpp.
29 m_position.x= m_position.x - m_size * x;
30 m_position.y= m_position.y + m_size * y;
void Orbiter::move |
( |
const float |
z | ) |
|
rapproche / eloigne la camera du centre.
Definition at line 33 of file orbiter.cpp.
35 m_size= m_size - m_size * 0.01f * z;
renvoie la transformation vue.
Definition at line 40 of file orbiter.cpp.
42 return Translation( -m_position.x, -m_position.y, -m_size )
representation d'un vecteur 3d.
Transform RotationX(const float a)
renvoie la matrice representation une rotation de angle degree autour de l'axe X. ...
Transform Translation(const Vector &v)
renvoie la matrice representant une translation par un vecteur.
Transform RotationY(const float a)
renvoie la matrice representation une rotation de a degree autour de l'axe Y.
Transform Orbiter::projection |
( |
const float |
width, |
|
|
const float |
height, |
|
|
const float |
fov |
|
) |
| const |
renvoie la projection reglee pour une image d'aspect width / height, et une ouverture de fov degres.
Definition at line 47 of file orbiter.cpp.
53 float d=
distance(m_center,
Point(m_position.x, m_position.y, m_size));
56 return Perspective(fov, width / height, std::max(0.1f, d - m_radius), std::max(1.f, d + m_radius));
Transform Perspective(const float fov, const float aspect, const float znear, const float zfar)
renvoie la matrice representant une transformation projection perspective.
float distance(const Point &a, const Point &b)
renvoie la distance etre 2 points.
representation d'un point 3d.
void Orbiter::frame |
( |
const float |
width, |
|
|
const float |
height, |
|
|
const float |
z, |
|
|
const float |
fov, |
|
|
Point & |
dO, |
|
|
Vector & |
dx, |
|
|
Vector & |
dy |
|
) |
| const |
renvoie les coorodnnees de l'origine d0 et les axes dx, dy du plan image dans le repere du monde. permet de construire un rayon pour le pixel x, y :
- l'extremite : un point dans le plan image avec z = 0 :
camera.
frame(width, height, 0, fov, d0, dx0, dy0);
Point e= d0 + x*dx0 + y*dy0;
- l'origine :
ou autre solution, reproduire la projection openGL :
- extremite : un point dans le plan image avec z = 1 :
camera.
frame( width, height, 1, fov, d1, dx1, dy1);
Point e= d1 + x*dx1 + y*dy1;
- origine : un point dans le plan image avec z = 0 :
camera.
frame(width, height, 0, fov, d0, dx0, dy0);
Point o= d0 + x*dx0 + y*dy0;
Definition at line 59 of file orbiter.cpp.
68 dO= tinv(
Point(0, 0, z));
Transform Viewport(const float width, const float height)
renvoie la matrice representant une transformation viewport.
Transform view() const
renvoie la transformation vue.
representation d'un vecteur 3d.
Transform projection(const float width, const float height, const float fov) const
renvoie la projection reglee pour une image d'aspect width / height, et une ouverture de fov degres...
representation d'un point 3d.
Point Orbiter::position |
( |
| ) |
|
renvoie la position de la camera dans le repere du monde.
Definition at line 78 of file orbiter.cpp.
83 return tinv(
Point(0, 0, 0));
Transform view() const
renvoie la transformation vue.
representation d'un point 3d.
int Orbiter::read_orbiter |
( |
const char * |
filename | ) |
|
relit la position de l'orbiter depuis un fichier texte.
Definition at line 86 of file orbiter.cpp.
88 FILE *in= fopen(filename,
"rt");
91 printf(
"[error] loading orbiter '%s'...\n", filename);
95 printf(
"loading orbiter '%s'...\n", filename);
98 if(fscanf(in,
"c %f %f %f \n", &m_center.x, &m_center.y, &m_center.z) != 3)
100 if(fscanf(in,
"p %f %f\n", &m_position.x, &m_position.y) != 2)
102 if(fscanf(in,
"r %f %f\n", &m_rotation.x, &m_rotation.y) != 2)
104 if(fscanf(in,
"s %f\n", &m_size) != 1)
110 printf(
"[error] loading orbiter '%s'...\n", filename);
void printf(Text &text, const int px, const int py, const char *format,...)
affiche un texte a la position x, y. meme utilisation que printf().
int Orbiter::write_orbiter |
( |
const char * |
filename | ) |
|
enregistre la position de l'orbiter dans un fichier texte.
Definition at line 117 of file orbiter.cpp.
119 FILE *out= fopen(filename,
"wt");
123 printf(
"writing orbiter '%s'...\n", filename);
125 fprintf(out,
"c %f %f %f\n", m_center.x, m_center.y, m_center.z);
126 fprintf(out,
"p %f %f\n", m_position.x, m_position.y);
127 fprintf(out,
"r %f %f\n", m_rotation.x, m_rotation.y);
128 fprintf(out,
"s %f\n", m_size);
void printf(Text &text, const int px, const int py, const char *format,...)
affiche un texte a la position x, y. meme utilisation que printf().
The documentation for this class was generated from the following files: