Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (02/11/90)
Submitted-by: <edavies@sanjuan.uvic.ca> Posting-number: Volume 90, Issue 066 Archive-name: applications/surf-r2/part04 #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 4 (of 4)." # Contents: gadgetdef.c mapstuff.c # Wrapped by tadguy@xanth on Sat Feb 10 15:47:43 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'gadgetdef.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'gadgetdef.c'\" else echo shar: Extracting \"'gadgetdef.c'\" \(14722 characters\) sed "s/^X//" >'gadgetdef.c' <<'END_OF_FILE' X/* this file contains definition for the screen */ X X#include "scrnio.ih" X#include <exec/memory.h> X#ifdef MANX X#include <functions.h> X#endif X X#include "scrndef.h" X#include "gadgetdef.h" X#include "mytypes.h" X#include "bezpt.h" X#include "poly.h" X#include "revolve.h" X#include "readilbm.h" X X/* X * definition for image of hourglass X */ Xstatic UWORD HourGlassDat[] = { X 0x0, 0x0, 0x0, 0xffff, X 0x7ffe, 0x8001, 0x6006, 0x9ff9, X 0x2004, 0x5ffa, 0x1c38, 0x2ff4, X 0xf70, 0x17e8, 0x7e0, 0xbd0, X 0x2c0, 0x5a0, 0x240, 0x5a0, X 0x420, 0xbd0, 0x910, 0x17e8, X 0x1788, 0x2ff4, 0x2fe4, 0x5ffa, X 0x7ff6, 0x9ff9, 0x7ffe, 0x8001, X 0x0, 0xffff, 0x0, 0x0 X }; X XUWORD *HourGlass = NULL; X X X X X/* X * actual gadget definitions X */ X#define TOP 13 X#define ROW 9 X#define COL 8 X#define TxOff 1 X /* X * start of boolean gadgets X */ X#define BOOLGADFLAGS (RELVERIFY|TOPBORDER) X#define BOOLTOP 0 X#define BOOLLEFT 0 X Xstatic struct IntuiText TextDefLines = { X -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Lines", NULL }; X Xstatic struct Gadget G_DefLines = { X NULL, X BOOLLEFT , BOOLTOP , 5*COL, ROW, /* loc and size of hit box */ X GADGHBOX, /* complemented when pressed */ X BOOLGADFLAGS, /* just get gadget up messages */ X BOOLGADGET, X NULL, NULL, X &TextDefLines, X 0, NULL, X (int)N_DefLines, X NULL X }; X X Xstatic struct IntuiText TextEditBez = { X -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Curves", NULL }; X Xstatic struct Gadget G_EditBez = { X &G_DefLines, X BOOLLEFT+COL*6, BOOLTOP, 6*COL, ROW, /* loc and size of hit box */ X GADGHBOX, /* complemented when pressed */ X RELVERIFY, /* just get gadget up messages */ X BOOLGADGET, X NULL, NULL, X &TextEditBez, X 0, NULL, X (int)N_EditBez, X NULL X }; X X Xstatic struct IntuiText TextMap = { X -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Map", NULL }; X Xstatic struct Gadget G_Map = { X &G_EditBez, X BOOLLEFT +24*COL, BOOLTOP, 3*COL, ROW, /* loc and size of hit box */ X GADGHBOX, /* complemented when pressed */ X RELVERIFY, /* just get gadget up messages */ X BOOLGADGET, X NULL, NULL, X &TextMap, X 0, NULL, X (int)N_Map, X NULL X }; X X Xstatic struct IntuiText TextWire = { X -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Wire", NULL }; X Xstatic struct Gadget G_Wire = { X &G_Map, X BOOLLEFT +13*COL, BOOLTOP, 4*COL, ROW, /* loc and size of hit box */ X GADGHBOX, /* complemented when pressed */ X RELVERIFY, /* just get gadget up messages */ X BOOLGADGET, X NULL, NULL, X &TextWire, X 0, NULL, X (int)N_Wire, X NULL X }; X Xstatic struct IntuiText TextShaded = { X -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Shade", NULL }; X Xstatic struct Gadget G_Shaded = { X &G_Wire, X BOOLLEFT +18*COL, BOOLTOP, 5*COL, ROW, /* loc and size of hit box */ X GADGHBOX, /* complemented when pressed */ X RELVERIFY, /* just get gadget up messages */ X BOOLGADGET, X NULL, NULL, X &TextShaded, X 0, NULL, X (int)N_Shaded, X NULL X }; X Xstatic struct IntuiText TextGoPanel = { X -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Panel", NULL }; X Xstatic struct Gadget G_GoPanel = { X &G_Shaded, X BOOLLEFT +28*COL, BOOLTOP, 5*COL, ROW, /* loc and size of hit box */ X GADGHBOX, /* complemented when pressed */ X RELVERIFY, /* just get gadget up messages */ X BOOLGADGET, X NULL, NULL, X &TextGoPanel, X 0, NULL, X (int)N_GoPanel, X NULL X }; X Xstatic struct IntuiText TextGoSurf = { X 1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Display", NULL }; X Xstatic short S_GoSurf[] = { X -2,-1, -2,ROW+1, 7*COL+2,ROW+1, 7*COL+2,-1, -2,-1 X }; X Xstatic struct Border B_GoSurf = { 0, 0, 1, 0, JAM1, 5, S_GoSurf, NULL }; X Xstatic struct Gadget G_GoSurf = { X NULL, X 2*COL, TOP, 7*COL, ROW, /* loc and size of hit box */ X GADGHBOX, /* complemented when pressed */ X RELVERIFY, /* just get gadget up messages */ X BOOLGADGET, X (APTR)&B_GoSurf, NULL, X &TextGoSurf, X 0, NULL, X (int)N_GoSurf, X NULL X }; X X /* X * beginning of slider gadgets X */ X#define GadFlags (GADGIMAGE | GADGHNONE) /* my gadget flags */ X#define MyPropType (PROPGADGET) X X/* X * definitions for the number of Revolution Slices X */ X Xstatic char DispRevSlices[] = { "Rev Slices=[ ]" }; X Xstatic struct IntuiText TextRevSlices = { X 1,1,JAM1, -sizeof(DispRevSlices)*COL, TxOff, NULL, X (UBYTE *)DispRevSlices, NULL X }; X Xstruct GadExtens VRevSlices = {0.0, 0.0, 0.0, 1, 360, DefRevMeshVal, false }; X Xstatic struct Gadget G_RevSlices = { X &G_GoSurf, X COL*57 , TOP+ROW*2, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType, X NULL, X NULL , /* high lighted */ X &TextRevSlices, X 0x0, X NULL, X (int)N_RevSlices, X (APTR) &VRevSlices X }; X X/* X * definition for the background shade X */ Xstatic char DispBackPlane[] = { "Background = [ ]" }; X Xstatic struct IntuiText TextBackPlane = { X 1,1,JAM1, -sizeof(DispBackPlane)*COL, TxOff, NULL, X (UBYTE *)DispBackPlane, NULL X }; X Xstruct GadExtens VBackPlane = {0.0, 0.0, 0.0, 0, 31, DefBkPlane, false}; X X Xstatic struct Gadget G_BackPlane = { X &G_RevSlices, X COL*57 , TOP+ROW*13, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType, X NULL, X NULL , /* high lighted */ X &TextBackPlane, X 0x0, X NULL, X (int)N_BackPlane, X (APTR) &VBackPlane X }; X X X/* X * definitions for the number of Revolution Angles X */ X Xstatic char DispRevAngle[] = { "Rev Angle=[ ]" }; X Xstatic struct IntuiText TextRevAngle = { X 1,1,JAM1, -sizeof(DispRevAngle)*COL, TxOff, NULL, X (UBYTE *)DispRevAngle, NULL X }; X Xstruct GadExtens VRevAngle = { 0.0, 0.0, 0.0, 0, 360, DefRotRange, false }; X X Xstatic struct Gadget G_RevAngle = { X &G_BackPlane, X COL*57 , TOP+ROW*3, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType , X NULL, X NULL, /* high lighted */ X &TextRevAngle, X 0x0, X NULL, X (int)N_RevAngle, X (APTR) &VRevAngle X }; X/* X * definitions for start rotation angle X */ X Xstatic char DispRevStart[] = { "Start Angle=[ ]" }; X Xstatic struct IntuiText TextRevStart = { X 1,1,JAM1, -sizeof(DispRevStart)*COL, TxOff, NULL, X (UBYTE *)DispRevStart, NULL X }; X Xstruct GadExtens VRevStart = { 0.0, 0.0, 0.0, 0, 360, DefRotStart, false }; X X Xstatic struct Gadget G_RevStart = { X &G_RevAngle, X COL*57 , TOP+ROW*4, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType , X NULL, X NULL, /* high lighted */ X &TextRevStart, X 0x0, X NULL, X (int)N_RevStart, X (APTR) &VRevStart X }; X X/* X * definitions for the number of Bezier Slices X */ X Xstatic char DispBezSlices[] = { "Bez Slices=[ ]" }; X Xstatic struct IntuiText TextBezSlices = { X 1,1,JAM1, -sizeof(DispBezSlices)*COL, TxOff, NULL, X (UBYTE *)DispBezSlices, NULL X }; X X Xstruct GadExtens VBezSlices = { 0.0, 0.0, 0.0, 1, 100, DefBezMeshVal, false }; X Xstatic struct Gadget G_BezSlices = { X &G_RevStart, X COL*20 , TOP+ROW*2, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType , X NULL, X NULL, /* high lighted */ X &TextBezSlices, X 0x0, X NULL, X (int)N_BezSlices, X (APTR)&VBezSlices X }; X X/* X * definitions for tilt angle X */ X Xstatic char DispTiltAng[] = { "Tilt Angle=[ ]" }; X Xstatic struct IntuiText TextTiltAng = { X 1,1,JAM1, -sizeof(DispTiltAng)*COL, TxOff, NULL, X (UBYTE *)DispTiltAng, NULL X }; X X Xstruct GadExtens VTiltAng = { 0.0, 0.0, 0.0, 0, 360, DefTilt, false }; X Xstatic struct Gadget G_TiltAng = { X &G_BezSlices, X COL*20 , TOP+ROW*3, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType , X NULL, X NULL, /* high lighted */ X &TextTiltAng, X 0x0, X NULL, X (int)N_TiltAng, X (APTR) &VTiltAng X }; X X X/* X * definitions for K Specular X */ X Xstatic char DispKspec[] = {"Kspecular=[ ] " }; X Xstatic struct IntuiText TextKspec = { X 1,1,JAM1, -sizeof(DispKspec)*COL, TxOff, NULL, X (UBYTE *)DispKspec, NULL X }; X X Xstruct GadExtens VKspec = { 0.0, 1.0, DefKs, 0, 0, 0, true }; X Xstatic struct Gadget G_Kspec = { X &G_TiltAng, X 49*COL , TOP+ROW*9, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType , X NULL, X NULL, /* high lighted */ X &TextKspec, X 0x0, X NULL, X (int)N_Kspec, X (APTR) &VKspec X }; X X/* X * definitions for K diffuse X */ X Xstatic char DispKdiffuse[] = {"Kdiffuse=[ ] " }; X Xstatic struct IntuiText TextKdiffuse = { X 1,1,JAM1, -sizeof(DispKdiffuse)*COL, TxOff, NULL, X (UBYTE *)DispKdiffuse, NULL X }; X X Xstruct GadExtens VKdiffuse = { 0.0, 1.0, DefKd, 0, 0, 0, true }; X Xstatic struct Gadget G_Kdiffuse = { X &G_Kspec, X 49*COL , TOP+ROW*10, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType , X NULL, X NULL, /* high lighted */ X &TextKdiffuse, X 0x0, X NULL, X (int)N_Kdiffuse, X (APTR) &VKdiffuse X }; X X X X/* X * definitions for DispPtIntens X */ X X Xstatic struct IntuiText PtProperties = { X 1,1,JAM1, -10*COL, -ROW, NULL, X (UBYTE *)"Properties", NULL X }; X Xstatic char DispPtIntens[] = {"Intensity=[ ] " }; X Xstatic struct IntuiText TextPtIntens = { X 1,1,JAM1, -sizeof(DispPtIntens)*COL, TxOff, NULL, X (UBYTE *)DispPtIntens, &PtProperties X }; X X Xstruct GadExtens VPtIntens = { 0.0, 2.5, DefIntensity , 0, 0, 0, true }; X Xstatic struct Gadget G_PtIntens = { X &G_Kdiffuse, X 49*COL , TOP+ROW*8, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType , X NULL, X NULL, /* high lighted */ X &TextPtIntens, X 0x0, X NULL, X (int)N_PtIntens, X (APTR) &VPtIntens X }; X X X X X/* X * definitions for background intensity X */ Xstatic struct IntuiText DispAmbient= { X 1,1,JAM1,- COL*3, -ROW, NULL, X (UBYTE *) "Other", NULL X }; X Xstatic char DispBkIntens[] = { "Ambience=[ ] " }; X Xstatic struct IntuiText TextBkIntens = { X 1,1,JAM1, -sizeof(DispBkIntens)*COL, TxOff, NULL, X (UBYTE *) DispBkIntens, &DispAmbient X }; X Xstruct GadExtens VBkIntens = { 0.0, 1.0, DefAmbience, 0, 0, 0, true }; X X Xstatic struct Gadget G_BkIntens = { X &G_PtIntens, X 20*COL , TOP+ROW*13, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType, X NULL, X NULL, /* high lighted */ X &TextBkIntens, X 0x0, X NULL, X (int)N_BkIntens, X (APTR)&VBkIntens X }; X X X X X/* X * Definitions for Surface distance X */ X Xstatic char DispSurfDist[] = {"Surf Dist=[ ] " }; X Xstatic struct IntuiText TextSurfDist = { X 1,1,JAM1, -sizeof(DispSurfDist)*COL, TxOff, NULL, X (UBYTE *) DispSurfDist, NULL X }; X X Xstruct GadExtens VSurfDist = {0.0, 0.0, 0.0, -500, 3000, DefSurfDist, false}; X Xstatic struct Gadget G_SurfDist = { X &G_BkIntens, X 20*COL , TOP+ROW*4, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType, X NULL, X NULL, /* high lighted */ X &TextSurfDist, X 0x0, X NULL, X (int)N_SurfDist, X (APTR)&VSurfDist X }; X X X X X/* X * definitions for location.x X */ Xstatic struct IntuiText PointLight = { X 1,1,JAM1, 9*COL, -ROW*2, NULL, X (UBYTE *) "Point Light Source", NULL X }; X Xstatic struct IntuiText TextPtLocXYZ = { X 1,1,JAM1, -4, -ROW, NULL, X (UBYTE *) "Location", &PointLight X }; X Xstatic char DispPtLocX[] = { "x=[ ] " }; X Xstatic struct IntuiText TextPtLocX = { X 1,1,JAM1, -sizeof(DispPtLocX)*COL, TxOff, NULL, X (UBYTE *) DispPtLocX, &TextPtLocXYZ X }; X X Xstruct GadExtens VPtLocX = {0.0, 0.0, 0.0, -6000, 6000, DefLightSrcX, false }; X Xstatic struct Gadget G_PtLocX = { X &G_SurfDist, X 12*COL , TOP+ROW*8, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType, X NULL, X NULL, /* high lighted */ X &TextPtLocX, X 0x0, X NULL, X (int)N_PtLocX, X (APTR) &VPtLocX X }; X X X X/* X * definitions for location.x X */ X Xstatic char DispPtLocY[] = "y=[ ] "; X Xstatic struct IntuiText TextPtLocY = { X 1,1,JAM1, -sizeof(DispPtLocY)*COL, TxOff, NULL, X (UBYTE *) DispPtLocY, NULL X }; X X Xstruct GadExtens VPtLocY = { 0.0, 0.0, 0.0, -6000, 6000, DefLightSrcY, false }; X Xstatic struct Gadget G_PtLocY = { X &G_PtLocX, X 12*COL , TOP+ROW*9, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType, X NULL, X NULL, /* high lighted */ X &TextPtLocY, X 0x0, X NULL, X (int)N_PtLocY, X (APTR) &VPtLocY X }; X X X X /* X * definitions for location.z X */ X Xstatic char DispPtLocZ[] = { "z=[ ] " }; X Xstatic struct IntuiText TextPtLocZ = { X 1,1,JAM1, -sizeof(DispPtLocZ)*COL, TxOff, NULL, X (UBYTE *)DispPtLocZ, NULL X }; X X Xstruct GadExtens VPtLocZ ={ 0.0, 0.0, 0.0, -1000, 3000, DefLightSrcZ, false }; X Xstatic struct Gadget G_PtLocZ = { X &G_PtLocY, X 12*COL , TOP+ROW*10, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType, X NULL, X NULL, /* high lighted */ X &TextPtLocZ, X 0x0, X NULL, X (int)N_PtLocZ, X (APTR) &VPtLocZ X }; X X /* X * definitions for Map replication in horizontal axis X */ X Xstatic char DispRepH[] = { "Map RepH=[ ] " }; X Xstatic struct IntuiText TextRepH = { X 1,1,JAM1, -sizeof(DispRepH)*COL, TxOff, NULL, X (UBYTE *)DispRepH, NULL X }; X X Xstruct GadExtens VRepH ={ 0.0, 0.0, 0.0, 1, 300, DefRepH, false }; X Xstatic struct Gadget G_RepH = { X &G_PtLocZ, X 20*COL , TOP+ROW*15, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType, X NULL, X NULL, /* high lighted */ X &TextRepH, X 0x0, X NULL, X (int)N_RepH, X (APTR) &VRepH X }; X X X /* X * definitions for map replication in vertical axis X */ X Xstatic char DispRepV[] = { "Map RepV=[ ] " }; X Xstatic struct IntuiText TextRepV = { X 1,1,JAM1, -sizeof(DispRepV)*COL, TxOff, NULL, X (UBYTE *)DispRepV, NULL X }; X X Xstruct GadExtens VRepV ={ 0.0, 0.0, 0.0, 1, 300, DefRepV, false }; X Xstatic struct Gadget G_RepV = { X &G_RepH, X 57*COL , TOP+ROW*15, COL*15, ROW, /* loc and size */ X GadFlags, X RELVERIFY, X MyPropType, X NULL, X NULL, /* high lighted */ X &TextRepV, X 0x0, X NULL, X (int)N_RepV, X (APTR) &VRepV X }; X X X X X X XLoadChipMem( dest, src, srcsize) X UWORD **dest; X UWORD *src; X int srcsize; X{ X UWORD *d; X X d = (UWORD *)AllocMem( srcsize, MEMF_CHIP ); X if( !d ) { X OutErr("not enough chip mem"); X CloseDisplay(); X exit(-1); X } X *dest = d; X while( srcsize ) { X *d++ = *src++; X srcsize -= sizeof( UWORD ); X } X} X X Xvoid InitGadgets() X{ X struct Gadget *vp; X LoadChipMem( &HourGlass, HourGlassDat, sizeof(HourGlassDat)); X X X CntrlWinDef.FirstGadget = &G_RepV; X GadWinDef.FirstGadget = &G_GoPanel; X /* X * fill in numeric fields X */ X for( vp = CntrlWinDef.FirstGadget; vp; vp = vp->NextGadget ) { X GadgetSetVal( vp ); X GadgetUpdate(vp, false ); X } X} X X Xvoid EndGadgets() X{ X if( HourGlass ) { X FreeMem(HourGlass, sizeof(HourGlassDat )); X } X} END_OF_FILE if test 14722 -ne `wc -c <'gadgetdef.c'`; then echo shar: \"'gadgetdef.c'\" unpacked with wrong size! fi # end of 'gadgetdef.c' fi if test -f 'mapstuff.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mapstuff.c'\" else echo shar: Extracting \"'mapstuff.c'\" \(9900 characters\) sed "s/^X//" >'mapstuff.c' <<'END_OF_FILE' X#include <math.h> X#include "mytypes.h" X#include "poly.h" X#include "bezpt.h" X#include "revolve.h" X#include "readilbm.h" X#include "mapstuff.h" X#include "menuexp.h" X X#define FarRight 1e6 X#define FarLeft -1e6 X#define FarTop 0x7fff X#define FarBottom -0x7fff X X X#ifndef MANX X#include <libraries/mathffp.h> X#define ceil SPCeil X#define floor SPFloor X#define fabs SPAbs X#endif X X Xtypedef struct { float left, right; } Hedge; X Xstatic float *BezMapping = null, X *RevMapping = null; Xstatic float revmin, revdiff, X bezmin, bezdiff; X X X/* X * given the ptlist of a polygon, find its vertical range X */ Xstatic void FindVRange(scrnlist, top, bottom) X register ScrnPair *scrnlist; X short *top, *bottom; X{ X short i; X short localtop, localbot; X X localtop = FarBottom; X localbot = FarTop; X X for( i = 4; i--; scrnlist++ ) { X if( localtop < scrnlist->y ) localtop = scrnlist->y; X if( localbot > scrnlist->y ) localbot = scrnlist->y; X } X *top = localtop; X *bottom = localbot; X} X/* X * allocate table to store a quick and dirty representation of the X * quadrilateral segments X */ Xstatic Hedge *InitVRange( depth, tabptr, olddepth ) X short depth, *olddepth; X Hedge *tabptr; X{ X Hedge *edgel, *tab; X if( *olddepth < depth || !tabptr ) { X if( tabptr ) free( tabptr); X tab = (Hedge *) malloc(sizeof(Hedge)*depth); X *olddepth = depth; X } X else { X tab = tabptr; X } X if( !tab ) return( null); X X for( edgel = tab; depth--; edgel++) { X edgel->left = FarRight; X edgel->right = FarLeft; X } X return( tab ); X} X X X/* X * add line to quadrilateral descriptions X */ Xstatic void AddVLine( tab, x1, y1, x2, y2 ) X Hedge *tab; X short x1, y1, x2, y2; X{ X short dy; X float curx, slope; X /* X * want y1 to have smaller value, ie, y1 below y2 X */ X if( y1 > y2 ) { X short temp; X temp = y1; y1 = y2; y2 = temp; X temp = x1; x1 = x2; x2 = temp; X } X dy = y2 - y1; X tab += y1; X X if( !dy ) { X if ( x1 < x2 ) { X short tempx; X tempx = x1; x1 = x2; x2 = tempx; X } X if( x2 < tab->left ) tab->left = x2; X if( x1 > tab->right ) tab->right = x1; X return; X } X slope = (float)(x2 - x1)/dy; X X curx = x1; X#define ZipIt(xxx) { if( xxx < tab->left) tab->left = xxx; \ X if( xxx > tab->right ) tab->right = xxx; } X ZipIt(curx); X while( dy--) { X curx += slope; X tab++; X ZipIt(curx); X } X} X X Xstatic void AdjMapXY( inx, iny, outpair) X float inx, iny; X ScrnPair *outpair; X{ X float outx, outy; X MapXYRatio( inx, iny, &outx, &outy); X X outpair->y = MapImageH * (bezmin + bezdiff * outy); X outpair->x = MapImageV * (revmin + revdiff * outx); X X/* X if( RevAxis == RevX ) { X outpair->y = MapImageH * (bezmin + bezdiff * outy); X outpair->x = MapImageV * (revmin + revdiff * outx); X } else { X outpair->x = MapImageH * (bezmin + bezdiff * outy); X outpair->y = MapImageV * (revmin + revdiff * outx); X } X */ X} X Xstatic void ScanCnvQuad( tab, pt) X Hedge *tab; X ScrnPair pt[]; X{ X register int i; X ScrnPair *listb, *liste; X X liste = pt; X listb = liste + 3; X for ( i = 4; i--;) { X AddVLine( tab, listb->x, listb->y, liste->x, liste->y); X listb = liste++; X } X} X Xstatic float AverageShade(pts) X ScrnPair pts[]; X{ X register Hedge *tab; X static Hedge *tabfree = null; X static short olddepth = 0; X short top, bot; X long shade = 0, X pixcnt = 0; X X FindVRange( pts, &top, &bot); X tabfree = tab = InitVRange( top - bot + 1, tabfree, &olddepth); X if(!tabfree) return(0.0); X X ScanCnvQuad( tab-bot, pts ); X#if DEBUG X if( DebugOn ) { X printf("AverageShade top is %d, bot = %d\n", top, bot ); X } X#endif DEBUG X X while( bot <= top ) { X register int hori; X int right, left; X#if DEBUG X if( DebugOn ) { X printf("....row %d \t%d -> %d\n", bot, left, right ); X } X#endif DEBUG X X left = (int) ceil(tab->left - SingleTinyVal); X right = (int)floor(tab->right+ SingleTinyVal); X X for( hori= left; hori <= right; hori++ ) { X shade += GetImgPix( bot, hori); X pixcnt++; X } X X /* X if( RevAxis == RevX ) { X for( hori= left; hori <= right; hori++ ) { X shade += GetImgPix( bot, hori); X pixcnt++; X } X } X else { X for( hori= left; hori <= right; hori++ ) { X shade += GetImgPix( hori, bot); X pixcnt++; X } X } X */ X tab++; X bot++; X } X return( (float)shade / (pixcnt *(15 *16)) ); X} X X/* X * mess with the number so truncation doesn't X * do nasty things to a float containing an int X */ Xstatic int NearestInt( afloat ) X float afloat; X{ X afloat += ( afloat > 0 )? 1e-2 : -1e-2; X return( (int)afloat ); X} X X Xstatic void ShadeQuad(tab, top, bot, intensity) X register Hedge *tab; X short top, bot; X float intensity; X{ X short vert; X float rowminl, rowminr, X rowmaxl, rowmaxr; X Hedge *oldtab, *nexttab; X X for ( vert = bot; X nexttab = tab+1, vert <= top; X vert++, oldtab = tab, tab++ ) { X float hori; X float colmin, colmax; X float leftmost, rightmost; X int ihori, ileftmost, irightmost; X ScrnPair MpPnts[4]; X X#define lefttop MpPnts[0] X#define leftbot MpPnts[3] X#define righttop MpPnts[1] X#define rightbot MpPnts[2] X X X rowminl = (float)vert; X rowmaxr = rowmaxl = rowminr = rowminl; X X if( vert > bot && oldtab->left < tab->left ) { X rowminl -= 0.5; X } X if( vert > bot && oldtab->right > tab->right ) { X rowminr -= 0.5; X } X if( vert < top && nexttab->left < tab->left ) { X rowmaxl += 0.5; X } X if( vert < top && nexttab->right > tab->right ) { X rowmaxr += 0.5; X } X X irightmost = NearestInt( tab->right ); X rightmost = irightmost; X ileftmost = NearestInt( tab->left ); X leftmost = ileftmost; X if( irightmost < ileftmost ) { X irightmost = ileftmost; X } X for( ihori = leftmost, hori = leftmost; X ihori <= irightmost; X ihori += 1, hori += 1.0 ) { X X X if( AbortDraw ) { return; } X X colmin = hori - 0.5; X colmax = hori + 0.5; X X colmin =(colmin > leftmost)?colmin: tab->left; X colmax =(colmax < rightmost)?colmax: tab->right; X X AdjMapXY( colmin, rowmaxl, &lefttop, MP_XMIN| MP_YMAX); X AdjMapXY( colmax, rowmaxr, &righttop, MP_XMAX| MP_YMAX); X AdjMapXY( colmin, rowminl, &leftbot, MP_XMIN| MP_YMIN); X AdjMapXY( colmax, rowminr, &rightbot, MP_XMAX| MP_YMIN); X X PaintPoint(ihori, vert, AverageShade(MpPnts) *intensity); X } X } X#undef lefttop X#undef righttop X#undef rightbot X#undef leftbot X} X X Xvoid DrawRhomMap(mpr) X MapRhomboid *mpr; X{ X short top, bottom; X static Hedge *tab = null; X static short olddepth = 0; X X CalcMapConsts( mpr->rhom.pt ); X FindVRange( mpr->rhom.pt, &top, &bottom ); X tab = InitVRange( top - bottom + 1, tab, &olddepth ); X if(!tab) return; X ScanCnvQuad( tab -bottom, mpr->rhom.pt ); X X bezmin = BezMapping[mpr->bezindex];/* make it global */ X bezdiff = BezMapping[mpr->bezindex+1] - bezmin; X revmin = RevMapping[mpr->revindex]; X revdiff = RevMapping[mpr->revindex+1] - revmin; X#if DEBUG X if( DebugOn ) { X DBMAP(mpr->rhom.pt, mpr->bezindex, mpr->revindex); X } X#endif DEBUG X ShadeQuad(tab, top, bottom, mpr->rhom.intensity); X} X X#ifdef DEBUG XDBMAP(ptlist, bindex, rindex) XScrnPair ptlist[]; Xshort bindex, rindex; X{ X int i; X X printf("...................................\n"); X for( i = 0; i < 4; i++ ) { X printf("%10d", ptlist[i].x); X }; X printf("\n"); X for( i = 0; i < 4; i++ ) { X printf("%10d", ptlist[i].y); X }; X printf("\n"); X printf(" bezmin %f bezdiff %f index = %d \n", bezmin, bezdiff, bindex ); X printf(" revmin %f revdiff %f index = %d \n", revmin, revdiff, rindex ); X} X#endif DEBUG X X X/* X * return true if image mappings could not be performed X * false if successful X */ Xbool InitMapping() { X float *vfmptr; X float totallen = 0, X scaling; X short numvslices; X X if( BezMapping ) free( BezMapping ); X if( RevMapping ) free( RevMapping ); X X /* X * compute width of each bezier segment X */ X numvslices = BezMesh*GetNumSegs() +1; X vfmptr = BezMapping = (float *) malloc(sizeof(float) * numvslices); X if( !BezMapping ) return(true); X X *vfmptr++ = totallen = 0.0; X ResetActSeg(); X do { X float t, ffromx, ftox, ffromy, ftoy; X int i; X InitCalcBez(); X for( i = 1, ffromx = StartPtX(ActSeg), ffromy = StartPtY(ActSeg); X i <= BezMesh; i++, ffromx = ftox, ffromy = ftoy ) { X float diffx, diffy; X X t = (float)i/BezMesh; X X CalcBezPt( t, &ftox, &ftoy ); X diffx = ftox - ffromx; X diffy = ftoy - ffromy; X totallen += sqrt( diffx * diffx + diffy * diffy ); X *vfmptr++ = totallen; X } X NextSeg(); X } while( ActSeg); X /* X * convert scale floating point values to integer pixel positions X */ X scaling = 1.0 / totallen; X for( vfmptr = BezMapping; numvslices; numvslices--, vfmptr++ ) { X *vfmptr *= scaling; X } X /* X * compute height of each revolution segment X */ X RevMapping = (float *) malloc( sizeof(float) * (RevMesh + 1)); X if( !RevMapping ) return( true ); X { X short i; X for( i = 0; i <= RevMesh; i++ ) { X RevMapping[i] = ((float) i)/RevMesh; X } X } X X return(false); X} END_OF_FILE if test 9900 -ne `wc -c <'mapstuff.c'`; then echo shar: \"'mapstuff.c'\" unpacked with wrong size! fi # end of 'mapstuff.c' fi echo shar: End of archive 4 \(of 4\). cp /dev/null ark4isdone MISSING="" for I in 1 2 3 4 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 4 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mail submissions (sources or binaries) to <amiga@cs.odu.edu>. Mail comments to the moderator at <amiga-request@cs.odu.edu>. Post requests for sources, and general dicussion to comp.sys.amiga.