![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 /* 00002 Copyright 2005-2010 Intel Corporation. All Rights Reserved. 00003 00004 This file is part of Threading Building Blocks. 00005 00006 Threading Building Blocks is free software; you can redistribute it 00007 and/or modify it under the terms of the GNU General Public License 00008 version 2 as published by the Free Software Foundation. 00009 00010 Threading Building Blocks is distributed in the hope that it will be 00011 useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00012 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with Threading Building Blocks; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 As a special exception, you may use this file as part of a free software 00020 library without restriction. Specifically, if other files instantiate 00021 templates or use macros or inline functions from this file, or you compile 00022 this file and link it with other files to produce an executable, this 00023 file does not by itself cause the resulting executable to be covered by 00024 the GNU General Public License. This exception does not however 00025 invalidate any other reasons why the executable file might be covered by 00026 the GNU General Public License. 00027 */ 00028 00029 /* 00030 The original source for this example is 00031 Copyright (c) 1994-2008 John E. Stone 00032 All rights reserved. 00033 00034 Redistribution and use in source and binary forms, with or without 00035 modification, are permitted provided that the following conditions 00036 are met: 00037 1. Redistributions of source code must retain the above copyright 00038 notice, this list of conditions and the following disclaimer. 00039 2. Redistributions in binary form must reproduce the above copyright 00040 notice, this list of conditions and the following disclaimer in the 00041 documentation and/or other materials provided with the distribution. 00042 3. The name of the author may not be used to endorse or promote products 00043 derived from this software without specific prior written permission. 00044 00045 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00046 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00047 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00048 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00049 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00050 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00051 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00052 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00053 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00054 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00055 SUCH DAMAGE. 00056 */ 00057 00058 #if __MINGW32__ 00059 #include <malloc.h> 00060 #elif _WIN32 00061 #include <malloc.h> 00062 #define alloca _alloca 00063 #elif __FreeBSD__ 00064 #include <stdlib.h> 00065 #else 00066 #include <alloca.h> 00067 #endif 00068 00069 /* 00070 * types.h - This file contains all of the type definitions for the raytracer 00071 * 00072 * $Id: types.h,v 1.2 2007-02-22 17:54:16 dpoulsen Exp $ 00073 */ 00074 00075 #define MAXOCTNODES 25 /* subdivide octants /w > # of children */ 00076 #define SPEPSILON 0.000001 /* amount to crawl down a ray */ 00077 #define EPSILON 0.000001 /* amount to crawl down a ray */ 00078 #define TWOPI 6.2831853 /* guess */ 00079 #define FHUGE 1e18 /* biggest fp number we can represent */ 00080 00081 /* Maximum internal table sizes */ 00082 /* Use prime numbers for best memory system performance */ 00083 #define INTTBSIZE 1024 /* maximum intersections we can hold */ 00084 #define MAXLIGHTS 39 /* maximum number of lights in a scene */ 00085 #define MAXIMGS 39 /* maxiumum number of distinct images */ 00086 #define RPCQSIZE 113 /* number of RPC messages to queue */ 00087 00088 /* Parameter values for rt_boundmode() */ 00089 #define RT_BOUNDING_DISABLED 0 /* spatial subdivision/bounding disabled */ 00090 #define RT_BOUNDING_ENABLED 1 /* spatial subdivision/bounding enabled */ 00091 00092 /* Parameter values for rt_displaymode() */ 00093 #define RT_DISPLAY_DISABLED 0 /* video output enabled */ 00094 #define RT_DISPLAY_ENABLED 1 /* video output disabled */ 00095 00096 /* Ray flags */ 00097 #define RT_RAY_REGULAR 1 00098 #define RT_RAY_SHADOW 2 00099 #define RT_RAY_BOUNDED 4 00100 #define RT_RAY_FINISHED 8 00101 00102 #ifdef USESINGLEFLT 00103 typedef float flt; /* generic floating point number, using float */ 00104 #else 00105 typedef double flt; /* generic floating point number, using double */ 00106 #endif 00107 00108 typedef unsigned char byte; /* 1 byte */ 00109 typedef signed int word; /* 32 bit integer */ 00110 00111 typedef struct { 00112 flt x; /* X coordinate value */ 00113 flt y; /* Y coordinate value */ 00114 flt z; /* Z coordinate value */ 00115 } vector; 00116 00117 typedef struct { 00118 flt r; /* Red component */ 00119 flt g; /* Green component */ 00120 flt b; /* Blue component */ 00121 } color; 00122 00123 typedef struct { 00124 byte r; /* Red component */ 00125 byte g; /* Green component */ 00126 byte b; /* Blue component */ 00127 } bytecolor; 00128 00129 typedef struct { /* Raw 24 bit image structure, for tga, ppm etc */ 00130 int loaded; /* image memory residence flag */ 00131 int xres; /* image X axis size */ 00132 int yres; /* image Y axis size */ 00133 int bpp; /* image bits per pixel */ 00134 char name[96]; /* image filename (with path) */ 00135 unsigned char * data; /* pointer to raw byte image data */ 00136 } rawimage; 00137 00138 typedef struct { /* Scalar Volume Data */ 00139 int loaded; /* Volume data memory residence flag */ 00140 int xres; /* volume X axis size */ 00141 int yres; /* volume Y axis size */ 00142 int zres; /* volume Z axis size */ 00143 flt opacity; /* opacity per unit length */ 00144 char name[96]; /* Volume data filename */ 00145 unsigned char * data; /* pointer to raw byte volume data */ 00146 } scalarvol; 00147 00148 typedef struct { 00149 color (* texfunc)(void *, void *, void *); 00150 int shadowcast; /* does the object cast a shadow */ 00151 int islight; /* light flag... */ 00152 color col; /* base object color */ 00153 flt ambient; /* ambient lighting */ 00154 flt diffuse; /* diffuse reflection */ 00155 flt phong; /* phong specular highlights */ 00156 flt phongexp; /* phong exponent/shininess factor */ 00157 int phongtype; /* phong type: 0 == plastic, nonzero == metal */ 00158 flt specular; /* specular reflection */ 00159 flt opacity; /* how opaque the object is */ 00160 vector ctr; /* origin of texture */ 00161 vector rot; /* rotation of texture about origin */ 00162 vector scale; /* scale of texture in x,y,z */ 00163 vector uaxs; /* planar map U axis */ 00164 vector vaxs; /* planar map V axis */ 00165 void * img; /* pointer to image for image mapping */ 00166 void * obj; /* object ptr, hack for volume shaders for now */ 00167 } texture; 00168 00169 typedef struct { 00170 void (* intersect)(void *, void *); /* intersection func ptr */ 00171 void (* normal)(void *, void *, void *, void *); /* normal function ptr */ 00172 int (* bbox)(void *, vector *, vector *); /* return the object bbox */ 00173 void (* free)(void *); /* free the object */ 00174 } object_methods; 00175 00176 typedef struct { 00177 unsigned int id; /* Unique Object serial number */ 00178 void * nextobj; /* pointer to next object in list */ 00179 object_methods * methods; /* this object's methods */ 00180 texture * tex; /* object texture */ 00181 } object; 00182 00183 typedef struct { 00184 object * obj; /* to object we hit */ 00185 flt t; /* distance along the ray to the hit point */ 00186 } intersection; 00187 00188 typedef struct { 00189 int num; /* number of intersections */ 00190 intersection closest; /* closest intersection > 0.0 */ 00191 intersection list[INTTBSIZE]; /* list of all intersections */ 00192 } intersectstruct; 00193 00194 typedef struct { 00195 char outfilename[200]; /* name of the output image */ 00196 unsigned char * rawimage; /* pointer to a raw rgb image to be stored */ 00197 int hres; /* horizontal output image resolution */ 00198 int vres; /* vertical output image resolution */ 00199 flt aspectratio; /* aspect ratio of output image */ 00200 int raydepth; /* maximum recursion depth */ 00201 int antialiasing; /* number of antialiasing rays to fire */ 00202 int verbosemode; /* verbose reporting flag */ 00203 int boundmode; /* automatic spatial subdivision flag */ 00204 int boundthresh; /* threshold number of subobjects */ 00205 int displaymode; /* run-time X11 display flag */ 00206 vector camcent; /* center of the camera in world coords */ 00207 vector camviewvec; /* view direction of the camera (Z axis) */ 00208 vector camrightvec; /* right axis for the camera (X axis) */ 00209 vector camupvec; /* up axis for the camera (Y axis) */ 00210 flt camzoom; /* zoom factor for the camera */ 00211 color background; /* scene background color */ 00212 } scenedef; 00213 00214 typedef struct { 00215 intersectstruct * intstruct; /* ptr to thread's intersection data */ 00216 unsigned int depth; /* levels left to recurse.. (maxdepth - curdepth) */ 00217 unsigned int flags; /* ray flags, any special treatment needed etc */ 00218 unsigned int serial; /* serial number of the ray */ 00219 unsigned int * mbox; /* mailbox array for optimizing intersections */ 00220 vector o; /* origin of the ray X,Y,Z */ 00221 vector d; /* normalized direction of the ray */ 00222 flt maxdist; /* maximum distance to search for intersections */ 00223 vector s; /* startpoint of the ray (may differ from origin */ 00224 vector e; /* endpoint of the ray if bounded */ 00225 scenedef * scene; /* pointer to the scene, for global parms such as */ 00226 /* background colors etc */ 00227 } ray; 00228 00229 typedef struct { 00230 int type; /* RPC call type */ 00231 int from; /* Sending processor */ 00232 int len; /* length of parms in bytes */ 00233 void * parms; /* Parameters to RPC */ 00234 } rpcmsg;
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.