From f7b0227299d82b2b4ca381b235914a752ec076bd Mon Sep 17 00:00:00 2001 From: Jeff Teunissen Date: Sun, 14 Oct 2001 05:55:21 +0000 Subject: [PATCH] This is all seriously broken, but I'm committing it so that it can be worked on by other people as well. :) --- tools/Forge/CameraView.m | 139 ++++++++++++++++--------- tools/Forge/Clipper.m | 113 +++++++++++++------- tools/Forge/English.lproj/Forge.gorm | Bin 12081 -> 11194 bytes tools/Forge/Entity.m | 4 +- tools/Forge/Forge.m | 32 +++--- tools/Forge/GNUmakefile | 5 +- tools/Forge/Headers/Brush.h | 31 ++++++ tools/Forge/Headers/CameraView.h | 52 ++++++--- tools/Forge/Headers/Clipper.h | 47 ++++++++- tools/Forge/Headers/Dict.h | 47 --------- tools/Forge/Headers/Entity.h | 76 +++++++++----- tools/Forge/Headers/EntityArray.h | 34 +++++- tools/Forge/Headers/EntityClass.h | 33 +++++- tools/Forge/Headers/Forge.h | 46 ++++++-- tools/Forge/Headers/InspectorControl.h | 30 ++++++ tools/Forge/Headers/KeypairView.h | 30 ++++++ tools/Forge/Headers/Map.h | 34 +++++- tools/Forge/Headers/PopScrollView.h | 31 ++++++ tools/Forge/Headers/Preferences.h | 5 +- tools/Forge/Headers/Project.h | 35 ++++++- tools/Forge/Headers/SetBrush.h | 48 +++++++-- tools/Forge/Headers/TexturePalette.h | 60 ++++++++--- tools/Forge/Headers/TextureView.h | 29 ++++++ tools/Forge/Headers/Things.h | 32 +++++- tools/Forge/Headers/UserPath.h | 2 + tools/Forge/Headers/XYView.h | 75 +++++++++---- tools/Forge/Headers/ZScrollView.h | 35 ++++++- tools/Forge/Headers/ZView.h | 46 ++++++-- tools/Forge/Headers/cmdlib.h | 2 - tools/Forge/Headers/mathlib.h | 67 ------------ tools/Forge/Headers/qedefs.h | 59 ----------- tools/Forge/Headers/render.h | 30 ++++++ tools/Forge/Map.m | 23 ++-- tools/Forge/Preferences.m | 17 ++- tools/Forge/Project.m | 4 +- tools/Forge/SetBrush.m | 65 ++++++------ tools/Forge/TexturePalette.m | 132 ++++++++++------------- tools/Forge/mathlib.c | 128 ----------------------- 38 files changed, 1023 insertions(+), 655 deletions(-) delete mode 100644 tools/Forge/Headers/Dict.h delete mode 100644 tools/Forge/Headers/mathlib.h delete mode 100644 tools/Forge/Headers/qedefs.h delete mode 100644 tools/Forge/mathlib.c diff --git a/tools/Forge/CameraView.m b/tools/Forge/CameraView.m index e5d35c91f..688a8987c 100644 --- a/tools/Forge/CameraView.m +++ b/tools/Forge/CameraView.m @@ -1,22 +1,61 @@ -#import "qedefs.h" +/* + CameraView.m -id cameraview_i; -BOOL timedrawing = 0; + Camera view object + + Copyright (C) 2001 Jeff Teunissen + + 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 +#import + +#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; diff --git a/tools/Forge/Clipper.m b/tools/Forge/Clipper.m index 90b83d11e..08d22ce98 100644 --- a/tools/Forge/Clipper.m +++ b/tools/Forge/Clipper.m @@ -1,14 +1,56 @@ +/* + Clipper.h -#include "qedefs.h" + Clipping plane class -id clipper_i; + Copyright (C) 2001 Jeff Teunissen + + 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 +#include + +#import +#import + +#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 ; iVbmC*Oi9k^S6?EUdHwlll=k)*kfA8vTISolh-{1_)n<5d$ck_nn&pgVjNpXay7(AH)~I8_9}GTVm9wpl>C;b6-6U| zNl;Og%CRxs0I3$LgNkCYSYEqvHGk~MTf-kS3*!8dER6AougFX23R7iOEi4L|m4f!J z)`9+btnb=Lc!-x5vM9#(uFgnzM?Boe1q%Ft21=%p>*!L`G(!lkPnzL}bYlsS#dLRx zPk#fxFQFfn)RP-&i`_)e=!>->SW0J`=ZBUh^LUX;K*Z@z7DG=`&n0>;(VO`n&B92$ zH=Kaw$;l9=OEhkJzoq4`1}JdP9$KJEJwq8(Xa?x3jK5>x562hjpk$;&Cx81M3={gU;s zDXt>7qko`$I*cUkuvTU)$Yd|RLlGzGj+jRK=d2W+98rM4<6 zU5(t;2=`-ETV)t5YT^O8-E2AI`U>CmxAKXK)WC0S_b{ zY%BcY{F-1J27Zu!TIwYaoohGfnxcOg6_3ybE+6?Nz18I~%lL^cGFAc}Mg3#+F_(k< zioWCu)?K8>HXlceCuGgJnVNGoZLyvKtSt^t@`Ur!bw4lq!Ya38l~2G^7qq_vLp_~6 z<^?Om(VChX_%-c!r_TBjx5qsM&!GKpq`fwiTC3>{55aHgJMN%6Rc)<7(J4waJd_$y z0-i6L7t<{p5WxPVXmTAjQz_7>4e{;XK0k9>pd>=Jl*a|W!~rU(JNi~ro2qT zJWbcK!LWB>jP|-b@*;)2HvJ3ey_0r&o#glDMt--~uYVC0yXbRXKY8h#;<&d$zZ(^Q zpe~<{{PCP(q0jGn85OT&UyFImBXQWnOjqHT2v6ZXgue8gbG9C7N=y6Xz-Qh1Lf2X_B;*b4a+TqQoMP*j9 zkCvCEtgk5xI>s^Z{_GOwcBypSTRJtXjW@B4{cu3GL3kSk-ohCFpu{94*M>KeH;FDLD=`u>3tFQ-#lzXR#>(fK0up8vi$S!dRKVW zV5BG94)8kJxu81s9vl_gdiE|H6S7)%5RMB9vA1AC zXzSRUa6-s{jl&o8j`D!MnLP?$B9&_&hOdOAiEV?E!oHS00H=hkk=+lc1vRj}@U@_N z_BZ%OP#t?6z7(agoXN4rhUWV@k0ox7V(>;}CInC@vl_&zIvlmoC1U9iT zm1qzHI;Ik>kTtMpRiYDE&z@05DvBMah2q9420NWl^CtCo0LK6I1QFQI+J=NmZ_@g4BVkq)_@9GoJ}Y&DE<@D@rAkk~ZAGC1q{RsddZ0 zETq@;-1oUKGDlHKk=WBEi!*i?ZtINrqHV2`$+D0_{{Kp{B<*;g%(2&+-l)F3 z(Qr>Zwh9%BGENFrVwPQ>zY#mT77Rths}d@)B%R|VZ=9Hst(=YcifrSIIXT-o8zeh8 z=ZxSxDxCa9kMGE(oOP02oVAkOoHdd?oQY&FXDpEW`jSrey+l9acM{7G&&sS*5YMo) zXc|EJmW`Z23?hERIF%!PEvN$Nw4h3)Q__1X;z@Q24Xcp8VkeQRk-ijkDbg2$YLHGy zmuZL->;xJD(s4F{6hb;C)g!gYN7*ry)**e)jw00~9g+G5#Lw6f6gDDllENm$4Qvw% zrz5Rn8<3ij?i4fw>2^VvAq~nA%tVaI!m;@y zUMq1fVyDDb#Q7525HFWF53y0=e8d`w?T7)1S0K72b|6{=n#q;Omq_tdhT&*6q{FGzI8%PXE9Q)2nmTU*&l~$2r5=#@WV&?(G>($s=vf5Gh zVc7`}l?2*`*Cr6&kAx5~5a2FQ%Dbkeg;HqU(gr9k4dq!%OA545Ug?1e}&mzqnTum$`@N6hG61VWfL0dsh$QUZXRob^s7 zrqV~_PPULtXYCw=Kht2HQ;F%L&$Cknyl28NTiBYZ#DQWVc{F2>r&EQrlTGGM;X|{P zbx$Q~%h)z}aHVK5+fY)XkV|KeLkU;q9hU%XTL+g81Jo>nR?%8+!zMl6qaJuPy0DN* zr;?~kv{41swoA2bWn-+!3h;ASmYJg6Y)55d#X`Z!qB66Cg{BhNvz(Jr1)Z#YDsd=n zFRHr`3r{5u+W7@1JF7a*8LDTc_3Ojqn_?_He%TqeK0Nka#=@gZj6pFzRu`?_Fv?i4c*} z?XlKvB<7sONXl_?v-ybVGW$^J{`ur_8!YF{;37kA`sS;yHt;q>0)iUTdX6MU7pG=RC{Eb)h6RK$M*BP1OE zA`X_*{=woE>x1PA7%UrWI2thfS)Zn+8tI$JPVtEw5IAhqDzFOZw zP^>#>3pglJ0+VQ7Zq{z|J;1BRXkNORb^A5dX!$=ETv!< zP#zl3&D5MXQZDKpQ=CU()h4*nNa=X}dj?51?WPVVL1eouS;fnbrncrQ*{GR_G=J!^Z zzY>^#26aLWIkg4tG_KAT(uMSSqkaUaf95$-e^o>3qhg;A3qD z-%^eDz)C>F0E+#jUsFT+{`#b=nI^arc*TCwpH(6KS|I(p-y!LfK>C4mBz=nPRg=96 zk`@D&UNNont%CgW-zLbd8osZu&$k!NwdXyr*w6RD3f~Ffdxq@SSKfGX-p(b@Q=m@+ z=Qo@q=ZDDVus1NnhUF~Wu;8AC4x8&(&s0Jyf&r}UgvPIpK>Vu{Qry7#;Q{75DtpB` zbz#`F+~`uLR&8;Uxt^`AQB>Lgn;X=L+RhgD7wq{;DHAsb*(ReKuH_n&$dXExV^C*= zzE(B~XM`M^XK~0wk}HD!k%9lZh>-oUtl z)Ae1{#}E!DHONDTmq!wJ>%2dPykC9xYUzZcKZNj~&l?TE|J>w_jN`c2@aiV0E9dRS<|&K<+47v=0dVMb$O?@(;F;tm}7 zhNi3=5pM+R-b8iv&C7vwHk~XKbLl%g8{ZtXaef&a4YtO!QIi(5^es(UIxOA_mcEVZ z>Tg8wHBI)o4Y}pWL=N79hzF=nb>HB+P~)$K^|4Tr8t%`kWGgUeLlscAp8_?fC8XRF$Ib ztc`^nXd7T$-X}f-s{WMZ>1Y2bdr|yZP)*jarbfnJEufuhfoG<}nbiXx*bX8tm$E3u5O5Q8_^sB1JI)b<6? z_E!zG%{bVzFVfS%oTZV~1sWJ?m~lM5z665*nwsiSMcv3`#NRX!tC19Dovz`TOwjVP zpx|#wh`xg6>=Smb5SeizsA^XH-O75pVg3kFyBSBd3Tpc@X#0B-rEkL33Mc+yWgR`N zorO|rJ@n5MFa#e3>0cos`V4sWY`P%6x{`2h_a-x>BEtcf`&mY-vllHO44*6 zSV{O|MSLr$=EO2;;L8Nq0$|Iao^OMm?~u5f5ol*%R~8wC;Qek;S<P{L+<@#`%^GAiJ zq!jJPNS}j-fq)QClm{%%f@-cWrVAG5K|QxGqh}39U%}4Jr?c>7K|q>{(BhrTs2!9)u(h_nd*oS*Z)l?8ZuupPZ)~FC zi2Q=Z2b!ojEI(&)_fx24ZQLb4Yw-)3kT@hiWAV*RR2-C_w)hsRsINx&Qbc~z;_hcj z%UTtcAG7$@CX|`-35!RlqP`NKGF<-TuPlBMJ=QZr^y)>Pw)j&tC2r0UKm5$6;pKqE zpX#m(7QZ-H@4zWHe`4`V%3J6-TASw@f6)@;$A)7yNi)nYg~uV~Z1HXNvu0ki2GV?4 zGmE?53H9MwyHB2!MVXV1JS?Z>q}(S*zUyHbf>RgA|fLka(P`*$;OvO_GACwP6;WVJP$Oi#gfZm|c^?>eI z=pdkbiJ=6*d&qe+0Pm9bK${x?-J#GSK#LFqPyxP#ykfR_+V0)#%I;-dh;w+K@J!Bq%n0Rl@Gm;Mi5=Kl!* diff --git a/tools/Forge/Entity.m b/tools/Forge/Entity.m index b5dd169c4..59e3cc808 100644 --- a/tools/Forge/Entity.m +++ b/tools/Forge/Entity.m @@ -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; diff --git a/tools/Forge/Forge.m b/tools/Forge/Forge.m index b508021a5..3bb89a65b 100644 --- a/tools/Forge/Forge.m +++ b/tools/Forge/Forge.m @@ -10,8 +10,8 @@ #include #include -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]]; diff --git a/tools/Forge/GNUmakefile b/tools/Forge/GNUmakefile index 749dd77a9..217c26b73 100644 --- a/tools/Forge/GNUmakefile +++ b/tools/Forge/GNUmakefile @@ -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 diff --git a/tools/Forge/Headers/Brush.h b/tools/Forge/Headers/Brush.h index 26bd11652..8fffa9af4 100644 --- a/tools/Forge/Headers/Brush.h +++ b/tools/Forge/Headers/Brush.h @@ -1,3 +1,34 @@ +/* + Brush.h + + (description) + + Copyright (C) 2001 Jeff Teunissen + + 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 #import "SetBrush.h" #import "EditWindow.h" diff --git a/tools/Forge/Headers/CameraView.h b/tools/Forge/Headers/CameraView.h index 15a42f07a..bf01012b9 100644 --- a/tools/Forge/Headers/CameraView.h +++ b/tools/Forge/Headers/CameraView.h @@ -1,16 +1,38 @@ -#import -#import "mathlib.h" +/* + CameraView.h + + Perspective viwer class definitions + + Copyright (C) 2001 Jeff Teunissen + + 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 + #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); diff --git a/tools/Forge/Headers/Clipper.h b/tools/Forge/Headers/Clipper.h index 623a712bf..1b9de6d54 100644 --- a/tools/Forge/Headers/Clipper.h +++ b/tools/Forge/Headers/Clipper.h @@ -1,11 +1,47 @@ +/* + Clipper.h -extern id clipper_i; + Clipping plane class definition + + Copyright (C) 2001 Jeff Teunissen + + 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 +#include + +#import +#import + +#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; diff --git a/tools/Forge/Headers/Dict.h b/tools/Forge/Headers/Dict.h deleted file mode 100644 index 38d2b194f..000000000 --- a/tools/Forge/Headers/Dict.h +++ /dev/null @@ -1,47 +0,0 @@ - -#import - -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); diff --git a/tools/Forge/Headers/Entity.h b/tools/Forge/Headers/Entity.h index 1b56b1f16..469400c8b 100644 --- a/tools/Forge/Headers/Entity.h +++ b/tools/Forge/Headers/Entity.h @@ -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 + + 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 + +@class NSArray, NSDictionary; // an Entity is a list of brush objects, with additional key / value info - -@interface Entity: NSMutableArray +@interface Entity: NSObject { - 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 diff --git a/tools/Forge/Headers/EntityArray.h b/tools/Forge/Headers/EntityArray.h index ae383532c..ac2a89280 100644 --- a/tools/Forge/Headers/EntityArray.h +++ b/tools/Forge/Headers/EntityArray.h @@ -1,8 +1,37 @@ +/* + EntityArray.h + + (description) + + Copyright (C) 2001 Jeff Teunissen + + 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 #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; diff --git a/tools/Forge/Headers/EntityClass.h b/tools/Forge/Headers/EntityClass.h index 4c21fe21c..f1e34694a 100644 --- a/tools/Forge/Headers/EntityClass.h +++ b/tools/Forge/Headers/EntityClass.h @@ -1,3 +1,34 @@ +/* + EntityClass.h + + EntityClass (used by Entity) class definitions + + Copyright (C) 2001 Jeff Teunissen + + 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 #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 diff --git a/tools/Forge/Headers/Forge.h b/tools/Forge/Headers/Forge.h index 707e71730..10329e57c 100644 --- a/tools/Forge/Headers/Forge.h +++ b/tools/Forge/Headers/Forge.h @@ -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 -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 @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 + diff --git a/tools/Forge/Headers/InspectorControl.h b/tools/Forge/Headers/InspectorControl.h index 60b781b80..80fff70bd 100644 --- a/tools/Forge/Headers/InspectorControl.h +++ b/tools/Forge/Headers/InspectorControl.h @@ -1,3 +1,33 @@ +/* + InspectorControl.h + + Inspector control class definitions + + Copyright (C) 2001 Jeff Teunissen + + 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 diff --git a/tools/Forge/Headers/KeypairView.h b/tools/Forge/Headers/KeypairView.h index ba865c903..e4b8496ea 100644 --- a/tools/Forge/Headers/KeypairView.h +++ b/tools/Forge/Headers/KeypairView.h @@ -1,3 +1,33 @@ +/* + KeypairView.h + + Key pair viewer class definitions + + Copyright (C) 2001 Jeff Teunissen + + 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; diff --git a/tools/Forge/Headers/Map.h b/tools/Forge/Headers/Map.h index 0e98f5ef6..860a30c24 100644 --- a/tools/Forge/Headers/Map.h +++ b/tools/Forge/Headers/Map.h @@ -1,8 +1,36 @@ +/* + Map.h + + Map class definition for Forge + + Copyright (C) 2001 Jeff Teunissen + + 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; diff --git a/tools/Forge/Headers/PopScrollView.h b/tools/Forge/Headers/PopScrollView.h index ac5dc4872..d357366e9 100644 --- a/tools/Forge/Headers/PopScrollView.h +++ b/tools/Forge/Headers/PopScrollView.h @@ -1,3 +1,34 @@ +/* + PopScrollView.h + + (description) + + Copyright (C) 2001 Jeff Teunissen + + 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 @interface PopScrollView: NSScrollView diff --git a/tools/Forge/Headers/Preferences.h b/tools/Forge/Headers/Preferences.h index 53ba48bfa..afccb9a1c 100644 --- a/tools/Forge/Headers/Preferences.h +++ b/tools/Forge/Headers/Preferences.h @@ -3,8 +3,7 @@ Preferences class definition for Forge - Copyright (C) 1996 Id Software, Inc. - Copyright (C) 2001 Jeff Teunissen + Copyright (C) 2001 Jeff Teunissen 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; diff --git a/tools/Forge/Headers/Project.h b/tools/Forge/Headers/Project.h index 8a9750750..7feb33833 100644 --- a/tools/Forge/Headers/Project.h +++ b/tools/Forge/Headers/Project.h @@ -1,5 +1,35 @@ +/* + Project.h + + Project class definition for Forge + + Copyright (C) 2001 Jeff Teunissen + + 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 -#include #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); diff --git a/tools/Forge/Headers/SetBrush.h b/tools/Forge/Headers/SetBrush.h index 522ea93c0..3facc6acd 100644 --- a/tools/Forge/Headers/SetBrush.h +++ b/tools/Forge/Headers/SetBrush.h @@ -1,25 +1,52 @@ +/* + SetBrush.h + SetBrush class definition for Forge + + Copyright (C) 2001 Jeff Teunissen + + 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 +@interface SetBrush: NSObject { BOOL regioned; // not active BOOL selected; diff --git a/tools/Forge/Headers/TexturePalette.h b/tools/Forge/Headers/TexturePalette.h index 4fc4a2440..943b02838 100644 --- a/tools/Forge/Headers/TexturePalette.h +++ b/tools/Forge/Headers/TexturePalette.h @@ -1,7 +1,43 @@ +/* + TexturePalette.h + + Texture Palette handling for Forge + + Copyright (C) 2001 Jeff Teunissen + + 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 +#import +#import + +#import 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; diff --git a/tools/Forge/Headers/TextureView.h b/tools/Forge/Headers/TextureView.h index ee642a79a..288b25b7a 100644 --- a/tools/Forge/Headers/TextureView.h +++ b/tools/Forge/Headers/TextureView.h @@ -1,4 +1,33 @@ +/* + TextureView.h + Texture viewer class definition for Forge + + Copyright (C) 2001 Jeff Teunissen + + 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 { diff --git a/tools/Forge/Headers/Things.h b/tools/Forge/Headers/Things.h index a5b007525..dfa4a11ba 100644 --- a/tools/Forge/Headers/Things.h +++ b/tools/Forge/Headers/Things.h @@ -1,3 +1,33 @@ +/* + Things.h + + (description) + + Copyright (C) 2001 Jeff Teunissen + + 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 @@ -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 diff --git a/tools/Forge/Headers/UserPath.h b/tools/Forge/Headers/UserPath.h index 58652af4b..13112ffb0 100644 --- a/tools/Forge/Headers/UserPath.h +++ b/tools/Forge/Headers/UserPath.h @@ -45,6 +45,8 @@ typedef struct _UP { BOOL ping; } UserPath; +extern UserPath *userPath; + /* UserPath functions */ NSZone *userPathZone(); UserPath *newUserPath(); diff --git a/tools/Forge/Headers/XYView.h b/tools/Forge/Headers/XYView.h index 054647999..15ecc2be2 100644 --- a/tools/Forge/Headers/XYView.h +++ b/tools/Forge/Headers/XYView.h @@ -1,29 +1,44 @@ +/* + XYView.h + + X/Y "perspective" viewer class definitions + + Copyright (C) 2001 Jeff Teunissen + + 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 #import -#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); diff --git a/tools/Forge/Headers/ZScrollView.h b/tools/Forge/Headers/ZScrollView.h index 6f3e60623..87b06316c 100644 --- a/tools/Forge/Headers/ZScrollView.h +++ b/tools/Forge/Headers/ZScrollView.h @@ -1,3 +1,34 @@ +/* + ZScrollView.h + + Depth scroller class definition + + Copyright (C) 2001 Jeff Teunissen + + 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 @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 diff --git a/tools/Forge/Headers/ZView.h b/tools/Forge/Headers/ZView.h index d6079bae2..1c69ae3e1 100644 --- a/tools/Forge/Headers/ZView.h +++ b/tools/Forge/Headers/ZView.h @@ -1,12 +1,37 @@ +/* + ZView.h -#import -#import "mathlib.h" + Depth viewer class definition -extern id zview_i; + Copyright (C) 2001 Jeff Teunissen -// 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 + +#include @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; diff --git a/tools/Forge/Headers/cmdlib.h b/tools/Forge/Headers/cmdlib.h index 22321bf07..3d041f424 100644 --- a/tools/Forge/Headers/cmdlib.h +++ b/tools/Forge/Headers/cmdlib.h @@ -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 diff --git a/tools/Forge/Headers/mathlib.h b/tools/Forge/Headers/mathlib.h deleted file mode 100644 index 607b18f17..000000000 --- a/tools/Forge/Headers/mathlib.h +++ /dev/null @@ -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 - -#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 diff --git a/tools/Forge/Headers/qedefs.h b/tools/Forge/Headers/qedefs.h deleted file mode 100644 index e3c61a107..000000000 --- a/tools/Forge/Headers/qedefs.h +++ /dev/null @@ -1,59 +0,0 @@ - -#import -#import -#import -#import -#import -#import - -#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; diff --git a/tools/Forge/Headers/render.h b/tools/Forge/Headers/render.h index 211b489e7..70411633b 100644 --- a/tools/Forge/Headers/render.h +++ b/tools/Forge/Headers/render.h @@ -1,3 +1,33 @@ +/* + render.h + + Software renderer definitions and prototypes + + Copyright (C) 2001 Jeff Teunissen + + 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; diff --git a/tools/Forge/Map.m b/tools/Forge/Map.m index 616055475..80575a5c6 100644 --- a/tools/Forge/Map.m +++ b/tools/Forge/Map.m @@ -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) diff --git a/tools/Forge/Preferences.m b/tools/Forge/Preferences.m index b06e2ed30..5caa93cb7 100644 --- a/tools/Forge/Preferences.m +++ b/tools/Forge/Preferences.m @@ -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; } diff --git a/tools/Forge/Project.m b/tools/Forge/Project.m index 03c204998..a2e62faaf 100644 --- a/tools/Forge/Project.m +++ b/tools/Forge/Project.m @@ -8,13 +8,13 @@ #import "Preferences.h" -id project_i; +Project * project; @implementation Project - init { - project_i = self; + project = self; return self; } diff --git a/tools/Forge/SetBrush.m b/tools/Forge/SetBrush.m index df56d86cd..92a5901ce 100644 --- a/tools/Forge/SetBrush.m +++ b/tools/Forge/SetBrush.m @@ -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]; diff --git a/tools/Forge/TexturePalette.m b/tools/Forge/TexturePalette.m index 8c20cf809..58b3aca11 100644 --- a/tools/Forge/TexturePalette.m +++ b/tools/Forge/TexturePalette.m @@ -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 ; ichan[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 ; inumlumps); 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 ; itype != TYP_MIPTEX) Error ("TEX_InitFromWad: %s is not a miptex!",lumpinfo->name); CleanupName (lumpinfo->name,qtextures[tex_count].name); diff --git a/tools/Forge/mathlib.c b/tools/Forge/mathlib.c deleted file mode 100644 index c038d185a..000000000 --- a/tools/Forge/mathlib.c +++ /dev/null @@ -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; -} -