File: fixplane.c

package info (click to toggle)
acm 5.0-23.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 8,364 kB
  • ctags: 4,793
  • sloc: ansic: 42,444; makefile: 706; cpp: 293; perl: 280; sh: 198
file content (39 lines) | stat: -rw-r--r-- 803 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "../V/lib/Vlib.h"

main () {

	int	i, k;
	VObject *obj;
	VPolygon **poly;
	VPoint	*q, tmp;
	VMatrix mtx;

        if ((obj = VReadObject(stdin)) == (VObject *) NULL) {
                fprintf (stderr, "Error reading the object definition.\n");
                exit (1);
        }

/*
 *  Prepare a transformation matrix that:
 *	(a) swaps X and Y coordinates.
 *	(b) negates Z coordinate.
 */

	VIdentMatrix (&mtx);
	mtx.m[0][0] = 0.0;
	mtx.m[0][1] = 1.0;
	mtx.m[1][0] = 1.0;
	mtx.m[1][1] = 0.0;
	mtx.m[2][2] = -1.0;

	poly = obj->polygon;

        for (i=0; i<obj->numPolys; ++i) {
            for ((k=0, q=poly[i]->vertex); k<poly[i]->numVtces; (++k, ++q)) {
                    VTransform(q, &mtx, &tmp);
                    *q = tmp;
            }
        }

	VWriteObject (stdout, obj);
}