windmill-gint/src/camera.hpp

124 lines
2.6 KiB
C++

//-----------------------------------------------------------------------------
//
// CAMERA
//
// Repere monde Repere camera : z rentre dans l'ecran
// z O------ x
// | y |
// |/ |
// ☐☐◁ O---- x y
//
// rotation autour de z de x vers y : rotation droite vers gauche : yaw
// rotation autour de y' de x' vers z' : rotation de bas vers haut : pitch
//
// avec yaw = pitch = 0, la camera regarde vers x, avec y à gauche et z en haut
//
// les objets sont affiches dans le sens trigo
//
// texture : O----->w
// |
// |
// h
//
// sens trigonométrique pour afficher la face avant
// le 0 texture correspond au 0 triangle et 0 rectangle
//
// triangle : 0-----2 avec offset 0-----2
// | / de 50% c'est | |
// | / le point 1 | |
// | / qui se décale | |
// | / |
// 1 1
//
// rectangle : 0-----2
// | /|
// | / |
// | / |
// | / |
// 1-----3 3 est automatiquement crée
//-----------------------------------------------------------------------------
#ifndef DEF_CAMERA
#define DEF_CAMERA
extern "C"
{
#define __BSD_VISIBLE 1
#include <openlibm.h>
#include <gint/defs/util.h>
}
//#define PI 3.1415
#define DEG 180.0
#define to_rad(x) M_PI / DEG * x
#define to_deg(x) DEG / M_PI * x
#define SCALE_AI 128
class Camera
{
public:
Camera();
void set(float _x, float _y, float _z, float _yaw, float _pitch);
void set(Camera* _camera);
void update();
void direction_vector(float* _x, float* _y);
//void move(float _x, float _y, float _z);
void move_front(float value);
void move_side(float value);
void move_altitude(float value);
void turn_yaw(float value);
void turn_pitch(float value);
void set_yaw(float value);
void set_pitch(float value);
void look_at(float _x, float _y, float _z, float duration);
void turn(float _yaw, float _pitch);
//int min(int a, int b);
//int max(int a, int b);
public:
float x, y, z;
float yaw, pitch;
public:
int look_at_type;
float look_at_yaw;
float look_at_pitch;
float look_at_duration;
//int nx, ny, nz;
float nx, ny, nz;
float cos_yaw, sin_yaw;
float cos_pitch, sin_pitch;
float fov;
int cos_fov;
//int sin_fov;
float sin_fov;
float cos_fov_square;
int scale_coef;
int near;
int far;
float near_coef;
int far_coef;
float normal_x, normal_y, normal_z;
int a1, a2, a3, a4, a5, a6, a7, a8, a9;
};
#endif