From 9f8ae69a0c429a85191758e20341afa27062cd42 Mon Sep 17 00:00:00 2001 From: jmbaud Date: Thu, 1 Aug 2024 13:48:14 +0200 Subject: [PATCH] Control part drawing was wrong in some cases. --- data/aircrafts/yf22.3d | 99 +++++++++++++++++++++++++++++++++++++++--- src/sardraw.c | 66 ++++++++++++++++++---------- 2 files changed, 135 insertions(+), 30 deletions(-) diff --git a/data/aircrafts/yf22.3d b/data/aircrafts/yf22.3d index 36dcc95..f8d10ea 100644 --- a/data/aircrafts/yf22.3d +++ b/data/aircrafts/yf22.3d @@ -842,33 +842,54 @@ begin_quads normal -0.948683 0.000000 -0.316228 -0.900000 -3.200000 0.000000 -1.700000 -4.200000 2.300000 - -1.700000 -5.100000 2.300000 + -1.700000 -4.700000 2.300000 + -1.000000 -5.800000 0.330000 + normal -0.948683 0.000000 -0.316228 + -0.900000 -3.200000 0.000000 + -1.000000 -5.800000 0.330000 + -1.000000 -6.200000 0.330000 -0.900000 -6.400000 0.000000 end_quads texture_select yf22_vstab_outside_right texture_orient_yz -3.200000 0.000000 3.200000 2.300000 begin_quads normal 0.948683 0.000000 -0.316228 - 0.900000 -6.400000 0.000000 - 1.700000 -5.100000 2.300000 + 1.000000 -5.800000 0.330000 + 1.700000 -4.700000 2.300000 1.700000 -4.200000 2.300000 0.900000 -3.200000 0.000000 + normal 0.948683 0.000000 -0.316228 + 0.900000 -3.200000 0.000000 + 0.900000 -6.400000 0.000000 + 1.000000 -6.200000 0.330000 + 1.000000 -5.800000 0.330000 end_quads texture_select yf22_vstab_inside texture_orient_yz -3.200000 0.000000 3.200000 2.300000 begin_quads normal 0.948683 0.000000 0.316228 - -0.900000 -6.400000 0.000000 - -1.700000 -5.100000 2.300000 - -1.700000 -4.200000 2.300000 + -1.001140 -5.800006 0.329600 + -1.699430 -4.699997 2.300200 + -1.701141 -4.200006 2.299599 + -0.898860 -3.199994 0.000400 + normal 0.948683 0.000000 0.316228 + -1.000000 -5.800000 0.330000 -0.900000 -3.200000 0.000000 + -0.900000 -6.400000 0.000000 + -1.000000 -6.200000 0.330000 normal -0.948683 0.000000 0.316228 0.900000 -3.200000 0.000000 1.700000 -4.200000 2.300000 - 1.700000 -5.100000 2.300000 + 1.700000 -4.700000 2.300000 + 1.000000 -5.800000 0.330000 + normal -0.948683 0.000000 0.316228 + 0.900000 -3.200000 0.000000 + 1.000000 -5.800000 0.330000 + 1.000000 -6.200000 0.330000 0.900000 -6.400000 0.000000 end_quads texture_off + # Thrust vain top left color 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0.100000 0.000000 texture_select yf22_engine_vain @@ -1329,6 +1350,70 @@ begin_triangles 0.800000 -6.400000 0.000000 end_triangles end_model shadow + +# Left rudder +#rudder_top_new +rudder_top_new -1.698 -4.701 2.294 10.0 26.0 -21.9 -20.0 20.0 +begin_model rudder_top +color 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0.500000 0.300000 0.000000 +texture_select yf22_vstab_outside_left +# Next 2 lignes must report "rudder_top_new" translate and rotate data +translate -1.698 -4.701 2.294 +rotate 10.0 26.0 -21.9 +begin_quads + normal -0.948683 0.000000 -0.316228 + texcoord 0.469104 0.998306 + 0.000632 -0.000476 0.000284 + texcoord 0.624950 0.997418 + 0.000031 -0.354475 -0.185961 + texcoord 0.970536 0.146853 + 0.000828 -0.354515 -2.548353 + texcoord 0.814692 0.147742 + 0.000825 -0.000520 -2.362107 +#inside + normal 0.948683 0.000000 -0.316228 + texcoord 0.970536 0.146853 + 0.000828 -0.354515 -2.548353 + texcoord 0.624950 0.997418 + 0.000031 -0.354475 -0.185961 + texcoord 0.469104 0.998306 + 0.000632 -0.000476 0.000284 + texcoord 0.814692 0.147742 + 0.000825 -0.000520 -2.362107 +end_quads +end_model rudder_top + +# Right rudder +#rudder_top_new +rudder_top_new 1.698 -4.701 2.294 -10.0 26.0 21.9 -20.0 20.0 +begin_model rudder_top +texture_select yf22_vstab_outside_right +# Next 2 lignes must report "rudder_top_new" translate and rotate data +translate 1.698 -4.701 2.294 +rotate -10.0 26.0 21.9 +begin_quads + normal -0.948683 0.000000 0.316228 + texcoord 0.469104 0.998306 + 0.000570 0.014003 0.000200 + texcoord 0.624950 0.997418 + -0.000034 -0.339996 -0.186045 + texcoord 0.970536 0.146853 + -0.001433 -0.340036 -2.548437 + texcoord 0.814692 0.147742 + -0.001433 0.013959 -2.362191 +#outside + normal 0.948683 0.000000 -0.316228 + texcoord 0.970536 0.146853 + -0.001433 -0.340036 -2.548437 + texcoord 0.624950 0.997418 + -0.000034 -0.339996 -0.186045 + texcoord 0.469104 0.998306 + 0.000570 0.014003 0.000200 + texcoord 0.814692 0.147742 + -0.001433 0.013959 -2.362191 +end_quads +end_model rudder_top + # Left Aileron # x y z h p b t_min t_max aileron_left_new -2.8 -3.47 0.0 19.95 0.0 0.0 -22.5 22.5 diff --git a/src/sardraw.c b/src/sardraw.c index 62ba7a4..37b7428 100644 --- a/src/sardraw.c +++ b/src/sardraw.c @@ -1201,29 +1201,49 @@ static void SARDrawPart( /* Begin drawing by part type */ switch(part->type) { -#define DO_DRAW_CONTROL_PART { \ - glTranslatef( \ - pos_cen->x, pos_cen->z, -pos_cen->y \ - ); \ - theta = dir_cen->heading + heading_mod; \ - if(theta != 0.0f) \ - glRotatef( \ - (GLfloat)-SFMRadiansToDegrees(theta), \ - 0.0f, 1.0f, 0.0f \ - ); \ - theta = dir_cen->pitch + pitch_mod; \ - if(theta != 0.0f) \ - glRotatef( \ - (GLfloat)-SFMRadiansToDegrees(theta), \ - 1.0f, 0.0f, 0.0f \ - ); \ - theta = dir_cen->bank + bank_mod; \ - if(theta != 0.0f) \ - glRotatef( \ - (GLfloat)-SFMRadiansToDegrees(theta), \ - 0.0f, 0.0f, 1.0f \ - ); \ - SARVisualModelCallList(vmodel); \ +#define DO_DRAW_CONTROL_PART { \ + /* First, move control part to the right place */ \ + glTranslatef( \ + pos_cen->x, pos_cen->z, -pos_cen->y \ + ); \ + theta = dir_cen->heading; \ + if(theta != 0.0f) \ + glRotatef( \ + (GLfloat)-SFMRadiansToDegrees(theta), \ + 0.0f, 1.0f, 0.0f \ + ); \ + theta = dir_cen->pitch; \ + if(theta != 0.0f) \ + glRotatef( \ + (GLfloat)-SFMRadiansToDegrees(theta), \ + 1.0f, 0.0f, 0.0f \ + ); \ + theta = dir_cen->bank; \ + if(theta != 0.0f) \ + glRotatef( \ + (GLfloat)-SFMRadiansToDegrees(theta), \ + 0.0f, 0.0f, 1.0f \ + ); \ + /* Then, apply modification angle */ \ + theta = heading_mod; \ + if(theta != 0.0f) \ + glRotatef( \ + (GLfloat)-SFMRadiansToDegrees(theta), \ + 0.0f, 1.0f, 0.0f \ + ); \ + theta = pitch_mod; \ + if(theta != 0.0f) \ + glRotatef( \ + (GLfloat)-SFMRadiansToDegrees(theta), \ + 1.0f, 0.0f, 0.0f \ + ); \ + theta = bank_mod; \ + if(theta != 0.0f) \ + glRotatef( \ + (GLfloat)-SFMRadiansToDegrees(theta), \ + 0.0f, 0.0f, 1.0f \ + ); \ + SARVisualModelCallList(vmodel); \ } case SAR_OBJ_PART_TYPE_AILERON_LEFT: