page@swan.ulowell.edu (Bob Page) (10/20/88)
Submitted-by: edavies@uvvm.bitnet (Eric Davies) Posting-number: Volume 2, Issue 4 Archive-name: graphics/surf.3of3 # This is a shell archive. Remove anything before this line # then unpack it by saving it in a file and typing "sh file" # (Files unpacked will be owned by you and have default permissions). # This archive contains the following files: # ./README.DOC # ./bezpt.c # ./bezpt.h # ./control.c # ./control.h # ./fasttrig.c # ./fasttrig.h # ./functions.h # ./gadgetdef.c # if `test ! -s ./README.DOC` then echo "writing ./README.DOC" cat > ./README.DOC << '\Rogue\Monster\' Program: BezSurf Author: Eric Davies Resources and Tech Assistance: LateNight Developments (LND) Corporation. Distribution ------------ BezSurf is public domain. Feel free to copy it, enhance it, or port it to other machines, etc. Compilation ----------- Compiled under Lattice C 4.0 at the LND offices. Will also compile under Aztec 3.4a and up. Software Disclaimer ------------------- This is your standard software disclaimer: Use this software at your risk. Any loss of sleep is your own concern. Document Disclaimer ------------------- This document gives a partial description of BezSurf and its use. Many of the menu-items and gadgets are not described here. I believe most people will discover their purpose without too much trouble. If I'm wrong, you can query me by email at: edavies@uvicctr or edavies@uvvm.bitnet Or by snail mail (if some part of Canada Post is not on strike) at: Eric Davies 1442 Harrop Rd. Victoria, B.C. Canada V8P 2S6 How soon you get a response depends on how behind my school work I am and how easily I can determine a return path to you :-). Description ----------- BezSurf (or Surf for short) is a program for producing bezier surfaces of revolution. It produces awesome pictures of wineglasses and doorknobs, and other objects one could turn on a lathe. BezSurf includes the capacity to map iff image files onto any surface that it can draw. History ------- I originally wrote BezSurf for my final project in an introductory course in computer graphics at the University of Victoria. The target machine was a colour Sun Work Station. Being a loyal amigoid, I ported it down to the Amiga when I had a bit more free time, the Late Night Developers supplying resources and technical assistence as needed. I proudly claim any errors or bugs as my own, following the lead of a certain wine glass manufacturer, "the minute flaws in the product are your guarantee of its handcrafted nature". Usage ----- I've run it successfully from Matt Dillon's Shell and the bare cli. It should run fine from workbench, provided somebody whips up an icon for it. Basic Usage ----------- Once run, you should see a 320x200 lores screen with the text "lines curves wire shade map panel" along the top edge. These are the basic control gadgets. 1) press "lines" (screen clears and crosshairs appear). press and hold down the left mouse button. move the mouse someplace else and release the button. a line should have been rubber banded and left on the screen. repeat as desired { press and drag the mouse to define new line connected to last one line. } 2) press "curves". the endpoints of the first line should be bracked by squares. repeat as desired { bring the left mouse button near one of squares. press left button, move to new location, and release left button. nearest square should have accompanied mouse, causing the line to curve in strange and wonderful ways. press right button to move the next line. } 3) press "panel" takes you to the control panel, so you can change the lighting, save files, etc. It is suggested that you try "tilt" with about 20 degrees ( adds a more 3d effect ). to get back to display, press [display] on the control panel. 4) press "wire" generates wireframe with hidden line removal. 5) press "shade" generates shaded image with hidden surface removal. 6) saving the images you created is done via the "files" menu in the control panel. save as... saves the ilbm to the specfied file name save first... tacks on a ".0" to the file name and saves save next... tacks on an ascending number and saves "save first" and "save next" are provided in case somebody wants to try producing animation sequences with Surf. 7) Anything else, excluding maps, should be self apparent with a little bit of experimentation. Error Messages -------------- Error messages are displayed in a requestor. If displayed, you must click in the requestor's close box to continue. The messages usually indicate that your file name is wrong, screwy file contents, you don't have enough memory, etc. Aborting a time consuming activity ---------------------------------- Under the "Image" menu, the "abort" item will terminate any drawing in progress. Mapping Iff images onto Surfaces (Grey Scale Result) -------------------------------- This is my answer to photon paints mapping of images onto spheres, cones, etc. Before you can perform the mapping, you need two things: (1) a loaded map image, and (2) a surface { not necessarily in that order though its probably better to load the image first if you are not sure you have enough memory }. Loading the map image: Go to the control panel window (see earlier discussion). Under the files menu, select the "Open Map" item. Enter the pathname of an ilbm image file (note:Ehb not supported). Wait until the hourglass goes away. Now, go and define a surface if you haven't already. Once you have both a surface defined and an image file loaded, click on the "Map" gadget on the display screen. Be prepared to wait an hour or two for your image to be produced, it is very slow. Using lots of bezier and revolution slices (ie, very small patches) results in images that look less scarred. The "MapRevV" and "MapRevH" sliders determine how many times the map image is replicated on the surface. Closing the map file frees up the memory used to store the map image file. Openning a new map file automatically closes the old one. Mapping Iff images onto Surfaces (Colour Result) -------------------------------- The idea here is to produce three different image files, one that contains the red component, one the green, and one the blue. After the files are produced, use the mergergb tool to combine them into a single file for use by the RAY2 program available from the QRT (public domain) package or DBW (shareware). procedure: set interlace and lores screen. set the grey model to "R only" load the iff image file set the screen color to "Red" (or grey). Generate the surface mapping. Save with a ".r" extension. set the grey model to "G only" load the iff image file again set the screen color to "Green" (or grey). Generate the surface mapping. Save with a ".g" extension. set the grey model to "B only". load the iff image file again. set the screen color to "Blue" (or grey). Generate the surface mapping. Save with a ".b" extension. now run the mergergb program with the filename without extensions as the sole argument. Ie, if you named the files smith.r, smith.g, and smith.b, then type: mergergb smith In this case, mergergb will produce smith.tmp, which can then be fed into RAY2. Without other arguments, RAY2 wil produce an interlaced ham image. Future ------ Be kind of neat if somebody adapted BezSurf to produce object descriptions for Sc*lpt3D or VideoSc*pe3D. Anyone feeling brave and bored? \Rogue\Monster\ else echo "will not over write ./README.DOC" fi if `test ! -s ./bezpt.c` then echo "writing ./bezpt.c" cat > ./bezpt.c << '\Rogue\Monster\' #include "scrnio.h" #include "control.h" #include "bezpt.h" #include "mytypes.h" BezCoord Bezpt[MaxSegs+1]; int NumBezPts; int ActSeg; bool SegDrawn; int BezMesh = DefBezMeshVal; float BezStepSize = 1.0/DefBezMeshVal; void SetBezMesh( value ) int value; { BezMesh = value; BezStepSize = 1.0/value; } void ClearSegments() { NumBezPts = 0; ActSeg = 0; } static float xa, xb, xc, xd; static float ya, yb, yc, yd; /* * start up calculations that must be performed before calling * CalcBezPt on any given segment */ void InitCalcBez() { xa = -StartPtX(ActSeg) + 3.0*( Cntrl1X(ActSeg) - Cntrl2X(ActSeg)) + EndPtX(ActSeg); xb = 3.0 *( StartPtX(ActSeg) + Cntrl2X(ActSeg) - 2.0*Cntrl1X(ActSeg)); xc = 3.0*( Cntrl1X(ActSeg) - StartPtX(ActSeg)); xd = StartPtX(ActSeg); ya = -StartPtY(ActSeg) + 3.0*( Cntrl1Y(ActSeg) - Cntrl2Y(ActSeg)) + EndPtY(ActSeg); yb = 3.0 *( StartPtY(ActSeg) + Cntrl2Y(ActSeg) - 2.0*Cntrl1Y(ActSeg)); yc = 3.0*( Cntrl1Y(ActSeg) - StartPtY(ActSeg)); yd = StartPtY(ActSeg); } /* * calculate a point on the bezier curve of a segment */ void CalcBezPt( t, xvp, yvp) float t; float *xvp, *yvp; { *xvp = (( t*xa + xb) * t + xc) *t + xd; *yvp = (( t*ya + yb) * t + yc) *t + yd; } void XdrawBezSeg() { float t; float ftox, ftoy; int fromx, fromy, tox, toy; InitCalcBez(); for( fromx = StartPtX(ActSeg), fromy = StartPtY(ActSeg), t=BezStepSize; t < 1.0; fromx = tox, fromy = toy, t+= BezStepSize ) { CalcBezPt( t, &ftox, &ftoy ); tox = (int)ftox; toy = (int)ftoy; DrawLine( fromx, fromy, tox, toy, XOR ); DrawPnt( tox, toy, XOR ); } DrawLine( fromx, fromy, EndPtX(ActSeg), EndPtY(ActSeg),XOR); } void XdrawAllBezSegs() { ResetActSeg(); do { XdrawBezSeg(); NextSeg(); } while( ActSeg); DrawControl0(); DrawControl1(); } void ResetCurve() { if( NumBezPts > 0 && CurMode == FITBEZIER ) { int i; ClrWindow(true); for( i = 0; i < NumBezPts; i++ ) { Bezpt[i].x.cur1 = Bezpt[i].x.prev2 = Bezpt[i].x.cur0; Bezpt[i].y.cur1 = Bezpt[i].y.prev2 = Bezpt[i].y.cur0; } ActSeg = 0; XdrawAllBezSegs(); } } /* * set the value of a bezpt element */ static void SetBezPt( xval, yval ) int xval, yval; { BezVal *i; i = &Bezpt[NumBezPts-1].x; i->cur0 = i->prev2 = i->cur1 = xval; i = &Bezpt[NumBezPts-1].y; i->cur0 = i->prev2 = i->cur1 = yval; } void InitBezPt(xval,yval) int xval, yval; { int segno; NumBezPts++; SetBezPt(xval,yval); segno = NumBezPts -2; if( segno >= 0) { DrawLine( StartPtX( segno), StartPtY(segno), EndPtX( segno), EndPtY(segno), XOR ); } } void EditBezPt(xval, yval) { int segno = NumBezPts -2; DrawLine( StartPtX(segno), StartPtY(segno), EndPtX( segno ), EndPtY(segno), XOR ); SetBezPt(xval, yval); DrawLine( StartPtX( segno), StartPtY(segno), EndPtX( segno), EndPtY(segno), XOR ); } \Rogue\Monster\ else echo "will not over write ./bezpt.c" fi if `test ! -s ./bezpt.h` then echo "writing ./bezpt.h" cat > ./bezpt.h << '\Rogue\Monster\' #include "fasttrig.h" /* * structures and such for manipulating bezier curves */ #define MaxSegs 50 /* max number of bezier segments */ typedef struct { int prev2; /* second control point of segment n-1 */ int cur0; /* begin of segment n, end of segment n-1 */ int cur1; /* first control point of segment n */ } BezVal; typedef struct { BezVal x, y; } BezCoord; #define DefBezMeshVal 10 extern BezCoord Bezpt[MaxSegs+1]; extern void SetBezMesh( /* Panel_item, int, struct input_event */); extern int BezMesh; extern float BezStepSize; extern void InitCalcBez( /* void */ ); extern void CalcBezPt(/* float, float *, float * */); extern void XdrawAllBezSegs(/* void */); extern void XdrawBezSeg(/* void */); extern void InitBezPt( /* int, int */); extern void EditBezPt( /* int, int */); extern void ResetCurve( /* void */ ); extern int NumBezPts; extern int ActSeg; #define GetNumSegs() (NumBezPts-1) #define ResetActSeg() { ActSeg = 0; } #define GetCurSeg() (ActSeg) #define NextSeg() { ActSeg = (ActSeg +1) %(NumBezPts -1); } #define StartPtX(XSegNo) Bezpt[XSegNo].x.cur0 #define StartPtY(XSegNo) Bezpt[XSegNo].y.cur0 #define Cntrl1X(XSegNo) Bezpt[XSegNo].x.cur1 #define Cntrl1Y(XSegNo) Bezpt[XSegNo].y.cur1 #define Cntrl2X(XSegNo) Bezpt[XSegNo+1].x.prev2 #define Cntrl2Y(XSegNo) Bezpt[XSegNo+1].y.prev2 #define EndPtX(XSegNo) Bezpt[XSegNo+1].x.cur0 #define EndPtY(XSegNo) Bezpt[XSegNo+1].y.cur0 #define DrawControl0() DrawSqr( Bezpt[ActSeg].x.cur1,\ Bezpt[ActSeg].y.cur1, XOR ) #define DrawControl1() DrawSqr( Bezpt[ActSeg+1].x.prev2,\ Bezpt[ActSeg+1].y.prev2, XOR ) \Rogue\Monster\ else echo "will not over write ./bezpt.h" fi if `test ! -s ./control.c` then echo "writing ./control.c" cat > ./control.c << '\Rogue\Monster\' #include "bezpt.h" #include "control.h" #include "scrnio.h" #include "mytypes.h" CURMODE CurMode = DRAWPOLY; void SetFitBez() { if( GetNumSegs() < 1 ) { return; } ClrWindow(true); CurMode = FITBEZIER; XdrawAllBezSegs(); } void SetPolyDraw() { ClrWindow(true); CurMode = DRAWPOLY; ClearSegments(); } void EditControl0(x,y) int x, y; { DrawControl0(); XdrawBezSeg(); Cntrl1X(GetCurSeg()) = x; Cntrl1Y(GetCurSeg()) = y; XdrawBezSeg(); DrawControl0(); } void EditControl1(x,y) int x, y; { DrawControl1(); XdrawBezSeg(); Cntrl2X(GetCurSeg()) = x; Cntrl2Y(GetCurSeg()) = y; XdrawBezSeg(); DrawControl1(); } \Rogue\Monster\ else echo "will not over write ./control.c" fi if `test ! -s ./control.h` then echo "writing ./control.h" cat > ./control.h << '\Rogue\Monster\' typedef enum { FITBEZIER, DRAWPOLY, NOTACTIVE } CURMODE; void SetFitBez(); void SetPolyDraw(); extern CURMODE CurMode; extern void EditControl0(); extern void EditControl1(); \Rogue\Monster\ else echo "will not over write ./control.h" fi if `test ! -s ./fasttrig.c` then echo "writing ./fasttrig.c" cat > ./fasttrig.c << '\Rogue\Monster\' #include <math.h> #include "fasttrig.h" extern char *malloc(); float *sintab; float *costab; static int oldn = -1, oldrange = -1, oldstart = -1; /* * return true if could not get memory for trig lookup tables */ bool InitFastTrig(angstart, angrange, n) int angstart; int angrange; int n; { int i; float value; float AngleInc; float curangle; if( n == oldn && oldrange == angrange && oldstart == angstart ) { return(false); } if( n != oldn ) { if( sintab ) free(sintab); if( costab ) free(costab); sintab = (float *)malloc( n * sizeof( float )); costab = (float *)malloc( n * sizeof( float )); if( !sintab || !costab ) { return(true); } } oldn = n; oldrange = angrange; oldstart = angstart; AngleInc = (PI*angrange)/(180 *(n-1)); for( curangle = angstart*PI/180.0, i = 0; i< n; i++, curangle += AngleInc ) { sintab[i] = sin( curangle ); costab[i] = cos( curangle ); } return(false); } \Rogue\Monster\ else echo "will not over write ./fasttrig.c" fi if `test ! -s ./fasttrig.h` then echo "writing ./fasttrig.h" cat > ./fasttrig.h << '\Rogue\Monster\' #ifndef FASTTRIG_H_FILE #define FASTTRIG_H_FILE #ifndef MYTYPES_H_FILE #include "mytypes.h" #endif !MYTYPES_H_FILE #define MaxTrigEntries 512 #define PI 3.1415927 extern float *sintab; extern float *costab; #define fsin(sdeg) sintab[sdeg] #define fcos(sdeg) costab[sdeg] bool InitFastTrig(/* float, int */); #endif !FASTTRIG_H_FILE \Rogue\Monster\ else echo "will not over write ./fasttrig.h" fi if `test ! -s ./functions.h` then echo "writing ./functions.h" cat > ./functions.h << '\Rogue\Monster\' typedef long cList; long AbleICR(); void AbortIO(); long ActivateGadget(); void ActivateWindow(); void AddAnimOb(); void AddBob(); void AddConfigDev(); void AddDevice(); long AddDosNode(); void AddFont(); long AddFreeList(); short AddGadget(); unsigned short AddGList(); void AddHead(); struct Interrupt * AddICRVector(); void AddIntServer(); void AddLibrary(); long AddMemList(); void AddPort(); void AddResource(); void AddSemaphore(); void AddTail(); void AddTask(); void AddTime(); void AddVSprite(); long Alert(); void * AllocAbs(); long AllocBoardMem(); cList AllocCList(); struct ConfigDev * AllocConfigDev(); struct MemList * AllocEntry(); long AllocExpansionMem(); void * AllocMem(); long AllocPotBits(); void * AllocRaster(); char * AllocRemember(); long AllocSignal(); long AllocTrap(); struct WBObject * AllocWBObject(); void * Allocate(); void AlohaWorkbench(); void AndRectRegion(); long AndRegionRegion(); void Animate(); short AreaDraw(); long AreaEllipse(); void AreaEnd(); short AreaMove(); void AskFont(); long AskSoftStyle(); long AttemptLockLayerRom(); long AttemptSemaphore(); short AutoRequest(); long AvailFonts(); long AvailMem(); void BeginIO(); void BeginRefresh(); void BeginUpdate(); void BeginLayer(); long BltBitMap(); long BltBitMapRastPort(); void BltClear(); void BltMaskBitMapRastPort(); void BltPattern(); void BltTemplate(); struct Window * BuildSysRequest(); char * BumpRevision(); void Cause(); void CBump(); void CDInputHandler(); void ChangeSprite(); struct IORequest * CheckIO(); short ClearDMRequest(); void ClearEOL(); void ClearMenuStrip(); void ClearPointer(); void ClearRegion(); long ClearRectRegion(); void ClearScreen(); void ClipBit(); void Close(); void CloseDevice(); void CloseFont(); void CloseLibrary(); void CloseScreen(); void CloseWindow(); short CloseWorkBench(); void CMove(); short CmpTime(); long ConcatCList(); long ConfigBoard(); long ConfigChain(); long ConsoleDevice(); long CopperListInit(); cList CopyCList(); void CopyMem(); void CopyMemQuick(); void CopySBitMap(); void CreateBehindLayer(); struct Lock * CreateDir(); struct MsgPort * CreatePort(); struct Process * CreateProc(); struct IOStdReq * CreateStdIO(); struct Task * CreateTask(); void CreateUpfrontLayer(); struct Lock * CurrentDir(); void CurrentTime(); void CWait(); long * DateStamp(); void Deallocate(); void Debug(); void Delay(); short DeleteFile(); void DeleteLayer(); void DeletePort(); void DeleteStdIO(); void DeleteTask(); struct Process * DeviceProc(); void Disable(); void DisownBlitter(); short DisplayAlert(); void DisplayBeep(); void DisposeRegion(); void DoCollision(); long DoIO(); short DoubleClick(); void Draw(); void DrawBorder(); void DrawEllipse(); void DrawGList(); void DrawImage(); struct Lock * DupLock(); void Enable(); void EndRefresh(); void EndRequest(); void EndUpdate(); void Enqueue(); short ExNext(); short Examine(); short Execute(); void Exit(); struct ConfigDev * FindConfigDev(); struct Node * FindName(); struct MsgPort * FindPort(); long FindResident(); struct SignalSemaphore *FindSemaphore(); struct Task * FindTask(); char * FindToolType(); void Flood(); void FlushCList(); void Forbid(); void FreeBoardMem(); void FreeCList(); void FreeColorMap(); void FreeConfigDev(); void FreeCopList(); void FreeCprList(); void FreeDiskObject(); void FreeEntry(); void FreeExpansionMem(); void FreeFreeList(); void FreeGBuffers(); void FreeMem(); void FreePotBits(); void FreeRaster(); void FreeRemember(); void FreeSignal(); void FreeSprite(); void FreeSysRequest(); void FreeTrap(); void FreeVPortCopLists(); void FreeWBObject(); long GetCC(); long GetCLBuf(); short GetCLChar(); short GetCLWord(); struct ColorMap * GetColorMap(); long GetCurrentBinding(); struct Preferences * GetDefPrefs(); struct DiskObject * GetDiskObject(); void GetGBuffers(); long GetIcon(); struct Message * GetMsg(); struct Preferences * GetPrefs(); short GetRGB4(); long GetScreenData(); short GetSprite(); struct WBObject * GetWBObject(); long IncrCLMark(); short Info(); void InitArea(); void InitBitMap(); long InitCLPool(); void InitCode(); void InitGMasks(); void InitGels(); void InitMasks(); void InitRastPort(); void InitRequester(); void InitResident(); void InitSemaphore(); void InitStruct(); void InitTmpRas(); void InitVPort(); void InitView(); struct FileHandle * Input(); void Insert(); struct Region * InstallClipRegion(); long IntuiTextLength(); struct InputEvent * Intuition(); long IoErr(); short IsInteractive(); struct MenuItem * ItemAddress(); void LoadRGB4(); struct Segment * LoadSeg(); void LoadView(); struct Lock * Lock(); void LockLayer(); void LockLayerInfo(); void LockLayerRom(); void LockLayers(); struct DeviceNode * MakeDosNode(); long MakeFunctions(); struct Library * MakeLibrary(); void MakeScreen(); void MakeVPort(); long MarkCList(); long MatchToolValue(); void ModifyIDCMP(); void ModifyProp(); void Move(); void MoveLayer(); void MoveScreen(); void MoveSprite(); void MoveWindow(); void MrgCop(); void NewList(); void NewModifyProp(); struct Region * NewRegion(); void ObtainConfigBinding(); void ObtainSemaphore(); void ObtainSemaphoreList(); void OffGadget(); void OffMenu(); void OnGadget(); void OnMenu(); struct FileHandle * Open(); long OpenDevice(); struct Font * OpenDiskFont(); struct Font * OpenFont(); void OpenIntuition(); struct Library * OpenLibrary(); struct MiscResource * OpenResource(); struct Screen * OpenScreen(); struct Window * OpenWindow(); short OpenWorkBench(); void OrRectRegion(); long OrRegionRegion(); struct FileHandle * Output(); void OwnBlitter(); struct Lock * ParentDir(); short PeekCLMark(); void Permit(); void PolyDraw(); void PrintIText(); long PutCLBuf(); long PutCLChar(); long PutCLWord(); short PutDiskObject(); long PutIcon(); void PutMsg(); long PutWBObject(); void QBSBlit(); void QBlit(); short RawKeyConvert(); long Read(); char ReadExpansionByte(); long ReadExpansionRom(); short ReadPixel(); void RectFill(); void RefreshGadgets(); void RefreshGList(); void RefreshWindowFrame(); void ReleaseConfigBinding(); void ReleaseSemaphore(); void ReleaseSemaphoreList(); void RemConfigDev(); void RemDevice(); void RemFont(); struct Node * RemHead(); void RemIBob(); void RemICRVector(); void RemIntServer(); long RemLibrary(); unsigned short RemoveGList(); void RemPort(); void RemResource(); void RemSemaphore(); struct Node * RemTail(); void RemTask(); void RemVSprite(); void RemakeDisplay(); void Remove(); unsigned short RemoveGadget(); short Rename(); void ReplyMsg(); void ReportMouse(); short Request(); void RethinkDisplay(); void ScreenToBack(); void ScreenToFront(); void ScrollLayer(); void ScrollRaster(); void ScrollVPort(); long Seek(); void SendIO(); void SetAPen(); void SetBPen(); void SetCollision(); short SetComment(); void SetCurrentBinding(); short SetDMRequest(); void SetDRMd(); long SetExcept(); long SetFont(); long SetFunction(); long SetICR(); struct Interrupt * SetIntVector(); void SetMenuStrip(); void SetPointer(); void SetPrefs(); short SetProtection(); void SetRast(); void SetRGB4(); void SetRGB4CM(); long SetSR(); long SetSignal(); long SetSoftStyle(); short SetTaskPri(); void SetWindowTitles(); void ShowTitle(); void Signal(); long SizeCList(); void SizeLayer(); void SizeWindow(); void SortGList(); cList SplitCList(); cList SubCList(); void SubTime(); void SubLibrary(); void SumKickData(); long SuperState(); void SwapBitsRastPortClipRect(); void SyncSBitMap(); long Text(); long TextLength(); long Translate(); long UnGetCLChar(); long UnGetCLWord(); void UnLoadSeg(); void UnLock(); short UnPutCLChar(); short UnPutCLWord(); void UnlockLayer(); void UnlockLayerInfo(); void UnlockLayerRom(); void UnlockLayers(); void UpfrontLayer(); void UserState(); short VBeamPos(); struct View * ViewAddress(); struct ViewPort * ViewPortAddress(); short WBenchToBack(); short WBenchToFront(); long Wait(); void WaitBOVP(); void WaitBlit(); short WaitForChar(); long WaitIO(); struct Message * WaitPort(); void WaitTOF(); struct Layer * WhichLayer(); short WindowLimits(); void WindowToBack(); void WindowToFront(); long Write(); long WriteExpansionByte(); void WritePixel(); void WritePotgo(); void XorRectRegion(); long XorRegionRegion(); \Rogue\Monster\ else echo "will not over write ./functions.h" fi if `test ! -s ./gadgetdef.c` then echo "writing ./gadgetdef.c" cat > ./gadgetdef.c << '\Rogue\Monster\' /* this file contains definition for the screen */ #include "scrnio.ih" #include <exec/memory.h> #ifdef MANX #include <functions.h> #endif #include "scrndef.h" #include "gadgetdef.h" #include "mytypes.h" #include "bezpt.h" #include "poly.h" #include "revolve.h" #include "readilbm.h" /* * definition for image of hourglass */ static UWORD HourGlassDat[] = { 0x0, 0x0, 0x0, 0xffff, 0x7ffe, 0x8001, 0x6006, 0x9ff9, 0x2004, 0x5ffa, 0x1c38, 0x2ff4, 0xf70, 0x17e8, 0x7e0, 0xbd0, 0x2c0, 0x5a0, 0x240, 0x5a0, 0x420, 0xbd0, 0x910, 0x17e8, 0x1788, 0x2ff4, 0x2fe4, 0x5ffa, 0x7ff6, 0x9ff9, 0x7ffe, 0x8001, 0x0, 0xffff, 0x0, 0x0 }; UWORD *HourGlass = NULL; /* * actual gadget definitions */ #define TOP 13 #define ROW 9 #define COL 8 #define TxOff 1 /* * start of boolean gadgets */ #define BOOLGADFLAGS (RELVERIFY|TOPBORDER) #define BOOLTOP 0 #define BOOLLEFT 0 static struct IntuiText TextDefLines = { -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Lines", NULL }; static struct Gadget G_DefLines = { NULL, BOOLLEFT , BOOLTOP , 5*COL, ROW, /* loc and size of hit box */ GADGHBOX, /* complemented when pressed */ BOOLGADFLAGS, /* just get gadget up messages */ BOOLGADGET, NULL, NULL, &TextDefLines, 0, NULL, (int)N_DefLines, NULL }; static struct IntuiText TextEditBez = { -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Curves", NULL }; static struct Gadget G_EditBez = { &G_DefLines, BOOLLEFT+COL*6, BOOLTOP, 6*COL, ROW, /* loc and size of hit box */ GADGHBOX, /* complemented when pressed */ RELVERIFY, /* just get gadget up messages */ BOOLGADGET, NULL, NULL, &TextEditBez, 0, NULL, (int)N_EditBez, NULL }; static struct IntuiText TextMap = { -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Map", NULL }; static struct Gadget G_Map = { &G_EditBez, BOOLLEFT +24*COL, BOOLTOP, 3*COL, ROW, /* loc and size of hit box */ GADGHBOX, /* complemented when pressed */ RELVERIFY, /* just get gadget up messages */ BOOLGADGET, NULL, NULL, &TextMap, 0, NULL, (int)N_Map, NULL }; static struct IntuiText TextWire = { -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Wire", NULL }; static struct Gadget G_Wire = { &G_Map, BOOLLEFT +13*COL, BOOLTOP, 4*COL, ROW, /* loc and size of hit box */ GADGHBOX, /* complemented when pressed */ RELVERIFY, /* just get gadget up messages */ BOOLGADGET, NULL, NULL, &TextWire, 0, NULL, (int)N_Wire, NULL }; static struct IntuiText TextShaded = { -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Shade", NULL }; static struct Gadget G_Shaded = { &G_Wire, BOOLLEFT +18*COL, BOOLTOP, 5*COL, ROW, /* loc and size of hit box */ GADGHBOX, /* complemented when pressed */ RELVERIFY, /* just get gadget up messages */ BOOLGADGET, NULL, NULL, &TextShaded, 0, NULL, (int)N_Shaded, NULL }; static struct IntuiText TextGoPanel = { -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Panel", NULL }; static struct Gadget G_GoPanel = { &G_Shaded, BOOLLEFT +28*COL, BOOLTOP, 5*COL, ROW, /* loc and size of hit box */ GADGHBOX, /* complemented when pressed */ RELVERIFY, /* just get gadget up messages */ BOOLGADGET, NULL, NULL, &TextGoPanel, 0, NULL, (int)N_GoPanel, NULL }; static struct IntuiText TextGoSurf = { 1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Display", NULL }; static short S_GoSurf[] = { -2,-1, -2,ROW+1, 7*COL+2,ROW+1, 7*COL+2,-1, -2,-1 }; static struct Border B_GoSurf = { 0, 0, 1, 0, JAM1, 5, S_GoSurf, NULL }; static struct Gadget G_GoSurf = { NULL, 2*COL, TOP, 7*COL, ROW, /* loc and size of hit box */ GADGHBOX, /* complemented when pressed */ RELVERIFY, /* just get gadget up messages */ BOOLGADGET, (APTR)&B_GoSurf, NULL, &TextGoSurf, 0, NULL, (int)N_GoSurf, NULL }; /* * beginning of slider gadgets */ #define GadFlags (GADGIMAGE | GADGHNONE) /* my gadget flags */ #define MyPropType (PROPGADGET) /* * definitions for the number of Revolution Slices */ static char DispRevSlices[] = { "Rev Slices=[ ]" }; static struct IntuiText TextRevSlices = { 1,1,JAM1, -sizeof(DispRevSlices)*COL, TxOff, NULL, (UBYTE *)DispRevSlices, NULL }; struct GadExtens VRevSlices = {0.0, 0.0, 0.0, 1, 360, DefRevMeshVal, false }; static struct Gadget G_RevSlices = { &G_GoSurf, COL*57 , TOP+ROW*2, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType, NULL, NULL , /* high lighted */ &TextRevSlices, 0x0, NULL, (int)N_RevSlices, (APTR) &VRevSlices }; /* * definition for the background shade */ static char DispBackPlane[] = { "Background = [ ]" }; static struct IntuiText TextBackPlane = { 1,1,JAM1, -sizeof(DispBackPlane)*COL, TxOff, NULL, (UBYTE *)DispBackPlane, NULL }; struct GadExtens VBackPlane = {0.0, 0.0, 0.0, 0, 31, DefBkPlane, false}; static struct Gadget G_BackPlane = { &G_RevSlices, COL*57 , TOP+ROW*13, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType, NULL, NULL , /* high lighted */ &TextBackPlane, 0x0, NULL, (int)N_BackPlane, (APTR) &VBackPlane }; /* * definitions for the number of Revolution Angles */ static char DispRevAngle[] = { "Rev Angle=[ ]" }; static struct IntuiText TextRevAngle = { 1,1,JAM1, -sizeof(DispRevAngle)*COL, TxOff, NULL, (UBYTE *)DispRevAngle, NULL }; struct GadExtens VRevAngle = { 0.0, 0.0, 0.0, 0, 360, DefRotRange, false }; static struct Gadget G_RevAngle = { &G_BackPlane, COL*57 , TOP+ROW*3, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType , NULL, NULL, /* high lighted */ &TextRevAngle, 0x0, NULL, (int)N_RevAngle, (APTR) &VRevAngle }; /* * definitions for start rotation angle */ static char DispRevStart[] = { "Start Angle=[ ]" }; static struct IntuiText TextRevStart = { 1,1,JAM1, -sizeof(DispRevStart)*COL, TxOff, NULL, (UBYTE *)DispRevStart, NULL }; struct GadExtens VRevStart = { 0.0, 0.0, 0.0, 0, 360, DefRotStart, false }; static struct Gadget G_RevStart = { &G_RevAngle, COL*57 , TOP+ROW*4, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType , NULL, NULL, /* high lighted */ &TextRevStart, 0x0, NULL, (int)N_RevStart, (APTR) &VRevStart }; /* * definitions for the number of Bezier Slices */ static char DispBezSlices[] = { "Bez Slices=[ ]" }; static struct IntuiText TextBezSlices = { 1,1,JAM1, -sizeof(DispBezSlices)*COL, TxOff, NULL, (UBYTE *)DispBezSlices, NULL }; struct GadExtens VBezSlices = { 0.0, 0.0, 0.0, 1, 100, DefBezMeshVal, false }; static struct Gadget G_BezSlices = { &G_RevStart, COL*20 , TOP+ROW*2, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType , NULL, NULL, /* high lighted */ &TextBezSlices, 0x0, NULL, (int)N_BezSlices, (APTR)&VBezSlices }; /* * definitions for tilt angle */ static char DispTiltAng[] = { "Tilt Angle=[ ]" }; static struct IntuiText TextTiltAng = { 1,1,JAM1, -sizeof(DispTiltAng)*COL, TxOff, NULL, (UBYTE *)DispTiltAng, NULL }; struct GadExtens VTiltAng = { 0.0, 0.0, 0.0, 0, 360, DefTilt, false }; static struct Gadget G_TiltAng = { &G_BezSlices, COL*20 , TOP+ROW*3, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType , NULL, NULL, /* high lighted */ &TextTiltAng, 0x0, NULL, (int)N_TiltAng, (APTR) &VTiltAng }; /* * definitions for K Specular */ static char DispKspec[] = {"Kspecular=[ ] " }; static struct IntuiText TextKspec = { 1,1,JAM1, -sizeof(DispKspec)*COL, TxOff, NULL, (UBYTE *)DispKspec, NULL }; struct GadExtens VKspec = { 0.0, 1.0, DefKs, 0, 0, 0, true }; static struct Gadget G_Kspec = { &G_TiltAng, 49*COL , TOP+ROW*9, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType , NULL, NULL, /* high lighted */ &TextKspec, 0x0, NULL, (int)N_Kspec, (APTR) &VKspec }; /* * definitions for K diffuse */ static char DispKdiffuse[] = {"Kdiffuse=[ ] " }; static struct IntuiText TextKdiffuse = { 1,1,JAM1, -sizeof(DispKdiffuse)*COL, TxOff, NULL, (UBYTE *)DispKdiffuse, NULL }; struct GadExtens VKdiffuse = { 0.0, 1.0, DefKd, 0, 0, 0, true }; static struct Gadget G_Kdiffuse = { &G_Kspec, 49*COL , TOP+ROW*10, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType , NULL, NULL, /* high lighted */ &TextKdiffuse, 0x0, NULL, (int)N_Kdiffuse, (APTR) &VKdiffuse }; /* * definitions for DispPtIntens */ static struct IntuiText PtProperties = { 1,1,JAM1, -10*COL, -ROW, NULL, (UBYTE *)"Properties", NULL }; static char DispPtIntens[] = {"Intensity=[ ] " }; static struct IntuiText TextPtIntens = { 1,1,JAM1, -sizeof(DispPtIntens)*COL, TxOff, NULL, (UBYTE *)DispPtIntens, &PtProperties }; struct GadExtens VPtIntens = { 0.0, 2.5, DefIntensity , 0, 0, 0, true }; static struct Gadget G_PtIntens = { &G_Kdiffuse, 49*COL , TOP+ROW*8, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType , NULL, NULL, /* high lighted */ &TextPtIntens, 0x0, NULL, (int)N_PtIntens, (APTR) &VPtIntens }; /* * definitions for background intensity */ static struct IntuiText DispAmbient= { 1,1,JAM1,- COL*3, -ROW, NULL, (UBYTE *) "Other", NULL }; static char DispBkIntens[] = { "Ambience=[ ] " }; static struct IntuiText TextBkIntens = { 1,1,JAM1, -sizeof(DispBkIntens)*COL, TxOff, NULL, (UBYTE *) DispBkIntens, &DispAmbient }; struct GadExtens VBkIntens = { 0.0, 1.0, DefAmbience, 0, 0, 0, true }; static struct Gadget G_BkIntens = { &G_PtIntens, 20*COL , TOP+ROW*13, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType, NULL, NULL, /* high lighted */ &TextBkIntens, 0x0, NULL, (int)N_BkIntens, (APTR)&VBkIntens }; /* * Definitions for Surface distance */ static char DispSurfDist[] = {"Surf Dist=[ ] " }; static struct IntuiText TextSurfDist = { 1,1,JAM1, -sizeof(DispSurfDist)*COL, TxOff, NULL, (UBYTE *) DispSurfDist, NULL }; struct GadExtens VSurfDist = {0.0, 0.0, 0.0, -500, 3000, DefSurfDist, false}; static struct Gadget G_SurfDist = { &G_BkIntens, 20*COL , TOP+ROW*4, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType, NULL, NULL, /* high lighted */ &TextSurfDist, 0x0, NULL, (int)N_SurfDist, (APTR)&VSurfDist }; /* * definitions for location.x */ static struct IntuiText PointLight = { 1,1,JAM1, 9*COL, -ROW*2, NULL, (UBYTE *) "Point Light Source", NULL }; static struct IntuiText TextPtLocXYZ = { 1,1,JAM1, -4, -ROW, NULL, (UBYTE *) "Location", &PointLight }; static char DispPtLocX[] = { "x=[ ] " }; static struct IntuiText TextPtLocX = { 1,1,JAM1, -sizeof(DispPtLocX)*COL, TxOff, NULL, (UBYTE *) DispPtLocX, &TextPtLocXYZ }; struct GadExtens VPtLocX = {0.0, 0.0, 0.0, -6000, 6000, DefLightSrcX, false }; static struct Gadget G_PtLocX = { &G_SurfDist, 12*COL , TOP+ROW*8, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType, NULL, NULL, /* high lighted */ &TextPtLocX, 0x0, NULL, (int)N_PtLocX, (APTR) &VPtLocX }; /* * definitions for location.x */ static char DispPtLocY[] = "y=[ ] "; static struct IntuiText TextPtLocY = { 1,1,JAM1, -sizeof(DispPtLocY)*COL, TxOff, NULL, (UBYTE *) DispPtLocY, NULL }; struct GadExtens VPtLocY = { 0.0, 0.0, 0.0, -6000, 6000, DefLightSrcY, false }; static struct Gadget G_PtLocY = { &G_PtLocX, 12*COL , TOP+ROW*9, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType, NULL, NULL, /* high lighted */ &TextPtLocY, 0x0, NULL, (int)N_PtLocY, (APTR) &VPtLocY }; /* * definitions for location.z */ static char DispPtLocZ[] = { "z=[ ] " }; static struct IntuiText TextPtLocZ = { 1,1,JAM1, -sizeof(DispPtLocZ)*COL, TxOff, NULL, (UBYTE *)DispPtLocZ, NULL }; struct GadExtens VPtLocZ ={ 0.0, 0.0, 0.0, -1000, 3000, DefLightSrcZ, false }; static struct Gadget G_PtLocZ = { &G_PtLocY, 12*COL , TOP+ROW*10, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType, NULL, NULL, /* high lighted */ &TextPtLocZ, 0x0, NULL, (int)N_PtLocZ, (APTR) &VPtLocZ }; /* * definitions for Map replication in horizontal axis */ static char DispRepH[] = { "Map RepH=[ ] " }; static struct IntuiText TextRepH = { 1,1,JAM1, -sizeof(DispRepH)*COL, TxOff, NULL, (UBYTE *)DispRepH, NULL }; struct GadExtens VRepH ={ 0.0, 0.0, 0.0, 1, 300, DefRepH, false }; static struct Gadget G_RepH = { &G_PtLocZ, 20*COL , TOP+ROW*15, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType, NULL, NULL, /* high lighted */ &TextRepH, 0x0, NULL, (int)N_RepH, (APTR) &VRepH }; /* * definitions for map replication in vertical axis */ static char DispRepV[] = { "Map RepV=[ ] " }; static struct IntuiText TextRepV = { 1,1,JAM1, -sizeof(DispRepV)*COL, TxOff, NULL, (UBYTE *)DispRepV, NULL }; struct GadExtens VRepV ={ 0.0, 0.0, 0.0, 1, 300, DefRepV, false }; static struct Gadget G_RepV = { &G_RepH, 57*COL , TOP+ROW*15, COL*15, ROW, /* loc and size */ GadFlags, RELVERIFY, MyPropType, NULL, NULL, /* high lighted */ &TextRepV, 0x0, NULL, (int)N_RepV, (APTR) &VRepV }; LoadChipMem( dest, src, srcsize) UWORD **dest; UWORD *src; int srcsize; { UWORD *d; d = (UWORD *)AllocMem( srcsize, MEMF_CHIP ); *dest = d; while( srcsize ) { *d++ = *src++; srcsize -= sizeof( UWORD ); } } void InitGadgets() { struct Gadget *vp; LoadChipMem( &HourGlass, HourGlassDat, sizeof(HourGlassDat)); CntrlWinDef.FirstGadget = &G_RepV; GadWinDef.FirstGadget = &G_GoPanel; /* * fill in numeric fields */ for( vp = CntrlWinDef.FirstGadget; vp; vp = vp->NextGadget ) { GadgetSetVal( vp ); GadgetUpdate(vp, false ); } } void EndGadgets() { if( HourGlass ) { FreeMem(HourGlass, sizeof(HourGlassDat )); } } \Rogue\Monster\ else echo "will not over write ./gadgetdef.c" fi echo "Finished archive 3 of 3" # if you want to concatenate archives, remove anything after this line exit -- Bob Page, U of Lowell CS Dept. page@swan.ulowell.edu ulowell!page "I can't tell the difference between ABC News and Hill Street Blues" -Bono