X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Ftangram.c;h=a5aa8a9d3bba1656b5d32366338b77180f1243f9;hp=2c4e4db5dbaaacbf4f2f92921f754d3aae2a26d4;hb=0d6b320def9180cf907ceaed56b23a972a11b757;hpb=3f438031d610c7e15fd33876a879b97e290e05fb diff --git a/hacks/glx/tangram.c b/hacks/glx/tangram.c index 2c4e4db5..a5aa8a9d 100644 --- a/hacks/glx/tangram.c +++ b/hacks/glx/tangram.c @@ -1,12 +1,18 @@ /* tangram, Copyright (c) 2005 Jeremy English * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation. No representations are made about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation. No representations are made + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * Sun 10 July 2005 Changed the code that solves the puzzles. + * Also, limited the palette and added names. + * + * Wed 13 July 2005 Added option to turn off rotation. + * Changed color and materials */ @@ -14,15 +20,15 @@ extern XtAppContext app; -#define PROGCLASS "TANGRAM" +#define PROGCLASS "Tangram" #define HACK_INIT init_tangram #define HACK_DRAW draw_tangram #define HACK_RESHAPE reshape_tangram #define sws_opts xlockmore_opts -#define DEFAULTS "*delay: 30000 \n" \ - "*wireframe: False \n" \ +#define DEFAULTS "*delay: 10000 \n" \ + "*wireframe: False \n" \ #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -39,11 +45,7 @@ extern XtAppContext app; #include #include #include "tangram_shapes.h" - -typedef enum { - true = 1, - false = 0 -} bool; +#include "glxfonts.h" typedef struct { GLubyte r; @@ -62,9 +64,17 @@ typedef struct { GLint r; /* rotation */ GLint fr; /* flip Rotate. Used to keep track during animation */ GLint dl; /* display List */ - + GLfloat dz; /* velocity */ + GLfloat ddz; /* Acceleration */ + GLfloat solved; /* shapes state */ + Bool up; /* Move up the z axis? */ } tangram_shape; +typedef struct { + char *name; + tangram_shape ts[7]; +} puzzle; + typedef enum { no_shape = -1, small_triangle1 = 0, @@ -76,763 +86,545 @@ typedef enum { rhomboid = 6 } shape_type; -typedef enum { - state_exploding, - state_solving, - state_solved -} tangram_state; - -tangram_shape solved[][7] = { - { - {{-1.664000, -1.552000, 0}, 135, 0, 0}, - {{-1.696000, 0.944000, 0}, 315, 0, 0}, - {{0.064000, -2.128000, 0}, 135, 0, 0}, - {{-0.960000, -1.056000, 0}, 90, 0, 0}, - {{1.104000, 0.960000, 0}, 270, 0, 0}, - {{-1.376000, -0.800000, 0}, 180, 0, 0}, - {{1.152000, 0.736000, 0}, 360, 0, 0}, - }, - { - {{-0.096000, 1.552000, 0}, 135, 180, 0}, - {{-0.064000, 2.336000, 0}, 315, 0, 0}, - {{-0.080000, -0.224000, 0}, 135, 180, 0}, - {{-2.096000, 1.584000, 0}, 90, 180, 0}, - {{1.920000, 1.584000, 0}, 270, 0, 0}, - {{0.416000, -0.192000, 0}, 180, 0, 0}, - {{-0.096000, -1.296000, 0}, 335, 0, 0}, - }, - { - {{-0.144000, -0.720000, 0}, 225, 0, 0}, - {{0.608000, 0.032000, 0}, 135, 0, 0}, - {{-1.584000, 0.720000, 0}, 0, 0, 0}, - {{-0.112000, -0.720000, 0}, 315, 0, 0}, - {{-0.096000, -0.704000, 0}, 45, 0, 0}, - {{0.592000, 0.016000, 0}, 225, 0, 0}, - {{-0.880000, -0.032000, 0}, 315, 0, 0}, - }, - { - {{1.472000, 2.176000, 0}, 225, 0, 0}, - {{1.248000, 3.488000, 0}, 270, 0, 0}, - {{-0.752000, -1.680000, 0}, 270, 0, 0}, - {{0.704000, -1.552000, 0}, 135, 0, 0}, - {{1.280000, -0.080000, 0}, 180, 0, 0}, - {{-0.016000, -0.896000, 0}, 225, 0, 0}, - {{-0.000000, -0.944000, 0}, 315, 0, 0}, - }, - { - {{0.320000, 1.360000, 0}, 90, 0, 0}, - {{0.704000, 3.072000, 0}, 270, 0, 0}, - {{-1.200000, -3.392000, 0}, 135, 0, 0}, - {{0.688000, -1.184000, 0}, 135, 0, 0}, - {{-0.768000, 0.192000, 0}, 315, 0, 0}, - {{-1.168000, -2.304000, 0}, 180, 0, 0}, - {{1.312000, 1.296000, 0}, 270, 0, 0}, - }, - { - {{-2.064000, 0.848000, 0}, 65, 0, 0}, - {{0.096000, 1.424000, 0}, 99, 180, 0}, - {{2.016000, -2.448000, 0}, 270, 180, 0}, - {{-2.016000, 0.368000, 0}, 315, 0, 0}, - {{-0.560000, -1.040000, 0}, 135, 0, 0}, - {{1.312000, -1.696000, 0}, 225, 0, 0}, - {{0.864000, 0.336000, 0}, 180, 180, 0}, - }, - { - {{0.560000, -0.208000, 0}, 135, 0, 0}, - {{0.336000, -1.552000, 0}, 90, 180, 0}, - {{-2.336000, 1.248000, 0}, 90, 180, 0}, - {{1.296000, -1.504000, 0}, 180, 0, 0}, - {{-0.896000, 1.200000, 0}, 135, 180, 0}, - {{0.304000, -2.544000, 0}, 180, 0, 0}, - {{1.248000, 0.544000, 0}, 225, 0, 0}, - }, - { - {{-0.480000, -2.832000, 0}, 45, 0, 0}, - {{-0.544000, -2.832000, 0}, 225, 180, 0}, - {{-0.064000, -0.880000, 0}, 225, 180, 0}, - {{-2.528000, 2.656000, 0}, 0, 0, 0}, - {{-2.512000, 0.640000, 0}, 45, 180, 0}, - {{0.192000, -2.096000, 0}, 225, 0, 0}, - {{-0.064000, -0.832000, 0}, 180, 0, 0}, - }, - { - {{0.880000, -1.456000, 0}, 45, 0, 0}, - {{0.832000, 0.592000, 0}, 180, 180, 0}, - {{-2.016000, 1.648000, 0}, 135, 180, 0}, - {{0.448000, 2.064000, 0}, 315, 0, 0}, - {{-0.992000, 0.688000, 0}, 315, 180, 0}, - {{1.856000, -0.400000, 0}, 180, 0, 0}, - {{-0.128000, -1.424000, 0}, 90, 0, 0}, - }, - { - {{2.208000, 2.000000, 0}, 180, 0, 0}, - {{-0.640000, 3.072000, 0}, 180, 180, 0}, - {{1.360000, -3.312000, 0}, 180, 0, 0}, - {{-0.592000, 2.256000, 0}, 360, 0, 0}, - {{-0.960000, -0.160000, 0}, 45, 180, 0}, - {{0.288000, -2.896000, 0}, 135, 0, 0}, - {{0.496000, -0.128000, 0}, 135, 0, 0}, - }, - { - {{-0.480000, 0.864000, 0}, 58, 180, 0}, - {{0.624000, -0.752000, 0}, 90, 180, 0}, - {{0.576000, -0.560000, 0}, 180, 180, 0}, - {{-0.192000, -1.264000, 0}, 225, 0, 0}, - {{-0.176000, -1.280000, 0}, 135, 180, 0}, - {{-0.816000, -0.528000, 0}, 123, 0, 0}, - {{-0.416000, -0.528000, 0}, 90, 0, 0}, - }, - { - {{0.688000, -0.144000, 0}, 45, 180, 0}, - {{-0.080000, 0.592000, 0}, 225, 0, 0}, - {{-0.048000, 0.592000, 0}, 315, 180, 0}, - {{-1.488000, -0.848000, 0}, 45, 0, 0}, - {{1.376000, -0.864000, 0}, 225, 180, 0}, - {{0.688000, -0.128000, 0}, 135, 0, 0}, - {{-1.504000, -0.832000, 0}, 135, 0, 0}, - }, - { - {{0.624000, -1.776000, 0}, 225, 180, 0}, - {{-0.144000, 0.432000, 0}, 225, 0, 0}, - {{-0.800000, -0.272000, 0}, 45, 180, 0}, - {{-2.320000, -0.304000, 0}, 45, 0, 0}, - {{2.048000, -0.320000, 0}, 225, 180, 0}, - {{-0.112000, 0.480000, 0}, 135, 0, 0}, - {{-0.832000, -0.320000, 0}, 135, 180, 0}, - }, - { - {{-1.744000, -0.400000, 0}, 45, 180, 0}, - {{0.416000, 1.776000, 0}, 315, 0, 0}, - {{-1.008000, 0.272000, 0}, 90, 180, 0}, - {{0.800000, 1.488000, 0}, 135, 0, 0}, - {{0.832000, 1.440000, 0}, 45, 180, 0}, - {{-1.744000, -1.872000, 0}, 135, 0, 0}, - {{-1.008000, 0.320000, 0}, 45, 180, 0}, - }, - { - {{-0.720000, 3.440000, 0}, 180, 180, 0}, - {{0.912000, -1.072000, 0}, 225, 0, 0}, - {{0.736000, 3.440000, 0}, 180, 180, 0}, - {{0.720000, 1.984000, 0}, 225, 0, 0}, - {{-0.672000, 0.544000, 0}, 45, 180, 0}, - {{-0.192000, -3.840000, 0}, 135, 0, 0}, - {{-0.528000, -2.480000, 0}, 135, 0, 0}, - }, - { - {{1.184000, 1.904000, 0}, 90, 180, 0}, - {{-2.256000, 0.960000, 0}, 90, 0, 0}, - {{-0.208000, -0.528000, 0}, 45, 180, 0}, - {{-0.256000, -0.512000, 0}, 135, 0, 0}, - {{0.144000, -0.944000, 0}, 135, 180, 0}, - {{-0.608000, -3.648000, 0}, 105, 0, 0}, - {{0.832000, -0.912000, 0}, 135, 0, 0}, - }, - { - {{-1.056000, -2.272000, 0}, 90, 0, 0}, - {{0.960000, -1.264000, 0}, 180, 0, 0}, - {{-0.000000, -2.288000, 0}, 135, 0, 0}, - {{-1.088000, -2.256000, 0}, 180, 0, 0}, - {{0.992000, 0.736000, 0}, 0, 0, 0}, - {{0.960000, -0.256000, 0}, 180, 0, 0}, - {{-0.064000, 0.752000, 0}, 180, 180, 0}, - }, - { - {{-1.360000, -0.224000, 0}, 0, 0, 0}, - {{-0.336000, -0.176000, 0}, 90, 0, 0}, - {{0.688000, -0.192000, 0}, 45, 0, 0}, - {{-1.424000, -1.168000, 0}, 180, 0, 0}, - {{1.744000, 0.816000, 0}, 0, 0, 0}, - {{-0.384000, -0.176000, 0}, 180, 0, 0}, - {{1.648000, -1.216000, 0}, 270, 180, 0}, - }, - { - {{2.112000, 1.504000, 0}, 0, 0, 0}, - {{-1.040000, 1.472000, 0}, 180, 180, 0}, - {{0.032000, -1.600000, 0}, 135, 0, 0}, - {{1.056000, 1.504000, 0}, 270, 0, 0}, - {{-0.992000, -0.528000, 0}, 0, 180, 0}, - {{2.080000, 0.512000, 0}, 180, 0, 0}, - {{-1.104000, 0.480000, 0}, 270, 180, 0}, - }, - { - {{0.608000, 1.184000, 0}, 135, 0, 0}, - {{-2.928000, -1.584000, 0}, 135, 0, 0}, - {{0.688000, 0.560000, 0}, 90, 180, 0}, - {{0.640000, -0.832000, 0}, 180, 0, 0}, - {{-0.752000, -2.304000, 0}, 315, 180, 0}, - {{-2.192000, -0.912000, 0}, 315, 0, 0}, - {{2.704000, 1.616000, 0}, 270, 0, 0}, - }, - { - {{0.880000, 0.960000, 0}, 45, 0, 0}, - {{0.832000, -0.960000, 0}, 0, 0, 0}, - {{1.536000, 1.712000, 0}, 225, 180, 0}, - {{-0.992000, 2.096000, 0}, 315, 0, 0}, - {{0.480000, 2.704000, 0}, 180, 180, 0}, - {{0.816000, 0.912000, 0}, 315, 0, 0}, - {{0.784000, -1.952000, 0}, 315, 180, 0}, - }, - { - {{0.176000, 3.584000, 0}, 270, 0, 0}, - {{2.016000, -1.424000, 0}, 90, 0, 0}, - {{2.496000, 0.608000, 0}, 180, 180, 0}, - {{-0.304000, 0.496000, 0}, 270, 0, 0}, - {{-0.256000, -0.144000, 0}, 0, 180, 0}, - {{-1.600000, -0.368000, 0}, 303, 0, 0}, - {{0.768000, 0.912000, 0}, 180, 0, 0}, - }, - { - {{-2.096000, 1.696000, 0}, 315, 0, 0}, - {{-1.632000, -1.440000, 0}, 45, 0, 0}, - {{-1.232000, -0.064000, 0}, 315, 180, 0}, - {{0.304000, 2.416000, 0}, 315, 0, 0}, - {{1.776000, -0.496000, 0}, 315, 180, 0}, - {{1.168000, -0.240000, 0}, 332, 0, 0}, - {{-0.880000, -1.216000, 0}, 135, 0, 0}, - }, - { - {{-0.432000, -0.496000, 0}, 259, 0, 0}, - {{0.176000, -1.488000, 0}, 105, 0, 0}, - {{1.184000, -1.168000, 0}, 300, 180, 0}, - {{1.824000, 0.096000, 0}, 195, 0, 0}, - {{-2.400000, -0.048000, 0}, 11, 180, 0}, - {{-0.240000, -1.200000, 0}, 315, 0, 0}, - {{-0.688000, -1.488000, 0}, 281, 180, 0}, - }, - { - {{0.096000, 2.000000, 0}, 315, 0, 0}, - {{0.432000, 0.160000, 0}, 360, 0, 0}, - {{0.208000, -1.504000, 0}, 220, 180, 0}, - {{-1.104000, -0.336000, 0}, 50, 0, 0}, - {{-1.136000, -0.288000, 0}, 310, 180, 0}, - {{0.416000, 1.232000, 0}, 360, 0, 0}, - {{0.048000, 2.016000, 0}, 225, 180, 0}, - }, - { - {{-2.128000, 2.112000, 0}, 45, 0, 0}, - {{0.128000, 1.856000, 0}, 360, 0, 0}, - {{2.128000, -0.720000, 0}, 180, 180, 0}, - {{-1.376000, 2.816000, 0}, 360, 0, 0}, - {{-1.360000, 0.768000, 0}, 45, 180, 0}, - {{0.128000, 0.336000, 0}, 360, 0, 0}, - {{0.432000, -2.944000, 0}, 149, 0, 0}, - }, - { - {{1.952000, -0.800000, 0}, 225, 0, 0}, - {{2.064000, -0.816000, 0}, 45, 0, 0}, - {{0.928000, 0.688000, 0}, 225, 0, 0}, - {{-1.568000, 3.152000, 0}, 0, 0, 0}, - {{-1.520000, 1.104000, 0}, 45, 0, 0}, - {{2.720000, -0.064000, 0}, 225, 0, 0}, - {{1.968000, 0.672000, 0}, 270, 0, 0}, - }, - { - {{2.480000, -0.912000, 0}, 225, 0, 0}, - {{2.592000, -0.928000, 0}, 45, 0, 0}, - {{0.352000, 1.280000, 0}, 315, 0, 0}, - {{-0.688000, 0.336000, 0}, 135, 0, 0}, - {{1.808000, -0.112000, 0}, 135, 0, 0}, - {{3.248000, -0.176000, 0}, 225, 0, 0}, - {{-1.472000, 1.024000, 0}, 225, 0, 0}, - }, - { - {{-0.400000, -1.232000, 0}, 270, 0, 0}, - {{0.400000, -0.640000, 0}, 270, 0, 0}, - {{1.904000, -3.232000, 0}, 180, 0, 0}, - {{1.872000, -1.776000, 0}, 225, 0, 0}, - {{1.552000, 0.656000, 0}, 270, 0, 0}, - {{1.056000, 1.760000, 0}, 270, 0, 0}, - {{-0.320000, -1.024000, 0}, 135, 180, 0}, - }, - { - {{0.896000, -0.480000, 0}, 0, 0, 0}, - {{0.128000, -0.720000, 0}, 45, 0, 0}, - {{0.960000, -1.728000, 0}, 270, 0, 0}, - {{-1.040000, -1.648000, 0}, 90, 0, 0}, - {{-0.848000, 2.304000, 0}, 0, 0, 0}, - {{-0.096000, 0.944000, 0}, 315, 0, 0}, - {{-1.568000, -1.728000, 0}, 90, 180, 0}, - }, - { - {{0.416000, 3.648000, 0}, 270, 0, 0}, - {{-0.000000, -1.072000, 0}, 331, 0, 0}, - {{1.360000, 0.528000, 0}, 180, 0, 0}, - {{0.880000, 0.464000, 0}, 270, 0, 0}, - {{0.576000, -3.184000, 0}, 151, 0, 0}, - {{0.864000, 2.576000, 0}, 270, 0, 0}, - {{-1.120000, 0.528000, 0}, 90, 0, 0}, - }, - { - {{-1.056000, -3.456000, 0}, 90, 0, 0}, - {{0.736000, 2.000000, 0}, 135, 0, 0}, - {{-1.488000, 1.760000, 0}, 45, 0, 0}, - {{-0.432000, 0.016000, 0}, 0, 180, 0}, - {{-0.432000, -0.064000, 0}, 0, 0, 0}, - {{0.560000, -2.576000, 0}, 225, 0, 0}, - {{0.032000, 2.656000, 0}, 0, 0, 0}, - }, - { - {{-2.800000, -2.304000, 0}, 101, 0, 0}, - {{1.888000, 2.032000, 0}, 135, 180, 0}, - {{-1.856000, 2.016000, 0}, 315, 0, 0}, - {{0.352000, -0.144000, 0}, 315, 180, 0}, - {{-2.848000, 0.976000, 0}, 0, 0, 0}, - {{-1.424000, -1.104000, 0}, 236, 0, 0}, - {{-1.792000, 2.016000, 0}, 45, 0, 0}, - }, - { - {{0.864000, 0.880000, 0}, 180, 0, 0}, - {{0.912000, -2.288000, 0}, 180, 180, 0}, - {{-1.136000, -0.144000, 0}, 45, 0, 0}, - {{-1.136000, -3.312000, 0}, 360, 180, 0}, - {{-1.168000, 1.920000, 0}, 0, 0, 0}, - {{-1.184000, -1.248000, 0}, 180, 0, 0}, - {{-1.136000, -0.224000, 0}, 0, 0, 0}, - }, - { - {{0.592000, 0.704000, 0}, 90, 0, 0}, - {{0.576000, -2.496000, 0}, 90, 180, 0}, - {{2.624000, -1.440000, 0}, 225, 0, 0}, - {{2.640000, -3.504000, 0}, 270, 180, 0}, - {{2.656000, 1.712000, 0}, 270, 0, 0}, - {{0.544000, 0.704000, 0}, 180, 0, 0}, - {{1.648000, 0.640000, 0}, 0, 0, 0}, - }, - { - {{0.448000, -3.344000, 0}, 90, 0, 0}, - {{-1.616000, 1.984000, 0}, 90, 180, 0}, - {{-1.584000, 0.928000, 0}, 45, 0, 0}, - {{-1.600000, -2.288000, 0}, 0, 180, 0}, - {{1.536000, -1.328000, 0}, 270, 0, 0}, - {{2.592000, -3.328000, 0}, 180, 0, 0}, - {{-1.600000, 0.832000, 0}, 0, 0, 0}, - }, - { - {{0.608000, 0.880000, 0}, 180, 0, 0}, - {{0.576000, -2.304000, 0}, 180, 180, 0}, - {{-1.456000, -0.176000, 0}, 45, 0, 0}, - {{-1.472000, -3.344000, 0}, 0, 180, 0}, - {{-1.472000, 1.888000, 0}, 0, 0, 0}, - {{0.640000, -1.168000, 0}, 180, 0, 0}, - {{-1.456000, -0.256000, 0}, 0, 0, 0}, - }, - { - {{-0.208000, -0.352000, 0}, 225, 0, 0}, - {{0.528000, 1.856000, 0}, 225, 180, 0}, - {{-0.176000, -3.904000, 0}, 135, 0, 0}, - {{-0.880000, 0.384000, 0}, 45, 180, 0}, - {{-0.192000, -0.384000, 0}, 315, 0, 0}, - {{0.304000, -2.864000, 0}, 180, 0, 0}, - {{-0.224000, 2.528000, 0}, 315, 0, 0}, - }, - { - {{-0.032000, 0.704000, 0}, 315, 0, 0}, - {{2.208000, -1.504000, 0}, 225, 180, 0}, - {{-0.720000, -0.064000, 0}, 0, 0, 0}, - {{-0.720000, -1.536000, 0}, 45, 180, 0}, - {{-0.016000, 1.744000, 0}, 315, 180, 0}, - {{0.464000, 0.736000, 0}, 180, 0, 0}, - {{1.456000, -0.816000, 0}, 315, 0, 0}, - }, - { - {{-0.944000, 1.040000, 0}, 360, 0, 0}, - {{1.120000, 0.000000, 0}, 180, 180, 0}, - {{0.080000, -0.048000, 0}, 315, 0, 0}, - {{0.080000, -1.104000, 0}, 135, 180, 0}, - {{0.080000, 1.120000, 0}, 315, 180, 0}, - {{1.120000, 0.048000, 0}, 180, 0, 0}, - {{0.064000, 0.992000, 0}, 180, 180, 0}, - }, - { - {{-0.688000, 0.784000, 0}, 135, 0, 0}, - {{0.800000, 0.784000, 0}, 135, 0, 0}, - {{0.512000, -2.512000, 0}, 315, 0, 0}, - {{1.488000, 0.000000, 0}, 225, 0, 0}, - {{-1.392000, 0.000000, 0}, 45, 0, 0}, - {{0.496000, -2.432000, 0}, 180, 0, 0}, - {{0.480000, -2.496000, 0}, 270, 0, 0}, - }, - { - {{-0.992000, -2.160000, 0}, 90, 0, 0}, - {{-1.040000, -1.152000, 0}, 270, 0, 0}, - {{0.064000, -2.144000, 0}, 135, 0, 0}, - {{0.080000, -1.088000, 0}, 90, 0, 0}, - {{0.032000, -1.072000, 0}, 180, 0, 0}, - {{0.544000, -3.216000, 0}, 180, 0, 0}, - {{2.160000, -1.136000, 0}, 270, 0, 0}, - }, - { - {{-2.896000, -0.128000, 0}, 45, 0, 0}, - {{-0.800000, 0.992000, 0}, 135, 0, 0}, - {{-1.152000, -0.416000, 0}, 225, 0, 0}, - {{-0.016000, 0.656000, 0}, 315, 0, 0}, - {{1.456000, -0.736000, 0}, 135, 0, 0}, - {{2.864000, 0.736000, 0}, 180, 0, 0}, - {{-0.048000, 1.664000, 0}, 180, 180, 0}, - }, - { - {{2.960000, -1.376000, 0}, 270, 0, 0}, - {{1.952000, -1.312000, 0}, 90, 0, 0}, - {{-0.096000, 0.720000, 0}, 315, 0, 0}, - {{-2.112000, -0.320000, 0}, 90, 180, 0}, - {{1.904000, -0.320000, 0}, 180, 180, 0}, - {{-0.096000, -1.776000, 0}, 135, 0, 0}, - {{-3.168000, -2.304000, 0}, 360, 180, 0}, - }, - { - {{-1.600000, -1.232000, 0}, 270, 0, 0}, - {{-1.600000, -0.128000, 0}, 180, 0, 0}, - {{2.272000, -0.128000, 0}, 225, 0, 0}, - {{-0.160000, -3.648000, 0}, 315, 180, 0}, - {{-0.176000, 2.336000, 0}, 135, 180, 0}, - {{-2.608000, -1.184000, 0}, 90, 0, 0}, - {{1.280000, -2.208000, 0}, 360, 180, 0} - } +#define SPEED 0.03 +enum { + BOTTOM = 0, + DEF_WAIT = 500, + INIT_DZ = 2, + NUM_SHAPES = 7 }; +typedef struct { + GLXContext *glx_context; + tangram_shape tsm1, tsm2, tm, tlg1, tlg2, sq, rh; + tangram_shape n_tsm1, n_tsm2, n_tm, n_tlg1, n_tlg2, n_sq, n_rh; + char *puzzle_name; + int csi; -/* Dream */ -color palette[] = { - {22, 26, 28}, - {122, 142, 139}, - {72, 82, 76}, - {94, 115, 108}, - {194, 202, 195}, - {165, 175, 171}, - {132, 117, 107}, - {49, 54, 48}, - {111, 84, 78}, - {155, 144, 137}, - {82, 99, 100}, - {87, 57, 52}, - {131, 132, 125}, - {110, 130, 125}, - {62, 70, 68}, - {156, 160, 153}, - {182, 190, 184}, - {112, 116, 111}, - {56, 37, 35}, - {226, 230, 226}, - {146, 158, 154}, - {111, 101, 91}, - {96, 99, 96}, - {158, 130, 115}, - {147, 117, 105}, - {90, 85, 83}, - {112, 124, 121}, - {140, 144, 136}, - {176, 162, 156}, - {69, 56, 52}, - {183, 177, 169}, - {34, 38, 33}, - {213, 219, 212}, - {96, 108, 107}, - {143, 132, 121}, - {159, 166, 156}, - {132, 124, 113}, - {141, 151, 149}, - {132, 100, 94}, - {75, 73, 68}, - {57, 62, 57}, - {78, 90, 83}, - {210, 205, 207}, - {155, 152, 143}, - {42, 47, 40}, - {94, 70, 64}, - {195, 193, 188}, - {124, 116, 106}, - {123, 124, 117}, - {173, 182, 172}, - {133, 138, 135}, - {183, 185, 178}, - {120, 130, 120}, - {96, 100, 110}, - {127, 88, 78}, - {166, 161, 154}, - {91, 92, 98}, - {132, 124, 136}, - {101, 122, 117}, - {112, 108, 99}, - {140, 144, 151}, - {98, 109, 116}, - {58, 58, 51}, - {84, 84, 82}, - {132, 132, 142}, - {112, 116, 127}, - {58, 48, 48}, - {66, 66, 58}, - {205, 210, 205}, - {70, 78, 80}, - {246, 246, 244}, - {167, 168, 159}, - {147, 152, 145}, - {166, 154, 148}, - {107, 73, 67}, - {175, 177, 168}, - {132, 117, 126}, - {86, 106, 101}, - {78, 78, 75}, - {123, 138, 135}, - {112, 92, 83}, - {143, 138, 127}, - {133, 109, 95}, - {38, 34, 44}, - {150, 134, 147}, - {147, 123, 115}, - {46, 48, 54}, - {195, 198, 195}, - {194, 186, 188}, - {122, 110, 100}, - {105, 116, 106}, - {42, 42, 42}, - {223, 221, 220}, - {68, 71, 65}, - {156, 160, 164}, - {114, 124, 132}, - {155, 152, 163}, - {103, 94, 89}, - {58, 63, 70}, - {132, 143, 137}, - {168, 143, 128}, - {190, 198, 190}, - {239, 237, 237}, - {103, 101, 94}, - {84, 90, 84}, - {211, 213, 210}, - {183, 185, 188}, - {94, 94, 108}, - {203, 204, 196}, - {123, 125, 135}, - {120, 132, 133}, - {111, 110, 125}, - {28, 32, 28}, - {53, 56, 62}, - {88, 63, 59}, - {104, 108, 103}, - {140, 124, 115}, - {147, 126, 137}, - {155, 144, 157}, - {87, 98, 92}, - {188, 192, 189}, - {162, 133, 115}, - {148, 144, 134}, - {175, 169, 162}, - {138, 131, 120}, - {118, 124, 118}, - {139, 125, 135}, - {148, 144, 154}, - {72, 47, 44}, - {100, 72, 66}, - {66, 42, 39}, - {105, 84, 73}, - {86, 78, 82}, - {234, 238, 236}, - {108, 78, 73}, - {130, 110, 121}, - {134, 150, 146}, - {254, 254, 252}, - {151, 138, 130}, - {125, 99, 88}, - {80, 56, 52}, - {98, 63, 60}, - {114, 138, 132}, - {61, 42, 37}, - {150, 166, 164}, - {127, 94, 87}, - {225, 226, 223}, - {64, 47, 44}, - {218, 226, 220}, - {242, 242, 242}, - {150, 138, 150}, - {166, 138, 122}, - {102, 78, 71}, - {124, 118, 131}, - {74, 65, 66}, - {49, 33, 28}, - {182, 170, 175}, - {139, 117, 107}, - {120, 84, 76}, - {232, 232, 231}, - {46, 50, 41}, - {102, 102, 115}, - {104, 108, 119}, - {140, 118, 123}, - {120, 92, 84}, - {139, 108, 97}, - {156, 125, 107}, - {218, 214, 215}, - {144, 133, 143}, - {168, 161, 172}, - {58, 58, 68}, - {167, 169, 173}, - {148, 152, 158}, - {175, 177, 180}, - {67, 73, 77}, - {134, 143, 148}, - {79, 50, 45}, - {74, 83, 86}, - {150, 134, 124}, - {90, 86, 95}, - {184, 176, 186}, - {38, 39, 45}, - {160, 168, 166}, - {78, 73, 78}, - {195, 193, 196}, - {177, 184, 181}, - {43, 41, 52}, - {32, 33, 39}, - {135, 138, 148}, - {203, 198, 201}, - {26, 26, 28}, - {98, 116, 113}, - {198, 202, 199}, - {170, 176, 172}, - {54, 57, 48}, - {162, 146, 140}, - {114, 131, 130}, - {162, 160, 150}, - {118, 116, 108}, - {150, 159, 156}, - {118, 99, 84}, - {74, 54, 51}, - {138, 102, 100}, - {62, 64, 55}, - {162, 154, 146}, - {190, 185, 179}, - {98, 94, 94}, - {106, 124, 121}, - {118, 110, 100}, - {118, 117, 131}, - {50, 50, 60}, - {162, 152, 164}, - {94, 63, 58}, - {62, 70, 77}, - {174, 162, 172}, - {78, 91, 92}, - {85, 85, 93}, - {54, 50, 61}, - {67, 66, 74}, - {166, 154, 167}, - {126, 109, 119}, - {104, 116, 118}, - {83, 92, 95}, - {203, 205, 204}, - {88, 100, 101}, - {176, 169, 179}, - {145, 138, 148}, - {116, 78, 68}, - {78, 78, 84}, - {126, 142, 137}, - {78, 83, 76}, - {94, 58, 52}, - {62, 38, 36}, - {98, 86, 76}, - {38, 42, 34}, - {218, 220, 217}, - {82, 70, 60}, - {202, 194, 188}, - {178, 183, 172}, - {126, 131, 120}, - {138, 132, 143}, - {250, 250, 250}, - {114, 74, 68}, - {90, 108, 106}, - {50, 38, 36}, - {162, 161, 168}, - {118, 124, 132}, - {62, 65, 71}, - {190, 185, 193}, - {98, 94, 109}, - {126, 132, 138}, - {34, 34, 28}, - {162, 146, 163}, - {78, 85, 88}, - {158, 134, 124}, - {190, 178, 188} -}; + int ncolors; + XColor *colors; + int ccolor; -static tangram_shape tsm1 = { {-0.144, -0.72, 0}, 225, false, 0 }; -static tangram_shape tsm2 = { {0.608, 0.032, 0}, 135, false, 0 }; -static tangram_shape tm = { {-1.584, 0.72, 0}, 0, false, 0 }; -static tangram_shape tlg1 = { {-0.112, -0.72, 0}, 315, false, 0 }; -static tangram_shape tlg2 = { {-0.096, -0.704, 0}, 45, false, 0 }; -static tangram_shape sq = { {0.592, 0.016, 0}, 225, false, 0 }; -static tangram_shape rh = { {-0.88, -0.032, 0}, 315, false, 0 }; + XFontStruct *xfont1; + XFontStruct *xfont2; + XFontStruct *xfont3; + GLuint font1_dlist, font2_dlist, font3_dlist; + GLuint name_list; +} tangram_configuration; +static tangram_configuration *tps = NULL; #define DEF_VIEWING_TIME "5" +#define DEF_ROTATE_CAMERA "True" +#define DEF_X_CAMERA_ROTATE "0.2" +#define DEF_Y_CAMERA_ROTATE "0.5" +#define DEF_Z_CAMERA_ROTATE "0" + + static GLuint viewing_time = 0; +static Bool do_rotate = True; +static GLfloat x_camera_rotate = 0.3; +static GLfloat y_camera_rotate = 0.75; +static GLfloat z_camera_rotate = 0; +static int wire; static XrmOptionDescRec opts[] = { - {"-viewing_time", ".viewing_time", XrmoptionSepArg, 0} + {"-viewing_time", ".viewing_time", XrmoptionSepArg, 0}, + {"-rotate", ".rotate", XrmoptionNoArg, "True"}, + {"+rotate", ".rotate", XrmoptionNoArg, "False"}, + {"-x_camera_rotate", ".x_camera_rotate", XrmoptionSepArg, 0}, + {"-y_camera_rotate", ".y_camera_rotate", XrmoptionSepArg, 0}, + {"-z_camera_rotate", ".z_camera_rotate", XrmoptionSepArg, 0} }; static argtype vars[] = { - {&viewing_time, "viewing_time", "Viewing Time", DEF_VIEWING_TIME, t_Int} + {&viewing_time, "viewing_time", "Viewing Time", DEF_VIEWING_TIME, t_Int}, + {&do_rotate, "rotate", "Rotate", DEF_ROTATE_CAMERA, t_Bool}, + {&x_camera_rotate, "x_camera_rotate", "X Camera Rotate", DEF_X_CAMERA_ROTATE, t_Float}, + {&y_camera_rotate, "y_camera_rotate", "Y Camera Rotate", DEF_Y_CAMERA_ROTATE, t_Float}, + {&z_camera_rotate, "z_camera_rotate", "Z Camera Rotate", DEF_Z_CAMERA_ROTATE, t_Float} }; ModeSpecOpt sws_opts = { countof(opts), opts, countof(vars), vars, NULL }; -static int wire; -static int csi = -1; /* Current Shape index */ +static puzzle solved[] = { + {"Teapot", { + {{-1.664000, -1.552000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.696000, 0.944000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.064000, -2.128000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.960000, -1.056000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.104000, 0.960000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.376000, -0.800000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.152000, 0.736000, 0}, 360, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Candle", { + {{-0.016000, 2.176001, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{0.016000, 2.960001, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.000000, 0.400000, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-2.015998, 2.208001, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{2.000001, 2.208001, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.496000, 0.432000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.016000, -0.672000, 0}, 335, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Square", { + {{-0.048000, -0.016000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.704000, 0.736000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.488000, 1.424001, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.016000, -0.016000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.000000, 0.000000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.688000, 0.720000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.784000, 0.672000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Crane", { + {{1.248001, 1.759999, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.024000, 3.071999, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.975999, -2.096001, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.480000, -1.968001, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.056000, -0.496000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.239999, -1.312001, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.223999, -1.360001, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Crane", { + {{0.320000, 1.360000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.704000, 3.072000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.200000, -3.392000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.688000, -1.184000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.768000, 0.192000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.168000, -2.304000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.312000, 1.296000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Duck", { + {{-1.391999, 1.424000, 0}, 65, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.768000, 2.000000, 0}, 99, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{2.688001, -1.872000, 0}, 270, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.343999, 0.944000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.112000, -0.464000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.984001, -1.120000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.536001, 0.912000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Pelican", { + {{1.088000, 0.064001, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.864000, -1.279999, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.807999, 1.520000, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{1.824001, -1.231998, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.368000, 1.472000, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.832000, -2.271998, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.776001, 0.816000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Cat", { + {{0.416000, -2.432000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.352000, -2.432000, 0}, 225, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.832000, -0.480000, 0}, 225, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.632000, 3.056000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.616000, 1.040000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{1.088000, -1.696000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.832000, -0.432000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Coi", { + {{1.264000, -1.232000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.216000, 0.816000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.631999, 1.872000, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.832000, 2.287999, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.608000, 0.912000, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{2.240001, -0.176000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.256000, -1.200000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Man Skipping", { + {{1.727998, 2.303998, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.120000, 3.376001, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.879998, -3.008001, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.072000, 2.559999, 0}, 360, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.440000, 0.144000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.192001, -2.592001, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.015999, 0.176000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Old Man", { + {{-0.400000, 1.744000, 0}, 58, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.704000, 0.128000, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{0.656000, 0.320000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.112000, -0.384000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.096000, -0.399999, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.736000, 0.352000, 0}, 123, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.336000, 0.352000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Spear Head", { + {{0.688000, -0.144000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.080000, 0.592000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.048000, 0.592000, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.488000, -0.848000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.376000, -0.864000, 0}, 225, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{0.688000, -0.128000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.504000, -0.832000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Diamond", { + {{0.624000, -1.776000, 0}, 225, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.144000, 0.432000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.800000, -0.272000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-2.320000, -0.304000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{2.048000, -0.320000, 0}, 225, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.112000, 0.480000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.832000, -0.320000, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Arrow", { + {{-2.048001, -1.232000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{0.112000, 0.943999, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.312001, -0.560000, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{0.496000, 0.656000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.528000, 0.608000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-2.048001, -2.704000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.312001, -0.512000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Lady", { + {{-0.720000, 3.440000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.912000, -1.072000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.736000, 3.440000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.720000, 1.984000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.672000, 0.544000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.192000, -3.840000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.528000, -2.480000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Running Man", { + {{1.136000, 2.720000, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-2.304001, 1.776000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.256000, 0.288000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.304000, 0.304000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.096000, -0.128000, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.656000, -2.832000, 0}, 105, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.784000, -0.096000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Parallelogram", { + {{-1.104000, -1.455999, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.912000, -0.447999, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.048000, -1.471999, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.136000, -1.439999, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.944000, 1.552000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.912000, 0.560000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.112000, 1.568000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"N", { + {{-1.615999, 0.064000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.592000, 0.112000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.432000, 0.096000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.679999, -0.880000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.488001, 1.103999, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.640000, 0.112000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.392001, -0.928000, 0}, 270, 180, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Farm House", { + {{2.112000, 1.504000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.040000, 1.472000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{0.032000, -1.600000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.056000, 1.504000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.992000, -0.528000, 0}, 0, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{2.080000, 0.512000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.104000, 0.480000, 0}, 270, 180, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Vulture", { + {{0.912000, 1.728000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-2.623998, -1.040000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.992000, 1.104000, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{0.944000, -0.288000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.448000, -1.760000, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.887998, -0.368000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{3.008002, 2.160000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Swan", { + {{0.720000, 0.352000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.672000, -1.568000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.376000, 1.104000, 0}, 225, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.151999, 1.488000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.320000, 2.096000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.656000, 0.304000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.624000, -2.559999, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"High Karate", { + {{-0.144000, 2.576000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.696001, -2.432000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{2.176001, -0.400000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.624000, -0.512000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.576000, -1.152000, 0}, 0, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.919999, -1.376000, 0}, 303, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.448000, -0.096001, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Lazy", { + {{-2.416000, 1.120000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.952000, -2.016000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.552000, -0.640000, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.016000, 1.840000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.456000, -1.072000, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.848000, -0.816000, 0}, 332, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.200000, -1.792000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Bat", { + {{-0.304000, -0.352000, 0}, 259, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.304000, -1.344000, 0}, 105, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.312000, -1.024000, 0}, 300, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{1.952000, 0.240000, 0}, 195, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-2.272000, 0.096000, 0}, 11, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.112000, -1.056000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.560000, -1.344000, 0}, 281, 180, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Sail Boat", { + {{0.544000, 2.000000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.880000, 0.160000, 0}, 360, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.656000, -1.503999, 0}, 220, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.656000, -0.336000, 0}, 50, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.688000, -0.288000, 0}, 310, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.864000, 1.232000, 0}, 360, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.496000, 2.016001, 0}, 225, 180, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Glenda", { + {{-2.016000, 2.080000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.240001, 1.824000, 0}, 360, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{2.239999, -0.752000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.264000, 2.784000, 0}, 360, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.248000, 0.736000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{0.240001, 0.304000, 0}, 360, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.544000, -2.976001, 0}, 149, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Cat", { + {{1.376000, -1.536001, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.488000, -1.552001, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.352000, -0.048000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-2.144000, 2.415999, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-2.096000, 0.368000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{2.144000, -0.800000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.392000, -0.064000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Lying Cat", { + {{2.480000, -0.912000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{2.592000, -0.928000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.352000, 1.280000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.688000, 0.336000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.808000, -0.112000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{3.248000, -0.176000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.472000, 1.024000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Witch", { + {{-0.943999, -0.304000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.144000, 0.288000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.360000, -2.304000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.328000, -0.848000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.008000, 1.584000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.512000, 2.688000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.863999, -0.096000, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Laugh", { + {{0.703999, -0.160000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.064000, -0.400000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.767999, -1.408000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.232000, -1.328000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.040000, 2.624000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.288000, 1.264000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.760001, -1.408000, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Standing Man", { + {{0.272000, 3.392000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.144000, -1.328000, 0}, 331, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.216001, 0.272000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.736000, 0.208000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.432000, -3.440000, 0}, 151, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.720000, 2.320000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.263998, 0.272000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Walking Man", { + {{-1.056000, -3.456000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.736000, 2.000000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.488000, 1.760000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.432000, 0.016000, 0}, 0, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.432000, -0.064000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.560000, -2.576000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.032000, 2.656000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Repose", { + {{-2.800000, -2.304000, 0}, 101, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.888000, 2.032000, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.856000, 2.016000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.352000, -0.144000, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-2.848000, 0.976000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.424000, -1.104000, 0}, 236, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.792000, 2.016000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Shape", { + {{1.263999, 1.600001, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.311999, -1.568000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.736000, 0.576000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.736000, -2.591999, 0}, 360, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.768000, 2.640001, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.784000, -0.528000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.736000, 0.496000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Shape", { + {{-0.816000, 1.392000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.832000, -1.807999, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{1.216000, -0.752000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.232000, -2.815999, 0}, 270, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{1.248000, 2.400000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.864000, 1.392000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.240000, 1.328000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Lightning", { + {{0.176000, -2.448000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.888000, 2.880000, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.856000, 1.824000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.872000, -1.392000, 0}, 0, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{1.264000, -0.432000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{2.320001, -2.432000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.872000, 1.728000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"E", { + {{0.928000, 1.664000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.896000, -1.519998, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.136000, 0.608000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.152000, -2.559998, 0}, 0, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.152000, 2.672002, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.960000, -0.384000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.136000, 0.528000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Dagger", { + {{-0.096000, 0.448000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.640000, 2.656000, 0}, 225, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.064000, -3.104000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.767999, 1.184000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.080000, 0.416000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.416000, -2.064000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.112000, 3.328001, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Knight", { + {{-0.368000, 0.400000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.871998, -1.808000, 0}, 225, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.056000, -0.368000, 0}, 0, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.056000, -1.840000, 0}, 45, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.352000, 1.440000, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{0.128000, 0.432000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.119999, -1.120000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Candy", { + {{-1.039999, 1.136000, 0}, 360, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.024000, 0.096000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.016000, 0.048000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.016000, -1.008000, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.016000, 1.216000, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{1.024000, 0.144000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.032000, 1.088000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"King", { + {{-0.688000, 1.904000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.800000, 1.904000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.512000, -1.392000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{1.488000, 1.120000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.392000, 1.120000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.496000, -1.312000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.480000, -1.376000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Top", { + {{-1.055999, -0.800000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.103999, 0.208000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{0.000000, -0.784000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.016000, 0.272000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.032000, 0.288000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{0.480000, -1.855999, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{2.096001, 0.224000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Dog", { + {{-2.896000, -0.128000, 0}, 45, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.800000, 0.992000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-1.152000, -0.416000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.016000, 0.656000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.456000, -0.736000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{2.864000, 0.736000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.048000, 1.664000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, True}, + }, + }, + {"Moose Head", { + {{2.944000, -0.288000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.936000, -0.224000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.112000, 1.808000, 0}, 315, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{-2.128000, 0.768000, 0}, 90, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{1.888000, 0.768000, 0}, 180, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.112000, -0.688000, 0}, 135, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-3.184000, -1.216000, 0}, 360, 180, 0, INIT_DZ, -SPEED, 0, False}, + }, + }, + {"Negative Square", { + {{-1.520000, -0.624000, 0}, 270, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-1.520000, 0.480000, 0}, 180, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{2.352000, 0.480000, 0}, 225, 0, 0, INIT_DZ, -SPEED, 0, True}, + {{-0.080000, -3.040000, 0}, 315, 180, 0, INIT_DZ, -SPEED, 0, False}, + {{-0.096000, 2.944000, 0}, 135, 180, 0, INIT_DZ, -SPEED, 0, True}, + {{-2.528000, -0.576000, 0}, 90, 0, 0, INIT_DZ, -SPEED, 0, False}, + {{1.360000, -1.600000, 0}, 360, 180, INIT_DZ, -SPEED, 0, True}, + }} +}; + -static void get_solved_puzzle(tangram_shape * tsm1, tangram_shape * tsm2, +static void get_solved_puzzle(ModeInfo * mi, + tangram_shape * tsm1, tangram_shape * tsm2, tangram_shape * tm, tangram_shape * tlg1, tangram_shape * tlg2, tangram_shape * sq, tangram_shape * rh) { + tangram_configuration *tp = &tps[MI_SCREEN(mi)]; int sz = sizeof(solved) / sizeof(solved[0]); int r; - GLuint t_dl; + /* we don't want to see the same puzzle twice */ do { r = random() % sz; - } while (r == csi); - csi = r; - - t_dl = tsm1->dl; - *tsm1 = solved[r][small_triangle1]; - tsm1->dl = t_dl; - - t_dl = tsm2->dl; - *tsm2 = solved[r][small_triangle2]; - tsm2->dl = t_dl; - - t_dl = tm->dl; - *tm = solved[r][medium_triangle]; - tm->dl = t_dl; - - t_dl = tlg1->dl; - *tlg1 = solved[r][large_triangle1]; - tlg1->dl = t_dl; - - t_dl = tlg2->dl; - *tlg2 = solved[r][large_triangle2]; - tlg2->dl = t_dl; - - t_dl = sq->dl; - *sq = solved[r][square]; - sq->dl = t_dl; - - t_dl = rh->dl; - *rh = solved[r][rhomboid]; - rh->dl = t_dl; - -} - -static bool colors_match(color c1, color c2) -{ - bool res = false; - if (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b) - res = true; - return res; -} - -static color rand_palette(void) -{ - int l = sizeof(palette) / sizeof(color); - int r = random() % l; - return palette[r]; + } while (r == tp->csi); + tp->csi = r; + + *tsm1 = solved[r].ts[small_triangle1]; + *tsm2 = solved[r].ts[small_triangle2]; + *tm = solved[r].ts[medium_triangle]; + *tlg1 = solved[r].ts[large_triangle1]; + *tlg2 = solved[r].ts[large_triangle2]; + *sq = solved[r].ts[square]; + *rh = solved[r].ts[rhomboid]; + + tp->puzzle_name = solved[r].name; } static int approach_number(int goal, int current, int step) @@ -860,64 +652,37 @@ static int approach_number(int goal, int current, int step) } /* gt - floating point greater than comparison */ -static bool gt(GLfloat x1, GLfloat x2, GLfloat per) +static Bool gt(GLfloat x1, GLfloat x2, GLfloat per) { if ((x1 > x2) && (fabs(x1 - x2) > per)) - return true; + return True; else - return false; + return False; } /* lt - floating point less than comparison */ -static bool lt(GLfloat x1, GLfloat x2, GLfloat per) +static Bool lt(GLfloat x1, GLfloat x2, GLfloat per) { if ((x1 < x2) && (fabs(x1 - x2) > per)) - return true; + return True; else - return false; + return False; } -/* eq - Check the equality of a pair of floating point numbers to a certain perscision */ -static bool eq(GLfloat x1, GLfloat x2, GLfloat per) -{ - if (fabs(x1 - x2) < per) - return true; - else - return false; -} - - static GLfloat approach_float(GLfloat goal, GLfloat current, - bool * changed, GLfloat per) + Bool * changed, GLfloat per) { - *changed = false; + *changed = False; if (gt(goal, current, per)) { current += per; - *changed = true; + *changed = True; } else if (lt(goal, current, per)) { current -= per; - *changed = true; + *changed = True; } return current; } -static bool coords_match(coord c1, coord c2, GLfloat per) -{ - if (eq(c1.x, c2.x, per) && eq(c1.y, c2.y, per) && eq(c1.z, c2.z, per)) - return true; - else - return false; -} - -static bool xy_coords_match(coord c1, coord c2, GLfloat per) -{ - if (eq(c1.x, c2.x, per) && eq(c1.y, c2.y, per)) - return true; - else - return false; -} - - #if 0 static void print_shape(char *s, tangram_shape sh) { @@ -928,117 +693,38 @@ static void print_shape(char *s, tangram_shape sh) fprintf(stderr, "\n"); } #endif + -/* approach_shape - bring use on step closer to the new shape */ -static tangram_shape approach_shape(tangram_shape old, tangram_shape new, - bool * b, char *name) +void reset_shape(tangram_shape * ts) { - - GLuint dl; - bool changed; - *b = false; - - old.fr = approach_number(new.fr, old.fr, 2); - if (old.fr != new.fr) { - return old; - } - - old.r = approach_number(new.r, old.r, 2); - if (old.r != new.r) { - return old; - } - - old.crd.x = approach_float(new.crd.x, old.crd.x, &changed, 0.1); - if (!changed) - old.crd.x = approach_float(new.crd.x, old.crd.x, &changed, 0.01); - if (!changed) - old.crd.x = approach_float(new.crd.x, old.crd.x, &changed, 0.001); - if (!changed) - old.crd.x = approach_float(new.crd.x, old.crd.x, &changed, 0.0001); - - old.crd.y = approach_float(new.crd.y, old.crd.y, &changed, 0.1); - if (!changed) - old.crd.y = approach_float(new.crd.y, old.crd.y, &changed, 0.01); - if (!changed) - old.crd.y = approach_float(new.crd.y, old.crd.y, &changed, 0.001); - if (!changed) - old.crd.y = approach_float(new.crd.y, old.crd.y, &changed, 0.0001); - - if (xy_coords_match(new.crd, old.crd, 0.0001)) { - old.crd.z = approach_float(new.crd.z, old.crd.z, &changed, 0.1); - if (!changed) - old.crd.z = - approach_float(new.crd.z, old.crd.z, &changed, 0.01); - if (!changed) - old.crd.z = - approach_float(new.crd.z, old.crd.z, &changed, 0.001); - if (!changed) - old.crd.z = - approach_float(new.crd.z, old.crd.z, &changed, 0.0001); - } - - - if (coords_match(new.crd, old.crd, 0.0001)) { - dl = old.dl; -#if 0 - fprintf(stderr, "%s\n", name); - print_shape("old", old); - print_shape("new", new); -#endif - old = new; /* pick up the rest of the settings; */ - old.dl = dl; - *b = true; - } - - return old; + GLfloat r = random() % 10; + GLfloat f = r / 10; + ts->crd.z = BOTTOM; + ts->dz = INIT_DZ + f; + ts->ddz = -SPEED; } -static color get_color(void) +void bounce(tangram_shape * ts) { - static color new_color = { 100, 100, 100 }; - static color old_color = { 100, 100, 100 }; - - if (colors_match(old_color, new_color)) { - old_color = new_color; - new_color = rand_palette(); + ts->crd.z *= -1; /* ignore this */ + ts->dz += ts->ddz; + ts->crd.z += ts->dz * SPEED; + if (ts->crd.z < BOTTOM) { + reset_shape(ts); } - if ((random() % 10) == 0) { /* slow down the cycle */ - old_color.r = approach_number(new_color.r, old_color.r, 1); - old_color.g = approach_number(new_color.g, old_color.g, 1); - old_color.b = approach_number(new_color.b, old_color.b, 1); - } - - return old_color; -} - -static void explode(tangram_shape * tsm1, tangram_shape * tsm2, - tangram_shape * tm, tangram_shape * tlg1, - tangram_shape * tlg2, tangram_shape * sq, - tangram_shape * rh) -{ - tsm1->crd.z = 1; - tsm1->r = 0; - tsm2->crd.z = -1; - tsm2->r = 0; - tm->crd.z = 2; - tm->r = 0; - tlg1->crd.z = -2; - tlg1->r = 0; - tlg2->crd.z = 3; - tlg2->r = 0; - sq->crd.z = -3; - sq->r = 0; - rh->crd.z = 4; - rh->r = 0; + ts->crd.z *= -1; /* ignore this */ } - static void draw_tangram_shape(tangram_shape ts) { glPushMatrix(); - glTranslatef(ts.crd.x, ts.crd.y, ts.crd.z); + if (!do_rotate) { + ts.up = True; + } + + glTranslatef(ts.crd.x, ts.crd.y, ts.up ? ts.crd.z : -ts.crd.z); glRotated(90, 1, 0, 0); glRotated(ts.fr, 1, 0, 0); glRotated(ts.r, 0, 1, 0); @@ -1046,25 +732,29 @@ static void draw_tangram_shape(tangram_shape ts) glPopMatrix(); } -static void draw_shapes(void) +static void load_fonts(ModeInfo * mi) { + tangram_configuration *tp = &tps[MI_SCREEN(mi)]; + load_font(mi->dpy, "titleFont", &tp->xfont1, &tp->font1_dlist); + load_font(mi->dpy, "titleFont2", &tp->xfont2, &tp->font2_dlist); + load_font(mi->dpy, "titleFont3", &tp->xfont3, &tp->font3_dlist); +} - if (!wire) { - color c = get_color(); - glColor3ub(c.r, c.g, c.b); - } - - draw_tangram_shape(tsm1); - - draw_tangram_shape(tsm2); - draw_tangram_shape(tm); - draw_tangram_shape(tlg1); - draw_tangram_shape(tlg2); - draw_tangram_shape(sq); - draw_tangram_shape(rh); +static void draw_shapes(ModeInfo * mi) +{ + tangram_configuration *tp = &tps[MI_SCREEN(mi)]; + draw_tangram_shape(tp->tsm1); + draw_tangram_shape(tp->tsm2); + draw_tangram_shape(tp->tm); + draw_tangram_shape(tp->tlg1); + draw_tangram_shape(tp->tlg2); + draw_tangram_shape(tp->sq); + draw_tangram_shape(tp->rh); + glCallList(tp->name_list); } + static void set_perspective(void) { glPushMatrix(); @@ -1084,11 +774,10 @@ void reshape_tangram(ModeInfo * mi, int w, int h) glLoadIdentity(); } -static void rotate_camera(void) +static void set_camera(void) { static GLfloat theta[3] = { 1, 1, 1 }; - static bool going_down[3] = { false, false, false }; - + static Bool going_down[3] = { False, False, False }; glPushMatrix(); glMatrixMode(GL_PROJECTION); @@ -1098,9 +787,11 @@ static void rotate_camera(void) gluLookAt(0, 5, -5, 0, 0, 0, 0, -1, 0); - glRotatef(theta[0], 1, 0, 0); - glRotatef(theta[1], 0, 1, 0); - glRotatef(theta[2], 0, 0, 1); + if (do_rotate) { + glRotatef(theta[0], 1, 0, 0); + glRotatef(theta[1], 0, 1, 0); + glRotatef(theta[2], 0, 0, 1); + } glMatrixMode(GL_MODELVIEW); glPopMatrix(); @@ -1108,138 +799,253 @@ static void rotate_camera(void) if (going_down[0] && theta[0] < 0) { - going_down[0] = false; + going_down[0] = False; } else if ((!going_down[0]) && theta[0] > 90) { - going_down[0] = true; + going_down[0] = True; } if (theta[1] > 360.0) theta[1] -= 360.0; + if (theta[2] > 360.0) + theta[2] -= 360.0; + if (going_down[0]) - theta[0] -= 0.5; + theta[0] -= x_camera_rotate; else - theta[0] += 0.5; - theta[1] += 1; + theta[0] += x_camera_rotate; + + theta[1] += y_camera_rotate; + theta[2] += z_camera_rotate; } -static void init_shapes(void) +static void init_shapes(ModeInfo * mi) { - get_solved_puzzle(&tsm1, &tsm2, &tm, &tlg1, &tlg2, &sq, &rh); - tsm1.dl = get_sm_tri_dl(wire); - tsm2.dl = get_sm_tri_dl(wire); - tm.dl = get_md_tri_dl(wire); - tlg1.dl = get_lg_tri_dl(wire); - tlg2.dl = get_lg_tri_dl(wire); - sq.dl = get_square_dl(wire); - rh.dl = get_rhomboid_dl(wire); + int wire = MI_IS_WIREFRAME(mi); + tangram_configuration *tp = &tps[MI_SCREEN(mi)]; + get_solved_puzzle(mi, &tp->tsm1, &tp->tsm2, &tp->tm, &tp->tlg1, + &tp->tlg2, &tp->sq, &tp->rh); + get_solved_puzzle(mi, &tp->n_tsm1, &tp->n_tsm2, &tp->n_tm, &tp->n_tlg1, + &tp->n_tlg2, &tp->n_sq, &tp->n_rh); + tp->tsm1.dl = get_sm_tri_dl(wire); + tp->tsm2.dl = get_sm_tri_dl(wire); + tp->tm.dl = get_md_tri_dl(wire); + tp->tlg1.dl = get_lg_tri_dl(wire); + tp->tlg2.dl = get_lg_tri_dl(wire); + tp->sq.dl = get_square_dl(wire); + tp->rh.dl = get_rhomboid_dl(wire); } -void init_tangram(ModeInfo * mi) +static void gl_init(ModeInfo * mi) { - GLfloat pos[4] = { 1, 1, -5, 1.00 }; - GLfloat pos2[4] = { 1, 1, 5, 1.00 }; - GLfloat lKa[4] = { 0, 0, 0, 1 }; - GLfloat lKd[4] = { 1, 1, 1, 1 }; - GLfloat lKs[4] = { 1, 1, 1, 1 }; - wire = MI_IS_WIREFRAME(mi); - init_GL(mi); + int wire = MI_IS_WIREFRAME(mi); - if (!wire) { - glLightfv(GL_LIGHT0, GL_POSITION, pos); - glLightfv(GL_LIGHT0, GL_AMBIENT, lKa); - glLightfv(GL_LIGHT0, GL_DIFFUSE, lKd); - glLightfv(GL_LIGHT0, GL_SPECULAR, lKs); + GLfloat y = do_rotate ? -10 : 3; + GLfloat x = do_rotate ? 5 : 10; + GLfloat pos[4] = { 0, 0, -5, 1.00 }; + GLfloat pos2[4] = { 0, 0, 5, 1.00 }; + GLfloat dif2[4] = { 1, 1, 1, 1 }; - glLightfv(GL_LIGHT1, GL_POSITION, pos2); - glLightfv(GL_LIGHT1, GL_AMBIENT, lKa); - glLightfv(GL_LIGHT1, GL_DIFFUSE, lKd); - glLightfv(GL_LIGHT1, GL_SPECULAR, lKs); + pos[0] = -x; + pos[1] = y; - glEnable(GL_DEPTH_TEST); + pos2[1] = x; + pos2[1] = y; + if (!wire) { glEnable(GL_LIGHTING); + glLightfv(GL_LIGHT0, GL_POSITION, pos); glEnable(GL_LIGHT0); - glEnable(GL_LIGHT1); + if (do_rotate) { + glLightfv(GL_LIGHT1, GL_POSITION, pos2); + glLightfv(GL_LIGHT1, GL_DIFFUSE, dif2); + glEnable(GL_LIGHT1); + } + glEnable(GL_DEPTH_TEST); + } + +} + +void init_tangram(ModeInfo * mi) +{ + tangram_configuration *tp; + + if (!tps) { + tps = (tangram_configuration *) + calloc(MI_NUM_SCREENS(mi), sizeof(tangram_configuration)); + if (!tps) { + fprintf(stderr, "%s: out of memory\n", progname); + exit(1); + } - glEnable(GL_COLOR_MATERIAL); + tp = &tps[MI_SCREEN(mi)]; } - init_shapes(); + tp = &tps[MI_SCREEN(mi)]; + + if ((tp->glx_context = init_GL(mi)) != NULL) { + gl_init(mi); + } + + wire = MI_IS_WIREFRAME(mi); + + load_fonts(mi); + init_shapes(mi); } -static tangram_shape explode_step(tangram_shape old, tangram_shape new, - bool * b, GLfloat per) +static Bool all_solved(tangram_shape * ls[]) { - old.crd.z = approach_float(new.crd.z, old.crd.z, b, per); - if (eq(new.crd.z, old.crd.z, per)) - *b = true; - else - *b = false; + int i; + Bool b = True; + for (i = 0; i < NUM_SHAPES; i++) { + b = (b && ls[i]->solved); + } + return b; +} + +static void solve(tangram_shape * new_s, tangram_shape * old_s) +{ + Bool moved_x, moved_y, moved_r, moved_fr, z_ok; - return old; + old_s->fr = approach_number(new_s->fr, old_s->fr, 2); + moved_fr = (old_s->fr != new_s->fr); + + old_s->r = approach_number(new_s->r, old_s->r, 2); + moved_r = (old_s->r != new_s->r); + + old_s->crd.x = + approach_float(new_s->crd.x, old_s->crd.x, &moved_x, 0.1); + if (!moved_x) + old_s->crd.x = new_s->crd.x; + + old_s->crd.y = + approach_float(new_s->crd.y, old_s->crd.y, &moved_y, 0.1); + if (!moved_y) + old_s->crd.y = new_s->crd.y; + + z_ok = (-old_s->crd.z <= BOTTOM); + + old_s->solved = (moved_x == False && moved_y == False && + moved_r == False && moved_fr == False && + z_ok == True); } +static void set_not_solved(tangram_shape * ls[]) +{ + int i; + for (i = 0; i < NUM_SHAPES; i++) + ls[i]->solved = False; +} + + void draw_tangram(ModeInfo * mi) { Display *dpy = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); - static tangram_state state = state_solved; - static tangram_shape n_tsm1, n_tsm2, n_tm, n_tlg1, n_tlg2, n_sq, n_rh; - static bool b_tsm1, b_tsm2, b_tm, b_tlg1, b_tlg2, b_sq, b_rh; - static time_t s_tm = 0; - static time_t c_tm; - rotate_camera(); - - switch (state) { - case state_exploding: - tsm1 = explode_step(tsm1, n_tsm1, &b_tsm1, 0.1); - tsm2 = explode_step(tsm2, n_tsm2, &b_tsm2, 0.1); - tm = explode_step(tm, n_tm, &b_tm, 0.1); - tlg1 = explode_step(tlg1, n_tlg1, &b_tlg1, 0.1); - tlg2 = explode_step(tlg2, n_tlg2, &b_tlg2, 0.1); - sq = explode_step(sq, n_sq, &b_sq, 0.1); - rh = explode_step(rh, n_rh, &b_rh, 0.1); - if (b_tsm1 && b_tsm2 && b_tm && b_tlg1 && b_tlg2 && b_sq && b_rh) { - get_solved_puzzle(&n_tsm1, &n_tsm2, &n_tm, &n_tlg1, &n_tlg2, - &n_sq, &n_rh); - state = state_solving; + tangram_configuration *tp = &tps[MI_SCREEN(mi)]; + + tangram_shape *ls[NUM_SHAPES]; + tangram_shape *nls[NUM_SHAPES]; + + + int i; + int MAX_DISPLAY; + static char *pn = ""; + static int display_counter = 0; + + static GLfloat color[4] = { 0.0, 0.0, 0.0, 1.0 }; + static GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 }; + MAX_DISPLAY = viewing_time * 100; + + ls[small_triangle1] = &tp->tsm1; + ls[small_triangle2] = &tp->tsm2; + ls[medium_triangle] = &tp->tm; + ls[large_triangle1] = &tp->tlg1; + ls[large_triangle2] = &tp->tlg2; + ls[square] = &tp->sq; + ls[rhomboid] = &tp->rh; + + nls[small_triangle1] = &tp->n_tsm1; + nls[small_triangle2] = &tp->n_tsm2; + nls[medium_triangle] = &tp->n_tm; + nls[large_triangle1] = &tp->n_tlg1; + nls[large_triangle2] = &tp->n_tlg2; + nls[square] = &tp->n_sq; + nls[rhomboid] = &tp->n_rh; + + set_camera(); + + if (display_counter <= 0) { + for (i = 0; i < NUM_SHAPES; i++) { + if (ls[i]->solved) { + if (all_solved(ls)) { + display_counter = MAX_DISPLAY; + pn = tp->puzzle_name; + get_solved_puzzle(mi, nls[small_triangle1], + nls[small_triangle2], + nls[medium_triangle], + nls[large_triangle1], + nls[large_triangle2], nls[square], + nls[rhomboid]); + tp->ncolors = 128; + tp->colors = + (XColor *) calloc(tp->ncolors, sizeof(XColor)); + + make_random_colormap(0, 0, 0, + tp->colors, &tp->ncolors, + True, False, 0, False); + + + color[0] = tp->colors[0].red / 65536.0; + color[1] = tp->colors[1].green / 65536.0; + color[2] = tp->colors[2].blue / 65536.0; + + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, + color); + + set_not_solved(ls); + break; + } + } else { + pn = ""; + bounce(ls[i]); + solve(nls[i], ls[i]); + } } - - break; - case state_solving: - - tsm1 = approach_shape(tsm1, n_tsm1, &b_tsm1, "small 1"); - tsm2 = approach_shape(tsm2, n_tsm2, &b_tsm2, "small 2"); - tm = approach_shape(tm, n_tm, &b_tm, "medium"); - tlg1 = approach_shape(tlg1, n_tlg1, &b_tlg1, "large 1"); - tlg2 = approach_shape(tlg2, n_tlg2, &b_tlg2, "large 2"); - sq = approach_shape(sq, n_sq, &b_sq, "square"); - rh = approach_shape(rh, n_rh, &b_rh, "rhomboid"); - if (b_tsm1 && b_tsm2 && b_tm && b_tlg1 && b_tlg2 && b_sq && b_rh) { - state = state_solved; - s_tm = time(0); - } - break; - case state_solved: - c_tm = time(0); - if (floor(difftime(c_tm, s_tm)) >= viewing_time) { - /*if ((random() % 100) == 0) { */ - explode(&n_tsm1, &n_tsm2, &n_tm, &n_tlg1, &n_tlg2, &n_sq, - &n_rh); - - state = state_exploding; - - } - break; + } else { + display_counter--; } - glPushMatrix(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); + glLoadIdentity(); + glNewList(tp->name_list, GL_COMPILE); + { + XFontStruct *f; + GLuint fl; + if (MI_WIDTH(mi) >= 500 && MI_HEIGHT(mi) >= 375) + f = tp->xfont1, fl = tp->font1_dlist; + else if (MI_WIDTH(mi) >= 350 && MI_HEIGHT(mi) >= 260) + f = tp->xfont2, fl = tp->font2_dlist; + else + f = tp->xfont3, fl = tp->font3_dlist; + + glColor3f(0.8, 0.8, 0); + print_gl_string(mi->dpy, f, fl, + mi->xgwa.width, mi->xgwa.height, + 10, mi->xgwa.height - 10, pn); + } + glEndList(); + + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); + glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 128); + + draw_shapes(mi); - draw_shapes(); glFlush(); glPopMatrix(); glXSwapBuffers(dpy, window);