comments
This commit is contained in:
parent
0c85e41ff1
commit
8450087c83
|
@ -10,7 +10,7 @@
|
|||
FE_position FE_user={0,0,0};
|
||||
double FE_dh,FE_dv,FE_roulis;
|
||||
|
||||
static double px,py,pz;
|
||||
static double px,py,pz; // instance flottante des coordonnées des joueurs
|
||||
|
||||
static uint32_t frame_interval=0, frame_interval_min=1000001, frame_interval_max=1; // in milliseconds
|
||||
static bool loaded_before=false;
|
||||
|
@ -19,7 +19,7 @@ static double dh_vel=0.05;
|
|||
static double dv_vel=0.05;
|
||||
static double roulis_vel=0.05;
|
||||
|
||||
static void FE_move() // call at each frame
|
||||
static void FE_move()
|
||||
{
|
||||
key_event_t event;
|
||||
while (true)
|
||||
|
@ -28,93 +28,104 @@ static void FE_move() // call at each frame
|
|||
if (event.type&KEYEV_DOWN)
|
||||
{
|
||||
if (event.key==KEY_LEFT)
|
||||
FE_dh-=dh_vel;
|
||||
FE_dh -= dh_vel;
|
||||
if (event.key==KEY_RIGHT)
|
||||
FE_dh+=dh_vel;
|
||||
FE_dh += dh_vel;
|
||||
if (event.key==KEY_UP)
|
||||
FE_dv+=dv_vel;
|
||||
FE_dv += dv_vel;
|
||||
if (event.key==KEY_DOWN)
|
||||
FE_dv-=dv_vel;
|
||||
FE_dv -= dv_vel;
|
||||
if (event.key==KEY_PLUS)
|
||||
FE_roulis+=roulis_vel;
|
||||
FE_dh=FE_modulo_2pi(FE_dh);
|
||||
FE_dv=FE_modulo_2pi(FE_dv);
|
||||
FE_roulis=FE_modulo_2pi(FE_roulis);
|
||||
FE_roulis += roulis_vel;
|
||||
FE_dh = FE_modulo_2pi(FE_dh);
|
||||
FE_dv = FE_modulo_2pi(FE_dv);
|
||||
FE_roulis = FE_modulo_2pi(FE_roulis);
|
||||
|
||||
if (event.key==KEY_8)
|
||||
{
|
||||
py+=FE_cos(FE_dh);
|
||||
px+=FE_sin(FE_dh);
|
||||
py += FE_cos(FE_dh);
|
||||
px += FE_sin(FE_dh);
|
||||
}
|
||||
if (event.key==KEY_5)
|
||||
{
|
||||
py+=FE_cos(FE_dh+pi);
|
||||
px+=FE_sin(FE_dh+pi);
|
||||
py += FE_cos(FE_dh + pi);
|
||||
px += FE_sin(FE_dh + pi);
|
||||
}
|
||||
if (event.key==KEY_4)
|
||||
{
|
||||
py+=FE_cos(FE_dh-pi_sur2);
|
||||
px+=FE_sin(FE_dh-pi_sur2);
|
||||
py += FE_cos(FE_dh - pi_sur2);
|
||||
px += FE_sin(FE_dh - pi_sur2);
|
||||
}
|
||||
if (event.key==KEY_6)
|
||||
{
|
||||
py+=FE_cos(FE_dh+pi_sur2);
|
||||
px+=FE_sin(FE_dh+pi_sur2);
|
||||
py += FE_cos(FE_dh + pi_sur2);
|
||||
px += FE_sin(FE_dh + pi_sur2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (event.type==KEYEV_NONE)
|
||||
if (event.type==KEYEV_NONE) // si tous les évènements ont été traités
|
||||
break;
|
||||
}
|
||||
FE_user.x=px;
|
||||
FE_user.y=py;
|
||||
FE_user.z=pz;
|
||||
|
||||
FE_user.x = px; // actualisation des coordonnées de position
|
||||
FE_user.y = py;
|
||||
FE_user.z = pz;
|
||||
}
|
||||
|
||||
void FE_new_frame(void)
|
||||
void FE_new_frame()
|
||||
{
|
||||
dupdate(); // fin du cycle précédent
|
||||
|
||||
// gestion du temps avec libprof
|
||||
if (loaded_before)
|
||||
{
|
||||
prof_leave(0);
|
||||
frame_interval=prof_time(0);
|
||||
frame_interval = prof_time(0);
|
||||
if (frame_interval<frame_interval_min)
|
||||
frame_interval_min=frame_interval;
|
||||
frame_interval_min = frame_interval;
|
||||
if (frame_interval>frame_interval_max)
|
||||
frame_interval_max=frame_interval;
|
||||
frame_interval_max = frame_interval;
|
||||
}
|
||||
else
|
||||
{
|
||||
prof_init(1,0);
|
||||
prof_init(1, 0);
|
||||
loaded_before=true;
|
||||
}
|
||||
prof_clear(0);
|
||||
prof_enter(0);
|
||||
|
||||
FE_move(); // Not implemented yet !
|
||||
FE_set_matrice();
|
||||
FE_zbuffer_clear();
|
||||
|
||||
//actualisation de la position, de la direction et des données liées
|
||||
FE_move();
|
||||
FE_set_matrice();
|
||||
|
||||
dupdate();
|
||||
dclear(C_WHITE);
|
||||
}
|
||||
|
||||
|
||||
static char fps_history[15];
|
||||
char* FE_get_fps_history()
|
||||
#define MICROSECOND = 1000000;
|
||||
|
||||
unsigned uint32_t FE_get_fps_current()
|
||||
{
|
||||
sprintf(fps_history,"%d/%d/%d",FE_get_fps_min(),FE_get_fps_current(),FE_get_fps_max());
|
||||
return fps_history;
|
||||
return MICROSECOND / frame_interval;
|
||||
}
|
||||
|
||||
unsigned uint32_t FE_get_fps_min()
|
||||
{
|
||||
return MICROSECOND / frame_interval_max;
|
||||
}
|
||||
|
||||
unsigned uint32_t FE_get_fps_max()
|
||||
{
|
||||
return MICROSECOND / frame_interval_min;
|
||||
}
|
||||
|
||||
|
||||
static const uint32_t unite=1000000;
|
||||
unsigned int FE_get_fps_current(void)
|
||||
{return unite/frame_interval;}
|
||||
static char fps_history[15];
|
||||
|
||||
unsigned int FE_get_fps_min(void)
|
||||
{return unite/frame_interval_max;}
|
||||
|
||||
unsigned int FE_get_fps_max(void)
|
||||
{return unite/frame_interval_min;}
|
||||
char* FE_get_fps_history()
|
||||
{
|
||||
sprintf(fps_history, "%d/%d/%d", FE_get_fps_min(), FE_get_fps_current(), FE_get_fps_max());
|
||||
return fps_history;
|
||||
}
|
|
@ -1,45 +1,56 @@
|
|||
#ifndef FENG_H
|
||||
#define FENG_H
|
||||
|
||||
|
||||
|
||||
#include "coord.h"
|
||||
#include "zbuffer.h"
|
||||
|
||||
/* Coordonnées de la caméra
|
||||
on utilise des double pour la direction
|
||||
et des int pour la position (bien qu'une copie flottante cachée existe)
|
||||
*/
|
||||
extern double FE_dh,FE_dv,FE_roulis;
|
||||
extern FE_position FE_user;
|
||||
|
||||
/*** FE_new_frame()
|
||||
* This function displays las frame content and prepares the next frame
|
||||
* Then, you have to use this in that order :
|
||||
* while (1) {
|
||||
* FE_new_frame()
|
||||
* calculating...
|
||||
* displaying model
|
||||
* post rendering functions
|
||||
* }
|
||||
**/
|
||||
/* FE_new_frame():
|
||||
affiche l'image précedemment dessinée et lance un nouveau cycle de dessin
|
||||
|
||||
Dépend de :
|
||||
"FxEngine.h"
|
||||
FE_move()
|
||||
"coord.h"
|
||||
FE_set_matrice()
|
||||
"zbuffer.h"
|
||||
FE_zbuffer_clear()
|
||||
<libprof.h>
|
||||
prof_init()
|
||||
prof_clear()
|
||||
prof_enter()
|
||||
prof_leave()
|
||||
prof_time() */
|
||||
void FE_new_frame(void); // calls move function
|
||||
|
||||
/** FE_get_fps_current()
|
||||
* return a fps number based on the last frame
|
||||
**/
|
||||
/* FE_get_fps_current():
|
||||
obtient le nombre d'Images Par Seconde (IPS) calculé à partir du dernier cycle */
|
||||
unsigned int FE_get_fps_current(void);
|
||||
|
||||
/** FE_get_fps_min()
|
||||
* return minimal fps number since the addin started
|
||||
**/
|
||||
/* FE_get_fps_min():
|
||||
obtient le nombre d'images par seconde le plus bas ayant existé depuis le démarrage du moteur 3d */
|
||||
unsigned int FE_get_fps_min(void);
|
||||
|
||||
/** FE_get_fps_max()
|
||||
* return maximal fps number since the addin started
|
||||
**/
|
||||
/* FE_get_fps_max():
|
||||
obtient le nombre d'images par seconde le plus haut ayant existé depuis le démarrage du moteur 3d */
|
||||
unsigned int FE_get_fps_max(void);
|
||||
|
||||
/** FE_get_fps_history()
|
||||
* returns minimal, current and maximal fps number since the addin started
|
||||
* the type is a char* and the fps are set using its format : min/current/max
|
||||
**/
|
||||
/* FE_get_fps_history():
|
||||
renvoie, dans une version compactée, les nombres minimum, actuel et maximum d'images par seconde
|
||||
|
||||
Dépend de :
|
||||
"FxEngine.h"
|
||||
FE_get_fps_min()
|
||||
FE_get_fps_max()
|
||||
FE_get_fps_max()
|
||||
<gint/std/stdio.h>
|
||||
sprintf() */
|
||||
char* FE_get_fps_history(void);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue