2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
5 This file is part of Quake 2 Tools source code.
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
27 int PortalVisibleSides (portal_t *p)
34 fcon = p->nodes[0]->contents;
35 bcon = p->nodes[1]->contents;
37 // same contents never create a face
41 // FIXME: is this correct now?
49 void OutputWinding (winding_t *w, FILE *glview)
51 static int level = 128;
55 fprintf (glview, "%i\n", w->numpoints);
57 light = (level&255)/255.0;
58 for (i=0 ; i<w->numpoints ; i++)
60 fprintf (glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
68 fprintf (glview, "\n");
76 void OutputPortal (portal_t *p, FILE *glview)
81 sides = PortalVisibleSides (p);
89 if (sides == 2) // back side
90 w = ReverseWinding (w);
92 OutputWinding (w, glview);
103 void WriteGLView_r (node_t *node, FILE *glview)
107 if (node->planenum != PLANENUM_LEAF)
109 WriteGLView_r (node->children[0], glview);
110 WriteGLView_r (node->children[1], glview);
114 // write all the portals
115 for (p=node->portals ; p ; p=nextp)
117 if (p->nodes[0] == node)
119 OutputPortal (p, glview);
132 void WriteGLView (tree_t *tree, char *source)
138 sprintf (name, "%s%s.gl",outbase, source);
139 printf ("Writing %s\n", name);
141 glview = fopen (name, "w");
143 Error ("Couldn't open %s", name);
144 WriteGLView_r (tree->headnode, glview);
147 printf ("%5i c_glfaces\n", c_glfaces);