2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 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 GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 int PortalVisibleSides( portal_t *p ){
33 fcon = p->nodes[0]->contents;
34 bcon = p->nodes[1]->contents;
36 // same contents never create a face
41 // FIXME: is this correct now?
51 void OutputWinding( winding_t *w, FILE *glview ){
52 static int level = 128;
56 fprintf( glview, "%i\n", w->numpoints );
58 light = ( level & 255 ) / 255.0;
59 for ( i = 0 ; i < w->numpoints ; i++ )
61 fprintf( glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
69 fprintf( glview, "\n" );
77 void OutputPortal( portal_t *p, FILE *glview ){
81 sides = PortalVisibleSides( p );
90 if ( sides == 2 ) { // back side
91 w = ReverseWinding( w );
94 OutputWinding( w, glview );
106 void WriteGLView_r( node_t *node, FILE *glview ){
109 if ( node->planenum != PLANENUM_LEAF ) {
110 WriteGLView_r( node->children[0], glview );
111 WriteGLView_r( node->children[1], glview );
115 // write all the portals
116 for ( p = node->portals ; p ; p = nextp )
118 if ( p->nodes[0] == node ) {
119 OutputPortal( p, glview );
133 void WriteGLView( tree_t *tree, char *source ){
138 sprintf( name, "%s%s.gl",outbase, source );
139 Sys_Printf( "Writing %s\n", name );
141 glview = fopen( name, "w" );
143 Error( "Couldn't open %s", name );
145 WriteGLView_r( tree->headnode, glview );
148 Sys_Printf( "%5i c_glfaces\n", c_glfaces );