diff options
-rw-r--r-- | xd.c | 144 |
1 files changed, 143 insertions, 1 deletions
@@ -165,10 +165,11 @@ static void CraterDemo(void); static void TriangleDemo(void); static void TriangleDemo2(void); static void FollowDemo(void); +static void CatwalkDemo(void); /* ---------------------------------------- GLOBAL VARS */ -#define NO_DEMOS 16 +#define NO_DEMOS 17 static int demo=NO_DEMOS-1; @@ -256,6 +257,11 @@ static DemoInfo demotbl[NO_DEMOS]= FollowDemo, UsesPixmap }, + { + "Catwalk trench", + CatwalkDemo, + UsesPixmap + }, }; /* ---------------------------------------- X11 VARS @@ -3750,4 +3756,140 @@ static void FollowDemo(void) } +/* ---------------------------------------- CATWALK DEMO + */ + +#define TRENCH_X 300 +#define TRENCH_Y_TOP -200 +#define TRENCH_Y_BOT 100 +#define TRENCH_Z_MAX 10000 +#define TRENCH_Z_MIN 10 +#define TRENCH_CWH 50 + +static void CatwalkDemo(void) +{ + static const int speed=5; + + static unsigned long col[2]; + + static Point3D trench_point[8] = + { + {-TRENCH_X, TRENCH_Y_TOP, TRENCH_Z_MAX}, /* 0 */ + {TRENCH_X, TRENCH_Y_TOP, TRENCH_Z_MAX}, /* 1 */ + {-TRENCH_X, TRENCH_Y_BOT, TRENCH_Z_MAX}, /* 2 */ + {TRENCH_X, TRENCH_Y_BOT, TRENCH_Z_MAX}, /* 3 */ + {-TRENCH_X, TRENCH_Y_TOP, TRENCH_Z_MIN}, /* 4 */ + {TRENCH_X, TRENCH_Y_TOP, TRENCH_Z_MIN}, /* 5 */ + {-TRENCH_X, TRENCH_Y_BOT, TRENCH_Z_MIN}, /* 6 */ + {TRENCH_X, TRENCH_Y_BOT, TRENCH_Z_MIN} /* 7 */ + }; + + static Poly3D trench_poly[3] = + { + {{2, 3, 7, 6}, 4, 0}, + {{1, 5, 7, 3}, 4, 0}, + {{0, 2, 6, 4}, 4, 0}, + }; + + static Point3D cw_point[4] = + { + {-TRENCH_X, 0, 0}, + {TRENCH_X, 0, 0}, + {TRENCH_X, TRENCH_CWH, 0}, + {-TRENCH_X, TRENCH_CWH, 0} + + }; + + static Poly3D cw_poly[1] = + { + {{0, 1, 2, 3}, 4, 1} + }; + + static Point3D trench_work_3d[8]; + static XPoint trench_work_xp[8]; + + static Obj3D trench = + {8,3,{0,0,0},trench_point,trench_poly,trench_work_3d,trench_work_xp, + 0,0,0,MODE_EDGE,-1,True}; + + static const int no_catwalk = 5; + + static Obj3D *catwalk; + + static int move=0; + + static int init=FALSE; + + int f,r; + + if (!init) + { + col[0]=GetCol(255, 255, 255); + col[1]=GetCol(255, 255, 0); + + catwalk = Grab(sizeof *catwalk * no_catwalk); + + for(f = 0; f < no_catwalk; f++) + { + catwalk[f].no_points = 4; + catwalk[f].no_poly = 1; + + catwalk[f].origin.x = 0; + catwalk[f].origin.y = RND2(TRENCH_Y_BOT, TRENCH_Y_TOP - TRENCH_CWH); + catwalk[f].origin.z = TRENCH_Z_MAX - 1500 * f; + + catwalk[f].ps = cw_point; + catwalk[f].poly = cw_poly; + + catwalk[f].workp3 = Grab(sizeof *catwalk[f].workp3 * 4); + catwalk[f].workxp = Grab(sizeof *catwalk[f].workxp * 4); + + catwalk[f].x_rot = 0; + catwalk[f].y_rot = 0; + catwalk[f].z_rot = 0; + + catwalk[f].mode = MODE_EDGE; + + catwalk[f].col = -1; + + catwalk[f].cull = True; + } + + init=TRUE; + } + + Cls(); + + DrawObj(&trench,col); + + for(f = 0; f < no_catwalk; f++) + { + DrawObj(catwalk + f,col); + + catwalk[f].origin.z -= speed; + } + + while(catwalk[no_catwalk-1].origin.z < TRENCH_Z_MIN) + { + Obj3D t = catwalk[no_catwalk-1]; + + for(f = no_catwalk-2; f >= 0; f--) + { + catwalk[f+1] = catwalk[f]; + } + + catwalk[0] = t; + + catwalk[0].origin.z = TRENCH_Z_MAX; + catwalk[0].origin.y = RND2(TRENCH_Y_BOT, TRENCH_Y_TOP - TRENCH_CWH); + } +} + +#undef TRENCH_X +#undef TRENCH_Y_TOP +#undef TRENCH_Y_BOT +#undef TRENCH_Z_MAX +#undef TRENCH_Z_MIN + + /* END OF FILE */ |