summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2015-04-15 17:03:24 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-07 09:53:08 +0200
commit88b30ef28c47106891d44f62798424c745ec1b8c (patch)
tree2187fa3bbedf20059f50f4341dec88d2ee015453 /src
parentfe674b160f6113600137db0bee4c9e0e422591f2 (diff)
evas: torus is normalized in Evas_3D examples.
Reviewers: Hermet, raster, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2334 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/examples/evas/evas-3d-primitives.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/examples/evas/evas-3d-primitives.c b/src/examples/evas/evas-3d-primitives.c
index 41b3fde15b..393ee1655f 100644
--- a/src/examples/evas/evas-3d-primitives.c
+++ b/src/examples/evas/evas-3d-primitives.c
@@ -457,7 +457,7 @@ evas_3d_add_terrain_frame(Eo *mesh, int frame, int p, vec2 tex_scale)
457} 457}
458 458
459void 459void
460evas_3d_add_torus_frame(Eo *mesh, int frame, float rratio, int p, vec2 tex_scale) 460evas_3d_add_torus_frame(Eo *mesh, int frame, float ratio, int p, vec2 tex_scale)
461{ 461{
462 int vcount, icount, vccount, i, j; 462 int vcount, icount, vccount, i, j;
463 icount = p * p * 6; 463 icount = p * p * 6;
@@ -470,6 +470,20 @@ evas_3d_add_torus_frame(Eo *mesh, int frame, float rratio, int p, vec2 tex_scale
470 470
471 d = 2 * M_PI / p; 471 d = 2 * M_PI / p;
472 472
473 float rratio;
474
475 if ((ratio > 1.0) || (ratio < 0.0))
476 {
477 printf("Ratio of torus should be between 0.0 and 1.0. \n");
478 printf("Ratio = %f is a bad value, so 0.25 is used like default ratio.\n",
479 ratio);
480 rratio = 0.25;
481 }
482 else
483 {
484 rratio = ratio;
485 }
486
473 for (j = 0; j < vccount; j++) 487 for (j = 0; j < vccount; j++)
474 { 488 {
475 theta = j * d; 489 theta = j * d;
@@ -480,16 +494,16 @@ evas_3d_add_torus_frame(Eo *mesh, int frame, float rratio, int p, vec2 tex_scale
480 fi = i * d; 494 fi = i * d;
481 sinfi = sin(fi); 495 sinfi = sin(fi);
482 cosfi = cos(fi); 496 cosfi = cos(fi);
483 vertices[i + j * vccount].x = (1 + rratio * cosfi) * costh; 497 vertices[i + j * vccount].x = (1.0 - rratio + rratio * cosfi) * costh * 0.5;
484 vertices[i + j * vccount].y = (1 + rratio * cosfi) * sinth; 498 vertices[i + j * vccount].y = (1.0 - rratio + rratio * cosfi) * sinth * 0.5;
485 vertices[i + j * vccount].z = rratio * sinfi; 499 vertices[i + j * vccount].z = rratio * sinfi * 0.5;
486 500
487 normals[i + j * vccount].x = cosfi * costh; 501 normals[i + j * vccount].x = cosfi * costh;
488 normals[i + j * vccount].y = cosfi * sinth; 502 normals[i + j * vccount].y = cosfi * sinth;
489 normals[i + j * vccount].z = sinfi; 503 normals[i + j * vccount].z = sinfi;
490 504
491 tangents[i + j * vccount].x = - sinfi * costh; 505 tangents[i + j * vccount].x = -sinfi * costh;
492 tangents[i + j * vccount].y = - sinfi * sinth; 506 tangents[i + j * vccount].y = -sinfi * sinth;
493 tangents[i + j * vccount].z = cosfi; 507 tangents[i + j * vccount].z = cosfi;
494 508
495 _vec3_normalize(&normals[i + j * vccount]); 509 _vec3_normalize(&normals[i + j * vccount]);