home *** CD-ROM | disk | FTP | other *** search
- /*
- ** CMD: Grass Maker
- **
- ** $VER: GrassMaker.lwm v1.2 (August 4,1994)
- **
- **
- ** DESCRIPTION:
- ** This Modeler macro creates a rectangular object consist-
- ** ing of an array of 2D particles (2-point polygons)
- ** resembling grass (or fibers,carpet,hair,etc.).
- **
- ** AUTHOR:
- ** William Frawley, © 1994 Ecliptic Arts
- **
- ***********************************************************/
-
- /*
- ** Initialize System
- */
-
- address "LWModelerARexx.port"
- call addlib "LWModelerARexx.port", 0
-
- /* call addlib "rexxsupport.library", 0, -30, 0 */
- /* call addlib "rexxmathlib.library", 0, -30, 0 */
-
- SIGNAL ON ERROR
- SIGNAL ON SYNTAX
-
-
-
- /*
- ** Initialize Variables
- */
-
- JList='NONE Tops_Only ALL'
- JRange='Low Medium High'
- Text1='If intended as "Image Modulator",'
- Text2='Width & Depth ratio should be set'
- Text3='for a video aspect of 1.342 to 1.'
-
-
- /*
- ** Configure Requester
- */
-
- CALL req_begin("Bill's Grass Maker v1.1")
-
- id_W = req_addcontrol('Terrain Width', 'n', 1)
- id_D = req_addcontrol('Terrain Depth', 'n', 1)
- id_H = req_addcontrol('Blade Height', 'n', 1)
- id_Seg = req_addcontrol('# of Blade Segments', 'n', 1)
- id_Space = req_addcontrol('Blade Spacing', 'n', 1)
- id_Jitter = req_addcontrol('Jitter', 'CH', JList)
- id_JS = req_addcontrol('Jitter Strength', 'CH', JRange)
- id_Center = req_addcontrol('Center?', 'B')
- id_NoteA = req_addcontrol(' ', 'T', ' ')
- id_NoteB = req_addcontrol('NOTE:', 'T', Text1)
- id_NoteC = req_addcontrol(' ', 'T', Text2)
- id_NoteD = req_addcontrol(' ', 'T', Text3)
- id_NoteE = req_addcontrol(' ', 'T', ' ')
-
- CALL req_setval(id_W, 13.42)
- CALL req_setval(id_D, 10)
- CALL req_setval(id_H, .3)
- CALL req_setval(id_Seg, 1)
- CALL req_setval(id_Space, .1)
- CALL req_setval(id_Jitter, 1)
- CALL req_setval(id_JS, 2)
- CALL req_setval(id_Center, 1)
-
-
- /*
- ** Post Requester
- */
-
- IF (~req_post()) THEN DO
- CALL req_end
- EXIT(5)
- END
-
- req=1
-
-
- /*
- ** Get Input From Requester
- */
-
- Width = req_getval(id_W)
- Depth = req_getval(id_D)
- Height = req_getval(id_H)
- Segments = req_getval(id_Seg)
- Spacing = req_getval(id_Space)
- Jit = req_getval(id_Jitter)
- JStren = req_getval(id_JS)
- Center = req_getval(id_Center)
-
- CALL req_end() /* End Requester mode */
-
-
- /*
- ** Make Array Of Blades
- */
-
- SegH=Height/Segments /* Height of each segment */
- Ops=((Width/Spacing)+1)*((Depth/Spacing)+1)%1 /* # loops */
- IF Ops>32124 THEN Ops=32124 /* ~Max# steps meter allows */
-
- CALL add_begin() /* Enter Data Creation mode */
- CALL meter_begin(ops,'Building Blade Array','Please Wait..')
-
- DO z=0 TO Depth BY Spacing /* Rows */
- DO x=0 TO Width BY Spacing /* Columns */
- DO y=0 TO Segments-1 /* Blade segments */
- PtIndex.1=add_point(x (y*SegH) z)
- PtIndex.2=add_point(x ((y+1)*SegH) z)
- CALL add_polygon(PtIndex.1 PtIndex.2) /* Make Line */
- END
- CALL meter_step() /* Step progress meter by 1/ops */
- END
- END
-
- CALL meter_end() /* Deactivate meter */
- CALL add_end() /* End Data Creation mode */
-
- CALL mergepoints() /* Merge common points of */
- /* multi-segmented blades */
-
- /*
- ** Jitter Blades?
- */
-
- IF Jit=2 | Jit=3 THEN DO /* Jitter Routines */
-
- IF Jit=2 THEN DO /* Select top points only */
- CALL sel_mode(USER)
- xL=0-Spacing/2
- yL=Height-SegH/2
- zL=0-Spacing/2
- xR=Width+Spacing/2
- yR=Height+SegH/2
- zR=Depth+Spacing/2
- CALL sel_point(SET,VOLUME, xL yL zL , xR yR zR)
- END
-
- IF JStren=1 THEN DO
- jxz = (Spacing * .5)
- jy = (Spacing * .15)
- END
-
- IF JStren=2 THEN DO
- jxz = (Spacing * 1)
- jy = (Spacing * .3)
- END
-
- IF JStren=3 THEN DO
- jxz = (Spacing * 1.5)
- jy = (Spacing * .45)
- END
-
- CALL jitter(jxz jy jxz)
-
- IF Jit=2 THEN DO
- CALL sel_point(CLEAR) /* Unselect all points */
- CALL end_all() /* Reset Selection mode to Global */
- END
-
- END /* End Jit=2|Jit=3 */
-
-
- /*
- ** Center On XZ Plane?
- */
-
- IF Center=1 THEN DO
- Box=boundingbox() /* Returns bounding box information */
- PARSE VAR Box n xL xR yL yR zL zR /* n= no.of points */
- cx=-(xR+xL)/2
- cz=-(zR+zL)/2
- CALL move(cx 0 cz)
- END
-
-
- /*
- ** Wrap It Up
- */
-
- CALL changesurface("Grass")
-
- CALL notify(1,'!Done!', 'Time to water the lawn...')
-
- EXIT(0)
-
-
- /*
- ** INTERNAL FUNCTIONS
- */
-
- SYNTAX:
-
- ERROR:
-
- T1='!Total Bummer Dude!'
- T2='!An error has been detected.'
- t=notify(1,T1,T2,'@'ErrorText(rc),'Line 'SIGL)
-
- IF req THEN CALL req_end()
-
- EXIT(20)