2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../../../idlib/precompiled.h"
36 int PortalVisibleSides( uPortal_t *p )
43 fcon = p->nodes[0]->opaque;
44 bcon = p->nodes[1]->opaque;
46 // same contents never create a face
57 void OutputWinding( idWinding *w, idFile *glview )
59 static int level = 128;
63 glview->WriteFloatString( "%i\n", w->GetNumPoints() );
65 light = (level&255)/255.0;
66 for ( i = 0; i < w->GetNumPoints(); i++ ) {
67 glview->WriteFloatString( "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
75 glview->WriteFloatString( "\n" );
83 void OutputPortal( uPortal_t *p, idFile *glview ) {
87 sides = PortalVisibleSides( p );
96 if ( sides == 2 ) { // back side
100 OutputWinding( w, glview );
112 void WriteGLView_r( node_t *node, idFile *glview )
114 uPortal_t *p, *nextp;
116 if ( node->planenum != PLANENUM_LEAF )
118 WriteGLView_r( node->children[0], glview );
119 WriteGLView_r( node->children[1], glview );
123 // write all the portals
124 for ( p = node->portals; p; p = nextp )
126 if ( p->nodes[0] == node )
128 OutputPortal( p, glview );
142 void WriteGLView( tree_t *tree, char *source )
147 common->Printf( "Writing %s\n", source );
149 glview = fileSystem->OpenExplicitFileWrite( source );
151 common->Error( "Couldn't open %s", source );
153 WriteGLView_r( tree->headnode, glview );
154 fileSystem->CloseFile( glview );
156 common->Printf( "%5i c_glfaces\n", c_glfaces );