home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-10 | 32.8 KB | 1,124 lines |
- /*************************************************************\
- / \
- ExplodeLoad V1.0, by Reinhard Grams © 1994
- \ /
- \*************************************************************/
-
- macro_name="ExplodeLoad V1.0"
- macro_path="/EXPL"
-
- /**************************************************************/
- call InitVariables()
- /**************************************************************/
-
- help.GERMAN.1="Dieses Makro lädt ein Lightwave Objekt und läßt es explodieren."
- help.GERMAN.2="Jede Fläche wird dabei mit unabhängigen Punkten versehen, so daß"
- help.GERMAN.3="die Flächen einzeln animiert werden können. Die Stärke der Ex-"
- help.GERMAN.4="plosion bestimmt der Explosion Factor. Die Richtung der Explosi-"
- help.GERMAN.5="on bestimmen Sie durch die Angabe des Zentrums der Explosion und"
- help.GERMAN.6="der Achsen, entlang denen die Explosion wirkt. Die Flächen ro-"
- help.GERMAN.7="tieren während der Explosion, die Stärke der Rotation bestimmen"
- help.GERMAN.8="Sie durch die Eingabe des minimalen und maximalen Rotationswin-"
- help.GERMAN.9="kels. Zusätzlich können die Flächen im Verlauf der Explosion"
- help.GERMAN.10="skaliert werden, eine Eingabe von 0 beim Parameter Scale Factor"
- help.GERMAN.11="bewirkt bspw. ein Verschwinden der Teile nach Ablauf der Explo-"
- help.GERMAN.12="sion."
- help.GERMAN.13="[PAGE]"
- help.GERMAN.14="Der Schalter Explode to Sphere bewirkt, daß die Flächen am Ende"
- help.GERMAN.15="der Explosion eine Kugelschale bilden. Den einzelnen Flächen"
- help.GERMAN.16="kann noch durch einen Random Factor eine für jede Fläche leicht"
- help.GERMAN.17="verschiedene Explosionswirkung verliehen werden. Den Verlauf der"
- help.GERMAN.18="Explosion bestimmen Sie in einem weiteren Requester, der die"
- help.GERMAN.19="""Hüllkurve"" der Explosion festlegt. Eine ""echte"" Explosion"
- help.GERMAN.20="entspricht der Wahl von SquareRoot. Beachten Sie, daß die Flä-"
- help.GERMAN.21="chen möglichst gleich weit vom Explode Center enfernt sind, um"
- help.GERMAN.22="eine gleichmäßige Wirkung zu erzielen."
- help.GERMAN.23="[PAGE]"
- help.GERMAN.24="Die Anzahl der zu berechnenden Objekte geben Sie beim Parameter"
- help.GERMAN.25="Frames an. Die Objekte werden durch Morphing animiert. Dazu ru-"
- help.GERMAN.26="fen Sie anschließend das Makro Morph2Scene auf, welches aus ei-"
- help.GERMAN.27="ner Reihe von Objekten eine LW-Scene generiert (siehe dort). Die"
- help.GERMAN.28="Scene können Sie einfach mit Load Scene als solche in den Lay-"
- help.GERMAN.29="outer einladen. Mächtiger ist jedoch die Möglichkeit, nur die"
- help.GERMAN.30="Morphsequenz mit Objects/Load from Scene in eine bestehende Sce-"
- help.GERMAN.31="ne einzubauen."
- help.GERMAN.32="[PAGE]"
- help.GERMAN.33="Beachten Sie bitte, daß die Anzahl der Objekte im direkten Zu-"
- help.GERMAN.34="sammenhang mit der Art der Explosion steht. Je nichtlinearer die"
- help.GERMAN.35="Explosion ist, desto mehr Objekte sollten Sie verwenden (d.h"
- help.GERMAN.36="möglichst wenig Interpolation durch LW). Die besten Ergebnisse"
- help.GERMAN.37="erzielen Sie mit einem Objekt pro Frame der Animation, aber in"
- help.GERMAN.38="den meisten Fällen reichen 3 bis 5 Interpolationsframes für ei-"
- help.GERMAN.39="nen ausreichend weichen Ablauf aus. D.h für 3 Sekunden Animation"
- help.GERMAN.40="(75 Frames) sollten Sie ca. 25 Objekte verwenden."
- help.GERMAN.41="[END]"
-
- help.ENGLISH.1="This macro loads a Lightwave object and simply explodes it. Each"
- help.ENGLISH.2="surface is made with independent points, so the single surface"
- help.ENGLISH.3="can become animated. The power of explosion is determined by the"
- help.ENGLISH.4="""Explosion Factor"". The direction of the explosion is selected"
- help.ENGLISH.5="by setting the center and the axes along the explosion operates."
- help.ENGLISH.6="The surfaces are rotating during the explosion, the intensity of"
- help.ENGLISH.7="rotation is selected with the input of minimal and maximal rota-"
- help.ENGLISH.8="tion-angle. Additionally the surfaces can be scaled during the"
- help.ENGLISH.9="explosion, if 0 is entered at ""ScaleFactor"", the parts will"
- help.ENGLISH.10="fade away when the explosion ends."
- help.ENGLISH.11="[PAGE]"
- help.ENGLISH.12="The ""Explode to Sphere"" switch makes the surfaces forming into"
- help.ENGLISH.13="a sphere socket in the end of the explosion. Each surface can"
- help.ENGLISH.14="get an own explosion-effect by setting a ""Random Factor"". You"
- help.ENGLISH.15="can determine the course of the explosion in another requester,"
- help.ENGLISH.16="which sets the ""covercurve"" of the explosion. A ""real"" ex-"
- help.ENGLISH.17="plosion is eqivalent to ""SquareRoot"". Have attention that all"
- help.ENGLISH.18="the surfaces have nearly the same distance to the explode center"
- help.ENGLISH.19="to get a symmetrical result."
- help.ENGLISH.20="[PAGE]"
- help.ENGLISH.21="You specify the number of the objects to calculate with the"
- help.ENGLISH.22="""Frames"" parameter. The objects are animated by morphing."
- help.ENGLISH.23="Therefor you run the macro Morph2Scene as next, which generates"
- help.ENGLISH.24="a LW-scene out of a row of objects (see there). Load the scene"
- help.ENGLISH.25="with ""Load Scene"" into the layouter as it is. The option to"
- help.ENGLISH.26="load only the morphing sequence with ""Objects/Load from Scene"""
- help.ENGLISH.27="into an existing scene is more powerful."
- help.ENGLISH.28="[PAGE]"
- help.ENGLISH.29="Remember that the number of objects influences the way of explo-"
- help.ENGLISH.30="sion directly. You should use more objects if the explosion is"
- help.ENGLISH.31="non-linear (means as less interpolation by LW as possible). You"
- help.ENGLISH.32="will get the best results with one object per frame for the"
- help.ENGLISH.33="whole animation, but in most cases 3 to 5 interpolation frames"
- help.ENGLISH.34="are enough for a smooth running. For 3 seconds of animation (75"
- help.ENGLISH.35="frames) You should use around 25 objects."
- help.ENGLISH.36="[END]"
-
- /**************************************************************/
-
- form0.1="influence=influence"
- form0.2="influence=sin(frame*(90/frames)*pi180)"
- form0.3="influence=1-cos(frame*(90/frames)*pi180)"
- form0.4="influence=influence*influence"
- form0.5="influence=influence*influence*influence"
- form0.6="influence=sqrt(influence)"
- form0.7="influence=tanh(influence*PI)"
-
- form1.1="influence=influence"
- form1.2="influence=sin((frame-1)*(90/(frames-1))*pi180)"
- form1.3="influence=1-cos((frame-1)*(90/(frames-1))*pi180)"
- form1.4="influence=influence*influence"
- form1.5="influence=influence*influence*influence"
- form1.6="influence=sqrt(influence)"
- form1.7="influence=tanh(influence*PI)"
-
- EX_LINEAR=1
- EX_SINUS=2
- EX_COSINUS=3
- EX_EXP2=4
- EX_EXP3=5
- EX_SQR=6
- EX_TANH=7
-
- /**************************************************************/
-
- explosion_type=EX_LINEAR
- object_name=""
- frames=11
- explode_factor=3
- explode_dist=3
- explode_random=0.33
- add_surfaces=1
- make_sphere=1
- random_seed=4713
- explode_type=6
- sphere_factor=1
- rotate_min=0.25
- rotate_max=0.5
- scale_factor=1
- start_object=1
- end_object=1
- start_exploded=0
- do_x=1
- do_y=1
- do_z=1
-
- /**************************************************************/
-
- call OpenLibs()
- call GlobalsRequester(macro_name)
- call HelpRequester(macro_name,"help",language)
-
- call LoadConfig()
- call Requester()
- explosion_type=ExTypeRequester()
- if (explosion_type=0) then call CleanExit()
- call SaveConfig()
-
- file_name=SelectFile(messages.language.OBJECT_MESS,"3D:Objects","",selection1)
- if (file_name="") then call CleanExit()
-
- object_name=SelectFile(messages.language.OUTPUT_MESS,"3D:Objects","",selection2)
- if (object_name="") then call CleanExit()
-
- call ExplodeSequence()
-
- call CloseLibs()
- exit 0
-
- /**************************************************************/
-
- Requester:
-
- call req_begin(macro_name)
-
- id_frames=req_addcontrol("Frames", 'n')
- id_type=req_addcontrol("Explosion Axis",'ch',"X Y Z XY XZ XYZ")
- id_surf=req_addcontrol("Add Surfaces", 'b')
- id_sphere=req_addcontrol("Explode to Sphere", 'b')
- id_start=req_addcontrol("Start Exploded", 'b')
- id_exp=req_addcontrol("Explosion Factor",'n')
- id_expr=req_addcontrol("Explosion Random",'n')
- id_sphfac=req_addcontrol("Sphere Factor", 'n')
- id_rotmm=req_addcontrol("Rotate Min, Max °", 'v')
- id_expc=req_addcontrol("Explode Center XYZ", 'v',1)
- id_scafac=req_addcontrol("Scale Factor", 'n')
- id_seed=req_addcontrol("Random Seed", 'n')
-
- call req_setval(id_frames, frames)
- call req_setval(id_type, explode_type)
- call req_setval(id_exp, explode_factor)
- call req_setval(id_expr, explode_random)
- call req_setval(id_seed, random_seed)
- call req_setval(id_surf, add_surfaces)
- call req_setval(id_sphere, make_sphere)
- call req_setval(id_sphfac, sphere_factor)
- call req_setval(id_rotmm, rotate_min*360 rotate_max*360 0)
- call req_setval(id_expc, offset_x offset_y offset_z)
- call req_setval(id_scafac, scale_factor)
- call req_setval(id_start, start_exploded)
-
- if (~req_post()) then call CleanExit()
-
- frames=req_getval(id_frames)
- explode_type=req_getval(id_type)
- explode_factor=req_getval(id_exp)
- explode_random=req_getval(id_expr)
- random_seed=req_getval(id_seed)
- add_surfaces=req_getval(id_surf)
- make_sphere=req_getval(id_sphere)
- sphere_factor=req_getval(id_sphfac)
- rmm=req_getval(id_rotmm)
- parse value rmm with rotate_min rotate_max .
- rotate_min=rotate_min/360; rotate_max=rotate_max/360
- of=req_getval(id_expc)
- parse value of with offset_x offset_y offset_z .
- scale_factor=req_getval(id_scafac)
- start_exploded=req_getval(id_start)
-
- call req_end()
-
- select
- when (explode_type=1) then do; do_x=1; do_y=0; do_z=0; end
- when (explode_type=2) then do; do_x=0; do_y=1; do_z=0; end
- when (explode_type=3) then do; do_x=0; do_y=0; do_z=1; end
- when (explode_type=4) then do; do_x=1; do_y=1; do_z=0; end
- when (explode_type=5) then do; do_x=1; do_y=0; do_z=1; end
- when (explode_type=6) then do; do_x=1; do_y=1; do_z=1; end
- end
-
- if (random_seed=0) then random_seed=time('s')
- if (frames<1) then frames=1
-
- return 1
-
- /**************************************************************/
-
- ExTypeRequester:
-
- mes.ENGLISH.1="Select Explosion Type"
- mes.GERMAN.1="Typ der Explosion"
-
- extypes="Linear Sin Cos Exp2 Exp3 SquareRoot Tanh"
- return VariableChoice(mes.language.1,"TYPE",,
- extypes,7,explosion_type)
-
- /**************************************************************/
-
- SaveConfig:
-
- if (open(state, config, 'W')) then do
- call writeln(state, "CONF")
- call writeln(state, explode_type add_surfaces make_sphere,
- sphere_factor scale_factor explode_factor explode_random,
- random_seed rotate_min rotate_max frames start_exploded,
- explosion_type offset_x offset_y offset_z)
- call close state
- end
- return
-
- /**************************************************************/
-
- LoadConfig:
-
- if (exists(config)) then do
- if (open(state, config, 'R')) then do
- if (readln(state)="CONF") then do
- parse value readln(state) with explode_type,
- add_surfaces make_sphere sphere_factor scale_factor,
- explode_factor explode_random random_seed rotate_min,
- rotate_max frames start_exploded explosion_type,
- offset_x offset_y offset_z .
- end
- end
- call close state
- end
- return
-
- /**************************************************************/
- /**************************************************************/
-
- ExplodeSequence:
-
- call randu(random_seed)
-
- frames=trunc(frames)
-
- call cut(); call cut()
- if (add_surfaces) then call load(file_name)
-
- call LoadLightwaveObject(file_name)
- call InitExplode()
- do frame=1 to frames
- call cut()
- call ExplodeFaces()
- if (frames>1) then do
- name=object_name||MakeExtension(frame,extension_digits)
- end
- else name=object_name
- call save(name)
- end
-
- if (verbose) then do
- call notify(1,! vmes.language.1 trunc(frames) vmes.language.2)
- end
-
- return
-
- /**************************************************************/
-
- LoadLightwaveObject: parse arg file_name
-
- points=0; faces=0; surfaces=0
-
- /* OPEN FILE */
-
- file=LW_OpenObject(file_name)
- if (file=0) then call CleanExit(OBJECT_ERR,file_name)
-
- /* DO SURFACES */
-
- if (add_surfaces) then do
- surfaces=LW_SetObject(file,"SURFACES","COUNT")
- if (surfaces>0) then do
- call meter_begin(surfaces,macro_name":" surfaces "SURFACES")
- do surface=1 to trunc(surfaces)
- surface_names.surface=LW_GetObject(file)
- call meter_step();
- end
- call meter_end()
- end
- end
-
- /* DO POINTS */
-
- points=LW_SetObject(file,"POINTS","COUNT")
- if (points=0) then call CleanExit(OBJECT_ERR,file_name)
-
- call meter_begin(points,macro_name":" points "POINTS")
- pointlist=""
- do point=1 to trunc(points)
- coords=LW_GetObject(file)
- parse value coords with x.point y.point z.point .
- pointlist=pointlist coords
- call meter_step();
- end
- call meter_end()
-
- /* DO POLYGONS */
-
- faces=LW_SetObject(file,"POLYGONS","COUNT")
- if (faces=0) then call CleanExit(OBJECT_ERR,file_name)
-
- call meter_begin(faces,macro_name":" faces "FACES")
- do face=1 to faces
- face_list.face=LW_GetObject(file)
- face_count.face=words(face_list.face)-1
- call meter_step();
- end
- call meter_end()
-
- /* CLOSE FILE */
-
- file=LW_CloseObject(file)
-
- return
-
- /**************************************************************/
-
- ExplodeFaces:
-
- call SetExplode()
- call add_begin()
- call meter_begin(faces,macro_name||mmes.language.1 frame mmes.language.2 frames)
-
- do face=1 to trunc(faces)
- call ExplodeFace(face,face_count.face)
- pointlist=""
- do p=1 to face_count.face
- pointlist=pointlist add_point(px.p py.p pz.p)
- end
- if (add_surfaces && surfaces>0) then do
- surface=word(face_list.face,face_count.face+1)
- call surface(surface_names.surface)
- end
- call add_polygon(pointlist)
- call meter_step();
- end
-
- call meter_end()
- call add_end()
-
- return
-
- /**************************************************************/
-
- ExplodeFace: parse arg face, face_points
-
- pointlist=""
- do p=1 to face_points
- offset=word(face_list.face,p)
- px.p=x.offset
- py.p=y.offset
- pz.p=z.offset
- pointlist=pointlist px.p py.p pz.p
- end
- parse value LW_PointsCenter(pointlist,"CENTER") with cx cy cz .
-
- cx=cx-center_x; cy=cy-center_y; cz=cz-center_z
- rotate=LW_InitRotate(rotate_x.face,rotate_y.face,rotate_z.face)
- do p=1 to face_points
- dx=((px.p-center_x)-cx)*scal
- dy=((py.p-center_y)-cy)*scal
- dz=((pz.p-center_z)-cz)*scal
- parse value LW_PointsRotate(rotate,dx,dy,dz) with dx dy dz .
-
- if (do_x) then px.p=explode_x*random.face*cx+dx+center_x
- if (do_y) then py.p=explode_y*random.face*cy+dy+center_y
- if (do_z) then pz.p=explode_z*random.face*cz+dz+center_z
-
- end
- rotate=LW_RemoveRotate(rotate)
-
- return
-
- /**************************************************************/
-
- InitExplode:
-
- center=LW_PointsCenter(pointlist,"CENTER")
- parse value center with center_xo center_yo center_zo .
- center_x=center_xo+offset_x
- center_y=center_yo+offset_y
- center_z=center_zo+offset_z
- center=LW_PointsCenter(pointlist,"RATIO")
- parse value center with ratio_x ratio_y ratio_z .
- ratio_xo=(ratio_x-1.0)*sphere_factor
- ratio_yo=(ratio_y-1.0)*sphere_factor
- ratio_zo=(ratio_z-1.0)*sphere_factor
-
- fac=360*PI180*(rotate_max-rotate_min)
- min=360*PI180*rotate_min
- do r=1 to faces
- v=2*randu()-1; rotate_xo.r=v*fac+(min*sign(v))
- v=2*randu()-1; rotate_yo.r=v*fac+(min*sign(v))
- v=2*randu()-1; rotate_zo.r=v*fac+(min*sign(v))
- random_o.r=(2*randu()-1.0)*explode_random
- end
-
- return
-
- /**************************************************************/
-
- SetExplode:
-
- influence=1
- if (frames>1) then do
- if (start_exploded) then do
- influence=frame/frames
- interpret(form0.explosion_type)
- end
- else do
- influence=(frame-1)/(frames-1)
- interpret(form1.explosion_type)
- end
- end
-
- expl=(explode_factor-1)*influence+1
- scal=(scale_factor-1)*influence+1
- ratio_x=ratio_xo*influence+1
- ratio_y=ratio_yo*influence+1
- ratio_z=ratio_zo*influence+1
-
- if (make_sphere) then do
- explode_x=expl*ratio_x
- explode_y=expl*ratio_y
- explode_z=expl*ratio_z
- end
- else do
- explode_x=expl
- explode_y=expl
- explode_z=expl
- end
- do r=1 to faces
- rotate_x.r=rotate_xo.r*influence
- rotate_y.r=rotate_yo.r*influence
- rotate_z.r=rotate_zo.r*influence
- random.r=random_o.r*influence+1
- end
-
- return
-
- /**************************************************************/
- /**************************************************************/
-
- ErrorMessage: parse arg status, add_string, user_cancel
-
- continue=0
- if (status~="") then do
- if (user_cancel~="") then user_sel=2; else user_sel=1
- if (verify(status,"0123456789")=0) then do
- if (status>0 & status<INTERNAL_ERR) then do
- if (add_string~="") then do
- continue=notify(user_sel,! errors.language.status"!",add_string)
- end
- else do
- continue=notify(user_sel,! errors.language.status"!")
- end
- end
- else do
- continue=notify(1,! errors.language.INTERNAL_ERR"!")
- end
- end
- else do
- if (add_string~="") then continue=notify(user_sel,! status,add_string)
- else continue=notify(user_sel,! status)
- end
- end
- return continue
-
- /**************************************************************/
-
- CleanExit: parse arg status, add_string, user_cancel
-
- call end_all()
- call ErrorMessage(status, add_string, user_cancel)
- call CloseLibs()
- exit 0
-
- /**************************************************************/
-
- OpenLibs:
-
- if (~show('L',rexxlib)) then do
- if ~addlib(rexxlib,0,-30,0) then do
- call ErrorMessage(OPEN_LIB_ERR,rexxlib)
- exit 10
- end
- if (~show('L',rexxlib)) then do
- call ErrorMessage(OPEN_LIB_ERR,rexxlib)
- exit 10
- end
- end
- if (~show('L',mathlib)) then do
- if ~addlib(mathlib,0,-30,0) then do
- call ErrorMessage(OPEN_LIB_ERR,mathlib)
- exit 10
- end
- if (~show('L',mathlib)) then do
- call ErrorMessage(OPEN_LIB_ERR,mathlib)
- exit 10
- end
- end
- if (~show('L',supplib)) then do
- if ~addlib(supplib,0,-30,0) then do
- call ErrorMessage(OPEN_LIB_ERR,supplib)
- exit 10
- end
- if (~show('L',supplib)) then do
- call ErrorMessage(OPEN_LIB_ERR,mathlib)
- exit 10
- end
- end
- port=addlib("LWModelerARexx.port",0)
- return
-
- /**************************************************************/
-
- CloseLibs:
-
- if (port~="") then call remlib("LWModelerARexx.port")
- return
-
- /**************************************************************/
-
- SelectFile: PROCEDURE EXPOSE selected_file selected_drawer
- parse arg title, drawer_name, file_name, config_file, mode
-
- if (exists(config_file)) then do
- if (open(state,config_file,'R')) then do
- if (readln(state)="FSEL") then do
- drawer_name=readln(state)
- file_name=readln(state)
- end
- call close state
- end
- end
- if (mode=DRAWER) then choice=getfilename(title,drawer_name,"")
- else choice=getfilename(title,drawer_name,file_name)
- if (choice="(none)") then return ""
- selected_drawer=LW_Drawer(choice)
- selected_file=LW_File(choice)
- if (mode~="DRAWER") then do
- if (selected_file="") then return ""
- end
- if (open(state,config_file,'W')) then do
- call writeln(state, "FSEL")
- call writeln(state, selected_drawer)
- call writeln(state, selected_file)
- call close(state)
- end
- select
- when (mode="DRAWER") then choice=selected_drawer
- when (mode="FILE") then choice=selected_file
- otherwise nop
- end
-
- return choice
-
- /**************************************************************/
-
- HelpRequester: parse arg title, text_array, language
-
- select
- when (help_type=HELP_NEVER) then return
- when (help_type=HELP_FIRST) then do
- if (exists(config)) then return
- end
- otherwise nop
- end
- if (~TextRequester(title,text_array,language)) then do
- call GlobalsRequester(title,1)
- end
- return
-
- /**************************************************************/
-
- TextRequester: parse arg title, text_array, language
-
- hpages=1
- hline=1
- do until (str="[END]")
- interpret("str="text_array"."language"."hline)
- if (str="[PAGE]") then hpages=hpages+1
- hline=hline+1
- end
- call req_begin(title||pmes.language.1 "1" pmes.language.2 hpages)
- hline=1; continue=1; hpage=1
- do while (continue)
- interpret("htext="text_array"."language"."hline)
- select
- when (htext="[PAGE]") then do
- go_on=req_post()
- call req_end()
- if (go_on) then do
- hpage=hpage+1
- call req_begin(title||pmes.language.1 hpage pmes.language.2 hpages)
- end
- else continue=0
- end
- when (htext="[END]") then do
- go_on=req_post()
- call req_end()
- continue=0
- end
- otherwise do
- id.hline=req_addcontrol("",'t',htext)
- end
- end
- hline=hline+1
- end
- return go_on
-
- /**************************************************************/
-
- SaveSettings: PROCEDURE EXPOSE ENV_ERR envpath globals language,
- help_type verbose extension_digits
-
- if (~exists(envpath)) then do
- address command "makedir" envpath
- if (~exists(envpath)) then call CleanExit(ENV_ERR)
- end
- ok=0
- if (open(state, globals, 'W')) then do
- call writeln(state, "GLBS")
- call writeln(state, language help_type verbose extension_digits)
- call close(state)
- ok=1
- end
- return ok
-
- /**************************************************************/
-
- LoadSettings: PROCEDURE EXPOSE ENV_ERR envpath globals language,
- help_type verbose extension_digits
-
- if (~exists(envpath)) then do
- address command "makedir" envpath
- if (~exists(envpath)) then call CleanExit(ENV_ERR)
- end
- ok=0
- if (exists(globals)) then do
- if (open(state, globals, 'R')) then do
- if (readln(state)="GLBS") then do
- parse value readln(state) with language help_type,
- verbose extension_digits .
- ok=1
- end
- call close(state)
- end
- end
- return ok
-
- /**************************************************************/
-
- GlobalsRequester: PROCEDURE EXPOSE ENV_ERR envpath globals language,
- help_type verbose extension_digits
- parse arg title, force
-
- loaded=LoadSettings()
- if (force="") then do
- if (loaded) then return
- end
- call req_begin(title": Globals")
- id_la=req_addcontrol("Language", 'ch',"English German")
- id_he=req_addcontrol("Help", 'ch',"First Always Never")
- id_ve=req_addcontrol("Verbose", 'b')
- id_ex=req_addcontrol("Ext. Digits", 'n')
- call req_setval(id_la, language)
- call req_setval(id_he, help_type)
- call req_setval(id_ve, verbose)
- call req_setval(id_ex, extension_digits)
- if (~req_post()) then do; call req_end(); return 0; end
- language=req_getval(id_la)
- help_type=req_getval(id_he)
- verbose=req_getval(id_ve)
- extension_digits=req_getval(id_ex)
- call req_end()
- if (extension_digits<2) then extension_digits=2
- call SaveSettings()
- return
-
- /**************************************************************/
-
- GetExtension: PROCEDURE; parse arg exname
-
- l=length(exname)
- s=verify(reverse(exname),"0123456789")
- if (s>l) then return exname
- if (s<2) then return ""
- return substr(exname,length(exname)+2-s)
-
- /**************************************************************/
-
- GetBaseName: PROCEDURE; parse arg exname
-
- b=length(exname)-length(GetExtension(exname))
- return substr(exname,1,b)
-
- /**************************************************************/
-
- GetExtensionDigits: PROCEDURE; parse arg exname
-
- return length(GetExtension(exname))
-
- /**************************************************************/
-
- MakeExtension: PROCEDURE; parse arg exname, ext_digits
-
- return right(exname,ext_digits,'0')
-
- /**************************************************************/
-
- SaveSelection: PROCEDURE EXPOSE sequence_name.
- parse arg selected, select_file, select_type
-
- ok=0
- if (open(state, select_file, 'W')) then do
- call writeln(state, "SSEL")
- call writeln(state, select_type)
- call writeln(state, selected)
- c=1
- do while (c<=selected)
- call writeln(state, sequence_name.c); c=c+1
- end
- call close(state)
- ok=1
- end
- return ok
-
- /**************************************************************/
-
- LoadSelection: PROCEDURE EXPOSE select_type sequence_name.
- parse arg select_file
-
- selected=0
- if (exists(select_file)) then do
- if (open(state, select_file, 'R')) then do
- if (readln(state)="SSEL") then do
- select_type=readln(state)
- selected=readln(state)
- c=1
- do while (c<=selected)
- sequence_name.c=readln(state); c=c+1
- end
- end
- call close(state)
- end
- end
- return selected
-
- /**************************************************************/
-
- SelectSequence: PROCEDURE EXPOSE language sequence_name.,
- EXTENSION_ERR SEQUENCE_ERR FILE_ERR READ_ERR GERMAN ENGLISH errors.,
- ST_SEQUENCE ST_SPECIFY ST_LIST ST_DIRECTORY ST_READ ST_REPEAT
- parse arg title, default_drawer, minimum_files, maximum_files,,
- selection1, selection2, select_file, select_type
-
- mes.ENGLISH.1="Select First"
- mes.ENGLISH.2="Select Last"
- mes.ENGLISH.3="Select Next (or CANCEL)"
- mes.ENGLISH.4="Select List"
- mes.ENGLISH.5="Select Directory"
- mes.ENGLISH.6="Need at least"
- mes.ENGLISH.7="File(s)"
- mes.ENGLISH.8="Maximum of"
- mes.ENGLISH.9="Files selected"
-
- mes.GERMAN.1="Wählen Sie die erste Datei"
- mes.GERMAN.2="Wählen Sie die letzte Datei"
- mes.GERMAN.3="Nächste Datei (oder CANCEL)"
- mes.GERMAN.4="Wählen Sie die Liste"
- mes.GERMAN.5="Wählen Sie das Verzeichnis"
- mes.GERMAN.6="Wählen Sie bitte mindestens"
- mes.GERMAN.7="Datei(en)"
- mes.GERMAN.8="Bitte nur maximal"
- mes.GERMAN.9="Datei(en) ausgewählt"
-
- old_selected=LoadSelection(select_file)
- select_type=TypeRequester(title,select_type,old_selected)
- if (select_type=0) then return 0
- if (title~="") then title=title": "
- seq_files=0
-
- select
- when (select_type=ST_SEQUENCE) then do
- name1=SelectFile(title||mes.language.1,default_drawer,"",selection1)
- if (name1="") then return 0
- name2=SelectFile(title||mes.language.2,selected_drawer,"",selection2)
- if (name2="") then return 0
-
- start_sequence=GetExtension(name1)
- end_sequence=GetExtension(name2)
- if (start_sequence="" | end_sequence="") then do
- call CleanExit(EXTENSION_ERR)
- end
- if (start_sequence>end_sequence) then do
- temp=start_sequence
- start_sequence=end_sequence
- end_sequence=temp
- end
- base_name=GetBaseName(name1)
- extension_digits=GetExtensionDigits(name1)
- if (upper(base_name)~=upper(GetBaseName(name2))) then do
- call CleanExit(SEQUENCE_ERR)
- end
- if (extension_digits~=GetExtensionDigits(name2)) then do
- extension_digits=0
- end
- do o=start_sequence to end_sequence
- seq_files=seq_files+1
- sequence_name.seq_files=base_name||MakeExtension(o,extension_digits)
- end
- end
-
- when (select_type=ST_SPECIFY) then do
-
- done=0
- do until (done)
- name=SelectFile(title||mes.language.3,default_drawer,"",selection1)
- if (name="") then do
- if (seq_files=0) then return 0
- else done=1
- end
- if (~done) then do
- seq_files=seq_files+1
- sequence_name.seq_files=name
- end
- end
- end
-
- when (select_type=ST_LIST) then do
-
- name=SelectFile(title||mes.language.4,"RAM:","",selection1)
- if (name="") then return 0
- if (~exists(name)) then call CleanExit(FILE_ERR)
- if (~open(state,name,'R')) then call CleanExit(READ_ERR)
- do until (name="")
- name=readln(state)
- if (name~="") then do
- seq_files=seq_files+1
- sequence_name.seq_files=name
- end
- end
- call close(state)
- end
-
- when (select_type=ST_DIRECTORY) then do
-
- drawer=SelectFile(title||mes.language.5,default_drawer,"",selection1,"DRAWER")
- if (drawer="") then return 0
- list=DeleteInfo(showdir(drawer,'F'))
- seq_files=words(list)
- do sequence=1 to seq_files
- name=LW_AddFile(drawer,word(list,sequence))
- sequence_name.sequence=name
- end
- end
-
- when (select_type=ST_READ) then do
-
- name1=SelectFile(title||mes.language.1,default_drawer,"",selection1)
- if (name1="") then return 0
- name2=SelectFile(title||mes.language.2,selected_drawer,"",selection2)
- if (name2="") then return 0
-
- drawer=LW_DRAWER(name1)
- list=DeleteInfo(showdir(drawer,'F'))
- list=LW_SortList(list,words(list))
- files=words(list)
- do_add=0
- do sequence=1 to files
- name=LW_AddFile(drawer,word(list,sequence))
- if (name=name1) then do_add=1
- if (do_add) then do
- seq_files=seq_files+1
- sequence_name.seq_files=name
- end
- if (name=name2) then leave
- end
- end
-
- when (select_type=ST_REPEAT) then do
- seq_files=old_selected
- end
- end
-
- if (seq_files<minimum_files) then do
- call notify(1,! mes.language.6 minimum_files mes.language.7); return 0
- end
- if (seq_files>maximum_files) then do
- call notify(1,! mes.language.8 maximum_files mes.language.7); return 0
- end
- if (~notify(2,! seq_files mes.language.9)) then return 0
-
- SaveSelection(seq_files,select_file,select_type)
- return seq_files
-
- /**************************************************************/
-
- DeleteInfo: parse arg flist
-
- elist=""
- if (flist~="") then do
- do i=1 to words(flist)
- w=word(flist,i)
- if (pos(".info",w,length(w)-5)=0) then elist=elist w
- end
- end
- return elist
-
- /**************************************************************/
-
- TypeRequester: PROCEDURE EXPOSE language ENGLISH GERMAN
- parse arg title, select_type, old_selected
-
- mes.ENGLISH.1=": Selection Type"
- mes.ENGLISH.2="Type of File Selection"
- mes.GERMAN.1=": Art der Auswahl"
- mes.GERMAN.2="Art der Dateiauswahl"
-
- if (title~="") then tstring=title||mes.language.1
- else tstring=mes.language.2
- cstring="Sequence Specify List Directory AlphaSort"
- if (old_selected>0) then cstring=cstring "Repeat"
- return VariableChoice(tstring,"TYPE",cstring,words(cstring),select_type)
-
- /**************************************************************/
-
- VariableChoice: PROCEDURE EXPOSE language ENGLISH GERMAN pmes.
- parse arg title, descriptor, array, visible, selected
-
- vchoice=0
- to_show=words(array); coffset=1; cpage=1; cpages=to_show/visible;
- if ((to_show//visible)>0) then cpages=cpages+1; cpages=trunc(cpages)
- do while (to_show>0)
- if (to_show>visible) then citems=visible; else citems=to_show
- vc=""; do i=coffset to citems+coffset-1; vc=vc word(array,i); end
- if (cpages>1) then call req_begin(title||pmes.language.1 cpage pmes.language.2 cpages)
- else call req_begin(title)
- vci=req_addcontrol(descriptor,'cv',vc)
- call req_setval(vci,selected)
- if (~req_post()) then do; call req_end(); return 0; end
- vchoice=req_getval(vci)
- call req_end()
- to_show=to_show-citems; coffset=coffset+citems
- end
- return vchoice
-
- /**************************************************************/
-
- error:
- syntax:
-
- t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
- call CleanExit()
-
- /**************************************************************/
- /**************************************************************/
-
- InitVariables:
-
- mathlib="rexxmathlib.library"
- rexxlib="rexxsupport.library"
- supplib="LWE.library"
- port=""
-
- envpath="ENV:LWEnhancer"
- globals=envpath"/LWEN.GLB"
- envname=envpath||macro_path
- config=envname".CNF"
-
- selection1=envname".1"
- selection2=envname".2"
- selection3=envname".3"
- selectionl=envname".L"
-
- /**************************************************************/
-
- ENGLISH=1
- GERMAN=2
-
- HELP_FIRST=1
- HELP_ALWAYS=2
- HELP_NEVER=3
-
- help_type=HELP_FIRST
- language=ENGLISH
- verbose=1
-
- /**************************************************************/
-
- ST_SEQUENCE=1
- ST_SPECIFY=2
- ST_LIST=3
- ST_DIRECTORY=4
- ST_READ=5
- ST_REPEAT=6
-
- extension_digits=3
-
- /**************************************************************/
-
- vmes.ENGLISH.1="Object exploded,"
- vmes.ENGLISH.2="Object(s) generated."
- vmes.GERMAN.1="Objekt wurde explodiert,"
- vmes.GERMAN.2="Objekt(e) erzeugt."
-
- mmes.ENGLISH.1=": Object"
- mmes.ENGLISH.2="of"
- mmes.GERMAN.1=": Objekt"
- mmes.GERMAN.2="von"
-
- pmes.ENGLISH.1=": Page"
- pmes.ENGLISH.2="from"
- pmes.GERMAN.1=": Seite"
- pmes.GERMAN.2="von"
-
- NO_ERROR=0
- FILE_ERR=1
- OPEN_LIB_ERR=2
- READ_ERR=3
- WRITE_ERR=4
- EXTENSION_ERR=5
- SEQUENCE_ERR=6
- ENV_ERR=7
- OBJECT_ERR=8
- INTERNAL_ERR=9
-
- errors.ENGLISH.FILE_ERR="File not found"
- errors.ENGLISH.OPEN_LIB_ERR="Can't open Library"
- errors.ENGLISH.READ_ERR="Read Error"
- errors.ENGLISH.WRITE_ERR="Write Error"
- errors.ENGLISH.EXTENSION_ERR="Numeric Extension Error"
- errors.ENGLISH.SEQUENCE_ERR="Base Names are different"
- errors.ENGLISH.ENV_ERR="Can't create"
- errors.ENGLISH.OBJECT_ERR="Not a valid object file"
- errors.ENGLISH.INTERNAL_ERR="Internal Error"
-
- errors.GERMAN.FILE_ERR="Datei nicht gefunden"
- errors.GERMAN.OPEN_LIB_ERR="Kann Library nicht öffnen"
- errors.GERMAN.READ_ERR="Fehler beim Lesen der Datei"
- errors.GERMAN.WRITE_ERR="Fehler beim Schreiben der Datei"
- errors.GERMAN.EXTENSION_ERR="Keine gültige numerische Extension"
- errors.GERMAN.SEQUENCE_ERR="Sequenz mit unterschiedlichen Basisnamen"
- errors.GERMAN.ENV_ERR="Kann Verzeichnis nicht anlegen"
- errors.GERMAN.OBJECT_ERR="Fehler beim Lesen der Objektdatei"
- errors.GERMAN.INTERNAL_ERR="Interner Fehler"
-
- /**************************************************************/
-
- SELECT_MESS=1
- MOTION_MESS=2
- OBJECT_MESS=3
- OUTPUT_MESS=4
- SEQUENCE_MESS=5
-
- messages.ENGLISH.SELECT_MESS="Please select File"
- messages.ENGLISH.MOTION_MESS="Please select Motion File"
- messages.ENGLISH.OBJECT_MESS="Please select Object File"
- messages.ENGLISH.OUTPUT_MESS="Please select Output File"
- messages.ENGLISH.SEQUENCE_MESS="Please select File Sequence"
-
- messages.GERMAN.SELECT_MESS="Bitte wählen Sie eine Datei"
- messages.GERMAN.MOTION_MESS="Bitte wählen Sie eine Motion-Datei"
- messages.GERMAN.OBJECT_MESS="Bitte wählen Sie eine Objekt-Datei"
- messages.GERMAN.OUTPUT_MESS="Bitte wählen Sie die Zieldatei"
- messages.GERMAN.SEQUENCE_MESS="Wählen Sie eine Sequenz von Dateien"
-
- /**************************************************************/
-
- PI=3.14159265358; PI180=pi/180; PI2=pi/2; DegrPerRad=180/pi
-
- /**************************************************************/
-
- return
-
-