![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <ctype.h>#include "types.h"#include "api.h"#include "parse.h"
Include dependency graph for parse.cpp:Go to the source code of this file.
Defines | |
| #define | PARSE_INTERNAL |
Functions | |
| static errcode | add_texture (void *tex, char name[TEXNAMELEN]) |
| apiflt | degtorad (apiflt deg) |
| static void | degvectoradvec (vector *degvec) |
| static void * | find_texture (char name[TEXNAMELEN]) |
| static errcode | GetBackGnd (FILE *dfile) |
| static errcode | GetBox (FILE *dfile) |
| static errcode | GetColor (FILE *dfile, color *c1) |
| static errcode | GetCylinder (FILE *dfile) |
| static errcode | GetFCylinder (FILE *dfile) |
| static errcode | GetLandScape (FILE *dfile) |
| static errcode | GetLight (FILE *dfile) |
| static errcode | GetObject (FILE *dfile, SceneHandle scene) |
| static errcode | GetPlane (FILE *dfile) |
| static errcode | GetPolyCylinder (FILE *dfile) |
| static errcode | GetRing (FILE *dfile) |
| static errcode | GetScenedefs (FILE *dfile, SceneHandle scene) |
| static errcode | GetSphere (FILE *dfile) |
| static errcode | GetSTri (FILE *dfile) |
| static errcode | GetString (FILE *dfile, const char *string) |
| static errcode | GetTexAlias (FILE *dfile) |
| void * | GetTexBody (FILE *dfile) |
| static errcode | GetTexDef (FILE *dfile) |
| static errcode | GetTexture (FILE *dfile, void **tex) |
| static errcode | GetTPolyFile (FILE *dfile) |
| static errcode | GetTri (FILE *dfile) |
| static errcode | GetVector (FILE *dfile, vector *v1) |
| static errcode | GetVol (FILE *dfile) |
| static void | InitRot3d (RotMat *rot, apiflt x, apiflt y, apiflt z) |
| unsigned int | readmodel (char *modelfile, SceneHandle scene) |
| static void | reset_tex_table (void) |
| static void | Rotate3d (RotMat *rot, vector *vec) |
| static void | Scale3d (vector *scale, vector *vec) |
| static int | stringcmp (const char *a, const char *b) |
| static void | Trans3d (vector *trans, vector *vec) |
Variables | |
| static texentry | defaulttex |
| static int | numobjectsparsed |
| static int | numtextures |
| static color | scenebackcol |
| static texentry | textable [NUMTEXS] |
| #define PARSE_INTERNAL |
| static errcode add_texture | ( | void * | tex, |
| char | name[TEXNAMELEN] | ||
| ) | [static] |
Definition at line 118 of file parse.cpp.
References numtextures, PARSEALLOCERR, PARSENOERR, and textable.
Referenced by GetTexAlias(), and GetTexDef().
{
textable[numtextures].tex=tex;
strcpy(textable[numtextures].name, name);
numtextures++;
if (numtextures > NUMTEXS) {
fprintf(stderr, "Parse: %d textures allocated, texture slots full!\n", numtextures);
numtextures--; /* keep writing over last texture if we've run out.. */
return PARSEALLOCERR;
}
return PARSENOERR;
}
Definition at line 143 of file parse.cpp.
Referenced by degvectoradvec().
{
apiflt tmp;
tmp=deg * 3.1415926 / 180.0;
return tmp;
}
| static void degvectoradvec | ( | vector * | degvec | ) | [static] |
| static void* find_texture | ( | char | name[TEXNAMELEN] | ) | [static] |
Definition at line 132 of file parse.cpp.
References defaulttex, numtextures, and textable.
Referenced by GetTexAlias(), and GetTexture().
{
int i;
for (i=0; i<numtextures; i++) {
if (strcmp(name, textable[i].name) == 0)
return textable[i].tex;
}
fprintf(stderr, "Undefined texture '%s', using default. \n",name);
return(defaulttex.tex);
}
| static errcode GetBackGnd | ( | FILE * | dfile | ) | [static] |
Definition at line 529 of file parse.cpp.
References color::b, color::g, g, PARSENOERR, and color::r.
Referenced by GetObject().
{
float r,g,b;
fscanf(dfile, "%f %f %f", &r, &g, &b);
scenebackcol.r=r;
scenebackcol.g=g;
scenebackcol.b=b;
return PARSENOERR;
}
| static errcode GetBox | ( | FILE * | dfile | ) | [static] |
Definition at line 679 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), and rt_box().
Referenced by GetObject().
| static errcode GetColor | ( | FILE * | dfile, |
| color * | c1 | ||
| ) | [static] |
| static errcode GetCylinder | ( | FILE * | dfile | ) | [static] |
Definition at line 541 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), and rt_cylinder().
Referenced by GetObject().
{
apiflt rad;
vector ctr, axis;
void * tex;
float a;
errcode rc;
rc = GetString(dfile, "CENTER");
rc |= GetVector(dfile, &ctr);
rc |= GetString(dfile, "AXIS");
rc |= GetVector(dfile, &axis);
rc |= GetString(dfile, "RAD");
fscanf(dfile, "%f", &a);
rad=a;
rc |= GetTexture(dfile, &tex);
rt_cylinder(tex, ctr, axis, rad);
return rc;
}
| static errcode GetFCylinder | ( | FILE * | dfile | ) | [static] |
Definition at line 562 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), rt_fcylinder(), vector::x, vector::y, and vector::z.
Referenced by GetObject().
{
apiflt rad;
vector ctr, axis;
vector pnt1, pnt2;
void * tex;
float a;
errcode rc;
rc = GetString(dfile, "BASE");
rc |= GetVector(dfile, &pnt1);
rc |= GetString(dfile, "APEX");
rc |= GetVector(dfile, &pnt2);
ctr=pnt1;
axis.x=pnt2.x - pnt1.x;
axis.y=pnt2.y - pnt1.y;
axis.z=pnt2.z - pnt1.z;
rc |= GetString(dfile, "RAD");
fscanf(dfile, "%f", &a);
rad=a;
rc |= GetTexture(dfile, &tex);
rt_fcylinder(tex, ctr, axis, rad);
return rc;
}
| static errcode GetLandScape | ( | FILE * | dfile | ) | [static] |
Definition at line 768 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), mission1::m, and rt_landscape().
Referenced by GetObject().
{
void * tex;
vector ctr;
apiflt wx, wy;
int m, n;
float a,b;
errcode rc;
rc = GetString(dfile, "RES");
fscanf(dfile, "%d %d", &m, &n);
rc |= GetString(dfile, "SCALE");
fscanf(dfile, "%f %f", &a, &b);
wx=a;
wy=b;
rc |= GetString(dfile, "CENTER");
rc |= GetVector(dfile, &ctr);
rc |= GetTexture(dfile, &tex);
rt_landscape(tex, m, n, ctr, wx, wy);
return rc;
}
| static errcode GetLight | ( | FILE * | dfile | ) | [static] |
Definition at line 507 of file parse.cpp.
References apitexture::col, GetColor(), GetString(), GetVector(), rt_light(), and rt_texture().
Referenced by GetObject().
{
apiflt rad;
vector ctr;
apitexture tex;
float a;
errcode rc;
memset(&tex, 0, sizeof(apitexture));
rc = GetString(dfile,"CENTER");
rc |= GetVector(dfile, &ctr);
rc |= GetString(dfile,"RAD");
fscanf(dfile,"%f",&a); /* read in radius */
rad=a;
rc |= GetColor(dfile, &tex.col);
rt_light(rt_texture(&tex), ctr, rad);
return rc;
}
| static errcode GetObject | ( | FILE * | dfile, |
| SceneHandle | scene | ||
| ) | [static] |
Definition at line 310 of file parse.cpp.
References GetBackGnd(), GetBox(), GetCylinder(), GetFCylinder(), GetLandScape(), GetLight(), GetPlane(), GetPolyCylinder(), GetRing(), GetSphere(), GetSTri(), GetTexAlias(), GetTexDef(), GetTPolyFile(), GetTri(), GetVol(), PARSEBADSYNTAX, PARSEEOF, and stringcmp().
Referenced by readmodel().
{
char objtype[80];
fscanf(dfile, "%s", objtype);
if (!stringcmp(objtype, "END_SCENE")) {
return PARSEEOF; /* end parsing */
}
if (!stringcmp(objtype, "TEXDEF")) {
return GetTexDef(dfile);
}
if (!stringcmp(objtype, "TEXALIAS")) {
return GetTexAlias(dfile);
}
if (!stringcmp(objtype, "BACKGROUND")) {
return GetBackGnd(dfile);
}
if (!stringcmp(objtype, "CYLINDER")) {
return GetCylinder(dfile);
}
if (!stringcmp(objtype, "FCYLINDER")) {
return GetFCylinder(dfile);
}
if (!stringcmp(objtype, "POLYCYLINDER")) {
return GetPolyCylinder(dfile);
}
if (!stringcmp(objtype, "SPHERE")) {
return GetSphere(dfile);
}
if (!stringcmp(objtype, "PLANE")) {
return GetPlane(dfile);
}
if (!stringcmp(objtype, "RING")) {
return GetRing(dfile);
}
if (!stringcmp(objtype, "BOX")) {
return GetBox(dfile);
}
if (!stringcmp(objtype, "SCALARVOL")) {
return GetVol(dfile);
}
if (!stringcmp(objtype, "TRI")) {
return GetTri(dfile);
}
if (!stringcmp(objtype, "STRI")) {
return GetSTri(dfile);
}
if (!stringcmp(objtype, "LIGHT")) {
return GetLight(dfile);
}
if (!stringcmp(objtype, "SCAPE")) {
return GetLandScape(dfile);
}
if (!stringcmp(objtype, "TPOLYFILE")) {
return GetTPolyFile(dfile);
}
fprintf(stderr, "Found bad token: %s expected an object type\n", objtype);
return PARSEBADSYNTAX;
}
| static errcode GetPlane | ( | FILE * | dfile | ) | [static] |
Definition at line 640 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), and rt_plane().
Referenced by GetObject().
| static errcode GetPolyCylinder | ( | FILE * | dfile | ) | [static] |
Definition at line 590 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), and rt_polycylinder().
Referenced by GetObject().
{
apiflt rad;
vector * temp;
void * tex;
float a;
int numpts, i;
errcode rc;
rc = GetString(dfile, "POINTS");
fscanf(dfile, "%d", &numpts);
temp = (vector *) malloc(numpts * sizeof(vector));
for (i=0; i<numpts; i++) {
rc |= GetVector(dfile, &temp[i]);
}
rc |= GetString(dfile, "RAD");
fscanf(dfile, "%f", &a);
rad=a;
rc |= GetTexture(dfile, &tex);
rt_polycylinder(tex, temp, numpts, rad);
free(temp);
return rc;
}
| static errcode GetRing | ( | FILE * | dfile | ) | [static] |
Definition at line 695 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), and rt_ring().
Referenced by GetObject().
{
vector normal;
vector ctr;
void * tex;
float a,b;
errcode rc;
rc = GetString(dfile, "CENTER");
rc |= GetVector(dfile, &ctr);
rc |= GetString(dfile, "NORMAL");
rc |= GetVector(dfile, &normal);
rc |= GetString(dfile, "INNER");
fscanf(dfile, " %f ", &a);
rc |= GetString(dfile, "OUTER");
fscanf(dfile, " %f ", &b);
rc |= GetTexture(dfile, &tex);
rt_ring(tex, ctr, normal, a, b);
return rc;
}
| static errcode GetScenedefs | ( | FILE * | dfile, |
| SceneHandle | scene | ||
| ) | [static] |
Definition at line 240 of file parse.cpp.
References GetString(), PARSENOERR, rt_camerasetup(), rt_scenesetup(), vector::x, vector::y, and vector::z.
Referenced by readmodel().
{
vector Ccenter, Cview, Cup;
apiflt zoom, aspectratio;
int raydepth, antialiasing;
char outfilename[200];
int xres, yres, verbose;
float a,b,c;
errcode rc = PARSENOERR;
rc |= GetString(dfile, "BEGIN_SCENE");
rc |= GetString(dfile, "OUTFILE");
fscanf(dfile, "%s", outfilename);
#ifdef _WIN32
if (strcmp (outfilename, "/dev/null") == 0) {
strcpy (outfilename, "NUL:");
}
#endif
rc |= GetString(dfile, "RESOLUTION");
fscanf(dfile, "%d %d", &xres, &yres);
rc |= GetString(dfile, "VERBOSE");
fscanf(dfile, "%d", &verbose);
rt_scenesetup(scene, outfilename, xres, yres, verbose);
rc |= GetString(dfile, "CAMERA");
rc |= GetString(dfile, "ZOOM");
fscanf(dfile, "%f", &a);
zoom=a;
rc |= GetString(dfile, "ASPECTRATIO");
fscanf(dfile, "%f", &b);
aspectratio=b;
rc |= GetString(dfile, "ANTIALIASING");
fscanf(dfile, "%d", &antialiasing);
rc |= GetString(dfile, "RAYDEPTH");
fscanf(dfile, "%d", &raydepth);
rc |= GetString(dfile, "CENTER");
fscanf(dfile,"%f %f %f", &a, &b, &c);
Ccenter.x = a;
Ccenter.y = b;
Ccenter.z = c;
rc |= GetString(dfile, "VIEWDIR");
fscanf(dfile,"%f %f %f", &a, &b, &c);
Cview.x = a;
Cview.y = b;
Cview.z = c;
rc |= GetString(dfile, "UPDIR");
fscanf(dfile,"%f %f %f", &a, &b, &c);
Cup.x = a;
Cup.y = b;
Cup.z = c;
rc |= GetString(dfile, "END_CAMERA");
rt_camerasetup(scene, zoom, aspectratio, antialiasing, raydepth,
Ccenter, Cview, Cup);
return rc;
}
| static errcode GetSphere | ( | FILE * | dfile | ) | [static] |
Definition at line 620 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), and rt_sphere().
Referenced by GetObject().
| static errcode GetSTri | ( | FILE * | dfile | ) | [static] |
Definition at line 738 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), and rt_stri().
Referenced by GetObject().
{
vector v0,v1,v2,n0,n1,n2;
void * tex;
errcode rc;
rc = GetString(dfile, "V0");
rc |= GetVector(dfile, &v0);
rc |= GetString(dfile, "V1");
rc |= GetVector(dfile, &v1);
rc |= GetString(dfile, "V2");
rc |= GetVector(dfile, &v2);
rc |= GetString(dfile, "N0");
rc |= GetVector(dfile, &n0);
rc |= GetString(dfile, "N1");
rc |= GetVector(dfile, &n1);
rc |= GetString(dfile, "N2");
rc |= GetVector(dfile, &n2);
rc |= GetTexture(dfile, &tex);
rt_stri(tex, v0, v1, v2, n0, n1, n2);
return rc;
}
| static errcode GetString | ( | FILE * | dfile, |
| const char * | string | ||
| ) | [static] |
Definition at line 192 of file parse.cpp.
References numobjectsparsed, PARSEBADSYNTAX, PARSENOERR, and stringcmp().
Referenced by GetBox(), GetColor(), GetCylinder(), GetFCylinder(), GetLandScape(), GetLight(), GetPlane(), GetPolyCylinder(), GetRing(), GetScenedefs(), GetSphere(), GetSTri(), GetTexBody(), GetTPolyFile(), GetTri(), and GetVol().
{
char data[255];
fscanf(dfile,"%s",data);
if (stringcmp(data, string) != 0) {
fprintf(stderr, "parse: Expected %s, got %s \n",string, data);
fprintf(stderr, "parse: Error while parsing object: %d \n",numobjectsparsed);
return PARSEBADSYNTAX;
}
return PARSENOERR;
}
| static errcode GetTexAlias | ( | FILE * | dfile | ) | [static] |
Definition at line 403 of file parse.cpp.
References add_texture(), find_texture(), and PARSENOERR.
Referenced by GetObject().
{
char texname[TEXNAMELEN];
char aliasname[TEXNAMELEN];
fscanf(dfile, "%s", texname);
fscanf(dfile, "%s", aliasname);
add_texture(find_texture(aliasname), texname);
return PARSENOERR;
}
| void* GetTexBody | ( | FILE * | dfile | ) |
Definition at line 429 of file parse.cpp.
References apitexture::ambient, color::b, apitexture::col, apitexture::ctr, apitexture::diffuse, color::g, GetString(), GetVector(), apitexture::imap, apitexture::opacity, color::r, apitexture::rot, RT_PHONG_METAL, RT_PHONG_PLASTIC, rt_tex_phong(), rt_texture(), apitexture::scale, apitexture::specular, stringcmp(), apitexture::texturefunc, apitexture::uaxs, and apitexture::vaxs.
Referenced by GetTexDef(), and GetTexture().
{
char tmp[255];
float a,b,c,d, phong, phongexp, phongtype;
apitexture tex;
void * voidtex;
errcode rc;
rc = GetString(dfile, "AMBIENT");
fscanf(dfile, "%f", &a);
tex.ambient=a;
rc |= GetString(dfile, "DIFFUSE");
fscanf(dfile, "%f", &b);
tex.diffuse=b;
rc |= GetString(dfile, "SPECULAR");
fscanf(dfile, "%f", &c);
tex.specular=c;
rc |= GetString(dfile, "OPACITY");
fscanf(dfile, "%f", &d);
tex.opacity=d;
fscanf(dfile, "%s", tmp);
if (!stringcmp("PHONG", tmp)) {
fscanf(dfile, "%s", tmp);
if (!stringcmp("METAL", tmp)) {
phongtype = RT_PHONG_METAL;
}
else if (!stringcmp("PLASTIC", tmp)) {
phongtype = RT_PHONG_PLASTIC;
}
else {
phongtype = RT_PHONG_PLASTIC;
}
fscanf(dfile, "%f", &phong);
GetString(dfile, "PHONG_SIZE");
fscanf(dfile, "%f", &phongexp);
fscanf(dfile, "%s", tmp);
}
else {
phong = 0.0;
phongexp = 100.0;
phongtype = RT_PHONG_PLASTIC;
}
fscanf(dfile, "%f %f %f", &a, &b, &c);
tex.col.r = a;
tex.col.g = b;
tex.col.b = c;
rc |= GetString(dfile, "TEXFUNC");
fscanf(dfile, "%d", &tex.texturefunc);
if (tex.texturefunc >= 7) { /* if its an image map, we need a filename */
fscanf(dfile, "%s", tex.imap);
}
if (tex.texturefunc != 0) {
rc |= GetString(dfile, "CENTER");
rc |= GetVector(dfile, &tex.ctr);
rc |= GetString(dfile, "ROTATE");
rc |= GetVector(dfile, &tex.rot);
rc |= GetString(dfile, "SCALE");
rc |= GetVector(dfile, &tex.scale);
}
if (tex.texturefunc == 9) {
rc |= GetString(dfile, "UAXIS");
rc |= GetVector(dfile, &tex.uaxs);
rc |= GetString(dfile, "VAXIS");
rc |= GetVector(dfile, &tex.vaxs);
}
voidtex = rt_texture(&tex);
rt_tex_phong(voidtex, phong, phongexp, (int) phongtype);
return voidtex;
}
| static errcode GetTexDef | ( | FILE * | dfile | ) | [static] |
Definition at line 394 of file parse.cpp.
References add_texture(), GetTexBody(), and PARSENOERR.
Referenced by GetObject().
{
char texname[TEXNAMELEN];
fscanf(dfile, "%s", texname);
add_texture(GetTexBody(dfile), texname);
return PARSENOERR;
}
| static errcode GetTexture | ( | FILE * | dfile, |
| void ** | tex | ||
| ) | [static] |
Definition at line 415 of file parse.cpp.
References find_texture(), GetTexBody(), PARSENOERR, and stringcmp().
Referenced by GetBox(), GetCylinder(), GetFCylinder(), GetLandScape(), GetPlane(), GetPolyCylinder(), GetRing(), GetSphere(), GetSTri(), GetTPolyFile(), GetTri(), and GetVol().
{
char tmp[255];
errcode rc = PARSENOERR;
fscanf(dfile, "%s", tmp);
if (!stringcmp("TEXTURE", tmp)) {
*tex = GetTexBody(dfile);
}
else
*tex = find_texture(tmp);
return rc;
}
| static errcode GetTPolyFile | ( | FILE * | dfile | ) | [static] |
Definition at line 794 of file parse.cpp.
References degvectoradvec(), GetString(), GetTexture(), GetVector(), InitRot3d(), PARSEBADSUBFILE, Rotate3d(), rt_tri(), Scale3d(), Trans3d(), vector::x, vector::y, and vector::z.
Referenced by GetObject().
{
void * tex;
vector ctr, rot, scale;
vector v1, v2, v0;
char ifname[255];
FILE *ifp;
int v, totalpolys;
RotMat RotA;
errcode rc;
totalpolys=0;
rc = GetString(dfile, "SCALE");
rc |= GetVector(dfile, &scale);
rc |= GetString(dfile, "ROT");
rc |= GetVector(dfile, &rot);
degvectoradvec(&rot);
InitRot3d(&RotA, rot.x, rot.y, rot.z);
rc |= GetString(dfile, "CENTER");
rc |= GetVector(dfile, &ctr);
rc |= GetString(dfile, "FILE");
fscanf(dfile, "%s", ifname);
rc |= GetTexture(dfile, &tex);
if ((ifp=fopen(ifname, "r")) == NULL) {
fprintf(stderr, "Can't open data file %s for input!! Aborting...\n", ifname);
return PARSEBADSUBFILE;
}
while (!feof(ifp)) {
fscanf(ifp, "%d", &v);
if (v != 3) { break; }
totalpolys++;
v=0;
rc |= GetVector(ifp, &v0);
rc |= GetVector(ifp, &v1);
rc |= GetVector(ifp, &v2);
Scale3d(&scale, &v0);
Scale3d(&scale, &v1);
Scale3d(&scale, &v2);
Rotate3d(&RotA, &v0);
Rotate3d(&RotA, &v1);
Rotate3d(&RotA, &v2);
Trans3d(&ctr, &v0);
Trans3d(&ctr, &v1);
Trans3d(&ctr, &v2);
rt_tri(tex, v1, v0, v2);
}
fclose(ifp);
return rc;
}
| static errcode GetTri | ( | FILE * | dfile | ) | [static] |
Definition at line 717 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), and rt_tri().
Referenced by GetObject().
| static errcode GetVector | ( | FILE * | dfile, |
| vector * | v1 | ||
| ) | [static] |
Definition at line 370 of file parse.cpp.
References PARSENOERR, vector::x, vector::y, and vector::z.
Referenced by GetBox(), GetCylinder(), GetFCylinder(), GetLandScape(), GetLight(), GetPlane(), GetPolyCylinder(), GetRing(), GetSphere(), GetSTri(), GetTexBody(), GetTPolyFile(), GetTri(), and GetVol().
{
float a, b, c;
fscanf(dfile, "%f %f %f", &a, &b, &c);
v1->x=a;
v1->y=b;
v1->z=c;
return PARSENOERR;
}
| static errcode GetVol | ( | FILE * | dfile | ) | [static] |
Definition at line 657 of file parse.cpp.
References GetString(), GetTexture(), GetVector(), and rt_scalarvol().
Referenced by GetObject().
{
vector min, max;
int x,y,z;
char fname[255];
void * tex;
errcode rc;
rc = GetString(dfile, "MIN");
rc |= GetVector(dfile, &min);
rc |= GetString(dfile, "MAX");
rc |= GetVector(dfile, &max);
rc |= GetString(dfile, "DIM");
fscanf(dfile, "%d %d %d ", &x, &y, &z);
rc |= GetString(dfile, "FILE");
fscanf(dfile, "%s", fname);
rc |= GetTexture(dfile, &tex);
rt_scalarvol(tex, min, max, x, y, z, fname, NULL);
return rc;
}
Definition at line 158 of file parse.cpp.
Referenced by GetTPolyFile().
{
rot->rx1=cos(y)*cos(z);
rot->rx2=sin(x)*sin(y)*cos(z) - cos(x)*sin(z);
rot->rx3=sin(x)*sin(z) + cos(x)*cos(z)*sin(y);
rot->ry1=cos(y)*sin(z);
rot->ry2=cos(x)*cos(z) + sin(x)*sin(y)*sin(z);
rot->ry3=cos(x)*sin(y)*sin(z) - sin(x)*cos(z);
rot->rz1=sin(y);
rot->rz2=sin(x)*cos(y);
rot->rz3=cos(x)*cos(y);
}
| unsigned int readmodel | ( | char * | modelfile, |
| SceneHandle | scene | ||
| ) |
Definition at line 205 of file parse.cpp.
References color::b, color::g, GetObject(), GetScenedefs(), numobjectsparsed, PARSEBADFILE, PARSEEOF, PARSENOERR, color::r, reset_tex_table(), and rt_background().
Referenced by main_init_parts().
{
FILE * dfile;
errcode rc;
reset_tex_table();
dfile=NULL;
dfile=fopen(modelfile,"r");
if (dfile==NULL) {
return PARSEBADFILE;
}
rc = GetScenedefs(dfile, scene);
if (rc != PARSENOERR)
return rc;
scenebackcol.r = 0.0; /* default background is black */
scenebackcol.g = 0.0;
scenebackcol.b = 0.0;
numobjectsparsed=0;
while ((rc = GetObject(dfile, scene)) == PARSENOERR) {
numobjectsparsed++;
}
fclose(dfile);
if (rc == PARSEEOF)
rc = PARSENOERR;
rt_background(scene, scenebackcol);
return rc;
}
| static void reset_tex_table | ( | void | ) | [static] |
Definition at line 100 of file parse.cpp.
References apitexture::ambient, color::b, apitexture::col, defaulttex, apitexture::diffuse, color::g, numtextures, apitexture::opacity, color::r, rt_texture(), apitexture::specular, textable, and apitexture::texturefunc.
Referenced by readmodel().
{
apitexture apitex;
numtextures=0;
memset(&textable, 0, sizeof(textable));
apitex.col.r=1.0;
apitex.col.g=1.0;
apitex.col.b=1.0;
apitex.ambient=0.1;
apitex.diffuse=0.9;
apitex.specular=0.0;
apitex.opacity=1.0;
apitex.texturefunc=0;
defaulttex.tex=rt_texture(&apitex);
}
| static void Rotate3d | ( | RotMat * | rot, |
| vector * | vec | ||
| ) | [static] |
| static int stringcmp | ( | const char * | a, |
| const char * | b | ||
| ) | [static] |
Definition at line 83 of file parse.cpp.
References test::s.
Referenced by GetObject(), GetString(), GetTexBody(), and GetTexture().
texentry defaulttex [static] |
Definition at line 78 of file parse.cpp.
Referenced by find_texture(), and reset_tex_table().
int numobjectsparsed [static] |
Definition at line 80 of file parse.cpp.
Referenced by GetString(), and readmodel().
int numtextures [static] |
Definition at line 79 of file parse.cpp.
Referenced by add_texture(), find_texture(), and reset_tex_table().
color scenebackcol [static] |
texentry textable[NUMTEXS] [static] |
Definition at line 77 of file parse.cpp.
Referenced by add_texture(), find_texture(), and reset_tex_table().
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.