]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/camera/misc.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / contrib / camera / misc.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 \r
22 /*\r
23 Camera plugin for GtkRadiant\r
24 Copyright (C) 2002 Splash Damage Ltd.\r
25 */\r
26 \r
27 void Sys_ERROR( char* text, ... );\r
28 char* UnixToDosPath( char* path );\r
29 void ExtractFilePath( const char *path, char *dest );\r
30 const char* ExtractFilename( const char* path );\r
31 bool FileExists (const char *filename);\r
32 int Q_stricmp (const char *s1, const char *s2);\r
33 \r
34 typedef int fileHandle_t;\r
35 \r
36 #define qfalse false\r
37 #define qtrue true\r
38 \r
39 extern "C" {\r
40 // command buffer\r
41 void Cbuf_AddText( const char *text );\r
42 void Cbuf_Execute (void);\r
43 \r
44 // common\r
45 #ifndef CDECL\r
46 #ifdef _WIN32\r
47         #define CDECL __cdecl\r
48 #else\r
49         #define CDECL\r
50 #endif\r
51 #endif\r
52 \r
53 void CDECL Com_Error( int level, const char *error, ... );\r
54 void CDECL Com_Printf( const char *msg, ... );\r
55 void CDECL Com_DPrintf( const char *msg, ... );\r
56 void *Com_Allocate( int bytes );\r
57 void Com_Dealloc( void *ptr );\r
58 \r
59 // filesystem\r
60 int FS_Read( void *buffer, int len, fileHandle_t f );\r
61 int FS_Write( const void *buffer, int len, fileHandle_t h );\r
62 int FS_ReadFile( const char *qpath, void **buffer );\r
63 void FS_FreeFile( void *buffer );\r
64 int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueFILE );\r
65 fileHandle_t FS_FOpenFileWrite( const char *filename );\r
66 void FS_FCloseFile( fileHandle_t f );\r
67 }\r
68 \r
69 // vectors\r
70 #define DotProduct(a,b)                 ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])\r
71 #define VectorSubtract(a,b,c)   ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])\r
72 #define VectorAdd(a,b,c)                ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])\r
73 #define VectorCopy(a,b)                 ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])\r
74 \r
75 #define VectorScale(v, s, o)    ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))\r
76 #define VectorMA(v, s, b, o)    ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))\r
77 #define CrossProduct(a,b,c)             ((c)[0]=(a)[1]*(b)[2]-(a)[2]*(b)[1],(c)[1]=(a)[2]*(b)[0]-(a)[0]*(b)[2],(c)[2]=(a)[0]*(b)[1]-(a)[1]*(b)[0])\r
78 \r
79 #define DotProduct4(x,y)                ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])\r
80 #define VectorSubtract4(a,b,c)  ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])\r
81 #define VectorAdd4(a,b,c)               ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])\r
82 #define VectorCopy4(a,b)                ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\r
83 #define VectorScale4(v, s, o)   ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))\r
84 #define VectorMA4(v, s, b, o)   ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s),(o)[3]=(v)[3]+(b)[3]*(s))\r
85 \r
86 #define VectorClear(a)                  ((a)[0]=(a)[1]=(a)[2]=0)\r
87 #define VectorNegate(a,b)               ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])\r
88 #define VectorSet(v, x, y, z)   ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))\r
89 #define Vector4Copy(a,b)                ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\r
90 \r
91 #define SnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}\r