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; Camera view object
BOOL timedrawing = 0;
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 @implementation CameraView
/* /*
================== (id) initWithFrame: (NSRect)
initFrame:
================== Given a frame, set up our view.
*/ */
- initWithFrame: (NSRect) frameRect - (id) initWithFrame: (NSRect) frameRect
{ {
int size; int size;
[super initWithFrame: frameRect]; [super initWithFrame: frameRect];
cameraview_i = self; cameraView = self;
angles[0] = angles[1] = angles[2] = 0.0; angles[0] = angles[1] = angles[2] = 0.0;
@ -28,7 +67,7 @@ initFrame:
move = 16; move = 16;
bounds = [self bounds]; bounds = frameRect;
size = bounds.size.width * bounds.size.height; size = bounds.size.width * bounds.size.height;
zbuffer = malloc (size*4); zbuffer = malloc (size*4);
imagebuffer = malloc (size*4); imagebuffer = malloc (size*4);
@ -72,7 +111,7 @@ initFrame:
{ {
sb_floor_dir = 1; sb_floor_dir = 1;
sb_floor_dist = 99999; sb_floor_dist = 99999;
[map_i makeObjectsPerformSelector: @selector(feetToFloor)]; [map makeObjectsPerformSelector: @selector(feetToFloor)];
if (sb_floor_dist == 99999) if (sb_floor_dist == 99999)
{ {
qprintf ("already on top floor"); qprintf ("already on top floor");
@ -80,7 +119,7 @@ initFrame:
} }
qprintf ("up floor"); qprintf ("up floor");
origin[2] += sb_floor_dist; origin[2] += sb_floor_dist;
[quakeed_i updateCamera]; [forge updateCamera];
return self; return self;
} }
@ -88,7 +127,7 @@ initFrame:
{ {
sb_floor_dir = -1; sb_floor_dir = -1;
sb_floor_dist = -99999; sb_floor_dist = -99999;
[map_i makeAllPerform: @selector(feetToFloor)]; [map makeAllPerform: @selector(feetToFloor)];
if (sb_floor_dist == -99999) if (sb_floor_dist == -99999)
{ {
qprintf ("already on bottom floor"); qprintf ("already on bottom floor");
@ -96,7 +135,7 @@ initFrame:
} }
qprintf ("down floor"); qprintf ("down floor");
origin[2] += sb_floor_dist; origin[2] += sb_floor_dist;
[quakeed_i updateCamera]; [forge updateCamera];
return self; return self;
} }
@ -119,7 +158,7 @@ homeView
[self matrixFromAngles]; [self matrixFromAngles];
[quakeed_i updateAll]; [forge updateAll];
qprintf ("homed view angle"); qprintf ("homed view angle");
@ -129,7 +168,7 @@ homeView
- drawMode: (NSMatrix) sender - drawMode: (NSMatrix) sender
{ {
drawmode = [sender selectedColumn]; drawmode = [sender selectedColumn];
[quakeed_i updateCamera]; [forge updateCamera];
return self; return self;
} }
@ -137,7 +176,7 @@ homeView
{ {
drawmode = mode; drawmode = mode;
[mode_radio_i selectCellAtRow: 0 column: mode]; [mode_radio_i selectCellAtRow: 0 column: mode];
[quakeed_i updateCamera]; [forge updateCamera];
return self; return self;
} }
@ -223,7 +262,7 @@ float mid_x, mid_y;
float topscale = (240.0/3)/160; float topscale = (240.0/3)/160;
float bottomscale = (240.0*2/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) void MakeCampt (vec3_t in, campt_t *pt)
{ {
@ -267,7 +306,7 @@ void CameraMoveto(vec3_t p)
{ {
campt_t *pt; campt_t *pt;
if (upath->numberOfPoints > 2048) if (userPath->numberOfPoints > 2048)
lineflush (); lineflush ();
pt = &campts[cam_cur]; pt = &campts[cam_cur];
@ -275,7 +314,7 @@ void CameraMoveto(vec3_t p)
MakeCampt (p,pt); MakeCampt (p,pt);
if (!pt->clipflags) if (!pt->clipflags)
{ // onscreen, so move there immediately { // 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; float d, d2, frac;
vec3_t new; vec3_t new;
plane_t *pl; mplane_t *pl;
float scale; float scale;
if (planenum == 5) if (planenum == 5)
@ -291,12 +330,12 @@ void ClipLine (vec3_t p1, vec3_t p2, int planenum)
scale = mid_x/p1[2]; scale = mid_x/p1[2];
new[0] = mid_x + p1[0]*scale; new[0] = mid_x + p1[0]*scale;
new[1] = mid_y + p1[1]*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]; scale = mid_x/p2[2];
new[0] = mid_x + p2[0]*scale; new[0] = mid_x + p2[0]*scale;
new[1] = mid_y + p2[1]*scale; new[1] = mid_y + p2[1]*scale;
UPlineto (upath, new[0], new[1]); UPlineto (userPath, new[0], new[1]);
return; return;
} }
@ -349,8 +388,8 @@ void CameraLineto(vec3_t p)
if (! bits ) if (! bits )
{ {
c_on++; c_on++;
UPmoveto (upath, p1->screen[0], p1->screen[1]); UPmoveto (userPath, p1->screen[0], p1->screen[1]);
UPlineto (upath, p2->screen[0], p2->screen[1]); UPlineto (userPath, p2->screen[0], p2->screen[1]);
return; // entirely on screen return; // entirely on screen
} }
@ -391,7 +430,7 @@ drawSolid
// //
// render the setbrushes // render the setbrushes
// //
[map_i makeAllPerform: @selector(CameraRenderSelf)]; [map makeAllPerform: @selector(CameraRenderSelf)];
// //
// display the output // display the output
@ -445,7 +484,7 @@ drawWire
// draw all entities // draw all entities
linestart (0,0,0); linestart (0,0,0);
[map_i makeUnselectedPerform: @selector(CameraDrawSelf)]; [map makeUnselectedPerform: @selector(CameraDrawSelf)];
lineflush (); lineflush ();
return self; return self;
@ -460,7 +499,7 @@ drawSelf
{ {
static float drawtime; // static to shut up compiler warning static float drawtime; // static to shut up compiler warning
if (timedrawing) if (timeDrawing)
drawtime = I_FloatTime (); drawtime = I_FloatTime ();
if (drawmode == dr_texture || drawmode == dr_flat) if (drawmode == dr_texture || drawmode == dr_flat)
@ -468,7 +507,7 @@ drawSelf
else else
[self drawWire: rects]; [self drawWire: rects];
if (timedrawing) { if (timeDrawing) {
// NSPing (); // NSPing ();
drawtime = I_FloatTime() - drawtime; drawtime = I_FloatTime() - drawtime;
printf ("CameraView drawtime: %5.3f\n", drawtime); printf ("CameraView drawtime: %5.3f\n", drawtime);
@ -591,7 +630,7 @@ modalMoveLoop
// //
if ([event modifierFlags] & NSShiftKeyMask) if ([event modifierFlags] & NSShiftKeyMask)
{ {
ent = [quakemap_i selectedEntity]; ent = [quakemap selectedEntity];
if (ent) if (ent)
{ {
[ent origin: temp]; [ent origin: temp];
@ -607,7 +646,7 @@ modalMoveLoop
drawentry: drawentry:
// instance draw new frame // instance draw new frame
[quakeed_i newinstance]; [forge newinstance];
[self display]; [self display];
event = [NSApp nextEventMatchingMask: eventMask event = [NSApp nextEventMatchingMask: eventMask
@ -656,7 +695,7 @@ XYmouseDown
movemod[2] = 0; movemod[2] = 0;
} }
[self modalMoveLoop: pt : movemod : xyview_i]; [self modalMoveLoop: pt : movemod : xyView];
return YES; return YES;
} }
@ -679,7 +718,7 @@ ZmouseDown
movemod[1] = 0; movemod[1] = 0;
movemod[2] = 1; movemod[2] = 1;
[self modalMoveLoop: pt : movemod : zview_i]; [self modalMoveLoop: pt : movemod : zView];
return YES; return YES;
} }
@ -719,7 +758,7 @@ viewDrag:
[self matrixFromAngles]; [self matrixFromAngles];
drawentry: drawentry:
[quakeed_i newinstance]; [forge newinstance];
[self display]; [self display];
event = [NSApp nextEventMatchingMask: eventMask event = [NSApp nextEventMatchingMask: eventMask
@ -772,20 +811,20 @@ mouseDown
// bare click to select a texture // bare click to select a texture
if (!flags) { if (!flags) {
[map_i getTextureRay: p1 : p2]; [map getTextureRay: p1 : p2];
return; return;
} }
// shift click to select / deselect a brush from the world // shift click to select / deselect a brush from the world
if (flags == NSShiftKeyMask) { if (flags == NSShiftKeyMask) {
[map_i selectRay: p1 : p2 : NO]; [map selectRay: p1 : p2 : NO];
return; return;
} }
// cmd-shift click to set a target/targetname entity connection // cmd-shift click to set a target/targetname entity connection
if (flags == (NSShiftKeyMask | NSCommandKeyMask)) { if (flags == (NSShiftKeyMask | NSCommandKeyMask)) {
[map_i entityConnect: p1 : p2]; [map entityConnect: p1 : p2];
return; return;
} }
@ -796,8 +835,8 @@ mouseDown
NopSound (); NopSound ();
return; return;
} }
[map_i setTextureRay: p1 : p2 : YES]; [map setTextureRay: p1 : p2 : YES];
[quakeed_i updateAll]; [forge updateAll];
return; return;
} }
@ -808,8 +847,8 @@ mouseDown
NopSound (); NopSound ();
return; return;
} }
[map_i setTextureRay: p1 : p2 : NO]; [map setTextureRay: p1 : p2 : NO];
[quakeed_i updateAll]; [forge updateAll];
return; return;
} }
@ -874,62 +913,62 @@ keyDown
case 'A': case 'A':
angles[0] += M_PI/8; angles[0] += M_PI/8;
[self matrixFromAngles]; [self matrixFromAngles];
[quakeed_i updateCamera]; [forge updateCamera];
return; return;
case 'z': case 'z':
case 'Z': case 'Z':
angles[0] -= M_PI/8; angles[0] -= M_PI/8;
[self matrixFromAngles]; [self matrixFromAngles];
[quakeed_i updateCamera]; [forge updateCamera];
return; return;
case NSRightArrowFunctionKey: case NSRightArrowFunctionKey:
angles[1] -= M_PI*move/(64*2); angles[1] -= M_PI*move/(64*2);
[self matrixFromAngles]; [self matrixFromAngles];
[quakeed_i updateCamera]; [forge updateCamera];
break; break;
case NSLeftArrowFunctionKey: case NSLeftArrowFunctionKey:
angles[1] += M_PI*move/(64*2); angles[1] += M_PI*move/(64*2);
[self matrixFromAngles]; [self matrixFromAngles];
[quakeed_i updateCamera]; [forge updateCamera];
break; break;
case NSUpArrowFunctionKey: case NSUpArrowFunctionKey:
origin[0] += move*cos(angles[1]); origin[0] += move*cos(angles[1]);
origin[1] += move*sin(angles[1]); origin[1] += move*sin(angles[1]);
[quakeed_i updateCamera]; [forge updateCamera];
break; break;
case NSDownArrowFunctionKey: case NSDownArrowFunctionKey:
origin[0] -= move*cos(angles[1]); origin[0] -= move*cos(angles[1]);
origin[1] -= move*sin(angles[1]); origin[1] -= move*sin(angles[1]);
[quakeed_i updateCamera]; [forge updateCamera];
break; break;
case '.': case '.':
origin[0] += move*cos(angles[1]-M_PI_2); origin[0] += move*cos(angles[1]-M_PI_2);
origin[1] += move*sin(angles[1]-M_PI_2); origin[1] += move*sin(angles[1]-M_PI_2);
[quakeed_i updateCamera]; [forge updateCamera];
break; break;
case ',': case ',':
origin[0] -= move*cos(angles[1]-M_PI_2); origin[0] -= move*cos(angles[1]-M_PI_2);
origin[1] -= move*sin(angles[1]-M_PI_2); origin[1] -= move*sin(angles[1]-M_PI_2);
[quakeed_i updateCamera]; [forge updateCamera];
break; break;
case 'd': case 'd':
case 'D': case 'D':
origin[2] += move; origin[2] += move;
[quakeed_i updateCamera]; [forge updateCamera];
break; break;
case 'c': case 'c':
case 'C': case 'C':
origin[2] -= move; origin[2] -= move;
[quakeed_i updateCamera]; [forge updateCamera];
break; break;
} }
return; 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 @implementation Clipper
- init - init
{ {
[super init]; [super init];
clipper_i = self; clipper = self;
return self; return self;
} }
@ -37,7 +79,7 @@ id clipper_i;
VectorCopy (temp, pos[2]); VectorCopy (temp, pos[2]);
break; break;
default: default:
qprintf ("no clip plane"); NSLog (@"No clipping plane");
NSBeep (); NSBeep ();
} }
return self; return self;
@ -70,7 +112,7 @@ id clipper_i;
if ( !norm[0] && !norm[1] && !norm[2] ) if ( !norm[0] && !norm[1] && !norm[2] )
return NO; return NO;
[texturepalette_i getTextureDef: &f->texture]; [texturepalette_i setTextureDef: &f->texture];
return YES; return YES;
} }
@ -85,18 +127,18 @@ XYClick
int i; int i;
vec3_t new; vec3_t new;
new[0] = [xyview_i snapToGrid: pt.x]; new[0] = [xyView snapToGrid: pt.x];
new[1] = [xyview_i snapToGrid: pt.y]; new[1] = [xyView snapToGrid: pt.y];
new[2] = [map_i currentMinZ]; new[2] = [map currentMinZ];
// see if a point is already there // see if a point is already there
for (i=0 ; i<num ; i++) { for (i=0 ; i<num ; i++) {
if (new[0] == pos[i][0] && new[1] == pos[i][1]) { if (new[0] == pos[i][0] && new[1] == pos[i][1]) {
if (pos[i][2] == [map_i currentMinZ]) if (pos[i][2] == [map currentMinZ])
pos[i][2] = [map_i currentMaxZ]; pos[i][2] = [map currentMaxZ];
else else
pos[i][2] = [map_i currentMinZ]; pos[i][2] = [map currentMinZ];
[quakeed_i updateAll]; [forge updateAll];
return self; return self;
} }
} }
@ -108,7 +150,7 @@ XYClick
VectorCopy (new, pos[num]); VectorCopy (new, pos[num]);
num++; num++;
[quakeed_i updateAll]; [forge updateAll];
return self; return self;
} }
@ -138,21 +180,20 @@ XYDrag
- carve - carve
{ {
[map_i makeSelectedPerform: @selector(carveByClipper)]; [map makeSelectedPerform: @selector(carveByClipper)];
num = 0; num = 0;
return self; return self;
} }
- cameraDrawSelf - (void) cameraDrawSelf
{ {
vec3_t mid; vec3_t mid;
int i; 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); VectorCopy (pos[i], mid);
mid[0] -= 8; mid[0] -= 8;
mid[1] -= 8; mid[1] -= 8;
@ -170,49 +211,47 @@ XYDrag
CameraLineto (mid); CameraLineto (mid);
} }
return self; return;
} }
- XYDrawSelf - (void) xyDrawSelf
{ {
int i; int i;
char text[8]; char text[8];
PSsetrgbcolor (1,0.5,0); PSsetrgbcolor (1, 0.5, 0);
PSselectfont("Helvetica-Medium",10/[xyview_i currentScale]); PSselectfont ("Helvetica-Medium", 10 / [xyView currentScale]);
PSrotate(0); PSrotate (0);
for (i=0 ; i<num ; i++) for (i = 0; i < num; i++) {
{ PSmoveto (pos[i][0] - 4, pos[i][1] - 4);
PSmoveto (pos[i][0]-4, pos[i][1]-4);
sprintf (text, "%i", i); sprintf (text, "%i", i);
PSshow (text); PSshow (text);
PSstroke (); PSstroke ();
PSarc ( pos[i][0], pos[i][1], 10, 0, 360); PSarc (pos[i][0], pos[i][1], 10, 0, 360);
PSstroke (); PSstroke ();
} }
return self; return;
} }
- ZDrawSelf - (void) zDrawSelf
{ {
int i; int i;
char text[8]; char text[8];
PSsetrgbcolor (1,0.5,0); PSsetrgbcolor (1, 0.5, 0);
PSselectfont("Helvetica-Medium",10/[zview_i currentScale]); PSselectfont ("Helvetica-Medium", 10 / [zView currentScale]);
PSrotate(0); PSrotate (0);
for (i=0 ; i<num ; i++) for (i = 0; i < num; i++) {
{ PSmoveto ((-28 + (i * 8)) - 4, pos[i][2] - 4);
PSmoveto (-28+i*8 - 4, pos[i][2]-4);
sprintf (text, "%i", i); sprintf (text, "%i", i);
PSshow (text); PSshow (text);
PSstroke (); PSstroke ();
PSarc ( -28+i*8, pos[i][2], 10, 0, 360); PSarc ((-28 + (i * 8)), pos[i][2], 10, 0, 360);
PSstroke (); PSstroke ();
} }
return self; return;
} }
@end @end

Binary file not shown.

View file

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

View file

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

View file

@ -114,7 +114,6 @@ Forge_OBJC_FILES= \
PopScrollView.m \ PopScrollView.m \
Preferences.m \ Preferences.m \
Project.m \ Project.m \
SetBrush.m \
TexturePalette.m \ TexturePalette.m \
TextureView.m \ TextureView.m \
Things.m \ Things.m \
@ -124,13 +123,13 @@ Forge_OBJC_FILES= \
ZView.m \ ZView.m \
misc.m \ misc.m \
render.m render.m
# SetBrush.m \
# #
# C files # C files
# #
Forge_C_FILES= \ Forge_C_FILES= \
cmdlib.c \ cmdlib.c
mathlib.c
-include GNUmakefile.preamble -include GNUmakefile.preamble
-include GNUmakefile.local -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 <appkit/appkit.h>
#import "SetBrush.h" #import "SetBrush.h"
#import "EditWindow.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" #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 @interface CameraView: NSView
{ {
float angles[3]; float angles[3];
@ -50,7 +72,7 @@ extern BOOL timedrawing;
- drawMode: (NSMatrix) sender; - drawMode: (NSMatrix) sender;
- setDrawMode: (drawmode_t) mode; - setDrawMode: (drawmode_t) mode;
- homeView: sender; - (id) homeView: (id) sender;
- XYDrawSelf; // for drawing viewpoint in XY view - XYDrawSelf; // for drawing viewpoint in XY view
- ZDrawSelf; // for drawing viewpoint in XY view - ZDrawSelf; // for drawing viewpoint in XY view
@ -62,3 +84,9 @@ extern BOOL timedrawing;
@end @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 @interface Clipper: NSObject
{ {
int num; int num;
vec3_t pos[3]; vec3_t pos[3];
plane_t plane; mplane_t plane;
} }
- (BOOL) hide; - (BOOL) hide;
@ -16,9 +52,10 @@ extern id clipper_i;
- flipNormal; - flipNormal;
- (BOOL) getFace: (face_t *) pl; - (BOOL) getFace: (face_t *) pl;
- cameraDrawSelf; - (void) cameraDrawSelf;
- XYDrawSelf; - (void) xyDrawSelf;
- ZDrawSelf; - (void) zDrawSelf;
@end @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 (description)
#define MAX_VALUE 128
typedef struct epair_s Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
{
struct epair_s *next; This program is free software; you can redistribute it and/or
char key[MAX_KEY]; modify it under the terms of the GNU General Public License as
char value[MAX_VALUE]; published by the Free Software Foundation; either version 2 of
} epair_t; 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 // an Entity is a list of brush objects, with additional key / value info
@interface Entity: NSObject <NSCopying, NSMutableCopying>
@interface Entity: NSMutableArray
{ {
epair_t *epairs; id brushes;
BOOL modifiable; id fields;
} }
- initClass: (char *)classname; - initWithClassname: (NSString *)classname;
- initFromTokens; - initWithTokens;
- (oneway void) release; - (NSString *) targetname;
- (BOOL)modifiable; - writeToFile: (NSString *) filename region: (BOOL) reg;
- setModifiable: (BOOL)m;
- (char *)targetname; - (id) objectForKey: (NSString *) k;
- 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;
- (Brush *) brushAtIndex: (unsigned) index;
- (id) fieldForKey: (
@end @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 <Foundation/Foundation.h>
#import "mathlib.h" #import "mathlib.h"
extern id entity_classes_i;
@interface EntityArray: NSMutableArray @interface EntityArray: NSMutableArray
{ {
id nullclass; id nullclass;
@ -15,3 +44,4 @@ extern id entity_classes_i;
@end @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 <Foundation/Foundation.h>
#import "mathlib.h" #import "mathlib.h"
@ -22,6 +53,6 @@ typedef enum {esize_model, esize_fixed} esize_t;
- (float *)maxs; // only for esize_fixed - (float *)maxs; // only for esize_fixed
- (float *)drawColor; - (float *)drawColor;
- (char *)comments; - (char *)comments;
- (char *)flagName: (unsigned)flagnum; - (char *)flagName: (unsigned) flagnum;
@end @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; Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
extern BOOL filter_clip_brushes, filter_water_brushes, filter_world;
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 @interface Forge: NSWindow
{ {
@ -100,3 +117,16 @@ void qprintf (char *fmt, ...); // prints text to cmd_out_i
@end @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> #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; 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 // Map is a collection of Entity objects
extern id map_i;
@interface Map: NSMutableArray @interface Map: NSMutableArray
{ {
id currentEntity; id currentEntity;
@ -66,3 +94,5 @@ extern id map_i;
- selectCompleteEntity: sender; - selectCompleteEntity: sender;
@end @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> #import <AppKit/AppKit.h>
@interface PopScrollView: NSScrollView @interface PopScrollView: NSScrollView

View file

@ -3,8 +3,7 @@
Preferences class definition for Forge Preferences class definition for Forge
Copyright (C) 1996 Id Software, Inc. Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as modify it under the terms of the GNU General Public License as
@ -89,3 +88,5 @@
+ (void) savePreferencesToDefaults: (NSDictionary *) dict; + (void) savePreferencesToDefaults: (NSDictionary *) dict;
@end @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> #import <AppKit/AppKit.h>
#include <sys/stat.h>
#define EntSubdir @"progs" #define EntSubdir @"progs"
#define MapSubdir @"maps" #define MapSubdir @"maps"
@ -99,5 +129,4 @@
@end @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 #define MAX_FACES 16
typedef float vec5_t[5]; typedef struct {
typedef struct
{
int numpoints; int numpoints;
vec5_t points[8]; // variable sized vec5_t points[8]; // variable sized
} winding_t; } winding_t;
#define MAX_POINTS_ON_WINDING 64 #define MAX_POINTS_ON_WINDING 64
typedef struct typedef struct {
{
vec3_t normal; vec3_t normal;
float dist; float dist;
} plane_t; } plane_t;
typedef struct typedef struct {
{
// implicit rep // implicit rep
vec3_t planepts[3]; vec3_t planepts[3];
texturedef_t texture; texturedef_t texture;
@ -44,8 +71,7 @@ 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); winding_t *NewWinding (int points);
@interface SetBrush: NSObject <NSCopying>
@interface SetBrush : NSObject <NSCopying>
{ {
BOOL regioned; // not active BOOL regioned; // not active
BOOL selected; 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 { typedef union pixel32_u {
byte chan[4]; byte chan[4];
unsigned p; unsigned int p;
} pixel32_t; } pixel32_t;
@ -13,10 +49,8 @@ typedef struct texturedef_s {
} texturedef_t; } texturedef_t;
typedef struct qtexture_s { typedef struct qtexture_s {
char name[16]; NSString *name;
NSSize size;
int width;
int height;
NSBitmapImageRep *rep; NSBitmapImageRep *rep;
void *data; void *data;
pixel32_t flatcolor; pixel32_t flatcolor;
@ -27,11 +61,11 @@ typedef struct qtexture_s {
extern int tex_count; extern int tex_count;
extern qtexture_t qtextures[MAX_TEXTURES]; extern qtexture_t qtextures[MAX_TEXTURES];
void TEX_InitFromWad (char *path); void TEX_InitFromWad (NSString *path);
qtexture_t *TEX_ForName (char *name); qtexture_t *TEX_ForName (NSString *name);
typedef struct { typedef struct {
id image; // NXImage id image; // NSImage
NSRect r; NSRect r;
char *name; char *name;
int index; int index;
@ -43,7 +77,7 @@ typedef struct {
extern id texturepalette_i; extern id texturepalette_i;
@interface TexturePalette:Object @interface TexturePalette: NSObject
{ {
char currentwad[1024]; char currentwad[1024];
id textureList_i; 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 @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> #import <AppKit/AppKit.h>
@ -5,7 +35,7 @@ extern id things_i;
#define ENTITYNAMEKEY "spawn" #define ENTITYNAMEKEY "spawn"
@interface Things:Object @interface Things: Object
{ {
id entity_browser_i; // browser id entity_browser_i; // browser
id entity_comment_i; // scrolling text window id entity_comment_i; // scrolling text window

View file

@ -45,6 +45,8 @@ typedef struct _UP {
BOOL ping; BOOL ping;
} UserPath; } UserPath;
extern UserPath *userPath;
/* UserPath functions */ /* UserPath functions */
NSZone *userPathZone(); NSZone *userPathZone();
UserPath *newUserPath(); 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 <AppKit/AppKit.h>
#import "mathlib.h"
#import "SetBrush.h" #import "SetBrush.h"
extern id xyview_i;
#define MINSCALE 0.125 #define MINSCALE 0.125
#define MAXSCALE 2.0 #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; typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
@interface XYView: NSView @interface XYView: NSView
{ {
NSRect realbounds, newrect, combinedrect; NSRect realbounds, newrect, combinedrect;
@ -47,20 +62,34 @@ typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
- setModeRadio: m; - setModeRadio: m;
- drawMode: sender; - drawMode: sender;
- setDrawMode: (drawmode_t)mode; - setDrawMode: (drawmode_t) mode;
- newSuperBounds; - newSuperBounds;
- newRealBounds: (NSRect *)nb; - newRealBounds: (NSRect) nb;
- addToScrollRange: (float)x :(float)y; - addToScrollRange: (float) x : (float) y;
- setOrigin: (NSPoint *)pt scale: (float)sc; - setOrigin: (NSPoint) pt scale: (float) sc;
- centerOn: (vec3_t)org; - centerOn: (vec3_t)org;
- drawMode: sender; - drawMode: sender;
- superviewChanged; - superviewChanged;
- (int)gridsize; - (int) gridsize;
- (float)snapToGrid: (float)f; - (float) snapToGrid: (float) f;
@end @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> #import <AppKit/AppKit.h>
@interface ZScrollView: NSScrollView @interface ZScrollView: NSScrollView
@ -5,7 +36,7 @@
id button1; id button1;
} }
- initFrame:(const NSRect *)frameRect button1: b1; - (id) initWithFrame: (const NSRect) frameRect button1: (id) b1;
- tile; - (void) tile;
@end @end

View file

@ -1,12 +1,37 @@
/*
ZView.h
#import <AppKit/AppKit.h> Depth viewer class definition
#import "mathlib.h"
extern id zview_i; Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
// zplane controls the objects displayed in the xyview This program is free software; you can redistribute it and/or
extern float zplane; modify it under the terms of the GNU General Public License as
extern float zplanedir; 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 @interface ZView: NSView
{ {
@ -19,6 +44,8 @@ extern float zplanedir;
vec3_t origin; vec3_t origin;
} }
- (float) currentScale;
- clearBounds; - clearBounds;
- getBounds: (float *)top :(float *)bottom; - getBounds: (float *)top :(float *)bottom;
@ -36,7 +63,12 @@ extern float zplanedir;
- setXYOrigin: (NSPoint) point; - setXYOrigin: (NSPoint) point;
- setOrigin: (NSPoint *)pt scale: (float)sc; - setOrigin: (NSPoint) pt scale: (float) sc;
@end @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); char *copystring(char *s);
void CRC_Init(unsigned short *crcvalue); void CRC_Init(unsigned short *crcvalue);
void CRC_ProcessByte(unsigned short *crcvalue, byte data); void CRC_ProcessByte(unsigned short *crcvalue, byte data);
unsigned short CRC_Value(unsigned short crcvalue); unsigned short CRC_Value(unsigned short crcvalue);
@ -112,5 +111,4 @@ void CopyFile (char *from, char *to);
extern qboolean archive; extern qboolean archive;
extern char archivedir[1024]; extern char archivedir[1024];
#endif #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 int r_width, r_height;
extern unsigned *r_picbuffer; extern unsigned *r_picbuffer;

View file

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

View file

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

View file

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

View file

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

View file

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