/* $XConsortium: refl_attrs.c,v 1.0 93/11/22 12:31:51 rws Exp $ */ /******************************************************************************/ /* */ /* (c) Copyright Hewlett-Packard Company, 1993, Fort Collins, Colorado */ /* */ /* All Rights Reserved */ /* */ /* Permission to use, copy, modify, and distribute this software and its */ /* documentation for any purpose and without fee is hereby granted, */ /* provided that the above copyright notices appear in all copies and that */ /* both the copyright notices and this permission notice appear in */ /* supporting documentation, and that the name of Hewlett-Packard not be */ /* used in advertising or publicity pertaining to distribution of the */ /* software without specific, written prior permission. */ /* */ /* HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS */ /* SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Hewlett-Packard */ /* shall not be liable for errors contained herein or direct, indirect, */ /* special, incidental or consequential damages in connection with the */ /* furnishing, performance or use of this software. */ /* */ /******************************************************************************/ /* * refl_attrs * * Ken Tidwell Oct. 9, 1992 */ /* * Basic set of include files for tests */ #include #include #include #include #include #include #include #define NORMAL_NORMALS 1 #define INVERTED_NORMALS -1 #define AMBIENT_BASE 1 #define NUM_AMBIENTS 4 #define AMBIENT_GRAY AMBIENT_BASE #define AMBIENT_RED AMBIENT_BASE + 1 #define AMBIENT_GREEN AMBIENT_BASE + 2 #define AMBIENT_BLUE AMBIENT_BASE + 3 #define DIRECT_BASE 10 #define NUM_DIRECTS 6 #define DIRECT_GRAY DIRECT_BASE #define DIRECT_RED DIRECT_BASE + 1 #define DIRECT_GREEN DIRECT_BASE + 2 #define DIRECT_BLUE DIRECT_BASE + 3 #define DIRECT_SPEC DIRECT_BASE + 4 #define DIRECT_MODEL DIRECT_BASE + 5 #define POINT_BASE 20 #define NUM_POINTS 5 #define POINT_1_GRAY POINT_BASE #define POINT_2_RED POINT_BASE + 1 #define POINT_3_GREEN POINT_BASE + 2 #define POINT_4_BLUE POINT_BASE + 3 #define POINT_5_MAGENTA POINT_BASE + 4 #define SPOT_BASE 30 #define NUM_SPOTS 18 #define SPOT_1_1_RED SPOT_BASE #define SPOT_1_2_GREEN SPOT_BASE + 1 #define SPOT_2_1_BLUE SPOT_BASE + 2 #define SPOT_2_2_MAGENTA SPOT_BASE + 3 #define SPOT_1_3_RED SPOT_BASE + 4 #define SPOT_1_4_GREEN SPOT_BASE + 5 #define SPOT_2_3_BLUE SPOT_BASE + 6 #define SPOT_2_4_MAGENTA SPOT_BASE + 7 #define SPOT_3_1_RED SPOT_BASE + 8 #define SPOT_3_2_GREEN SPOT_BASE + 9 #define SPOT_4_1_BLUE SPOT_BASE + 10 #define SPOT_4_2_MAGENTA SPOT_BASE + 11 #define SPOT_3_3_RED SPOT_BASE + 12 #define SPOT_3_4_GREEN SPOT_BASE + 13 #define SPOT_4_3_BLUE SPOT_BASE + 14 #define SPOT_4_4_MAGENTA SPOT_BASE + 15 #define SPOT_BEHIND SPOT_BASE + 16 #define SPOT_SPECULAR_1 SPOT_BASE + 17 /* * Various entries into the interior LUT */ #define FF_AMBIENT_ONLY 2 #define FF_DIFFUSE_ONLY 3 #define BF_AMBIENT_ONLY 4 #define BF_DIFFUSE_ONLY 5 #define FF_AMBIENT_ASF 6 #define BF_AMBIENT_ASF 7 #define OPAQUE 8 #define SEMI_OPAQUE 9 #define TRANSPARENT 10 PEXCoord ff_pgon[4] = {{-20.0, -20.0, 0.0}, {20.0, -20.0, 0.0}, {20.0, 20.0, 0.0}, {-20.0, 20.0, 0.0}}; PEXCoord bf_pgon[4] = { {-20.0, 20.0, 0.0}, {20.0, 20.0, 0.0}, {20.0, -20.0, 0.0}, {-20.0, -20.0, 0.0}}; PEXCoord ff_pgon_1[4] = {{-20.0, -20.0, 0.0}, {0.0, -20.0, 0.0}, {0.0, 0.0, 0.0}, {-20.0, 0.0, 0.0}}; PEXCoord ff_pgon_2[4] = {{-20.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 20.0, 0.0}, {-20.0, 20.0, 0.0}}; PEXCoord ff_pgon_3[4] = {{0.0, -20.0, 0.0}, {20.0, -20.0, 0.0}, {20.0, 0.0, 0.0}, {0.0, 0.0, 0.0}}; PEXCoord ff_pgon_4[4] = {{0.0, 0.0, 0.0}, {20.0, 0.0, 0.0}, {20.0, 20.0, 0.0}, {0.0, 20.0, 0.0}}; #define NUM_LONG_FACETS 60 #define NUM_LAT_FACETS 30 #define NUM_LONG_POINTS (NUM_LONG_FACETS +1) #define NUM_LAT_POINTS (NUM_LAT_FACETS +1) #define RADIUS 20.0 /* * Normalize */ normalize (vector) PEXVector *vector; { float r; r = vector->x * vector->x + vector->y * vector->y + vector->z * vector->z; if (r > 0) { r = 1.0 / sqrt (r); vector->x *= r; vector->y *= r; vector->z *= r; } } /* * build_sphere */ build_sphere (display, renderer, location, req_type, normal_type, facet_data_flag) Display *display; XID renderer; PEXVector *location; PEXOCRequestType req_type; int normal_type; unsigned int facet_data_flag; { PEXColor color; PEXVertexNormal verts[NUM_LONG_POINTS * NUM_LAT_POINTS]; PEXArrayOfVertex sphere; PEXMatrix transform; PEXArrayOfFacetData dummy; PEXVector tmp_normal, facet_normals[NUM_LONG_FACETS * NUM_LAT_FACETS]; unsigned int vertex_data_flag; double theta = 0, phi = 0; int i, j, index, index1, index2, index3, index4; for (i = 0; i