Shadowrun: Awakened 29 September 2011 - Build 871
Classes | Defines | Typedefs | Functions
api.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  apitexture

Defines

#define RT_BOUNDING_DISABLED   0
#define RT_BOUNDING_ENABLED   1
#define RT_DISPLAY_DISABLED   0
#define RT_DISPLAY_ENABLED   1
#define RT_PHONG_METAL   1
#define RT_PHONG_PLASTIC   0

Typedefs

typedef double apiflt
typedef void * SceneHandle

Functions

void rt_background (SceneHandle, color)
void rt_boundmode (SceneHandle, int)
void rt_boundthresh (SceneHandle, int)
void rt_box (void *, vector, vector)
void rt_camerasetup (SceneHandle, apiflt, apiflt, int, int, vector, vector, vector)
color rt_color (apiflt r, apiflt g, apiflt b)
void rt_cylinder (void *, vector, vector, apiflt)
void rt_deletescene (SceneHandle)
void rt_displaymode (SceneHandle, int)
void rt_extvol (void *, vector, vector, int, apiflt(*evaluator)(apiflt, apiflt, apiflt))
void rt_fcylinder (void *, vector, vector, apiflt)
void rt_finalize (void)
void rt_heightfield (void *, vector, int, int, apiflt *, apiflt, apiflt)
void rt_initialize (int *, char ***)
void rt_landscape (void *, int, int, vector, apiflt, apiflt)
void rt_light (void *, vector, apiflt)
SceneHandle rt_newscene (void)
void rt_outputfile (SceneHandle, const char *outname)
void rt_plane (void *, vector, vector)
void rt_polycylinder (void *, vector *, int, apiflt)
void rt_quadsphere (void *, vector, apiflt)
void rt_rawimage (SceneHandle, unsigned char *rawimage)
void rt_renderscene (SceneHandle)
void rt_resolution (SceneHandle, int hres, int vres)
void rt_ring (void *, vector, vector, apiflt, apiflt)
void rt_scalarvol (void *, vector, vector, int, int, int, char *, void *)
void rt_scenesetup (SceneHandle, char *, int, int, int)
void rt_sphere (void *, vector, apiflt)
void rt_stri (void *, vector, vector, vector, vector, vector, vector)
void rt_tex_color (void *voidtex, color col)
void rt_tex_phong (void *voidtex, apiflt phong, apiflt phongexp, int type)
void * rt_texture (apitexture *)
void rt_tri (void *, vector, vector, vector)
vector rt_vector (apiflt x, apiflt y, apiflt z)
void rt_verbose (SceneHandle, int v)

Define Documentation

#define RT_BOUNDING_DISABLED   0

Definition at line 138 of file api.h.

Referenced by getparm().

#define RT_BOUNDING_ENABLED   1

Definition at line 139 of file api.h.

Referenced by renderscene(), and rt_newscene().

#define RT_DISPLAY_DISABLED   0

Definition at line 145 of file api.h.

Referenced by getparm().

#define RT_DISPLAY_ENABLED   1

Definition at line 146 of file api.h.

Referenced by getparm(), main_init_parts(), and rt_newscene().

#define RT_PHONG_METAL   1

Definition at line 215 of file api.h.

Referenced by GetTexBody().

#define RT_PHONG_PLASTIC   0

Definition at line 214 of file api.h.

Referenced by GetTexBody().


Typedef Documentation

typedef double apiflt

Definition at line 78 of file api.h.

typedef void* SceneHandle

Definition at line 81 of file api.h.


Function Documentation

void rt_background ( SceneHandle  ,
color   
)

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  ,
int   
)

Definition at line 192 of file api.cpp.

References scenedef::boundmode, and scene.

Referenced by rt_newscene(), and useoptions().

                                                   {
  scenedef * scene = (scenedef *) voidscene;
  scene->boundmode = mode;
}
void rt_boundthresh ( SceneHandle  ,
int   
)

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;
  }
}
void rt_box ( void *  ,
vector  ,
vector   
)

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  ,
apiflt  ,
apiflt  ,
int  ,
int  ,
vector  ,
vector  ,
vector   
)

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;
}
color rt_color ( apiflt  r,
apiflt  g,
apiflt  b 
)

Definition at line 106 of file api.cpp.

References color::b, g, color::g, and color::r.

                                             {
  color c;
  
  c.r = r;
  c.g = g;
  c.b = b;
  
  return c;
}
void rt_cylinder ( void *  ,
vector  ,
vector  ,
apiflt   
)

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  )

Definition at line 246 of file api.cpp.

                                       {
  if (scene != NULL)
    free(scene);
}
void rt_displaymode ( SceneHandle  ,
int   
)

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;
}
void rt_extvol ( void *  ,
vector  ,
vector  ,
int  ,
apiflt(*)(apiflt, apiflt, apiflt evaluator 
)

Definition at line 359 of file api.cpp.

References add_object(), and newextvol().

                                                                                                  {
  add_object((object *) newextvol(tex, (vector)min, (vector)max, samples, evaluator));
}
void rt_fcylinder ( void *  ,
vector  ,
vector  ,
apiflt   
)

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_finalize ( void  )

Definition at line 183 of file video.cpp.

Referenced by main_init_parts(), and rtbomb().

                       {
    timerstart();
    if(global_usegraphics)
        do { rt_sleep(10); timerstop(); }
        while(timertime() < 10 && video->next_frame());
#ifdef _WINDOWS
    else rt_sleep(10000);
#endif
}
void rt_heightfield ( void *  ,
vector  ,
int  ,
int  ,
apiflt ,
apiflt  ,
apiflt   
)

Definition at line 97 of file apigeom.cpp.

References rt_tri(), vector::x, vector::y, and vector::z.

                                                          {
  int xx,yy; 
  vector v0, v1, v2; 
  apiflt xoff, yoff, zoff;

  xoff=ctr.x - (wx / 2.0);
  yoff=ctr.z - (wy / 2.0);
  zoff=ctr.y;

  for (yy=0; yy<(n-1); yy++) { 
    for (xx=0; xx<(m-1); xx++) {
      v0.x=wx*(xx    )/(m*1.0) + xoff; 
      v0.y=field[(yy    )*m + (xx    )] + zoff;
      v0.z=wy*(yy    )/(n*1.0) + yoff;

      v1.x=wx*(xx + 1)/(m*1.0) + xoff; 
      v1.y=field[(yy    )*m + (xx + 1)] + zoff;
      v1.z=wy*(yy    )/(n*1.0) + yoff;

      v2.x=wx*(xx + 1)/(m*1.0) + xoff; 
      v2.y=field[(yy + 1)*m + (xx + 1)] + zoff;
      v2.z=wy*(yy + 1)/(n*1.0) + yoff;

      rt_tri(tex, v1, v0, v2);

      v0.x=wx*(xx    )/(m*1.0) + xoff;
      v0.y=field[(yy    )*m + (xx    )] + zoff;
      v0.z=wy*(yy    )/(n*1.0) + yoff;

      v1.x=wx*(xx    )/(m*1.0) + xoff;
      v1.y=field[(yy + 1)*m + (xx    )] + zoff;
      v1.z=wy*(yy + 1)/(n*1.0) + yoff;

      v2.x=wx*(xx + 1)/(m*1.0) + xoff;
      v2.y=field[(yy + 1)*m + (xx + 1)] + zoff;
      v2.z=wy*(yy + 1)/(n*1.0) + yoff;
 
      rt_tri(tex, v0, v1, v2);
    }
  } 
} /* end of heightfield */
void rt_initialize ( int *  ,
char ***   
)

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 */
  }
}
void rt_landscape ( void *  ,
int  ,
int  ,
vector  ,
apiflt  ,
apiflt   
)

Definition at line 250 of file apigeom.cpp.

References mission1::m, rt_sheightfield(), and subdivide().

Referenced by GetLandScape().

                                                  {
  int totalsize, x, y;
  apiflt * field; 

  totalsize=m*n;

  srand(totalsize);

  field=(apiflt *) malloc(totalsize*sizeof(apiflt));

  for (y=0; y<n; y++) {
    for (x=0; x<m; x++) {
       field[x + y*m]=0.0;
    }
  }

  field[0 + 0]=1.0 + (rand() % 100)/100.0;
  field[m - 1]=1.0 + (rand() % 100)/100.0;
  field[0     + m*(n - 1)]=1.0 + (rand() % 100)/100.0;
  field[m - 1 + m*(n - 1)]=1.0 + (rand() % 100)/100.0;

  subdivide(field, m, n, wx, wy, 0, 0, m-1, n-1);

  rt_sheightfield(tex, ctr, m, n, field, wx, wy);

  free(field);
}
void rt_light ( void *  ,
vector  ,
apiflt   
)

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  ,
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);
}
void rt_plane ( void *  ,
vector  ,
vector   
)

Definition at line 375 of file api.cpp.

References add_object(), and newplane().

Referenced by GetPlane().

                                                   {
  add_object(newplane(tex, (vector)ctr, (vector)norm));
} 
void rt_polycylinder ( void *  ,
vector ,
int  ,
apiflt   
)

Definition at line 73 of file apigeom.cpp.

References rt_fcylinder(), rt_sphere(), vector::x, vector::y, and vector::z.

Referenced by GetPolyCylinder().

                                                                          {
  vector a;
  int i;

  if ((points == NULL) || (numpts == 0)) {
    return;
  }

  if (numpts > 0) {
    rt_sphere(tex, points[0], rad);
    
    if (numpts > 1) {
      for (i=1; i<numpts; i++) {
        a.x = points[i].x - points[i-1].x;
        a.y = points[i].y - points[i-1].y;
        a.z = points[i].z - points[i-1].z;
        
        rt_fcylinder(tex, points[i-1], a, rad);
        rt_sphere(tex, points[i], rad);
      }
    }
  }
}
void rt_quadsphere ( void *  ,
vector  ,
apiflt   
)

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.

                                                       {
  quadric * q;
  flt factor;
  q=(quadric *) newquadric();
  factor= 1.0 / (rad*rad);
  q->tex=(texture *)tex;
  q->ctr=ctr;
 
  q->mat.a=factor;
  q->mat.b=0.0;
  q->mat.c=0.0;
  q->mat.d=0.0;
  q->mat.e=factor;
  q->mat.f=0.0;
  q->mat.g=0.0;
  q->mat.h=factor;
  q->mat.i=0.0;
  q->mat.j=-1.0;
 
  add_object((object *)q);
}
void rt_rawimage ( SceneHandle  ,
unsigned char *  rawimage 
)

Definition at line 180 of file api.cpp.

References scenedef::rawimage, and scene.

Referenced by rt_newscene().

                                                                 {
  scenedef * scene = (scenedef *) voidscene;
  scene->rawimage = rawimage;
}
void rt_renderscene ( SceneHandle  )

Definition at line 130 of file api.cpp.

References renderscene(), and scene.

                                           {
  scenedef * scene = (scenedef *) voidscene;
  renderscene(*scene);
}
void rt_resolution ( SceneHandle  ,
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().

                                                              {
  scenedef * scene = (scenedef *) voidscene;
  scene->hres=hres;
  scene->vres=vres;
}
void rt_ring ( void *  ,
vector  ,
vector  ,
apiflt  ,
apiflt   
)

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 *  ,
vector  ,
vector  ,
int  ,
int  ,
int  ,
char *  ,
void *   
)

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  ,
char *  ,
int  ,
int  ,
int   
)

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);
}
void rt_sphere ( void *  ,
vector  ,
apiflt   
)

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));
}
void rt_stri ( void *  ,
vector  ,
vector  ,
vector  ,
vector  ,
vector  ,
vector   
)

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().

                                         {
  object * trn;
 
  trn = newstri(tex, (vector)v0, (vector)v1, (vector)v2, (vector)n0, (vector)n1, (vector)n2);

  if (trn != NULL) { 
    add_object(trn);
  }
} 
void rt_tex_color ( void *  voidtex,
color  col 
)

Definition at line 327 of file api.cpp.

References texture::col.

                                             {
  texture * tex = (texture *) voidtex;
  tex->col = col;
}
void rt_tex_phong ( void *  voidtex,
apiflt  phong,
apiflt  phongexp,
int  type 
)

Definition at line 332 of file api.cpp.

References texture::phong, texture::phongexp, and texture::phongtype.

Referenced by GetTexBody().

                                                                           {
  texture * tex = (texture *) voidtex;
  tex->phong = phong;
  tex->phongexp = phongexp;
  tex->phongtype = type;
}
void* rt_texture ( apitexture )

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);
}
void rt_tri ( void *  ,
vector  ,
vector  ,
vector   
)

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);
  }
} 
vector rt_vector ( apiflt  x,
apiflt  y,
apiflt  z 
)

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().

                                               {
  vector v;

  v.x = x;
  v.y = y;
  v.z = z;

  return v;
}
void rt_verbose ( SceneHandle  ,
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.

GNU Lesser General Public License 3 Sourceforge.net