Automatic Emitter Placement by Carolina South27th May 2006 12:30
|
---|
Summary This code is a function that will take a model created in 3D World Studio (or maybe another modeling package that supports entities - I haven't tested with any others yet) and auto Description ` This Code Is To Save A Lot Of Time Trying To Position Emitters At The Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` This Code Is To Save A Lot Of Time Trying To Position Emitters At The ` Locations You Want Them In Your 3D World Studio Models ` This Code Requires TGC's Cloth/Particles Expansion Pack ` This Code Rquires A Model Made in 3D World Studio and Exported As A LightMapped .DBO File ` Or A Model That Has Limbs Labeled As 'playerstart' ` Model Contruction Instructions: ` Make A Model In 3D World Studio, Place PlayerStart Entities At Each Location You ` Want An Emitter To Be Created At. Lightmap The Model (For Good Looks). ` Export The Model As A .DBO ` You Can Use Your Own Entity Names If 3DWS Supports Them ` Change 'playerstart' Code Where Appropriate If Using Your Own Entities. ` By Carolina South ` Use As You See Fit ` Setup Basic Stuff color backdrop 0 sync on sync rate 80 ModelNumber = 1 ` Model Number That Contains The 'PlayerStart' Entities Global EmitterImageNumber = 1 ` Image Number Of The Emitter Texture ` Load Required Media - Alter Paths To Point To The Location Of Your Media Load Image "C:\~~~~~\fire.png",EmitterImageNumber,1 ` This is the texture for the particle emitter ` - Mine Is A Fire Texture For This Example Load Object "C:\~~~~~\Entity.dbo",ModelNumber ` This is the 3DWS .DBO model containing 'playerstart' entities ` Place Model Where You Want It Position Object ModelNumber, 0, 0, 0 ` Center Of The Universe For Me ` Scale The Object (I can never get the scale to match from 3DWS to DBPro) Scale Object ModelNumber, 10,10,10 ` Move The Camera Back A Bit From The Center Of The Universe Position Camera 0,0,40,-100 ` Make The Particle Emitters Build_Emitters(ModelNumber) ` Pass In The Model Number To Create The Particle Emitters From ` Main Loop Do control camera using arrowkeys 0, 3, 1 `Allow Us Free Movement update physics ` Always Need This When Using TGC's Cloth/Particles Expansion Pack text 0,0, str$(screen fps()) ` Obligatory Frame Rate Code sync ` Piece Everything Together loop `*************************** ` Our Wonderful Function `*************************** Function Build_Emitters(ModelNumber as Integer) ` Accepts Model Number Passes In To Create The Particle Emitters From ` Create emitters for each limb ` that is identified as a 'PlayerStart' ` in the .DBO object. ` Required By TGC's Cloth/Particles Expansion Pack Set Physics Frame Rate 80 Empty Checklist ` Empty Our Limb Checklist If Object Exist(ModelNumber) ` Make Sure We Passed A Valid Object Number To The Function Perform Checklist For Object Limbs ModelNumber ` Find Number Of Limbs In Model For ERun=1 To Checklist Quantity() ` Check Each Limb To See If It Is ActualLimbYCoord A 'PlayerStart' Entity If Limb Exist(ModelNumber,ERun) = 1 If Left$(Limb Name$(ModelNumber,ERun),21) = "Classname=playerstart" LimbXCoord = Int(Limb Position X(ModelNumber, ERun)) ` Get The 3D Position Of The 'PlayerStart' Entity LimbYCoord = Int(Limb Position Y(ModelNumber, ERun)) LimbZCoord = Int(Limb Position Z(ModelNumber, ERun)) EmitNum = FreeObject() ` Find An Object Number That Hasn't Been Used Yet Make Basic Emitter EmitNum , 30 ` Make The Base Emitter Texture Object EmitNum, EmitterImageNumber Ghost Object On EmitNum Position Object EmitNum,LimbXCoord,LimbYCoord,LimbZCoord Disable Object Zwrite EmitNum Set Object Transparency EmitNum, 1 Set Emitter Rate EmitNum,10 Set Emitter Explode EmitNum, 150*0.01 Set Emitter Particle Velocity EmitNum,1.0,0 Set Emitter Particle Life EmitNum,1,0 Set Emitter Particle Mass EmitNum, 1, 30 Set Emitter Particle Size EmitNum,4, 0 Set Emitter Particle Color EmitNum,255,255,255,50 Set Particle Z Sorting EmitNum,1 EmitNum2 = FreeObject() ` Find An Object Number That Hasn't Been Used Yet Make Wind Effector EmitNum2 ` Make The Wind Effector Bind Effector To Object EmitNum2 ,EmitNum Set Wind Effector EmitNum2,0,5,0 EmitNum3 = FreeObject() ` Find An Object Number That Hasn't Been Used Yet Make Chaos Effector EmitNum3 ` Make The Chaos Effector Set Chaos Effector EmitNum3, 400 Bind Effector To Object EmitNum3,EmitNum endif endif next c Endif EndFunction function FreeObject() ` Simple Function To Determine An Unused Object Number do inc azo if object exist(azo)=0 then exit loop if azo>TopObject then TopObject=azo endfunction azo |