]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/camera/misc.h
merge branch work back into trunk
[xonotic/netradiant.git] / contrib / camera / misc.h
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
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.
11
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.
16
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
20 */
21
22 /*
23 Camera plugin for GtkRadiant
24 Copyright (C) 2002 Splash Damage Ltd.
25 */
26
27 void Sys_ERROR( char* text, ... );
28 char* UnixToDosPath( char* path );
29 void CAMERA_ExtractFilePath( const char *path, char *dest );
30 const char* ExtractFilename( const char* path );
31 bool FileExists (const char *filename);
32 int Q_stricmp (const char *s1, const char *s2);
33
34 typedef int fileHandle_t;
35
36 #define qfalse false
37 #define qtrue true
38
39 extern "C" {
40 // command buffer
41 void Cbuf_AddText( const char *text );
42 void Cbuf_Execute (void);
43
44 // common
45 #ifndef CDECL
46 #ifdef _WIN32
47         #define CDECL __cdecl
48 #else
49         #define CDECL
50 #endif
51 #endif
52
53 void CDECL Com_Error( int level, const char *error, ... );
54 void CDECL Com_Printf( const char *msg, ... );
55 void CDECL Com_DPrintf( const char *msg, ... );
56 void *Com_Allocate( int bytes );
57 void Com_Dealloc( void *ptr );
58
59 // filesystem
60 int FS_Read( void *buffer, int len, fileHandle_t f );
61 int FS_Write( const void *buffer, int len, fileHandle_t h );
62 int FS_ReadFile( const char *qpath, void **buffer );
63 void FS_FreeFile( void *buffer );
64 int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueFILE );
65 fileHandle_t FS_FOpenFileWrite( const char *filename );
66 void FS_FCloseFile( fileHandle_t f );
67 }
68
69 // vectors
70 #define DotProduct(a,b)                 ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
71 #define VectorSubtract(a,b,c)   ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
72 #define VectorAdd(a,b,c)                ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])
73 #define VectorCopy(a,b)                 ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
74
75 #define VectorScale(v, s, o)    ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
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))
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])
78
79 #define DotProduct4(x,y)                ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])
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])
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])
82 #define VectorCopy4(a,b)                ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
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))
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))
85
86 #define VectorClear(a)                  ((a)[0]=(a)[1]=(a)[2]=0)
87 #define VectorNegate(a,b)               ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
88 #define VectorSet(v, x, y, z)   ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))
89 #define Vector4Copy(a,b)                ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
90
91 #define SnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}