Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

glfile.c File Reference

#include "qbsp.h"

Include dependency graph for glfile.c:

Include dependency graph

Go to the source code of this file.

Functions

void OutputPortal (portal_t *p, FILE *glview)
void OutputWinding (winding_t *w, FILE *glview)
int PortalVisibleSides (portal_t *p)
void WriteGLView (tree_t *tree, char *source)
void WriteGLView_r (node_t *node, FILE *glview)

Variables

int c_glfaces


Function Documentation

void OutputPortal portal_t p,
FILE glview
 

Definition at line 76 of file glfile.c.

References c_glfaces, FreeWinding(), glview, OutputWinding(), p, portal_t, PortalVisibleSides(), ReverseWinding(), w, and portal_s::winding.

00077 {
00078     winding_t   *w;
00079     int     sides;
00080 
00081     sides = PortalVisibleSides (p);
00082     if (!sides)
00083         return;
00084 
00085     c_glfaces++;
00086 
00087     w = p->winding;
00088 
00089     if (sides == 2)     // back side
00090         w = ReverseWinding (w);
00091 
00092     OutputWinding (w, glview);
00093 
00094     if (sides == 2)
00095         FreeWinding(w);
00096 }

Here is the call graph for this function:

void OutputWinding winding_t w,
FILE glview
 

Definition at line 49 of file glfile.c.

00050 {
00051     static  int level = 128;
00052     vec_t       light;
00053     int         i;
00054 
00055     fprintf (glview, "%i\n", w->numpoints);
00056     level+=28;
00057     light = (level&255)/255.0;
00058     for (i=0 ; i<w->numpoints ; i++)
00059     {
00060         fprintf (glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
00061             w->p[i][0],
00062             w->p[i][1],
00063             w->p[i][2],
00064             light,
00065             light,
00066             light);
00067     }
00068     fprintf (glview, "\n");
00069 }

int PortalVisibleSides portal_t p  ) 
 

Definition at line 27 of file glfile.c.

References node_s::contents, portal_s::nodes, portal_s::onnode, p, and portal_t.

00028 {
00029     int     fcon, bcon;
00030 
00031     if (!p->onnode)
00032         return 0;       // outside
00033 
00034     fcon = p->nodes[0]->contents;
00035     bcon = p->nodes[1]->contents;
00036 
00037     // same contents never create a face
00038     if (fcon == bcon)
00039         return 0;
00040 
00041     // FIXME: is this correct now?
00042     if (!fcon)
00043         return 1;
00044     if (!bcon)
00045         return 2;
00046     return 0;
00047 }

void WriteGLView tree_t tree,
char *  source
 

Definition at line 132 of file glfile.c.

00133 {
00134     char    name[1024];
00135     FILE    *glview;
00136 
00137     c_glfaces = 0;
00138     sprintf (name, "%s%s.gl",outbase, source);
00139     printf ("Writing %s\n", name);
00140 
00141     glview = fopen (name, "w");
00142     if (!glview)
00143         Error ("Couldn't open %s", name);
00144     WriteGLView_r (tree->headnode, glview);
00145     fclose (glview);
00146 
00147     printf ("%5i c_glfaces\n", c_glfaces);
00148 }

void WriteGLView_r node_t node,
FILE glview
 

Definition at line 103 of file glfile.c.

References node_s::children, glview, portal_s::next, node_t, portal_s::nodes, OutputPortal(), p, node_s::planenum, portal_t, node_s::portals, and WriteGLView_r().

00104 {
00105     portal_t    *p, *nextp;
00106 
00107     if (node->planenum != PLANENUM_LEAF)
00108     {
00109         WriteGLView_r (node->children[0], glview);
00110         WriteGLView_r (node->children[1], glview);
00111         return;
00112     }
00113 
00114     // write all the portals
00115     for (p=node->portals ; p ; p=nextp)
00116     {
00117         if (p->nodes[0] == node)
00118         {
00119             OutputPortal (p, glview);
00120             nextp = p->next[0];
00121         }
00122         else
00123             nextp = p->next[1];
00124     }
00125 }

Here is the call graph for this function:


Variable Documentation

int c_glfaces
 

Definition at line 25 of file glfile.c.

Referenced by OutputPortal(), and WriteGLView().


Generated on Thu Aug 25 12:52:52 2005 for Quake III Arena by  doxygen 1.3.9.1