added all moons
BIN
images/moons/ariel.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/callisto.bmp
Normal file
After Width: | Height: | Size: 8.0 MiB |
BIN
images/moons/charon.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/deimos.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/dione.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/enceladus.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/europa.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/ganymede.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/iapetus.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/io.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/oberon.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/phobos.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/rhea.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/titan.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/titania.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/triton.bmp
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/moons/umbriel.bmp
Normal file
After Width: | Height: | Size: 513 KiB |
232
window.c
@ -35,7 +35,11 @@ static surface_t * _sun = NULL;
|
|||||||
static surface_t * _planet[9] = {NULL, NULL, NULL,
|
static surface_t * _planet[9] = {NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL};
|
NULL, NULL, NULL};
|
||||||
static surface_t * _moon = NULL;
|
static surface_t * _moon[18] = {NULL, NULL, NULL, NULL,
|
||||||
|
NULL, NULL, NULL, NULL,
|
||||||
|
NULL, NULL, NULL, NULL,
|
||||||
|
NULL, NULL, NULL, NULL,
|
||||||
|
NULL, NULL};
|
||||||
|
|
||||||
/* des variable d'états pour activer/désactiver des options de rendu */
|
/* des variable d'états pour activer/désactiver des options de rendu */
|
||||||
static int _use_tex = 1, _use_color = 0, _use_lighting = 1;
|
static int _use_tex = 1, _use_color = 0, _use_lighting = 1;
|
||||||
@ -90,16 +94,16 @@ int main(int argc, char ** argv) {
|
|||||||
/*!\brief init de nos données, spécialement les trois surfaces
|
/*!\brief init de nos données, spécialement les trois surfaces
|
||||||
* utilisées dans ce code */
|
* utilisées dans ce code */
|
||||||
void init(void) {
|
void init(void) {
|
||||||
uint id[9], sun_id, i, moon_id;
|
uint id[9], sun_id, i, moon_id[18];
|
||||||
/*vec4 g = {0, 1, 0, 1};*/
|
|
||||||
/* on créé nos trois type de surfaces */
|
|
||||||
_sun = mkSphere(12, 12); /*ça fait 12x12x2 trianles !*/
|
_sun = mkSphere(12, 12); /*ça fait 12x12x2 trianles !*/
|
||||||
_moon = mkSphere(12, 12);
|
for(i = 0; i < 18; ++i) {
|
||||||
/* on change les couleurs de surfaces */
|
_moon[i] = mkSphere(12, 12);
|
||||||
/*_sun->dcolor = g; */
|
}
|
||||||
for(i = 0; i < 9; ++i) {
|
for(i = 0; i < 9; ++i) {
|
||||||
_planet[i] = mkSphere(12, 12);
|
_planet[i] = mkSphere(12, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
sun_id = getTexFromBMP("images/2k-sun.bmp");
|
sun_id = getTexFromBMP("images/2k-sun.bmp");
|
||||||
id[0] = getTexFromBMP("images/2k-mercury.bmp");
|
id[0] = getTexFromBMP("images/2k-mercury.bmp");
|
||||||
id[1] = getTexFromBMP("images/2k-venus-surface.bmp");
|
id[1] = getTexFromBMP("images/2k-venus-surface.bmp");
|
||||||
@ -110,28 +114,49 @@ void init(void) {
|
|||||||
id[6] = getTexFromBMP("images/2k-uranus.bmp");
|
id[6] = getTexFromBMP("images/2k-uranus.bmp");
|
||||||
id[7] = getTexFromBMP("images/2k-neptune.bmp");
|
id[7] = getTexFromBMP("images/2k-neptune.bmp");
|
||||||
id[8] = getTexFromBMP("images/pluto.bmp");
|
id[8] = getTexFromBMP("images/pluto.bmp");
|
||||||
moon_id = getTexFromBMP("images/2k-moon.bmp");
|
// https://upload.wikimedia.org/wikipedia/commons/4/4f/Moons_of_solar_system_v7.jpg
|
||||||
|
moon_id[0] = getTexFromBMP("images/2k-moon.bmp");
|
||||||
|
moon_id[1] = getTexFromBMP("images/moons/phobos.bmp");
|
||||||
|
moon_id[2] = getTexFromBMP("images/moons/deimos.bmp");
|
||||||
|
moon_id[3] = getTexFromBMP("images/moons/io.bmp");
|
||||||
|
moon_id[4] = getTexFromBMP("images/moons/europa.bmp");
|
||||||
|
moon_id[5] = getTexFromBMP("images/moons/ganymede.bmp");
|
||||||
|
moon_id[6] = getTexFromBMP("images/moons/callisto.bmp");
|
||||||
|
moon_id[7] = getTexFromBMP("images/moons/enceladus.bmp");
|
||||||
|
moon_id[8] = getTexFromBMP("images/moons/dione.bmp");
|
||||||
|
moon_id[9] = getTexFromBMP("images/moons/rhea.bmp");
|
||||||
|
moon_id[10] = getTexFromBMP("images/moons/titan.bmp");
|
||||||
|
moon_id[11] = getTexFromBMP("images/moons/iapetus.bmp");
|
||||||
|
moon_id[12] = getTexFromBMP("images/moons/ariel.bmp");
|
||||||
|
moon_id[13] = getTexFromBMP("images/moons/umbriel.bmp");
|
||||||
|
moon_id[14] = getTexFromBMP("images/moons/titania.bmp");
|
||||||
|
moon_id[15] = getTexFromBMP("images/moons/oberon.bmp");
|
||||||
|
moon_id[16] = getTexFromBMP("images/moons/triton.bmp");
|
||||||
|
moon_id[17] = getTexFromBMP("images/moons/charon.bmp");
|
||||||
|
|
||||||
setTexId(_sun, sun_id);
|
setTexId(_sun, sun_id);
|
||||||
setTexId(_moon, moon_id);
|
for(i = 0; i < 18; ++i)
|
||||||
|
setTexId(_moon[i], moon_id[i]);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
setTexId(_planet[i], id[i]);
|
setTexId(_planet[i], id[i]);
|
||||||
/* si _use_tex != 0, on active l'utilisation de la texture pour les
|
|
||||||
* trois */
|
|
||||||
if(_use_tex) {
|
if(_use_tex) {
|
||||||
enableSurfaceOption(_sun, SO_USE_TEXTURE);
|
enableSurfaceOption(_sun, SO_USE_TEXTURE);
|
||||||
enableSurfaceOption(_moon, SO_USE_TEXTURE);
|
for(i = 0; i < 18; ++i)
|
||||||
|
enableSurfaceOption(_moon[i], SO_USE_TEXTURE);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
enableSurfaceOption(_planet[i], SO_USE_TEXTURE);
|
enableSurfaceOption(_planet[i], SO_USE_TEXTURE);
|
||||||
}
|
}
|
||||||
/* si _use_lighting != 0, on active l'ombrage */
|
/* si _use_lighting != 0, on active l'ombrage */
|
||||||
if(_use_lighting) {
|
if(_use_lighting) {
|
||||||
enableSurfaceOption(_sun, SO_USE_LIGHTING);
|
enableSurfaceOption(_sun, SO_USE_LIGHTING);
|
||||||
enableSurfaceOption(_moon, SO_USE_LIGHTING);
|
for(i = 0; i < 18; ++i)
|
||||||
|
enableSurfaceOption(_moon[i], SO_USE_LIGHTING);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
enableSurfaceOption(_planet[i], SO_USE_LIGHTING);
|
enableSurfaceOption(_planet[i], SO_USE_LIGHTING);
|
||||||
}
|
}
|
||||||
disableSurfaceOption(_sun, SO_USE_COLOR);
|
disableSurfaceOption(_sun, SO_USE_COLOR);
|
||||||
disableSurfaceOption(_moon, SO_USE_COLOR);
|
for(i = 0; i < 18; ++i)
|
||||||
|
disableSurfaceOption(_moon[i], SO_USE_COLOR);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
disableSurfaceOption(_planet[i], SO_USE_COLOR);
|
disableSurfaceOption(_planet[i], SO_USE_COLOR);
|
||||||
atexit(sortie);
|
atexit(sortie);
|
||||||
@ -142,9 +167,9 @@ void draw(void) {
|
|||||||
static float a = 0.0f;
|
static float a = 0.0f;
|
||||||
static double t0 = 0, t, dt;
|
static double t0 = 0, t, dt;
|
||||||
t = gl4dGetElapsedTime();
|
t = gl4dGetElapsedTime();
|
||||||
dt = (t - t0) / 10000.0;
|
dt = (t - t0) / 1000.0;
|
||||||
t0 = t;
|
t0 = t;
|
||||||
float mvMat[16], projMat[16], nmv[16];
|
float mvMat[16], projMat[16], nmv[16], cpy[16];
|
||||||
/* effacer l'écran et le buffer de profondeur */
|
/* effacer l'écran et le buffer de profondeur */
|
||||||
gl4dpClearScreen();
|
gl4dpClearScreen();
|
||||||
clearDepth();
|
clearDepth();
|
||||||
@ -155,13 +180,8 @@ void draw(void) {
|
|||||||
MFRUSTUM(projMat, -0.005f, 0.005f, -0.005f, 0.005f, 0.01f, 1000.0f);
|
MFRUSTUM(projMat, -0.005f, 0.005f, -0.005f, 0.005f, 0.01f, 1000.0f);
|
||||||
/* charger la matrice identité dans model-view */
|
/* charger la matrice identité dans model-view */
|
||||||
MIDENTITY(mvMat);
|
MIDENTITY(mvMat);
|
||||||
/* on place la caméra en arrière-haut, elle regarde le centre de la scène */
|
|
||||||
/*lookAt(mvMat, _xcam, _ycam, _zcam, _x, _y, _z, 0, 1, 0);*/
|
|
||||||
/*lookAt(mvMat, _cam.x, 0.0, _cam.z, _cam.x - sin(_cam.theta), 1.0f - _ym / 200.0f, _cam.z - cos(_cam.theta), 0.0, 1.0, 0.0);*/
|
|
||||||
/*_cam.x = (_xm - (_wW >> 1)) / (float)_wW;*/
|
|
||||||
|
|
||||||
// Y ----> 1.0 - (_ym - (_wH >> 1)) / (float)_wH * 5
|
// Y ----> 1.0 - (_ym - (_wH >> 1)) / (float)_wH * 5
|
||||||
/*_cam.y = 1.0 - (_ym - (_wH >> 1)) / 300.0f;*/
|
|
||||||
lookAt(mvMat, _cam.x, _cam.y, _cam.z, _cam.x - sin(_cam.theta), 1.0, _cam.z - cos(_cam.theta), 0.0, 1.0, 0.0);
|
lookAt(mvMat, _cam.x, _cam.y, _cam.z, _cam.x - sin(_cam.theta), 1.0, _cam.z - cos(_cam.theta), 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
// scales https://www.jpl.nasa.gov/infographics/infographic.view.php?id=10749
|
// scales https://www.jpl.nasa.gov/infographics/infographic.view.php?id=10749
|
||||||
@ -198,13 +218,10 @@ void draw(void) {
|
|||||||
rotate(nmv, a, -0.234f, 1.0f, 0.0f);
|
rotate(nmv, a, -0.234f, 1.0f, 0.0f);
|
||||||
transform_n_raster(_planet[2], nmv, projMat);
|
transform_n_raster(_planet[2], nmv, projMat);
|
||||||
|
|
||||||
// MOON
|
// Moon
|
||||||
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
translate(nmv, 11.0f, 2.0f, 0.0f);
|
||||||
rotate(nmv, (a / 365.2425f), 0.0f, 1.0f, 0.0f);
|
scale(nmv, (1/50.0f) , (1/50.0f), (1/50.0f));
|
||||||
translate(nmv, 11.0f, 1.0f, 0.0f);
|
transform_n_raster(_moon[0], nmv, projMat);
|
||||||
rotate(nmv, a, 0.0f, 1.0f, 0.0f);
|
|
||||||
scale(nmv, (1/108.0f) * 12.0f / 20, (1/108.0f) * 12.0f / 20, (1/108.0f) * 12.0f / 20);
|
|
||||||
transform_n_raster(_moon, nmv, projMat);
|
|
||||||
|
|
||||||
// MARS
|
// MARS
|
||||||
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
||||||
@ -214,6 +231,20 @@ void draw(void) {
|
|||||||
rotate(nmv, a / 1.0416f, -0.252f, 1.0f, 0.0f);
|
rotate(nmv, a / 1.0416f, -0.252f, 1.0f, 0.0f);
|
||||||
transform_n_raster(_planet[3], nmv, projMat);
|
transform_n_raster(_planet[3], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(cpy, nmv, sizeof cpy);
|
||||||
|
|
||||||
|
// Phobos
|
||||||
|
rotate(nmv, a * 4.3f, 0.0f, 0.1f, 0.0f);
|
||||||
|
translate(nmv, 10.0f, 1.0f, 0.0f);
|
||||||
|
scale(nmv, (1/5.0f), (1/5.0f), (1/5.0f));
|
||||||
|
transform_n_raster(_moon[1], nmv, projMat);
|
||||||
|
|
||||||
|
// Deimos
|
||||||
|
rotate(cpy, a / 1.5f, 0.0f, 0.1f, 0.0f);
|
||||||
|
translate(cpy, 25.0f, 1.0f, 0.0f);
|
||||||
|
scale(cpy, (1/6.0f), (1/6.0f), (1/6.0f));
|
||||||
|
transform_n_raster(_moon[2], cpy, projMat);
|
||||||
|
|
||||||
// JUPITER
|
// JUPITER
|
||||||
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
||||||
rotate(nmv, a / (12 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
rotate(nmv, a / (12 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
||||||
@ -222,6 +253,38 @@ void draw(void) {
|
|||||||
rotate(nmv, a / 0.416f, -0.031f, 1.0f, 0.0f);
|
rotate(nmv, a / 0.416f, -0.031f, 1.0f, 0.0f);
|
||||||
transform_n_raster(_planet[4], nmv, projMat);
|
transform_n_raster(_planet[4], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(cpy, nmv, sizeof cpy);
|
||||||
|
|
||||||
|
// Io
|
||||||
|
rotate(nmv, a * 3.0f, 0.0f, 0.1f, 0.0f);
|
||||||
|
translate(nmv, 5.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/11.2f), (1/11.2f), (1/11.2f)); // 1/11.2f -> Jupiter is bigger then earth 11.2x / 50 io ~= moon size.
|
||||||
|
transform_n_raster(_moon[3], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Europa
|
||||||
|
rotate(nmv, a / 2.0f, 0.0f, 0.1f, 0.0f);
|
||||||
|
translate(nmv, 8.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/13.2f), (1/13.2f), (1/13.2f));
|
||||||
|
transform_n_raster(_moon[4], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Ganymede
|
||||||
|
rotate(nmv, a / 3.0f, 0.0f, 0.1f, 0.0f);
|
||||||
|
translate(nmv, 10.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/9.0f), (1/9.0f), (1/9.0f));
|
||||||
|
transform_n_raster(_moon[5], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Callisto
|
||||||
|
rotate(nmv, a / 5.0f, 0.0f, 0.1f, 0.0f);
|
||||||
|
translate(nmv, 11.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/10.0f), (1/10.0f), (1/10.0f));
|
||||||
|
transform_n_raster(_moon[6], nmv, projMat);
|
||||||
|
|
||||||
// SATURN
|
// SATURN
|
||||||
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
||||||
rotate(nmv, a / (30 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
rotate(nmv, a / (30 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
||||||
@ -230,14 +293,86 @@ void draw(void) {
|
|||||||
rotate(nmv, a / 0.4583f, -0.267f, 1.0f, 0.0f);
|
rotate(nmv, a / 0.4583f, -0.267f, 1.0f, 0.0f);
|
||||||
transform_n_raster(_planet[5], nmv, projMat);
|
transform_n_raster(_planet[5], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(cpy, nmv, sizeof cpy);
|
||||||
|
|
||||||
|
// Enceladus
|
||||||
|
rotate(nmv, a * 5.0f, 0.0f, 0.1f, 0.0f);
|
||||||
|
translate(nmv, 2.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/20.0f), (1/20.0f), (1/20.0f));
|
||||||
|
transform_n_raster(_moon[7], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Dione
|
||||||
|
rotate(nmv, a * 4.0f, 0.0f, 0.01f, 0.0f);
|
||||||
|
translate(nmv, 3.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/18.0f), (1/18.0f), (1/18.0f));
|
||||||
|
transform_n_raster(_moon[8], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Rhea
|
||||||
|
rotate(nmv, a * 3.0f, 0.0f, 0.01f, 0.0f);
|
||||||
|
translate(nmv, 4.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/15.0f), (1/15.0f), (1/15.0f));
|
||||||
|
transform_n_raster(_moon[9], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Titan
|
||||||
|
rotate(nmv, a / 4.0f, 0.0f, 0.01f, 0.0f);
|
||||||
|
translate(nmv, 6.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/10.0f), (1/10.0f), (1/10.0f));
|
||||||
|
transform_n_raster(_moon[10], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Iapetus
|
||||||
|
rotate(nmv, a / 6.0f, 0.0f, 0.01f, 0.0f);
|
||||||
|
translate(nmv, 7.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/14.0f), (1/14.0f), (1/14.0f));
|
||||||
|
transform_n_raster(_moon[11], nmv, projMat);
|
||||||
|
|
||||||
// URANUS
|
// URANUS
|
||||||
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
||||||
rotate(nmv, a / (84 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
rotate(nmv, a / (84 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
||||||
translate(nmv, 192.0f, 1.0f, 0.0f);
|
translate(nmv, 192.0f, 1.0f, 0.0f);
|
||||||
scale(nmv, (1/26.8f) * 12.0f, (1/26.8f) * 12.0f, (1/26.8f) * 12.0f);
|
scale(nmv, (1/26.8f) * 12.0f, (1/26.8f) * 12.0f, (1/26.8f) * 12.0f);
|
||||||
rotate(nmv, a / 0.7083f, 0.978f, 0.0f, 0.0f);
|
rotate(nmv, a / 0.7083f, -0.978f, 0.0f, 0.0f);
|
||||||
transform_n_raster(_planet[6], nmv, projMat);
|
transform_n_raster(_planet[6], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy(cpy, nmv, sizeof cpy);
|
||||||
|
|
||||||
|
// Ariel
|
||||||
|
rotate(nmv, a , 0.01f, 0.0f, 0.0f);
|
||||||
|
translate(nmv, 0.0f, 3.0f, 0.0f);
|
||||||
|
scale(nmv, (1/20.0f), (1/20.0f), (1/20.0f));
|
||||||
|
transform_n_raster(_moon[12], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy (nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Umbriel
|
||||||
|
rotate(nmv, a / 2.0f, 0.01f, 0.0f, 0.0f);
|
||||||
|
translate(nmv, 0.0f, 4.0f, 0.0f);
|
||||||
|
scale(nmv, (1/20.0f), (1/20.0f), (1/20.0f));
|
||||||
|
transform_n_raster(_moon[13], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy (nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Titania
|
||||||
|
rotate(nmv, a / 3.0f, 0.01f, 0.0f, 0.0f);
|
||||||
|
translate(nmv, 0.0f, 5.0f, 0.0f);
|
||||||
|
scale(nmv, (1/17.0f), (1/17.0f), (1/17.0f));
|
||||||
|
transform_n_raster(_moon[14], nmv, projMat);
|
||||||
|
|
||||||
|
memcpy (nmv, cpy, sizeof nmv);
|
||||||
|
|
||||||
|
// Oberon
|
||||||
|
rotate(nmv, a / 5.0f, 0.01f, 0.0f, 0.0f);
|
||||||
|
translate(nmv, 0.0f, 6.0f, 0.0f);
|
||||||
|
scale(nmv, (1/17.0f), (1/17.0f), (1/17.0f));
|
||||||
|
transform_n_raster(_moon[15], nmv, projMat);
|
||||||
|
|
||||||
// NEPTUNE
|
// NEPTUNE
|
||||||
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
||||||
rotate(nmv, a / (165 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
rotate(nmv, a / (165 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
||||||
@ -246,6 +381,12 @@ void draw(void) {
|
|||||||
rotate(nmv, a / 0.6f, -0.283f, 1.0f, 0.0f);
|
rotate(nmv, a / 0.6f, -0.283f, 1.0f, 0.0f);
|
||||||
transform_n_raster(_planet[7], nmv, projMat);
|
transform_n_raster(_planet[7], nmv, projMat);
|
||||||
|
|
||||||
|
// Triton
|
||||||
|
rotate(nmv, a / 5.0f, 0.0f, 0.01f, 0.0f);
|
||||||
|
translate(nmv, 3.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/10.0f), (1/10.0f), (1/10.0f));
|
||||||
|
transform_n_raster(_moon[16], nmv, projMat);
|
||||||
|
|
||||||
// PLUTO
|
// PLUTO
|
||||||
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
||||||
rotate(nmv, a / (248 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
rotate(nmv, a / (248 * 365.2425f), 0.0f, 1.0f, 0.0f);
|
||||||
@ -254,12 +395,18 @@ void draw(void) {
|
|||||||
rotate(nmv, a / 6.4, -0.119f, 1.0f, 0.0f);
|
rotate(nmv, a / 6.4, -0.119f, 1.0f, 0.0f);
|
||||||
transform_n_raster(_planet[8], nmv, projMat);
|
transform_n_raster(_planet[8], nmv, projMat);
|
||||||
|
|
||||||
|
// Charon
|
||||||
|
rotate(nmv, a / 5.0f, 0.0f, 0.01f, 0.0f);
|
||||||
|
translate(nmv, 3.0f, 0.0f, 0.0f);
|
||||||
|
scale(nmv, (1/13.0f), (1/13.0f), (1/13.0f));
|
||||||
|
transform_n_raster(_moon[16], nmv, projMat);
|
||||||
|
|
||||||
/* déclarer qu'on a changé (en bas niveau) des pixels du screen */
|
/* déclarer qu'on a changé (en bas niveau) des pixels du screen */
|
||||||
gl4dpScreenHasChanged();
|
gl4dpScreenHasChanged();
|
||||||
/* fonction permettant de raffraîchir l'ensemble de la fenêtre*/
|
/* fonction permettant de raffraîchir l'ensemble de la fenêtre*/
|
||||||
gl4dpUpdateScreen(NULL);
|
gl4dpUpdateScreen(NULL);
|
||||||
if (_pause != 1)
|
if (_pause != 1)
|
||||||
a += (dt * 60) * _s; // 1 minute == 1 day
|
a += ((360.0 * dt) / 60) * _s; // 360 in 1 minute so 1 day = 1 min
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!\brief intercepte l'événement clavier pour modifier les options. */
|
/*!\brief intercepte l'événement clavier pour modifier les options. */
|
||||||
@ -274,10 +421,10 @@ void key(int keycode) {
|
|||||||
_cam.y -= 5 * dtheta;
|
_cam.y -= 5 * dtheta;
|
||||||
break;
|
break;
|
||||||
case GL4DK_RIGHT:
|
case GL4DK_RIGHT:
|
||||||
_s += 30.0f;
|
_s += 60.0f;
|
||||||
break;
|
break;
|
||||||
case GL4DK_LEFT:
|
case GL4DK_LEFT:
|
||||||
_s -= 30.0f;
|
_s -= 60.0f;
|
||||||
break;
|
break;
|
||||||
case GL4DK_w:
|
case GL4DK_w:
|
||||||
_cam.x += -_v * step * sin(_cam.theta);
|
_cam.x += -_v * step * sin(_cam.theta);
|
||||||
@ -320,7 +467,6 @@ void key(int keycode) {
|
|||||||
_cam.y = 1.0f;
|
_cam.y = 1.0f;
|
||||||
_cam.z = 10;
|
_cam.z = 10;
|
||||||
_cam.theta = 0;
|
_cam.theta = 0;
|
||||||
/*_cam = {0, 1.0f, 10, 0};*/
|
|
||||||
break;
|
break;
|
||||||
case GL4DK_1:
|
case GL4DK_1:
|
||||||
break;
|
break;
|
||||||
@ -330,10 +476,14 @@ void key(int keycode) {
|
|||||||
_use_tex = !_use_tex;
|
_use_tex = !_use_tex;
|
||||||
if(_use_tex) {
|
if(_use_tex) {
|
||||||
enableSurfaceOption(_sun, SO_USE_TEXTURE);
|
enableSurfaceOption(_sun, SO_USE_TEXTURE);
|
||||||
|
for(i = 0; i < 18; ++i)
|
||||||
|
enableSurfaceOption(_moon[i], SO_USE_TEXTURE);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
enableSurfaceOption(_planet[i], SO_USE_TEXTURE);
|
enableSurfaceOption(_planet[i], SO_USE_TEXTURE);
|
||||||
} else {
|
} else {
|
||||||
disableSurfaceOption(_sun, SO_USE_TEXTURE);
|
disableSurfaceOption(_sun, SO_USE_TEXTURE);
|
||||||
|
for(i = 0; i < 18; ++i)
|
||||||
|
disableSurfaceOption(_moon[i], SO_USE_TEXTURE);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
disableSurfaceOption(_planet[i], SO_USE_TEXTURE);
|
disableSurfaceOption(_planet[i], SO_USE_TEXTURE);
|
||||||
}
|
}
|
||||||
@ -342,10 +492,14 @@ void key(int keycode) {
|
|||||||
_use_color = !_use_color;
|
_use_color = !_use_color;
|
||||||
if(_use_color) {
|
if(_use_color) {
|
||||||
enableSurfaceOption(_sun, SO_USE_COLOR);
|
enableSurfaceOption(_sun, SO_USE_COLOR);
|
||||||
|
for(i = 0; i < 18; ++i)
|
||||||
|
enableSurfaceOption(_moon[i], SO_USE_COLOR);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
enableSurfaceOption(_planet[i], SO_USE_COLOR);
|
enableSurfaceOption(_planet[i], SO_USE_COLOR);
|
||||||
} else {
|
} else {
|
||||||
disableSurfaceOption(_sun, SO_USE_COLOR);
|
disableSurfaceOption(_sun, SO_USE_COLOR);
|
||||||
|
for(i = 0; i < 18; ++i)
|
||||||
|
disableSurfaceOption(_moon[i], SO_USE_COLOR);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
disableSurfaceOption(_planet[i], SO_USE_COLOR);
|
disableSurfaceOption(_planet[i], SO_USE_COLOR);
|
||||||
}
|
}
|
||||||
@ -354,10 +508,14 @@ void key(int keycode) {
|
|||||||
_use_lighting = !_use_lighting;
|
_use_lighting = !_use_lighting;
|
||||||
if(_use_lighting) {
|
if(_use_lighting) {
|
||||||
enableSurfaceOption(_sun, SO_USE_LIGHTING);
|
enableSurfaceOption(_sun, SO_USE_LIGHTING);
|
||||||
|
for(i = 0; i < 18; ++i)
|
||||||
|
enableSurfaceOption(_moon[i], SO_USE_LIGHTING);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
enableSurfaceOption(_planet[i], SO_USE_LIGHTING);
|
enableSurfaceOption(_planet[i], SO_USE_LIGHTING);
|
||||||
} else {
|
} else {
|
||||||
disableSurfaceOption(_sun, SO_USE_LIGHTING);
|
disableSurfaceOption(_sun, SO_USE_LIGHTING);
|
||||||
|
for(i = 0; i < 18; ++i)
|
||||||
|
disableSurfaceOption(_moon[i], SO_USE_LIGHTING);
|
||||||
for(i = 0; i < 9; ++i)
|
for(i = 0; i < 9; ++i)
|
||||||
disableSurfaceOption(_planet[i], SO_USE_LIGHTING);
|
disableSurfaceOption(_planet[i], SO_USE_LIGHTING);
|
||||||
}
|
}
|
||||||
@ -389,9 +547,11 @@ void sortie(void) {
|
|||||||
freeSurface(_sun);
|
freeSurface(_sun);
|
||||||
_sun = NULL;
|
_sun = NULL;
|
||||||
}
|
}
|
||||||
if(_moon) {
|
for(i = 0; i < 18; ++i) {
|
||||||
freeSurface(_moon);
|
if(_moon[i]){
|
||||||
_moon = NULL;
|
freeSurface(_moon[i]);
|
||||||
|
_moon[i] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for(i = 0; i < 9; ++i) {
|
for(i = 0; i < 9; ++i) {
|
||||||
if(_planet[i]){
|
if(_planet[i]){
|
||||||
|