10 m_position=
vec2(0, 0);
11 m_rotation=
vec2(0, 0);
23 m_rotation.x= m_rotation.x + y;
24 m_rotation.y= m_rotation.y + x;
29 m_position.x= m_position.x - m_size * x;
30 m_position.y= m_position.y + m_size * y;
35 m_size= m_size - m_size * 0.01f * z;
42 return Translation( -m_position.x, -m_position.y, -m_size )
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));
68 dO= tinv(
Point(0, 0, z));
83 return tinv(
Point(0, 0, 0));
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);
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);
vecteur generique, utilitaire.
void move(const float z)
rapproche / eloigne la camera du centre.
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.
int read_orbiter(const char *filename)
relit la position de l'orbiter depuis un fichier texte.
Point position()
renvoie la position de la camera dans le repere du monde.
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...
Transform RotationX(const float a)
renvoie la matrice representation une rotation de angle degree autour de l'axe X. ...
void lookat(const Point ¢er, const float size)
observe le point center a une distance size.
Transform Translation(const Vector &v)
renvoie la matrice representant une translation par un vecteur.
void translation(const float x, const float y)
deplace le centre / le point observe.
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().
Transform Perspective(const float fov, const float aspect, const float znear, const float zfar)
renvoie la matrice representant une transformation projection perspective.
void rotation(const float x, const float y)
change le point de vue / la direction d'observation.
float distance(const Point &a, const Point &b)
renvoie la distance etre 2 points.
representation d'un point 3d.
void frame(const float width, const float height, const float z, const float fov, Point &dO, Vector &dx, Vector &dy) const
int write_orbiter(const char *filename)
enregistre la position de l'orbiter dans un fichier texte.
Point center(const Point &a, const Point &b)
renvoie le milieu du segment ab.
Transform RotationY(const float a)
renvoie la matrice representation une rotation de a degree autour de l'axe Y.