aboutsummaryrefslogtreecommitdiffstats
path: root/q3map/brush_primit.c
diff options
context:
space:
mode:
authorzakk <zakk@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-08-26 04:48:05 +0000
committerzakk <zakk@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-08-26 04:48:05 +0000
commit952c5c128f9efaea89d41d882c4ea3ade7df4591 (patch)
tree91b84d9be7afad7e99ac64a640a65b6cb5081900 /q3map/brush_primit.c
parentc2c2e0d25d6cdb7d42d7dc981a863f65f94f281d (diff)
downloadioquake3-aero-952c5c128f9efaea89d41d882c4ea3ade7df4591.tar.gz
ioquake3-aero-952c5c128f9efaea89d41d882c4ea3ade7df4591.zip
Itsa me, quake3io!
git-svn-id: svn://svn.icculus.org/quake3/trunk@2 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'q3map/brush_primit.c')
-rwxr-xr-xq3map/brush_primit.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/q3map/brush_primit.c b/q3map/brush_primit.c
new file mode 100755
index 0000000..5ec44cc
--- /dev/null
+++ b/q3map/brush_primit.c
@@ -0,0 +1,52 @@
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code 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.
+
+Quake III Arena source code 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 Foobar; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+#include "qbsp.h"
+
+
+// global flag
+int g_bBrushPrimit;
+
+// NOTE : ComputeAxisBase here and in editor code must always BE THE SAME !
+// WARNING : special case behaviour of atan2(y,x) <-> atan(y/x) might not be the same everywhere when x == 0
+// rotation by (0,RotY,RotZ) assigns X to normal
+void ComputeAxisBase(vec3_t normal,vec3_t texX,vec3_t texY)
+{
+ vec_t RotY,RotZ;
+ // do some cleaning
+ if (fabs(normal[0])<1e-6)
+ normal[0]=0.0f;
+ if (fabs(normal[1])<1e-6)
+ normal[1]=0.0f;
+ if (fabs(normal[2])<1e-6)
+ normal[2]=0.0f;
+ // compute the two rotations around Y and Z to rotate X to normal
+ RotY=-atan2(normal[2],sqrt(normal[1]*normal[1]+normal[0]*normal[0]));
+ RotZ=atan2(normal[1],normal[0]);
+ // rotate (0,1,0) and (0,0,1) to compute texX and texY
+ texX[0]=-sin(RotZ);
+ texX[1]=cos(RotZ);
+ texX[2]=0;
+ // the texY vector is along -Z ( T texture coorinates axis )
+ texY[0]=-sin(RotY)*cos(RotZ);
+ texY[1]=-sin(RotY)*sin(RotZ);
+ texY[2]=-cos(RotY);
+}