Shadowrun: Awakened 29 September 2011 - Build 871
api.h
Go to the documentation of this file.
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 /*****************************************************************************
00059  * api.h - The declarations and prototypes needed so that 3rd party driver   *
00060  *         code can run the raytracer.  Third party driver code should       * 
00061  *         only use the functions in this header file to interface with      *
00062  *         the rendering engine.                                             *
00063  *************************************************************************** */
00064 
00065 
00066 /* 
00067  *  $Id: api.h,v 1.2 2007-02-22 17:54:15 dpoulsen Exp $
00068  */
00069 
00070 
00071 /********************************************/
00072 /* Types defined for use with the API calls */
00073 /********************************************/
00074 
00075 #ifdef USESINGLEFLT
00076 typedef float apiflt;   /* generic floating point number */
00077 #else
00078 typedef double apiflt;  /* generic floating point number */
00079 #endif
00080 
00081 typedef void * SceneHandle;
00082 
00083 typedef struct {
00084   int texturefunc; /* which texture function to use */
00085   color col;    /* base object color */
00086   int shadowcast;  /* does the object cast a shadow */
00087   apiflt ambient;  /* ambient lighting */
00088   apiflt diffuse;  /* diffuse reflection */
00089   apiflt specular; /* specular reflection */
00090   apiflt opacity;  /* how opaque the object is */ 
00091   vector ctr;   /* origin of texture */
00092   vector rot;   /* rotation of texture around origin */
00093   vector scale; /* scale of texture in x,y,z */ 
00094   vector uaxs;  /* planar map u axis */
00095   vector vaxs;  /* planar map v axis */
00096   char imap[96];   /* name of image map */ 
00097 } apitexture;
00098 
00099 
00100 /*******************************************************************
00101  *  NOTE: The value passed in apitexture.texturefunc corresponds to 
00102  *        the meanings given in this table:
00103  *
00104  *   0 - No texture function is applied other than standard lighting.
00105  *   1 - 3D checkerboard texture.  Red & Blue checkers through 3d space.
00106  *   2 - Grit texture, roughens up the surface of the object a bit.
00107  *   3 - 3D marble texture.  Makes a 3D swirl pattern through the object.
00108  *   4 - 3D wood texture.  Makes a 3D wood pattern through the object.
00109  *   5 - 3D gradient noise function.
00110  *   6 - I've forgotten :-)
00111  *   7 - Cylindrical Image Map  **** IMAGE MAPS REQUIRE the filename 
00112  *   8 - Spherical Image Map         of the image be put in imap[]
00113  *   9 - Planar Image Map            part of the texture...
00114  *        planar requires uaxs, and vaxs..
00115  *
00116  *******************************************************************/
00117 
00118 /********************************************/
00119 /* Functions implemented to provide the API */
00120 /********************************************/
00121 
00122 vector rt_vector(apiflt x, apiflt y, apiflt z); /* helper to make vectors */
00123 color  rt_color(apiflt r, apiflt g, apiflt b);  /* helper to make colors */
00124 
00125 void rt_initialize(int *, char ***);/* reset raytracer, memory deallocation */
00126 void rt_finalize(void); /* close down for good.. */
00127 
00128 SceneHandle rt_newscene(void);        /* allocate new scene */
00129 void rt_deletescene(SceneHandle); /* delete a scene */
00130 void rt_renderscene(SceneHandle); /* raytrace the current scene */  
00131 void rt_outputfile(SceneHandle, const char * outname); 
00132 void rt_resolution(SceneHandle, int hres, int vres);
00133 void rt_verbose(SceneHandle, int v);
00134 void rt_rawimage(SceneHandle, unsigned char *rawimage);
00135 void rt_background(SceneHandle, color);
00136 
00137 /* Parameter values for rt_boundmode() */
00138 #define RT_BOUNDING_DISABLED 0
00139 #define RT_BOUNDING_ENABLED  1
00140 
00141 void rt_boundmode(SceneHandle, int);
00142 void rt_boundthresh(SceneHandle, int);
00143 
00144 /* Parameter values for rt_displaymode() */
00145 #define RT_DISPLAY_DISABLED  0
00146 #define RT_DISPLAY_ENABLED   1
00147 
00148 void rt_displaymode(SceneHandle, int);
00149 
00150 void rt_scenesetup(SceneHandle, char *, int, int, int);
00151   /* scene, output filename, horizontal resolution, vertical resolution,
00152             verbose mode */
00153 
00154 
00155 void rt_camerasetup(SceneHandle, apiflt, apiflt, int, int,
00156     vector, vector,  vector);
00157   /* camera parms: scene, zoom, aspectratio, antialiasing, raydepth,
00158         camera center, view direction, up direction */
00159 
00160 
00161 
00162 void * rt_texture(apitexture *);
00163    /* pointer to the texture struct that would have been passed to each 
00164       object() call in older revisions.. */
00165 
00166 
00167 
00168 
00169 void rt_light(void * , vector, apiflt);     /* add a light */
00170   /* light parms: texture, center, radius */ 
00171 
00172 void rt_sphere(void *, vector, apiflt);    /* add a sphere */
00173   /* sphere parms: texture, center, radius */
00174 
00175 void rt_scalarvol(void *, vector, vector,
00176          int, int, int, char *, void *); 
00177 
00178 void rt_extvol(void *, vector, vector, int, apiflt (* evaluator)(apiflt, apiflt, apiflt)); 
00179 
00180 void rt_box(void *, vector, vector);  
00181   /* box parms: texture, min, max */
00182 
00183 void rt_plane(void *, vector, vector);  
00184   /* plane parms: texture, center, normal */
00185 
00186 void rt_ring(void *, vector, vector, apiflt, apiflt); 
00187   /* ring parms: texture, center, normal, inner, outer */
00188 
00189 void rt_tri(void *, vector, vector, vector);  
00190   /* tri parms: texture, vertex 0, vertex 1, vertex 2 */
00191 
00192 void rt_stri(void *, vector, vector, vector, 
00193             vector, vector, vector); 
00194  /* stri parms: texture, vertex 0, vertex 1, vertex 2, norm 0, norm 1, norm 2 */
00195 
00196 void rt_heightfield(void *, vector, int, int, apiflt *, apiflt, apiflt);
00197   /* field parms: texture, center, m, n, field, wx, wy */
00198 
00199 void rt_landscape(void *, int, int, vector,  apiflt, apiflt);
00200 
00201 void rt_quadsphere(void *, vector, apiflt); /* add quadric sphere */
00202   /* sphere parms: texture, center, radius */
00203 
00204 void rt_cylinder(void *, vector, vector, apiflt);
00205 
00206 void rt_fcylinder(void *, vector, vector, apiflt);
00207 
00208 void rt_polycylinder(void *, vector *, int, apiflt);
00209 
00210 
00211 /* new texture handling routines */
00212 void rt_tex_color(void * voidtex, color col); 
00213 
00214 #define RT_PHONG_PLASTIC 0
00215 #define RT_PHONG_METAL   1
00216 void rt_tex_phong(void * voidtex, apiflt phong, apiflt phongexp, int type); 

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net