This is all seriously broken, but I'm committing it so that it can be

worked on by other people as well. :)
This commit is contained in:
Jeff Teunissen 2001-10-14 05:55:21 +00:00
parent 2dafd4a496
commit f7b0227299
38 changed files with 1023 additions and 655 deletions

View file

@ -1,22 +1,61 @@
#import "qedefs.h"
/*
CameraView.m
id cameraview_i;
BOOL timedrawing = 0;
Camera view object
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#include "Config.h"
#import <Foundation/NSGeometry.h>
#import <Foundation/NSObject.h>
#import "CameraView.h"
#import "Forge.h"
#import "Map.h"
#import "UserPath.h"
#import "ZView.h"
#import "render.h"
CameraView *cameraView;
BOOL timeDrawing = 0;
@implementation CameraView
/*
==================
initFrame:
==================
(id) initWithFrame: (NSRect)
Given a frame, set up our view.
*/
- initWithFrame: (NSRect) frameRect
- (id) initWithFrame: (NSRect) frameRect
{
int size;
[super initWithFrame: frameRect];
cameraview_i = self;
cameraView = self;
angles[0] = angles[1] = angles[2] = 0.0;
@ -28,7 +67,7 @@ initFrame:
move = 16;
bounds = [self bounds];
bounds = frameRect;
size = bounds.size.width * bounds.size.height;
zbuffer = malloc (size*4);
imagebuffer = malloc (size*4);
@ -72,7 +111,7 @@ initFrame:
{
sb_floor_dir = 1;
sb_floor_dist = 99999;
[map_i makeObjectsPerformSelector: @selector(feetToFloor)];
[map makeObjectsPerformSelector: @selector(feetToFloor)];
if (sb_floor_dist == 99999)
{
qprintf ("already on top floor");
@ -80,7 +119,7 @@ initFrame:
}
qprintf ("up floor");
origin[2] += sb_floor_dist;
[quakeed_i updateCamera];
[forge updateCamera];
return self;
}
@ -88,7 +127,7 @@ initFrame:
{
sb_floor_dir = -1;
sb_floor_dist = -99999;
[map_i makeAllPerform: @selector(feetToFloor)];
[map makeAllPerform: @selector(feetToFloor)];
if (sb_floor_dist == -99999)
{
qprintf ("already on bottom floor");
@ -96,7 +135,7 @@ initFrame:
}
qprintf ("down floor");
origin[2] += sb_floor_dist;
[quakeed_i updateCamera];
[forge updateCamera];
return self;
}
@ -119,7 +158,7 @@ homeView
[self matrixFromAngles];
[quakeed_i updateAll];
[forge updateAll];
qprintf ("homed view angle");
@ -129,7 +168,7 @@ homeView
- drawMode: (NSMatrix) sender
{
drawmode = [sender selectedColumn];
[quakeed_i updateCamera];
[forge updateCamera];
return self;
}
@ -137,7 +176,7 @@ homeView
{
drawmode = mode;
[mode_radio_i selectCellAtRow: 0 column: mode];
[quakeed_i updateCamera];
[forge updateCamera];
return self;
}
@ -223,7 +262,7 @@ float mid_x, mid_y;
float topscale = (240.0/3)/160;
float bottomscale = (240.0*2/3)/160;
extern plane_t frustum[5];
//extern plane_t frustum[5];
void MakeCampt (vec3_t in, campt_t *pt)
{
@ -267,7 +306,7 @@ void CameraMoveto(vec3_t p)
{
campt_t *pt;
if (upath->numberOfPoints > 2048)
if (userPath->numberOfPoints > 2048)
lineflush ();
pt = &campts[cam_cur];
@ -275,7 +314,7 @@ void CameraMoveto(vec3_t p)
MakeCampt (p,pt);
if (!pt->clipflags)
{ // onscreen, so move there immediately
UPmoveto (upath, pt->screen[0], pt->screen[1]);
UPmoveto (userPath, pt->screen[0], pt->screen[1]);
}
}
@ -283,7 +322,7 @@ void ClipLine (vec3_t p1, vec3_t p2, int planenum)
{
float d, d2, frac;
vec3_t new;
plane_t *pl;
mplane_t *pl;
float scale;
if (planenum == 5)
@ -291,12 +330,12 @@ void ClipLine (vec3_t p1, vec3_t p2, int planenum)
scale = mid_x/p1[2];
new[0] = mid_x + p1[0]*scale;
new[1] = mid_y + p1[1]*scale;
UPmoveto (upath, new[0], new[1]);
UPmoveto (userPath, new[0], new[1]);
scale = mid_x/p2[2];
new[0] = mid_x + p2[0]*scale;
new[1] = mid_y + p2[1]*scale;
UPlineto (upath, new[0], new[1]);
UPlineto (userPath, new[0], new[1]);
return;
}
@ -349,8 +388,8 @@ void CameraLineto(vec3_t p)
if (! bits )
{
c_on++;
UPmoveto (upath, p1->screen[0], p1->screen[1]);
UPlineto (upath, p2->screen[0], p2->screen[1]);
UPmoveto (userPath, p1->screen[0], p1->screen[1]);
UPlineto (userPath, p2->screen[0], p2->screen[1]);
return; // entirely on screen
}
@ -391,7 +430,7 @@ drawSolid
//
// render the setbrushes
//
[map_i makeAllPerform: @selector(CameraRenderSelf)];
[map makeAllPerform: @selector(CameraRenderSelf)];
//
// display the output
@ -445,7 +484,7 @@ drawWire
// draw all entities
linestart (0,0,0);
[map_i makeUnselectedPerform: @selector(CameraDrawSelf)];
[map makeUnselectedPerform: @selector(CameraDrawSelf)];
lineflush ();
return self;
@ -460,7 +499,7 @@ drawSelf
{
static float drawtime; // static to shut up compiler warning
if (timedrawing)
if (timeDrawing)
drawtime = I_FloatTime ();
if (drawmode == dr_texture || drawmode == dr_flat)
@ -468,7 +507,7 @@ drawSelf
else
[self drawWire: rects];
if (timedrawing) {
if (timeDrawing) {
// NSPing ();
drawtime = I_FloatTime() - drawtime;
printf ("CameraView drawtime: %5.3f\n", drawtime);
@ -591,7 +630,7 @@ modalMoveLoop
//
if ([event modifierFlags] & NSShiftKeyMask)
{
ent = [quakemap_i selectedEntity];
ent = [quakemap selectedEntity];
if (ent)
{
[ent origin: temp];
@ -607,7 +646,7 @@ modalMoveLoop
drawentry:
// instance draw new frame
[quakeed_i newinstance];
[forge newinstance];
[self display];
event = [NSApp nextEventMatchingMask: eventMask
@ -656,7 +695,7 @@ XYmouseDown
movemod[2] = 0;
}
[self modalMoveLoop: pt : movemod : xyview_i];
[self modalMoveLoop: pt : movemod : xyView];
return YES;
}
@ -679,7 +718,7 @@ ZmouseDown
movemod[1] = 0;
movemod[2] = 1;
[self modalMoveLoop: pt : movemod : zview_i];
[self modalMoveLoop: pt : movemod : zView];
return YES;
}
@ -719,7 +758,7 @@ viewDrag:
[self matrixFromAngles];
drawentry:
[quakeed_i newinstance];
[forge newinstance];
[self display];
event = [NSApp nextEventMatchingMask: eventMask
@ -772,20 +811,20 @@ mouseDown
// bare click to select a texture
if (!flags) {
[map_i getTextureRay: p1 : p2];
[map getTextureRay: p1 : p2];
return;
}
// shift click to select / deselect a brush from the world
if (flags == NSShiftKeyMask) {
[map_i selectRay: p1 : p2 : NO];
[map selectRay: p1 : p2 : NO];
return;
}
// cmd-shift click to set a target/targetname entity connection
if (flags == (NSShiftKeyMask | NSCommandKeyMask)) {
[map_i entityConnect: p1 : p2];
[map entityConnect: p1 : p2];
return;
}
@ -796,8 +835,8 @@ mouseDown
NopSound ();
return;
}
[map_i setTextureRay: p1 : p2 : YES];
[quakeed_i updateAll];
[map setTextureRay: p1 : p2 : YES];
[forge updateAll];
return;
}
@ -808,8 +847,8 @@ mouseDown
NopSound ();
return;
}
[map_i setTextureRay: p1 : p2 : NO];
[quakeed_i updateAll];
[map setTextureRay: p1 : p2 : NO];
[forge updateAll];
return;
}
@ -874,62 +913,62 @@ keyDown
case 'A':
angles[0] += M_PI/8;
[self matrixFromAngles];
[quakeed_i updateCamera];
[forge updateCamera];
return;
case 'z':
case 'Z':
angles[0] -= M_PI/8;
[self matrixFromAngles];
[quakeed_i updateCamera];
[forge updateCamera];
return;
case NSRightArrowFunctionKey:
angles[1] -= M_PI*move/(64*2);
[self matrixFromAngles];
[quakeed_i updateCamera];
[forge updateCamera];
break;
case NSLeftArrowFunctionKey:
angles[1] += M_PI*move/(64*2);
[self matrixFromAngles];
[quakeed_i updateCamera];
[forge updateCamera];
break;
case NSUpArrowFunctionKey:
origin[0] += move*cos(angles[1]);
origin[1] += move*sin(angles[1]);
[quakeed_i updateCamera];
[forge updateCamera];
break;
case NSDownArrowFunctionKey:
origin[0] -= move*cos(angles[1]);
origin[1] -= move*sin(angles[1]);
[quakeed_i updateCamera];
[forge updateCamera];
break;
case '.':
origin[0] += move*cos(angles[1]-M_PI_2);
origin[1] += move*sin(angles[1]-M_PI_2);
[quakeed_i updateCamera];
[forge updateCamera];
break;
case ',':
origin[0] -= move*cos(angles[1]-M_PI_2);
origin[1] -= move*sin(angles[1]-M_PI_2);
[quakeed_i updateCamera];
[forge updateCamera];
break;
case 'd':
case 'D':
origin[2] += move;
[quakeed_i updateCamera];
[forge updateCamera];
break;
case 'c':
case 'C':
origin[2] -= move;
[quakeed_i updateCamera];
[forge updateCamera];
break;
}
return;

View file

@ -1,14 +1,56 @@
/*
Clipper.h
#include "qedefs.h"
Clipping plane class
id clipper_i;
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#include <QF/mathlib.h>
#include <QF/bspfile.h>
#import <AppKit/NSGraphics.h>
#import <AppKit/DPSOperators.h>
#import "CameraView.h"
#import "Clipper.h"
#import "Forge.h"
#import "Map.h"
#import "SetBrush.h"
#import "XYView.h"
#import "ZView.h"
Clipper *clipper;
@implementation Clipper
- init
{
[super init];
clipper_i = self;
clipper = self;
return self;
}
@ -37,7 +79,7 @@ id clipper_i;
VectorCopy (temp, pos[2]);
break;
default:
qprintf ("no clip plane");
NSLog (@"No clipping plane");
NSBeep ();
}
return self;
@ -70,7 +112,7 @@ id clipper_i;
if ( !norm[0] && !norm[1] && !norm[2] )
return NO;
[texturepalette_i getTextureDef: &f->texture];
[texturepalette_i setTextureDef: &f->texture];
return YES;
}
@ -85,18 +127,18 @@ XYClick
int i;
vec3_t new;
new[0] = [xyview_i snapToGrid: pt.x];
new[1] = [xyview_i snapToGrid: pt.y];
new[2] = [map_i currentMinZ];
new[0] = [xyView snapToGrid: pt.x];
new[1] = [xyView snapToGrid: pt.y];
new[2] = [map currentMinZ];
// see if a point is already there
for (i=0 ; i<num ; i++) {
if (new[0] == pos[i][0] && new[1] == pos[i][1]) {
if (pos[i][2] == [map_i currentMinZ])
pos[i][2] = [map_i currentMaxZ];
if (pos[i][2] == [map currentMinZ])
pos[i][2] = [map currentMaxZ];
else
pos[i][2] = [map_i currentMinZ];
[quakeed_i updateAll];
pos[i][2] = [map currentMinZ];
[forge updateAll];
return self;
}
}
@ -108,7 +150,7 @@ XYClick
VectorCopy (new, pos[num]);
num++;
[quakeed_i updateAll];
[forge updateAll];
return self;
}
@ -138,21 +180,20 @@ XYDrag
- carve
{
[map_i makeSelectedPerform: @selector(carveByClipper)];
[map makeSelectedPerform: @selector(carveByClipper)];
num = 0;
return self;
}
- cameraDrawSelf
- (void) cameraDrawSelf
{
vec3_t mid;
int i;
linecolor (1,0.5,0);
linecolor (1, 0.5, 0);
for (i=0 ; i<num ; i++)
{
for (i = 0; i < num; i++) {
VectorCopy (pos[i], mid);
mid[0] -= 8;
mid[1] -= 8;
@ -170,49 +211,47 @@ XYDrag
CameraLineto (mid);
}
return self;
return;
}
- XYDrawSelf
- (void) xyDrawSelf
{
int i;
char text[8];
PSsetrgbcolor (1,0.5,0);
PSselectfont("Helvetica-Medium",10/[xyview_i currentScale]);
PSrotate(0);
PSsetrgbcolor (1, 0.5, 0);
PSselectfont ("Helvetica-Medium", 10 / [xyView currentScale]);
PSrotate (0);
for (i=0 ; i<num ; i++)
{
PSmoveto (pos[i][0]-4, pos[i][1]-4);
for (i = 0; i < num; i++) {
PSmoveto (pos[i][0] - 4, pos[i][1] - 4);
sprintf (text, "%i", i);
PSshow (text);
PSstroke ();
PSarc ( pos[i][0], pos[i][1], 10, 0, 360);
PSarc (pos[i][0], pos[i][1], 10, 0, 360);
PSstroke ();
}
return self;
return;
}
- ZDrawSelf
- (void) zDrawSelf
{
int i;
char text[8];
PSsetrgbcolor (1,0.5,0);
PSselectfont("Helvetica-Medium",10/[zview_i currentScale]);
PSrotate(0);
PSsetrgbcolor (1, 0.5, 0);
PSselectfont ("Helvetica-Medium", 10 / [zView currentScale]);
PSrotate (0);
for (i=0 ; i<num ; i++)
{
PSmoveto (-28+i*8 - 4, pos[i][2]-4);
for (i = 0; i < num; i++) {
PSmoveto ((-28 + (i * 8)) - 4, pos[i][2] - 4);
sprintf (text, "%i", i);
PSshow (text);
PSstroke ();
PSarc ( -28+i*8, pos[i][2], 10, 0, 360);
PSarc ((-28 + (i * 8)), pos[i][2], 10, 0, 360);
PSstroke ();
}
return self;
return;
}
@end

Binary file not shown.

View file

@ -1,5 +1,5 @@
#include "qedefs.h"
#import "Entity.h"
@implementation Entity
@ -374,7 +374,7 @@ int nument;
if (![self count] && esize == esize_model)
{
printf ("WARNING:Entity with no brushes and esize_model\n");
[texturepalette_i getTextureDef: &td];
[texturepalette_i setTextureDef: &td];
for (i=0 ; i<3 ; i++)
{
emins[i] = org[i] - 8;

View file

@ -10,8 +10,8 @@
#include <sys/types.h>
#include <signal.h>
extern Preferences *prefs;
extern Preferences *prefs;
extern Project *project;
id quakeed_i;
id entclasses_i;
@ -75,7 +75,7 @@ void DisplayCmdOutput (void)
output = [NSString stringWithContentsOfFile: commandOutput];
unlink ([commandOutput cString]);
[project_i addToOutput: output];
[project addToOutput: output];
[output release];
if ([prefs objectForKey: ShowBSPOutput])
@ -379,7 +379,7 @@ App delegate methods
g_cmd_out_i = cmd_out_i; // for qprintf
prefs = [Preferences sharedInstance];
[project_i initProject];
[project initProject];
[xyview_i setModeRadio: xy_drawmode_i]; // because xy view is inside
// scrollview and can't be
@ -445,7 +445,7 @@ App delegate methods
- (void) openProject: (id) sender
{
[project_i openProject];
[project openProject];
return;
}
@ -660,7 +660,7 @@ saveBSP
//
// write the command to the bsp host
//
destdir = [project_i finalMapDirectory];
destdir = [project finalMapDirectory];
bsppath = [[destdir
stringByAppendingString: @"/"]
@ -672,8 +672,8 @@ saveBSP
NSLog (@"system: %s", expandedcmd);
[project_i addToOutput: @"\n\n========= BUSY =========\n\n"];
[project_i addToOutput: expandedcmd];
[project addToOutput: @"\n\n========= BUSY =========\n\n"];
[project addToOutput: expandedcmd];
if ([prefs objectForKey: ShowBSPOutput])
[inspcontrol_i changeInspectorTo:i_output];
@ -703,31 +703,31 @@ saveBSP
- (void) BSP_Full: (id) sender
{
[self saveBSP: [project_i fullVisCommand] dialog: NO];
[self saveBSP: [project fullVisCommand] dialog: NO];
return;
}
- (void) BSP_FastVis: (id) sender
{
[self saveBSP: [project_i fastVisCommand] dialog: NO];
[self saveBSP: [project fastVisCommand] dialog: NO];
return;
}
- (void) BSP_NoVis: (id) sender
{
[self saveBSP: [project_i noVisCommand] dialog: NO];
[self saveBSP: [project noVisCommand] dialog: NO];
return;
}
- (void) BSP_relight: (id) sender
{
[self saveBSP: [project_i relightCommand] dialog: NO];
[self saveBSP: [project relightCommand] dialog: NO];
return;
}
- (void) BSP_entities: (id) sender
{
[self saveBSP: [project_i entitiesCommand] dialog: NO];
[self saveBSP: [project entitiesCommand] dialog: NO];
return;
}
@ -740,7 +740,7 @@ saveBSP
kill (bsppid, 9);
// CheckCmdDone (cmdte, 0, NULL);
[project_i addToOutput: @"\n\n========= STOPPED =========\n\n"];
[project addToOutput: @"\n\n========= STOPPED =========\n\n"];
return;
}
@ -781,7 +781,7 @@ open
id fileTypes = [NSArray arrayWithObject: @"map"];
if ([openPanel
runModalForDirectory: [project_i mapDirectory]
runModalForDirectory: [project mapDirectory]
file: @""
types: fileTypes] != NSOKButton)
return;
@ -829,7 +829,7 @@ save:
dir = [[filename lastPathComponent] stringByDeletingPathExtension];
[panel_i setRequiredFileType: @"map"];
if ([panel_i runModalForDirectory: [project_i mapDirectory] file: dir] != NSOKButton)
if ([panel_i runModalForDirectory: [project mapDirectory] file: dir] != NSOKButton)
return;
[filename setString: [panel_i filename]];

View file

@ -114,7 +114,6 @@ Forge_OBJC_FILES= \
PopScrollView.m \
Preferences.m \
Project.m \
SetBrush.m \
TexturePalette.m \
TextureView.m \
Things.m \
@ -124,13 +123,13 @@ Forge_OBJC_FILES= \
ZView.m \
misc.m \
render.m
# SetBrush.m \
#
# C files
#
Forge_C_FILES= \
cmdlib.c \
mathlib.c
cmdlib.c
-include GNUmakefile.preamble
-include GNUmakefile.local

View file

@ -1,3 +1,34 @@
/*
Brush.h
(description)
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <appkit/appkit.h>
#import "SetBrush.h"
#import "EditWindow.h"

View file

@ -1,16 +1,38 @@
#import <AppKit/AppKit.h>
#import "mathlib.h"
/*
CameraView.h
Perspective viwer class definitions
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#include <QF/mathlib.h>
#import "SetBrush.h"
extern id cameraview_i;
extern byte renderlist[1024*1024*4];
void CameraMoveto (vec3_t p);
void CameraLineto (vec3_t p);
extern BOOL timedrawing;
@interface CameraView: NSView
{
float angles[3];
@ -50,7 +72,7 @@ extern BOOL timedrawing;
- drawMode: (NSMatrix) sender;
- setDrawMode: (drawmode_t) mode;
- homeView: sender;
- (id) homeView: (id) sender;
- XYDrawSelf; // for drawing viewpoint in XY view
- ZDrawSelf; // for drawing viewpoint in XY view
@ -62,3 +84,9 @@ extern BOOL timedrawing;
@end
extern CameraView *cameraView;
extern byte renderList[1024*1024*4];
extern BOOL timeDrawing;
void CameraMoveto (vec3_t p);
void CameraLineto (vec3_t p);

View file

@ -1,11 +1,47 @@
/*
Clipper.h
extern id clipper_i;
Clipping plane class definition
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#include <QF/mathlib.h>
#include <QF/bspfile.h>
#import <Foundation/NSGeometry.h>
#import <Foundation/NSObject.h>
#import "SetBrush.h"
@interface Clipper: NSObject
{
int num;
vec3_t pos[3];
plane_t plane;
mplane_t plane;
}
- (BOOL) hide;
@ -16,9 +52,10 @@ extern id clipper_i;
- flipNormal;
- (BOOL) getFace: (face_t *) pl;
- cameraDrawSelf;
- XYDrawSelf;
- ZDrawSelf;
- (void) cameraDrawSelf;
- (void) xyDrawSelf;
- (void) zDrawSelf;
@end
extern Clipper *clipper;

View file

@ -1,47 +0,0 @@
#import <AppKit/AppKit.h>
typedef struct
{
char *key;
char *value;
} dict_t;
@interface Dict:Storage
{
}
- initFromFile:(FILE *)fp;
- (id) parseMultipleFrom:(char *)value;
- (int) getValueUnits:(char *)key;
- delString:(char *)string fromValue:(char *)key;
- addString:(char *)string toValue:(char *)key;
- (char *)convertListToString:(id)list;
- (char *)getStringFor:(char *)name;
- removeKeyword:(char *)key;
- (unsigned int)getValueFor:(char *)name;
- changeStringFor:(char *)key to:(char *)value;
- (dict_t *) findKeyword:(char *)key;
- writeBlockTo:(FILE *)fp;
- writeFile:(char *)path;
// INTERNAL
- init;
- (id) parseBraceBlock:(FILE *)fp;
- setupMultiple:(char *)value;
- (char *)getNextParameter;
@end
int GetNextChar(FILE *fp);
void CopyUntilWhitespc(FILE *fp,char *buffer);
void CopyUntilQuote(FILE *fp,char *buffer);
int FindBrace(FILE *fp);
int FindQuote(FILE *fp);
int FindWhitespc(FILE *fp);
int FindNonwhitespc(FILE *fp);
char *FindWhitespcInBuffer(char *buffer);
char *FindNonwhitespcInBuffer(char *buffer);

View file

@ -1,40 +1,62 @@
/*
Entity.h
#define MAX_KEY 64
#define MAX_VALUE 128
typedef struct epair_s
{
struct epair_s *next;
char key[MAX_KEY];
char value[MAX_VALUE];
} epair_t;
(description)
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <Foundation/NSObject.h>
@class NSArray, NSDictionary;
// an Entity is a list of brush objects, with additional key / value info
@interface Entity: NSMutableArray
@interface Entity: NSObject <NSCopying, NSMutableCopying>
{
epair_t *epairs;
BOOL modifiable;
id brushes;
id fields;
}
- initClass: (char *)classname;
- initFromTokens;
- initWithClassname: (NSString *)classname;
- initWithTokens;
- (oneway void) release;
- (NSString *) targetname;
- (BOOL)modifiable;
- setModifiable: (BOOL)m;
- writeToFile: (NSString *) filename region: (BOOL) reg;
- (char *)targetname;
- writeToFILE: (FILE *)f region:(BOOL)reg;
- (char *)valueForQKey: (char *)k;
- getVector: (vec3_t)v forKey: (char *)k;
- setKey:(char *)k toValue:(char *)v;
- (int)numPairs;
- (epair_t *)epairs;
- removeKeyPair: (char *)key;
- (id) objectForKey: (NSString *) k;
- (Brush *) brushAtIndex: (unsigned) index;
- (id) fieldForKey: (
@end
@class NSMutableArray, NSMutableDictionary;
@interface MutableEntity: Entity
{
}
@end

View file

@ -1,8 +1,37 @@
/*
EntityArray.h
(description)
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <Foundation/Foundation.h>
#import "mathlib.h"
extern id entity_classes_i;
@interface EntityArray: NSMutableArray
{
id nullclass;
@ -15,3 +44,4 @@ extern id entity_classes_i;
@end
extern EntityArray *entityClasses;

View file

@ -1,3 +1,34 @@
/*
EntityClass.h
EntityClass (used by Entity) class definitions
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <Foundation/Foundation.h>
#import "mathlib.h"
@ -22,6 +53,6 @@ typedef enum {esize_model, esize_fixed} esize_t;
- (float *)maxs; // only for esize_fixed
- (float *)drawColor;
- (char *)comments;
- (char *)flagName: (unsigned)flagnum;
- (char *)flagName: (unsigned) flagnum;
@end

View file

@ -1,18 +1,35 @@
/*
Forge.h
extern id quakeed_i;
Main controller object class definitions
extern BOOL filter_light, filter_path, filter_entities;
extern BOOL filter_clip_brushes, filter_water_brushes, filter_world;
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
extern UserPath *upath;
This program 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.
extern id g_cmd_out_i;
This program 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.
double I_FloatTime (void);
See the GNU General Public License for more details.
void NopSound (void);
You should have received a copy of the GNU General Public
License along with this program; if not, write to:
void qprintf (char *fmt, ...); // prints text to cmd_out_i
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <AppKit/NSWindow.h>
@interface Forge: NSWindow
{
@ -100,3 +117,16 @@ void qprintf (char *fmt, ...); // prints text to cmd_out_i
@end
extern Forge *forge;
extern BOOL filter_light, filter_path, filter_entities;
extern BOOL filter_clip_brushes, filter_water_brushes, filter_world;
extern id g_cmd_out_i;
double I_FloatTime (void);
void NopSound (void);
void qprintf (char *fmt, ...); // prints text to cmd_out_i

View file

@ -1,3 +1,33 @@
/*
InspectorControl.h
Inspector control class definitions
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <AppKit/AppKit.h>

View file

@ -1,3 +1,33 @@
/*
KeypairView.h
Key pair viewer class definitions
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
extern id keypairview_i;

View file

@ -1,8 +1,36 @@
/*
Map.h
Map class definition for Forge
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
// Map is a collection of Entity objects
extern id map_i;
@interface Map: NSMutableArray
{
id currentEntity;
@ -66,3 +94,5 @@ extern id map_i;
- selectCompleteEntity: sender;
@end
extern Map *map;

View file

@ -1,3 +1,34 @@
/*
PopScrollView.h
(description)
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <AppKit/AppKit.h>
@interface PopScrollView: NSScrollView

View file

@ -3,8 +3,7 @@
Preferences class definition for Forge
Copyright (C) 1996 Id Software, Inc.
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@ -89,3 +88,5 @@
+ (void) savePreferencesToDefaults: (NSDictionary *) dict;
@end
extern Preferences *prefs;

View file

@ -1,5 +1,35 @@
/*
Project.h
Project class definition for Forge
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <AppKit/AppKit.h>
#include <sys/stat.h>
#define EntSubdir @"progs"
#define MapSubdir @"maps"
@ -99,5 +129,4 @@
@end
void changeString(char cf, char ct, char *string);
void changeString (char cf, char ct, char *string);

View file

@ -1,25 +1,52 @@
/*
SetBrush.h
SetBrush class definition for Forge
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import "TexturePalette.h"
#import "XYView.h"
#define MAX_FACES 16
typedef float vec5_t[5];
typedef struct
{
typedef struct {
int numpoints;
vec5_t points[8]; // variable sized
} winding_t;
#define MAX_POINTS_ON_WINDING 64
typedef struct
{
typedef struct {
vec3_t normal;
float dist;
} plane_t;
typedef struct
{
typedef struct {
// implicit rep
vec3_t planepts[3];
texturedef_t texture;
@ -41,11 +68,10 @@ typedef struct
winding_t *ClipWinding (winding_t *in, plane_t *split);
winding_t *CopyWinding (winding_t *w);
winding_t *CopyWinding (winding_t *w);
winding_t *NewWinding (int points);
@interface SetBrush : NSObject <NSCopying>
@interface SetBrush: NSObject <NSCopying>
{
BOOL regioned; // not active
BOOL selected;

View file

@ -1,7 +1,43 @@
/*
TexturePalette.h
Texture Palette handling for Forge
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <Foundation/NSGeometry.h>
#import <Foundation/NSString.h>
#import <Foundation/NSObject.h>
#import <AppKit/NSBitmapImageRep.h>
typedef union pixel32_u {
byte chan[4];
unsigned p;
byte chan[4];
unsigned int p;
} pixel32_t;
@ -13,25 +49,23 @@ typedef struct texturedef_s {
} texturedef_t;
typedef struct qtexture_s {
char name[16];
int width;
int height;
NSString *name;
NSSize size;
NSBitmapImageRep *rep;
void *data;
pixel32_t flatcolor;
void *data;
pixel32_t flatcolor;
} qtexture_t;
#define MAX_TEXTURES 1024
extern int tex_count;
extern int tex_count;
extern qtexture_t qtextures[MAX_TEXTURES];
void TEX_InitFromWad (char *path);
qtexture_t *TEX_ForName (char *name);
void TEX_InitFromWad (NSString *path);
qtexture_t *TEX_ForName (NSString *name);
typedef struct {
id image; // NXImage
id image; // NSImage
NSRect r;
char *name;
int index;
@ -43,7 +77,7 @@ typedef struct {
extern id texturepalette_i;
@interface TexturePalette:Object
@interface TexturePalette: NSObject
{
char currentwad[1024];
id textureList_i;

View file

@ -1,4 +1,33 @@
/*
TextureView.h
Texture viewer class definition for Forge
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
@interface TextureView: NSView
{

View file

@ -1,3 +1,33 @@
/*
Things.h
(description)
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <AppKit/AppKit.h>
@ -5,7 +35,7 @@ extern id things_i;
#define ENTITYNAMEKEY "spawn"
@interface Things:Object
@interface Things: Object
{
id entity_browser_i; // browser
id entity_comment_i; // scrolling text window

View file

@ -45,6 +45,8 @@ typedef struct _UP {
BOOL ping;
} UserPath;
extern UserPath *userPath;
/* UserPath functions */
NSZone *userPathZone();
UserPath *newUserPath();

View file

@ -1,29 +1,44 @@
/*
XYView.h
X/Y "perspective" viewer class definitions
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#include <QF/mathlib.h>
#import <AppKit/AppKit.h>
#import "mathlib.h"
#import "SetBrush.h"
extern id xyview_i;
#define MINSCALE 0.125
#define MAXSCALE 2.0
extern vec3_t xy_viewnormal; // v_forward for xy view
extern float xy_viewdist; // clip behind this plane
extern NSRect xy_draw_rect;
void linestart (float r, float g, float b);
void lineflush (void);
void linecolor (float r, float g, float b);
void XYmoveto (vec3_t pt);
void XYlineto (vec3_t pt);
typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
@interface XYView: NSView
{
NSRect realbounds, newrect, combinedrect;
@ -47,20 +62,34 @@ typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
- setModeRadio: m;
- drawMode: sender;
- setDrawMode: (drawmode_t)mode;
- setDrawMode: (drawmode_t) mode;
- newSuperBounds;
- newRealBounds: (NSRect *)nb;
- newRealBounds: (NSRect) nb;
- addToScrollRange: (float)x :(float)y;
- setOrigin: (NSPoint *)pt scale: (float)sc;
- addToScrollRange: (float) x : (float) y;
- setOrigin: (NSPoint) pt scale: (float) sc;
- centerOn: (vec3_t)org;
- drawMode: sender;
- superviewChanged;
- (int)gridsize;
- (float)snapToGrid: (float)f;
- (int) gridsize;
- (float) snapToGrid: (float) f;
@end
extern XYView *xyView;
extern vec3_t xy_viewnormal; // v_forward for xy view
extern float xy_viewdist; // clip behind this plane
extern NSRect xy_draw_rect;
void linestart (float r, float g, float b);
void lineflush (void);
void linecolor (float r, float g, float b);
void XYmoveto (vec3_t pt);
void XYlineto (vec3_t pt);

View file

@ -1,3 +1,34 @@
/*
ZScrollView.h
Depth scroller class definition
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <AppKit/AppKit.h>
@interface ZScrollView: NSScrollView
@ -5,7 +36,7 @@
id button1;
}
- initFrame:(const NSRect *)frameRect button1: b1;
- tile;
- (id) initWithFrame: (const NSRect) frameRect button1: (id) b1;
- (void) tile;
@end

View file

@ -1,12 +1,37 @@
/*
ZView.h
#import <AppKit/AppKit.h>
#import "mathlib.h"
Depth viewer class definition
extern id zview_i;
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
// zplane controls the objects displayed in the xyview
extern float zplane;
extern float zplanedir;
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <AppKit/NSView.h>
#include <QF/mathlib.h>
@interface ZView: NSView
{
@ -19,6 +44,8 @@ extern float zplanedir;
vec3_t origin;
}
- (float) currentScale;
- clearBounds;
- getBounds: (float *)top :(float *)bottom;
@ -36,7 +63,12 @@ extern float zplanedir;
- setXYOrigin: (NSPoint) point;
- setOrigin: (NSPoint *)pt scale: (float)sc;
- setOrigin: (NSPoint) pt scale: (float) sc;
@end
extern ZView *zView;
// zplane controls the objects displayed in the xyview
extern float zplane;
extern float zplanedir;

View file

@ -101,7 +101,6 @@ extern qboolean com_eof;
char *copystring(char *s);
void CRC_Init(unsigned short *crcvalue);
void CRC_ProcessByte(unsigned short *crcvalue, byte data);
unsigned short CRC_Value(unsigned short crcvalue);
@ -112,5 +111,4 @@ void CopyFile (char *from, char *to);
extern qboolean archive;
extern char archivedir[1024];
#endif

View file

@ -1,67 +0,0 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
#ifndef __MATHLIB__
#define __MATHLIB__
// mathlib.h
#include <math.h>
#ifdef DOUBLEVEC_T
typedef double vec_t;
#else
typedef float vec_t;
#endif
typedef vec_t vec3_t[3];
#define SIDE_FRONT 0
#define SIDE_ON 2
#define SIDE_BACK 1
#define SIDE_CROSS -2
#define Q_PI 3.14159265358979323846
extern vec3_t vec3_origin;
#define EQUAL_EPSILON 0.001
qboolean VectorCompare (vec3_t v1, vec3_t v2);
#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
vec_t Q_rint (vec_t in);
vec_t _DotProduct (vec3_t v1, vec3_t v2);
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
void _VectorCopy (vec3_t in, vec3_t out);
double VectorLength(vec3_t v);
void VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc);
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
vec_t VectorNormalize (vec3_t v);
void VectorInverse (vec3_t v);
void VectorScale (vec3_t v, vec_t scale, vec3_t out);
#endif

View file

@ -1,59 +0,0 @@
#import <AppKit/AppKit.h>
#import <ctype.h>
#import <sys/types.h>
#import <sys/dir.h>
#import <sys/time.h>
#import <unistd.h>
#import "UserPath.h"
#import "cmdlib.h"
#import "mathlib.h"
#import "EntityArray.h"
#import "EntityClass.h"
#import "Project.h"
#import "Forge.h"
#import "Map.h"
#import "TexturePalette.h"
#import "SetBrush.h"
#import "render.h"
#import "Entity.h"
#import "XYView.h"
#import "CameraView.h"
#import "ZView.h"
#import "ZScrollView.h"
#import "Preferences.h"
#import "InspectorControl.h"
#import "PopScrollView.h"
#import "KeypairView.h"
#import "Things.h"
#import "TextureView.h"
#import "Clipper.h"
void PrintRect (NSRect *r);
int FileTime (char *path);
void Sys_UpdateFile (char *path, char *netpath);
void CleanupName (char *in, char *out);
extern BOOL in_error;
void Error (char *error, ...);
#define MAXTOKEN 128
extern char token[MAXTOKEN];
extern int scriptline;
void StartTokenParsing (char *data);
qboolean GetToken (qboolean crossline); // returns false at eof
void UngetToken ();
extern NSString *commandOutput;
extern NSString *developerLogFile;
extern NSString *tempSaveFile;
extern NSString *autoSaveFile;
extern NSString *errorSaveFile;
extern char *debugname;

View file

@ -1,3 +1,33 @@
/*
render.h
Software renderer definitions and prototypes
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
This program 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.
This program 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 this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
extern int r_width, r_height;
extern unsigned *r_picbuffer;

View file

@ -1,5 +1,8 @@
#include "qedefs.h"
#import "Project.h"
extern Project *project;
id map_i;
@ -200,7 +203,8 @@ readMapFile
*/
- (void) readMapFile: (NSString *) fname
{
char *dat, *cl;
NSString *dat;
char *cl;
id new;
id ent;
int i, c;
@ -211,8 +215,8 @@ readMapFile
NSLog (@"loading %s\n", fname);
LoadFile ((char *) [fname cString], (void **) &dat);
StartTokenParsing (dat);
LoadFile ((char *) [fname lossyCString], (void **) &dat);
StartTokenParsing ((char *) [dat lossyCString]);
do {
new = [[Entity alloc] initFromTokens];
@ -228,13 +232,12 @@ readMapFile
[self addSelected];
// load the apropriate texture wad
dat = [currentEntity valueForQKey: "wad"];
if (dat && dat[0]) {
if (dat[0] == '/') { // remove old style fullpaths
[currentEntity removeKeyPair: "wad"];
if ((dat = [currentEntity objectForKey: @"wad"])) {
if ([dat hasPrefix: @"/"]) { // remove old style fullpaths
[currentEntity removeObjectForKey: @"wad"];
} else {
if (strcmp ([texturepalette_i currentWad], dat) )
[project_i setTextureWad: dat];
if (!([[texturepalette_i currentWad] isEqualToString: dat]))
[project setTextureWad: dat];
}
}
@ -588,7 +591,7 @@ setTextureRay
return self;
}
[texturepalette_i getTextureDef: &td];
[texturepalette_i setTextureDef: &td];
[quakeed_i disableFlushWindow];
if (allsides)

View file

@ -30,6 +30,8 @@
#import "Preferences.h"
id prefs;
static NSDictionary *defaultValues (void) {
static NSDictionary *dict = nil;
if (!dict) {
@ -59,10 +61,15 @@ static Preferences *sharedInstance = nil;
+ (void) saveDefaults
{
if (sharedInstance) {
[Preferences savePreferencesToDefaults: [sharedInstance preferences]];
[self savePreferencesToDefaults: [sharedInstance preferences]];
}
}
- (void) saveDefaults: (id) sender
{
[[self class] saveDefaults];
}
- (void) loadDefaults
{
if (currentValues)
@ -74,7 +81,7 @@ static Preferences *sharedInstance = nil;
+ (Preferences *) sharedInstance
{
return (sharedInstance ? sharedInstance : [[self alloc] init]);
return (sharedInstance ? sharedInstance : [[self alloc] init]);
}
- (id) init
@ -86,6 +93,12 @@ static Preferences *sharedInstance = nil;
currentValues = [[[self class] preferencesFromDefaults] copyWithZone:[self zone]];
[self discardDisplayedValues];
sharedInstance = self;
prefs = sharedInstance;
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(saveDefaults:)
name: @"NSApplicationWillTerminateNotification"
object: nil];
}
return sharedInstance;
}

View file

@ -8,13 +8,13 @@
#import "Preferences.h"
id project_i;
Project * project;
@implementation Project
- init
{
project_i = self;
project = self;
return self;
}

View file

@ -1,58 +1,51 @@
#import "qedefs.h"
#import "SetBrush.h"
@implementation SetBrush
/*
==================
textureAxisFromPlane
==================
textureAxisFromPlane
*/
#if 1
vec3_t baseaxis[18] =
{
{0,0,1}, {1,0,0}, {0,-1,0}, // floor
{0,0,-1}, {1,0,0}, {0,-1,0}, // ceiling
{1,0,0}, {0,1,0}, {0,0,-1}, // west wall
{-1,0,0}, {0,1,0}, {0,0,-1}, // east wall
{0,1,0}, {1,0,0}, {0,0,-1}, // south wall
{0,-1,0}, {1,0,0}, {0,0,-1} // north wall
vec3_t baseaxis[18] = {
{0, 0, 1}, {1, 0, 0}, {0,-1, 0}, // floor
{0, 0,-1}, {1, 0, 0}, {0,-1, 0}, // ceiling
{1, 0, 0}, {0, 1, 0}, {0, 0,-1}, // west wall
{-1,0, 0}, {0, 1, 0}, {0, 0,-1}, // east wall
{0, 1, 0}, {1, 0, 0}, {0, 0,-1}, // south wall
{0,-1, 0}, {1, 0, 0}, {0, 0,-1} // north wall
};
#else
vec3_t baseaxis[18] =
{
{0,0,1}, {1,0,0}, {0,-1,0}, // floor
{0,0,-1}, {1,0,0}, {0,1,0}, // ceiling
{1,0,0}, {0,1,0}, {0,0,-1}, // west wall
{-1,0,0}, {0,-1,0}, {0,0,-1}, // east wall
{0,1,0}, {-1,0,0}, {0,0,-1}, // south wall
{0,-1,0}, {1,0,0}, {0,0,-1} // north wall
vec3_t baseaxis[18] = {
{0, 0, 1}, {1, 0, 0}, {0,-1, 0}, // floor
{0, 0,-1}, {1, 0, 0}, {0, 1, 0}, // ceiling
{1, 0, 0}, {0, 1, 0}, {0, 0,-1}, // west wall
{-1,0, 0}, {0,-1, 0}, {0, 0,-1}, // east wall
{0, 1, 0}, {-1,0, 0}, {0, 0,-1}, // south wall
{0,-1, 0}, {1, 0, 0}, {0, 0,-1} // north wall
};
#endif
float TextureAxisFromPlane(plane_t *pln, float *xv, float *yv)
float
TextureAxisFromPlane (plane_t *pln, float *xv, float *yv)
{
int bestaxis;
float dot,best;
int bestaxis = 0;
float best = 0;
float dot;
int i;
best = 0;
bestaxis = 0;
for (i=0 ; i<6 ; i++)
{
dot = DotProduct (pln->normal, baseaxis[i*3]);
if (dot > best)
{
for (i = 0; i < 6; i++) {
dot = DotProduct (pln->normal, baseaxis[i * 3]);
if (dot > best) {
best = dot;
bestaxis = i;
}
}
VectorCopy (baseaxis[bestaxis*3+1], xv);
VectorCopy (baseaxis[bestaxis*3+2], yv);
VectorCopy (baseaxis[bestaxis * 3 + 1], xv);
VectorCopy (baseaxis[bestaxis * 3 + 2], yv);
return lightaxis[bestaxis>>1];
return lightaxis[bestaxis >> 1];
}
#define BOGUS_RANGE 18000
@ -621,12 +614,12 @@ initOwner:::
return self;
}
- copyWithZone:(NSZone *)zone
- mutableCopyWithZone: (NSZone *) zone
{
id new;
[self freeWindings];
new = [super copyWithZone: zone];
new = [[self class] copyWithZone: zone];
[self calcWindings];
[new calcWindings];

View file

@ -1,16 +1,16 @@
#import "Preferences.h"
#import "qedefs.h"
id texturepalette_i;
#define TYP_MIPTEX 67
int tex_count;
qtexture_t qtextures[MAX_TEXTURES];
typedef struct
{
typedef struct {
char name[16];
unsigned width, height;
unsigned offsets[4]; // four mip maps stored
@ -18,63 +18,52 @@ typedef struct
unsigned tex_palette[256];
unsigned badtex_d[] =
{
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
unsigned int badtex_d[] = {
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 0, 0, 0, 0, 0, 0, 0,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0,0,0,0,0,0,0,0,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff
0, 0, 0, 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
};
qtexture_t badtex = {"notexture",16,16,NULL, badtex_d, {0,0,255,255}};
qtexture_t badtex = {
@"notexture",
{16.0, 16.0},
nil,
badtex_d,
{{0, 0, 255, 255}}
};
/*
==============
TEX_InitPalette
==============
*/
void TEX_InitPalette (byte *pal)
void
TEX_InitPalette (byte *pal)
{
int r,g,b,v;
int i;
for (i=0 ; i<256 ; i++)
{
for (i = 0; i < 256; i++) {
r = pal[0];
g = pal[1];
b = pal[2];
pal += 3;
v = (r<<24) + (g<<16) + (b<<8) + 255;
v = (r << 24) + (g << 16) + (b << 8) + 255;
v = BigLong (v);
tex_palette[i] = v;
@ -83,11 +72,10 @@ void TEX_InitPalette (byte *pal)
/*
=================
TEX_ImageFromMiptex
=================
TEX_ImageFromMiptex
*/
void TEX_ImageFromMiptex (miptex_t *qtex)
void
TEX_ImageFromMiptex (miptex_t *qtex)
{
NSBitmapImageRep *bm;
byte *source;
@ -108,29 +96,28 @@ void TEX_ImageFromMiptex (miptex_t *qtex)
hasAlpha: NO
isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: width*4
bytesPerRow: width * 4
bitsPerPixel: 32];
dest = (unsigned *)[bm bitmapData];
count = width*height;
dest = (unsigned *) [bm bitmapData];
count = width * height;
source = (byte *)qtex + LittleLong(qtex->offsets[0]);
q = &qtextures[tex_count];
tex_count++;
q->width = width;
q->height = height;
q->size.width = width;
q->size.height = height;
q->rep = bm;
q->data = dest;
tr = tg = tb = 0;
for (i=0 ; i<count ; i++)
{
for (i = 0; i < count; i++) {
dest[i] = tex_palette[source[i]];
tr += ((pixel32_t *)&dest[i])->chan[0];
tg += ((pixel32_t *)&dest[i])->chan[1];
tb += ((pixel32_t *)&dest[i])->chan[2];
tr += ((pixel32_t *) &dest[i])->chan[0];
tg += ((pixel32_t *) &dest[i])->chan[1];
tb += ((pixel32_t *) &dest[i])->chan[2];
}
q->flatcolor.chan[0] = tr / count;
@ -141,16 +128,14 @@ void TEX_ImageFromMiptex (miptex_t *qtex)
//=============================================================================
typedef struct
{
typedef struct {
char identification[4]; // should be WAD2 or 2DAW
int numlumps;
int infotableofs;
} wadinfo_t;
typedef struct
{
typedef struct {
int filepos;
int disksize;
int size; // uncompressed
@ -165,11 +150,12 @@ typedef struct
TEX_InitFromWad
=================
*/
void TEX_InitFromWad (char *path)
void
TEX_InitFromWad (NSString *path)
{
int i;
char local[1024];
char newpath[1024];
NSString *local;
NSString *newpath;
byte *wadfile;
wadinfo_t *wadinfo;
lumpinfo_t *lumpinfo;
@ -178,17 +164,15 @@ void TEX_InitFromWad (char *path)
start = I_FloatTime ();
strcpy(newpath, [preferences_i getProjectPath]);
strcat(newpath,"/");
strcat(newpath, path);
newpath = [[prefs objectForKey: ProjectPath] stringByAppendingPathComponent: path];
// free any textures
for (i=0 ; i<tex_count ; i++)
[qtextures[i].rep dealloc];
// free any textures
for (i = 0; i < tex_count; i++)
[qtextures[i].rep release];
tex_count = 0;
// try and use the cached wadfile
sprintf (local, "/qcache%s", newpath);
// try and use the cached wadfile
local = [NSString initWithFormat: @"/qcache%@", newpath];
Sys_UpdateFile (local, newpath);
@ -204,8 +188,7 @@ void TEX_InitFromWad (char *path)
numlumps = LittleLong (wadinfo->numlumps);
lumpinfo = (lumpinfo_t *)(wadfile + LittleLong (wadinfo->infotableofs));
if (strcmp (lumpinfo->name, "PALETTE"))
{
if (strcmp (lumpinfo->name, "PALETTE")) {
unlink (local);
Error ("TEX_InitFromWad: %s doesn't have palette as 0",path);
}
@ -213,8 +196,7 @@ void TEX_InitFromWad (char *path)
TEX_InitPalette (wadfile + LittleLong(lumpinfo->filepos));
lumpinfo++;
for (i=1 ; i<numlumps ; i++, lumpinfo++)
{
for (i=1 ; i<numlumps ; i++, lumpinfo++) {
if (lumpinfo->type != TYP_MIPTEX)
Error ("TEX_InitFromWad: %s is not a miptex!",lumpinfo->name);
CleanupName (lumpinfo->name,qtextures[tex_count].name);

View file

@ -1,128 +0,0 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
// mathlib.c -- math primitives
#include "cmdlib.h"
#include "mathlib.h"
vec3_t vec3_origin = {0,0,0};
double VectorLength(vec3_t v)
{
int i;
double length;
length = 0;
for (i=0 ; i< 3 ; i++)
length += v[i]*v[i];
length = sqrt (length); // FIXME
return length;
}
qboolean VectorCompare (vec3_t v1, vec3_t v2)
{
int i;
for (i=0 ; i<3 ; i++)
if (fabs(v1[i]-v2[i]) > EQUAL_EPSILON)
return false;
return true;
}
vec_t Q_rint (vec_t in)
{
return floor (in + 0.5);
}
void VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc)
{
vc[0] = va[0] + scale*vb[0];
vc[1] = va[1] + scale*vb[1];
vc[2] = va[2] + scale*vb[2];
}
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross)
{
cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
}
vec_t _DotProduct (vec3_t v1, vec3_t v2)
{
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
}
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out)
{
out[0] = va[0]-vb[0];
out[1] = va[1]-vb[1];
out[2] = va[2]-vb[2];
}
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out)
{
out[0] = va[0]+vb[0];
out[1] = va[1]+vb[1];
out[2] = va[2]+vb[2];
}
void _VectorCopy (vec3_t in, vec3_t out)
{
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
}
vec_t VectorNormalize (vec3_t v)
{
int i;
double length;
length = 0;
for (i=0 ; i< 3 ; i++)
length += v[i]*v[i];
length = sqrt (length);
if (length == 0)
return 0;
for (i=0 ; i< 3 ; i++)
v[i] /= length;
return length;
}
void VectorInverse (vec3_t v)
{
v[0] = -v[0];
v[1] = -v[1];
v[2] = -v[2];
}
void VectorScale (vec3_t v, vec_t scale, vec3_t out)
{
out[0] = v[0] * scale;
out[1] = v[1] * scale;
out[2] = v[2] * scale;
}