10 m_position=
vec2(0, 0);
12 m_rotation=
vec2(0, 0);
24 m_rotation.x= m_rotation.x + y;
25 m_rotation.y= m_rotation.y + x;
30 m_position.x= m_position.x - m_size * x;
31 m_position.y= m_position.y + m_size * y;
36 m_size= m_size - m_size * 0.01f * z;
43 return Translation( -m_position.x, -m_position.y, -m_size )
45 *
Translation( -m_center.x, -m_center.y, -m_center.z );
60 float d=
distance(m_center,
Point(m_position.x, m_position.y, m_size));
61 return std::max(
float(0.001), d - m_radius);
67 float d=
distance(m_center,
Point(m_position.x, m_position.y, m_size));
68 return std::max(
float(1), d + m_radius);
99 dO= tinv(
Point(0, 0, z));
114 return tinv(
Point(0, 0, 0));
119 return {-m_position.x, -m_position.y, -m_size };
129 FILE *in= fopen(filename,
"rt");
132 printf(
"[error] loading orbiter '%s'...\n", filename);
136 printf(
"loading orbiter '%s'...\n", filename);
139 if(fscanf(in,
"c %f %f %f \n", &m_center.x, &m_center.y, &m_center.z) != 3)
141 if(fscanf(in,
"p %f %f\n", &m_position.x, &m_position.y) != 2)
143 if(fscanf(in,
"r %f %f\n", &m_rotation.x, &m_rotation.y) != 2)
145 if(fscanf(in,
"s %f %f\n", &m_size, &m_radius) != 2)
148 if(fscanf(in,
"f %f %f %f\n", &m_fov, &m_width, &m_height) != 3)
154 printf(
"[error] loading orbiter '%s'...\n", filename);
163 FILE *out= fopen(filename,
"wt");
167 printf(
"writing orbiter '%s'...\n", filename);
169 fprintf(out,
"c %f %f %f\n", m_center.x, m_center.y, m_center.z);
170 fprintf(out,
"p %f %f\n", m_position.x, m_position.y);
171 fprintf(out,
"r %f %f\n", m_rotation.x, m_rotation.y);
172 fprintf(out,
"s %f %f\n", m_size, m_radius);
173 fprintf(out,
"f %f %f %f\n", m_fov, m_width, m_height);
void lookat(const Point ¢er, const float size)
observe le point center a une distance size.
vec2 rotation()
renvoie les angles de rotation de l'orbiter
vec3 translation()
renvoie la translation de l'orbiter
void frame(const float z, Point &dO, Vector &dx, Vector &dy) const
int read_orbiter(const char *filename)
relit la position de l'orbiter depuis un fichier texte.
Transform viewport() const
renvoie la transformation viewport actuelle. doit etre initialise par projection(width,...
void move(const float z)
rapproche / eloigne la camera du centre.
float znear() const
renvoie le plan proche de la projection. distance min des points dans le frustum de la camera (valeur...
float zfar() const
revnvoie le plan loin de la projection. distance max des points dans le frustum de la camera (valeur ...
Transform projection() const
renvoie la transformation projection actuelle. doit etre initialise par projection(width,...
Point position()
renvoie la position de la camera dans le repere du monde.
int write_orbiter(const char *filename)
enregistre la position de l'orbiter dans un fichier texte.
Transform view() const
renvoie la transformation vue.
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().
Point center(const Point &a, const Point &b)
renvoie le milieu du segment ab.
Transform Viewport(const float width, const float height)
renvoie la matrice representant une transformation viewport.
Transform RotationX(const float a)
renvoie la matrice representation une rotation de angle degree autour de l'axe X.
float distance(const Point &a, const Point &b)
renvoie la distance etre 2 points.
Transform RotationY(const float a)
renvoie la matrice representation une rotation de a degree autour de l'axe Y.
Transform Perspective(const float fov, const float aspect, const float znear, const float zfar)
renvoie la matrice representant une transformation projection perspective.
Transform Translation(const Vector &v)
renvoie la matrice representant une translation par un vecteur.
representation d'un point 3d.
representation d'un vecteur 3d.
vecteur generique, utilitaire.
vecteur generique, utilitaire.