From 305a8144846ebc6cec34dcbacd36f61ef05e0773 Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta Date: Fri, 18 Dec 2020 08:41:32 +0100 Subject: [PATCH] playing with sphere size --- geometry.c | 6 +++--- moteur.h | 2 +- window.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/geometry.c b/geometry.c index b8593b2..a95db86 100644 --- a/geometry.c +++ b/geometry.c @@ -102,7 +102,7 @@ surface_t * mkCube(void) { /*!\brief fabrique et renvoie une surface représentant une sphère * centrée en zéro et de rayon 1. Elle est découpée en \a longitudes * longitudes et \a latitudes latitudes. */ -surface_t * mkSphere(int longitudes, int latitudes) { +surface_t * mkSphere(int longitudes, int latitudes, double s) { triangle_t * t; vertex_t * data; double phi, theta, r, y; @@ -118,8 +118,8 @@ surface_t * mkSphere(int longitudes, int latitudes) { assert(t); for(z = 0, k = 0; z <= latitudes; ++z) { theta = -M_PI_2 + z * cMPI_Lat; - y = sin(theta); - r = cos(theta); + y = sin(theta) * s; + r = cos(theta) * s; for(x = 0; x <= longitudes; ++x, ++k) { phi = x * c2MPI_Long; data[k].position.x = r * cos(phi); diff --git a/moteur.h b/moteur.h index 006535c..c29b282 100644 --- a/moteur.h +++ b/moteur.h @@ -155,7 +155,7 @@ extern "C" { /* dans geometry.c */ extern surface_t * mkQuad(void); extern surface_t * mkCube(void); - extern surface_t * mkSphere(int longitudes, int latitudes); + extern surface_t * mkSphere(int longitudes, int latitudes, double s); # ifdef __cplusplus } # endif diff --git a/window.c b/window.c index 09fbd00..82c76ec 100644 --- a/window.c +++ b/window.c @@ -91,10 +91,10 @@ void init(void) { GLuint id, id2; /*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, 2); /* ça fait 12x12x2 trianles ! */ /* on change les couleurs de surfaces */ /*_sun->dcolor = g; */ - _mercury = mkSphere(12,12); + _mercury = mkSphere(12,12, 0.3); id = getTexFromBMP("images/2k-sun.bmp"); id2 = getTexFromBMP("images/2k-mercury.bmp"); setTexId(_sun, id);