]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake2/q2map/glfile.c
set eol-style
[xonotic/netradiant.git] / tools / quake2 / q2map / glfile.c
index a5c0e30b72a84f831aae6c0348d92822be461b5d..b08053bd12ac2d752e6d5145272ae29075c9ac40 100644 (file)
-/*\r
-Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
-For a list of contributors, see the accompanying CONTRIBUTORS file.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
-*/\r
-\r
-#include "qbsp.h"\r
-\r
-int            c_glfaces;\r
-\r
-int PortalVisibleSides (portal_t *p)\r
-{\r
-       int             fcon, bcon;\r
-\r
-       if (!p->onnode)\r
-               return 0;               // outside\r
-\r
-       fcon = p->nodes[0]->contents;\r
-       bcon = p->nodes[1]->contents;\r
-\r
-       // same contents never create a face\r
-       if (fcon == bcon)\r
-               return 0;\r
-\r
-       // FIXME: is this correct now?\r
-       if (!fcon)\r
-               return 1;\r
-       if (!bcon)\r
-               return 2;\r
-       return 0;\r
-}\r
-\r
-void OutputWinding (winding_t *w, FILE *glview)\r
-{\r
-       static  int     level = 128;\r
-       vec_t           light;\r
-       int                     i;\r
-\r
-       fprintf (glview, "%i\n", w->numpoints);\r
-       level+=28;\r
-       light = (level&255)/255.0;\r
-       for (i=0 ; i<w->numpoints ; i++)\r
-       {\r
-               fprintf (glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",\r
-                       w->p[i][0],\r
-                       w->p[i][1],\r
-                       w->p[i][2],\r
-                       light,\r
-                       light,\r
-                       light);\r
-       }\r
-       fprintf (glview, "\n");\r
-}\r
-\r
-/*\r
-=============\r
-OutputPortal\r
-=============\r
-*/\r
-void OutputPortal (portal_t *p, FILE *glview)\r
-{\r
-       winding_t       *w;\r
-       int             sides;\r
-\r
-       sides = PortalVisibleSides (p);\r
-       if (!sides)\r
-               return;\r
-\r
-       c_glfaces++;\r
-\r
-       w = p->winding;\r
-\r
-       if (sides == 2)         // back side\r
-               w = ReverseWinding (w);\r
-\r
-       OutputWinding (w, glview);\r
-\r
-       if (sides == 2)\r
-               FreeWinding(w);\r
-}\r
-\r
-/*\r
-=============\r
-WriteGLView_r\r
-=============\r
-*/\r
-void WriteGLView_r (node_t *node, FILE *glview)\r
-{\r
-       portal_t        *p, *nextp;\r
-\r
-       if (node->planenum != PLANENUM_LEAF)\r
-       {\r
-               WriteGLView_r (node->children[0], glview);\r
-               WriteGLView_r (node->children[1], glview);\r
-               return;\r
-       }\r
-\r
-       // write all the portals\r
-       for (p=node->portals ; p ; p=nextp)\r
-       {\r
-               if (p->nodes[0] == node)\r
-               {\r
-                       OutputPortal (p, glview);\r
-                       nextp = p->next[0];\r
-               }\r
-               else\r
-                       nextp = p->next[1];\r
-       }\r
-}\r
-\r
-/*\r
-=============\r
-WriteGLView\r
-=============\r
-*/\r
-void WriteGLView (tree_t *tree, char *source)\r
-{\r
-       char    name[1024];\r
-       FILE    *glview;\r
-\r
-       c_glfaces = 0;\r
-       sprintf (name, "%s%s.gl",outbase, source);\r
-       Sys_Printf ("Writing %s\n", name);\r
-\r
-       glview = fopen (name, "w");\r
-       if (!glview)\r
-               Error ("Couldn't open %s", name);\r
-       WriteGLView_r (tree->headnode, glview);\r
-       fclose (glview);\r
-\r
-       Sys_Printf ("%5i c_glfaces\n", c_glfaces);\r
-}\r
-\r
+/*
+Copyright (C) 1999-2007 id Software, Inc. and contributors.
+For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+This file is part of GtkRadiant.
+
+GtkRadiant is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+GtkRadiant is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GtkRadiant; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include "qbsp.h"
+
+int            c_glfaces;
+
+int PortalVisibleSides (portal_t *p)
+{
+       int             fcon, bcon;
+
+       if (!p->onnode)
+               return 0;               // outside
+
+       fcon = p->nodes[0]->contents;
+       bcon = p->nodes[1]->contents;
+
+       // same contents never create a face
+       if (fcon == bcon)
+               return 0;
+
+       // FIXME: is this correct now?
+       if (!fcon)
+               return 1;
+       if (!bcon)
+               return 2;
+       return 0;
+}
+
+void OutputWinding (winding_t *w, FILE *glview)
+{
+       static  int     level = 128;
+       vec_t           light;
+       int                     i;
+
+       fprintf (glview, "%i\n", w->numpoints);
+       level+=28;
+       light = (level&255)/255.0;
+       for (i=0 ; i<w->numpoints ; i++)
+       {
+               fprintf (glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
+                       w->p[i][0],
+                       w->p[i][1],
+                       w->p[i][2],
+                       light,
+                       light,
+                       light);
+       }
+       fprintf (glview, "\n");
+}
+
+/*
+=============
+OutputPortal
+=============
+*/
+void OutputPortal (portal_t *p, FILE *glview)
+{
+       winding_t       *w;
+       int             sides;
+
+       sides = PortalVisibleSides (p);
+       if (!sides)
+               return;
+
+       c_glfaces++;
+
+       w = p->winding;
+
+       if (sides == 2)         // back side
+               w = ReverseWinding (w);
+
+       OutputWinding (w, glview);
+
+       if (sides == 2)
+               FreeWinding(w);
+}
+
+/*
+=============
+WriteGLView_r
+=============
+*/
+void WriteGLView_r (node_t *node, FILE *glview)
+{
+       portal_t        *p, *nextp;
+
+       if (node->planenum != PLANENUM_LEAF)
+       {
+               WriteGLView_r (node->children[0], glview);
+               WriteGLView_r (node->children[1], glview);
+               return;
+       }
+
+       // write all the portals
+       for (p=node->portals ; p ; p=nextp)
+       {
+               if (p->nodes[0] == node)
+               {
+                       OutputPortal (p, glview);
+                       nextp = p->next[0];
+               }
+               else
+                       nextp = p->next[1];
+       }
+}
+
+/*
+=============
+WriteGLView
+=============
+*/
+void WriteGLView (tree_t *tree, char *source)
+{
+       char    name[1024];
+       FILE    *glview;
+
+       c_glfaces = 0;
+       sprintf (name, "%s%s.gl",outbase, source);
+       Sys_Printf ("Writing %s\n", name);
+
+       glview = fopen (name, "w");
+       if (!glview)
+               Error ("Couldn't open %s", name);
+       WriteGLView_r (tree->headnode, glview);
+       fclose (glview);
+
+       Sys_Printf ("%5i c_glfaces\n", c_glfaces);
+}
+