![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include "machine.h"#include "types.h"#include "macros.h"#include "box.h"#include "cylinder.h"#include "plane.h"#include "quadric.h"#include "ring.h"#include "sphere.h"#include "triangle.h"#include "vol.h"#include "extvol.h"#include "texture.h"#include "light.h"#include "render.h"#include "camera.h"#include "vector.h"#include "intersect.h"#include "shade.h"#include "util.h"#include "imap.h"#include "global.h"#include "video.h"#include "api.h"
Include dependency graph for api.cpp:Go to the source code of this file.
Typedefs | |
| typedef void * | SceneHandle |
Functions | |
| void | apitextotex (apitexture *apitex, texture *tex) |
| void | rt_background (SceneHandle voidscene, color col) |
| void | rt_boundmode (SceneHandle voidscene, int mode) |
| void | rt_boundthresh (SceneHandle voidscene, int threshold) |
| void | rt_box (void *tex, vector min, vector max) |
| void | rt_camerasetup (SceneHandle voidscene, apiflt zoom, apiflt aspectratio, int antialiasing, int raydepth, vector camcent, vector viewvec, vector upvec) |
| color | rt_color (apiflt r, apiflt g, apiflt b) |
| void | rt_cylinder (void *tex, vector ctr, vector axis, apiflt rad) |
| void | rt_deletescene (SceneHandle scene) |
| void | rt_displaymode (SceneHandle voidscene, int mode) |
| void | rt_extvol (void *tex, vector min, vector max, int samples, flt(*evaluator)(flt, flt, flt)) |
| void | rt_fcylinder (void *tex, vector ctr, vector axis, apiflt rad) |
| void | rt_initialize (int *argc, char ***argv) |
| void | rt_light (void *tex, vector ctr, apiflt rad) |
| SceneHandle | rt_newscene (void) |
| void | rt_outputfile (SceneHandle voidscene, const char *outname) |
| void | rt_plane (void *tex, vector ctr, vector norm) |
| void | rt_quadsphere (void *tex, vector ctr, apiflt rad) |
| void | rt_rawimage (SceneHandle voidscene, unsigned char *rawimage) |
| void | rt_renderscene (SceneHandle voidscene) |
| void | rt_resolution (SceneHandle voidscene, int hres, int vres) |
| void | rt_ring (void *tex, vector ctr, vector norm, apiflt a, apiflt b) |
| void | rt_scalarvol (void *tex, vector min, vector max, int xs, int ys, int zs, char *fname, void *invol) |
| void | rt_scenesetup (SceneHandle voidscene, char *outname, int hres, int vres, int verbose) |
| void | rt_sphere (void *tex, vector ctr, apiflt rad) |
| void | rt_stri (void *tex, vector v0, vector v1, vector v2, vector n0, vector n1, vector n2) |
| void | rt_tex_color (void *voidtex, color col) |
| void | rt_tex_phong (void *voidtex, apiflt phong, apiflt phongexp, int type) |
| void * | rt_texture (apitexture *apitex) |
| void | rt_tri (void *tex, vector v0, vector v1, vector v2) |
| vector | rt_vector (apiflt x, apiflt y, apiflt z) |
| void | rt_verbose (SceneHandle voidscene, int v) |
| typedef void* SceneHandle |
| void apitextotex | ( | apitexture * | apitex, |
| texture * | tex | ||
| ) |
Definition at line 251 of file api.cpp.
References AllocateImage(), apitexture::ambient, texture::ambient, checker_texture(), apitexture::col, texture::col, apitexture::ctr, texture::ctr, cyl_checker_texture(), apitexture::diffuse, texture::diffuse, gnoise_texture(), grit_texture(), image_cyl_texture(), image_plane_texture(), image_sphere_texture(), apitexture::imap, texture::img, texture::islight, marble_texture(), apitexture::opacity, texture::opacity, texture::phong, texture::phongexp, texture::phongtype, apitexture::rot, texture::rot, apitexture::scale, texture::scale, texture::shadowcast, apitexture::specular, texture::specular, standard_texture(), texture::texfunc, apitexture::texturefunc, apitexture::uaxs, texture::uaxs, apitexture::vaxs, texture::vaxs, and wood_texture().
Referenced by rt_texture().
{
switch(apitex->texturefunc) {
case 0:
tex->texfunc=(color(*)(void *, void *, void *))(standard_texture);
break;
case 1:
tex->texfunc=(color(*)(void *, void *, void *))(checker_texture);
break;
case 2:
tex->texfunc=(color(*)(void *, void *, void *))(grit_texture);
break;
case 3:
tex->texfunc=(color(*)(void *, void *, void *))(marble_texture);
break;
case 4:
tex->texfunc=(color(*)(void *, void *, void *))(wood_texture);
break;
case 5:
tex->texfunc=(color(*)(void *, void *, void *))(gnoise_texture);
break;
case 6:
tex->texfunc=(color(*)(void *, void *, void *))(cyl_checker_texture);
break;
case 7:
tex->texfunc=(color(*)(void *, void *, void *))(image_sphere_texture);
tex->img=AllocateImage((char *)apitex->imap);
break;
case 8:
tex->texfunc=(color(*)(void *, void *, void *))(image_cyl_texture);
tex->img=AllocateImage((char *)apitex->imap);
break;
case 9:
tex->texfunc=(color(*)(void *, void *, void *))(image_plane_texture);
tex->img=AllocateImage((char *)apitex->imap);
break;
default:
tex->texfunc=(color(*)(void *, void *, void *))(standard_texture);
break;
}
tex->ctr = apitex->ctr;
tex->rot = apitex->rot;
tex->scale = apitex->scale;
tex->uaxs = apitex->uaxs;
tex->vaxs = apitex->vaxs;
tex->ambient = apitex->ambient;
tex->diffuse = apitex->diffuse;
tex->specular = apitex->specular;
tex->opacity = apitex->opacity;
tex->col = apitex->col;
tex->islight = 0;
tex->shadowcast = 1;
tex->phong = 0.0;
tex->phongexp = 0.0;
tex->phongtype = 0;
}
| void rt_background | ( | SceneHandle | voidscene, |
| color | col | ||
| ) |
Definition at line 185 of file api.cpp.
References color::b, scenedef::background, color::g, color::r, and scene.
Referenced by readmodel().
{
scenedef * scene = (scenedef *) voidscene;
scene->background.r = col.r;
scene->background.g = col.g;
scene->background.b = col.b;
}
| void rt_boundmode | ( | SceneHandle | voidscene, |
| int | mode | ||
| ) |
Definition at line 192 of file api.cpp.
References scenedef::boundmode, and scene.
Referenced by rt_newscene(), and useoptions().
| void rt_boundthresh | ( | SceneHandle | voidscene, |
| int | threshold | ||
| ) |
Definition at line 197 of file api.cpp.
References scenedef::boundthresh, MAXOCTNODES, rtmesg(), and scene.
Referenced by rt_newscene(), and useoptions().
{
scenedef * scene = (scenedef *) voidscene;
if (threshold > 1) {
scene->boundthresh = threshold;
}
else {
rtmesg("Ignoring out-of-range automatic bounding threshold.\n");
rtmesg("Automatic bounding threshold reset to default.\n");
scene->boundthresh = MAXOCTNODES;
}
}
Definition at line 363 of file api.cpp.
References add_object(), and newbox().
Referenced by GetBox().
{
add_object((object *) newbox(tex, (vector)min, (vector)max));
}
| void rt_camerasetup | ( | SceneHandle | voidscene, |
| apiflt | zoom, | ||
| apiflt | aspectratio, | ||
| int | antialiasing, | ||
| int | raydepth, | ||
| vector | camcent, | ||
| vector | viewvec, | ||
| vector | upvec | ||
| ) |
Definition at line 135 of file api.cpp.
References scenedef::antialiasing, scenedef::aspectratio, scenedef::camcent, scenedef::camrightvec, scenedef::camupvec, scenedef::camviewvec, scenedef::camzoom, scenedef::raydepth, scene, VCross(), and VNorm().
Referenced by GetScenedefs(), and rt_newscene().
{
scenedef * scene = (scenedef *) voidscene;
vector newupvec;
vector newviewvec;
vector newrightvec;
VCross((vector *) &upvec, &viewvec, &newrightvec);
VNorm(&newrightvec);
VCross((vector *) &viewvec, &newrightvec, &newupvec);
VNorm(&newupvec);
newviewvec=viewvec;
VNorm(&newviewvec);
scene->camzoom=zoom;
scene->aspectratio=aspectratio;
scene->antialiasing=antialiasing;
scene->raydepth=raydepth;
scene->camcent=camcent;
scene->camviewvec=newviewvec;
scene->camrightvec=newrightvec;
scene->camupvec=newupvec;
}
Definition at line 367 of file api.cpp.
References add_object(), and newcylinder().
Referenced by GetCylinder().
{
add_object(newcylinder(tex, (vector)ctr, (vector)axis, rad));
}
| void rt_deletescene | ( | SceneHandle | scene | ) |
| void rt_displaymode | ( | SceneHandle | voidscene, |
| int | mode | ||
| ) |
Definition at line 210 of file api.cpp.
References scenedef::displaymode, and scene.
Referenced by rt_newscene(), and useoptions().
{
scenedef * scene = (scenedef *) voidscene;
scene->displaymode = mode;
}
Definition at line 359 of file api.cpp.
References add_object(), and newextvol().
{
add_object((object *) newextvol(tex, (vector)min, (vector)max, samples, evaluator));
}
Definition at line 371 of file api.cpp.
References add_object(), and newfcylinder().
Referenced by GetFCylinder(), rt_polycylinder(), and rt_tri_cylinder().
{
add_object(newfcylinder(tex, (vector)ctr, (vector)axis, rad));
}
| void rt_initialize | ( | int * | argc, |
| char *** | argv | ||
| ) |
Definition at line 116 of file api.cpp.
References InitTextures(), parinitted, reset_lights(), reset_object(), and rpcmsg::type.
Referenced by main_init_parts().
{
rpcmsg msg;
reset_object();
reset_lights();
InitTextures();
if (!parinitted) {
parinitted=1;
msg.type=1; /* setup a ping message */
}
}
Definition at line 339 of file api.cpp.
References add_light(), add_object(), texture::diffuse, texture::islight, newlight(), texture::opacity, texture::shadowcast, texture::specular, and point_light::tex.
Referenced by GetLight().
{
point_light * li;
li=newlight(tex, (vector) ctr, rad);
li->tex->islight=1;
li->tex->shadowcast=1;
li->tex->diffuse=0.0;
li->tex->specular=0.0;
li->tex->opacity=1.0;
add_light(li);
add_object((object *)li);
}
| SceneHandle rt_newscene | ( | void | ) |
Definition at line 222 of file api.cpp.
References MAXOCTNODES, RT_BOUNDING_ENABLED, rt_boundmode(), rt_boundthresh(), rt_camerasetup(), RT_DISPLAY_ENABLED, rt_displaymode(), rt_outputfile(), rt_rawimage(), rt_resolution(), rt_vector(), rt_verbose(), and scene.
Referenced by main_init_parts().
{
scenedef * scene;
SceneHandle voidscene;
scene = (scenedef *) malloc(sizeof(scenedef));
memset(scene, 0, sizeof(scenedef)); /* clear all valuas to 0 */
voidscene = (SceneHandle) scene;
rt_outputfile(voidscene, "/dev/null"); /* default output file (.tga) */
rt_resolution(voidscene, 512, 512); /* 512x512 resolution */
rt_verbose(voidscene, 0); /* verbose messages off */
rt_rawimage(voidscene, NULL); /* raw image output off */
rt_boundmode(voidscene, RT_BOUNDING_ENABLED); /* spatial subdivision on */
rt_boundthresh(voidscene, MAXOCTNODES); /* default threshold */
rt_displaymode(voidscene, RT_DISPLAY_ENABLED); /* video output on */
rt_camerasetup(voidscene, 1.0, 1.0, 0, 6,
rt_vector(0.0, 0.0, 0.0),
rt_vector(0.0, 0.0, 1.0),
rt_vector(0.0, 1.0, 0.0));
return scene;
}
| void rt_outputfile | ( | SceneHandle | voidscene, |
| const char * | outname | ||
| ) |
Definition at line 164 of file api.cpp.
References scenedef::outfilename, and scene.
Referenced by rt_newscene(), rt_scenesetup(), and useoptions().
{
scenedef * scene = (scenedef *) voidscene;
strcpy((char *) &scene->outfilename, outname);
}
Definition at line 375 of file api.cpp.
References add_object(), and newplane().
Referenced by GetPlane().
{
add_object(newplane(tex, (vector)ctr, (vector)norm));
}
Definition at line 408 of file api.cpp.
References quadmatrix::a, add_object(), quadmatrix::b, quadmatrix::c, quadric::ctr, quadmatrix::d, quadmatrix::e, quadmatrix::f, quadmatrix::g, quadmatrix::h, quadmatrix::i, quadmatrix::j, quadric::mat, newquadric(), and quadric::tex.
| void rt_rawimage | ( | SceneHandle | voidscene, |
| unsigned char * | rawimage | ||
| ) |
Definition at line 180 of file api.cpp.
References scenedef::rawimage, and scene.
Referenced by rt_newscene().
| void rt_renderscene | ( | SceneHandle | voidscene | ) |
Definition at line 130 of file api.cpp.
References renderscene(), and scene.
{
scenedef * scene = (scenedef *) voidscene;
renderscene(*scene);
}
| void rt_resolution | ( | SceneHandle | voidscene, |
| int | hres, | ||
| int | vres | ||
| ) |
Definition at line 169 of file api.cpp.
References scenedef::hres, scene, and scenedef::vres.
Referenced by rt_newscene(), and rt_scenesetup().
Definition at line 379 of file api.cpp.
References add_object(), and newring().
Referenced by GetRing().
{
add_object(newring(tex, (vector)ctr, (vector)norm, a, b));
}
| void rt_scalarvol | ( | void * | tex, |
| vector | min, | ||
| vector | max, | ||
| int | xs, | ||
| int | ys, | ||
| int | zs, | ||
| char * | fname, | ||
| void * | invol | ||
| ) |
Definition at line 354 of file api.cpp.
References add_object(), and newscalarvol().
Referenced by GetVol().
{
add_object((object *) newscalarvol(tex, (vector)min, (vector)max, xs, ys, zs, fname, (scalarvol *) invol));
}
| void rt_scenesetup | ( | SceneHandle | voidscene, |
| char * | outname, | ||
| int | hres, | ||
| int | vres, | ||
| int | verbose | ||
| ) |
Definition at line 216 of file api.cpp.
References rt_outputfile(), rt_resolution(), and rt_verbose().
Referenced by GetScenedefs().
{
rt_outputfile(voidscene, outname);
rt_resolution(voidscene, hres, vres);
rt_verbose(voidscene, verbose);
}
Definition at line 383 of file api.cpp.
References add_object(), and newsphere().
Referenced by GetSphere(), and rt_polycylinder().
{
add_object(newsphere(tex, (vector)ctr, rad));
}
Definition at line 397 of file api.cpp.
References add_object(), and newstri().
Referenced by GetSTri(), rt_sheightfield(), rt_tri_fcylinder(), and rt_tri_ring().
| void rt_tex_color | ( | void * | voidtex, |
| color | col | ||
| ) |
Definition at line 332 of file api.cpp.
References texture::phong, texture::phongexp, and texture::phongtype.
Referenced by GetTexBody().
| void* rt_texture | ( | apitexture * | apitex | ) |
Definition at line 319 of file api.cpp.
References apitextotex(), and rt_getmem().
Referenced by GetLight(), GetTexBody(), and reset_tex_table().
{
texture * tex;
tex=(texture *)rt_getmem(sizeof(texture));
apitextotex(apitex, tex);
return(tex);
}
Definition at line 387 of file api.cpp.
References add_object(), and newtri().
Referenced by GetTPolyFile(), GetTri(), rt_heightfield(), and rt_tri_box().
{
object * trn;
trn = newtri(tex, (vector)v0, (vector)v1, (vector)v2);
if (trn != NULL) {
add_object(trn);
}
}
Definition at line 96 of file api.cpp.
References vector::x, vector::y, and vector::z.
Referenced by rt_newscene(), rt_sheightfield(), and rt_tri_box().
| void rt_verbose | ( | SceneHandle | voidscene, |
| int | v | ||
| ) |
Definition at line 175 of file api.cpp.
References scene, and scenedef::verbosemode.
Referenced by rt_newscene(), rt_scenesetup(), and useoptions().
{
scenedef * scene = (scenedef *) voidscene;
scene->verbosemode = v;
}
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.