1polygon3d(3)                    Allegro manual                    polygon3d(3)
2
3
4

NAME

6       polygon3d,  polygon3d_f - Draws a 3d polygon onto the specified bitmap.
7       Allegro game programming library.
8

SYNOPSIS

10       #include <allegro.h>
11
12
13       void polygon3d(BITMAP *bmp, int type,  BITMAP  *texture,  int  vc,  V3D
14       *vtx[]);
15
16       void  polygon3d_f(BITMAP *bmp, int type, BITMAP *texture, int vc, V3D_f
17       *vtx[]);
18

DESCRIPTION

20       Draw 3d polygons onto the specified bitmap, using the specified render‐
21       ing  mode.  Unlike the regular polygon() function, these routines don't
22       support concave or self-intersecting shapes, and they can't  draw  onto
23       mode-X  screen  bitmaps  (if  you want to write 3d code in mode-X, draw
24       onto a memory bitmap and then blit to the screen). The width and height
25       of  the texture bitmap must be powers of two, but can be different, eg.
26       a 64x16 texture is fine, but a 17x3 one is not. The vertex count param‐
27       eter  (vc)  should  be  followed by an array containing the appropriate
28       number of pointers to vertex structures:  polygon3d()  uses  the  fixed
29       point  V3D structure, while polygon3d_f() uses the floating point V3D_f
30       structure.  These are defined as:
31
32          typedef struct V3D
33          {
34             fixed x, y, z;       - position
35             fixed u, v;          - texture map coordinates
36             int c;               - color
37          } V3D;
38
39          typedef struct V3D_f
40          {
41             float x, y, z;       - position
42             float u, v;          - texture map coordinates
43             int c;               - color
44          } V3D_f;
45
46       How the vertex data is used depends on the rendering mode:
47
48       The `x' and `y' values specify the position of the vertex in 2d  screen
49       coordinates.
50
51       The  `z'  value is only required when doing perspective correct texture
52       mapping, and specifies the depth of the point in 3d world coordinates.
53
54       The `u' and `v' coordinates are only required when doing  texture  map‐
55       ping,  and specify a point on the texture plane to be mapped on to this
56       vertex.  The texture plane is an infinite plane with the texture bitmap
57       tiled  across it. Each vertex in the polygon has a corresponding vertex
58       on the texture plane, and the image of the  resulting  polygon  in  the
59       texture plane will be mapped on to the polygon on the screen.
60
61       We  refer  to  pixels  in  the texture plane as texels. Each texel is a
62       block, not just a point, and whole numbers for u and  v  refer  to  the
63       top-left corner of a texel. This has a few implications. If you want to
64       draw a rectangular polygon and map a texture sized 32x32 on to it,  you
65       would  use  the  texture coordinates (0,0), (0,32), (32,32) and (32,0),
66       assuming the vertices are specified in anticlockwise order. The texture
67       will  then  be  mapped  perfectly on to the polygon. However, note that
68       when we set u=32, the last column of texels seen on the screen  is  the
69       one  at  u=31, and the same goes for v. This is because the coordinates
70       refer to the top-left corner of the texels. In effect, texture  coordi‐
71       nates at the right and bottom on the texture plane are exclusive.
72
73       There  is another interesting point here. If you have two polygons side
74       by side sharing two vertices (like the two parts  of  folded  piece  of
75       cardboard),  and  you want to map a texture across them seamlessly, the
76       values of u and v on the vertices at the join will be the same for both
77       polygons.  For  example,  if they are both rectangular, one polygon may
78       use (0,0), (0,32), (32,32) and (32,0), and the other  may  use  (32,0),
79       (32,32), (64,32), (64,0). This would create a seamless join.
80
81       Of  course you can specify fractional numbers for u and v to indicate a
82       point part-way across a texel. In addition, since the texture plane  is
83       infinite,  you  can specify larger values than the size of the texture.
84       This can be used to tile the texture several times across the polygon.
85
86       The `c' value specifies the vertex color, and  is  interpreted  differ‐
87       ently  by various rendering modes. Read the beginning of chapter "Poly‐
88       gon rendering" for a list of rendering types  you  can  use  with  this
89       function.
90
91

SEE ALSO

93       triangle3d(3),  quad3d(3),  polygon(3), clip3d(3), cpu_capabilities(3),
94       excamera(3)
95
96
97
98Allegro                          version 4.4.3                    polygon3d(3)
Impressum