/* Authors: Arkeon & Bob Le Gob */ /* Last update: 08.01.03 */ /* Version: 1.01 */ typeof class = S;; // - Struct Flare - struct TFlare = [ FLARE_effectH3d : H3d, /* H3d */ FLARE_FatherH3d : H3d, /* H3d */ FLARE_H3d : H3d, /* H3d */ FLARE_Mat : HMat3d, FLARE_actif : I, FLARE_MaxDist : I, FLARE_MaxScale : I, FLARE_maxOpacity : I, FLARE_minOpacity : I, FLARE_PosX : I, FLARE_PosY : I, FLARE_PosZ : I, FLARE_sceneH3dl : [H3d r1] /* H3d */ ]mkFlare;; typeof FlareList = [TFlare r1];; var DefaultTextureFile = "dms/3d/plugins/flare/flare.png";; var DefaultMaxDist = 1000;; /*default value of the maximum sphere radius*/ var DefaultMaxScale = 200;; /*default value of the maximum sphere radius*/ var DefaultMinOpacity = 255;; /*default value of the minimum flare opacity*/ var DefaultMaxOpacity = 255;; /*default value of the minimum flare opacity*/ proto getSons = fun [H3d [H3d r1]] [H3d r1];; /* ************ */ /* Flares' anim */ /* ************ */ fun getBrother (elem, l)= if elem == nil then l else ( set l = elem::l; set l = getBrother M3getBrother session elem l; set l = getSons M3getBrother session elem l; );; fun getSons (elem, l)= let M3getFirstSon session elem -> PartH3D in if PartH3D == nil then l else ( set l = elem::l; set l = getBrother PartH3D l; set l = getSons PartH3D l; ) ;; /* fun getOccluded(list)= if list==nil then 0 else (((hd list)!=nil)&&(hd list))||(getOccluded tl list);; */ fun getOccluded(list)= if list==nil then 0 else let list -> [elem next] in ( // if elem == 1 then elem else _fooS strcat ">>>>>>>> " itoa elem; getOccluded next; );; fun fooSh3dList(list)= if list==nil then nil else let list -> [elem next] in ( _fooS strcat ">>>>>>>> " (M3objName session elem); fooSh3dList next; 0; );; fun AnimFlare(FlareStruct) = let getView3dSize w3d -> [iWinW iWinH] in if iWinW <= 0 || iWinH <=0 then nil else let M3getFather session ObGetMain owner -> objshell in let M3distance session FlareStruct.FLARE_FatherH3d objshell -> curdist in let (curdist * FlareStruct.FLARE_MaxScale) / (FlareStruct.FLARE_MaxDist) -> newScale in let (curdist * FlareStruct.FLARE_minOpacity) / (FlareStruct.FLARE_MaxDist) -> newtransp in let M3calcProjF session cam FlareStruct.FLARE_FatherH3d -> proj in let proj -> [px py fz fr] in let (cel.Cel3dfocal)/.(atof "57.29") -> d in let M3getCamera session cam -> [_ _ [clip _ _]] in let itof clip -> z in let (itof iWinW) /. (itof iWinH) -> dx in let ((z *. (tan d)) *. 2.0) -> iw in let ((z *. (tan d)) *. 2.0) /. dx -> ih in ( if proj == nil then M3unLink session FlareStruct.FLARE_H3d else ( let M3isMeshCulledByOthers session FlareStruct.FLARE_FatherH3d FlareStruct.FLARE_sceneH3dl -> ocl in ( if getOccluded ocl then M3unLink session FlareStruct.FLARE_H3d else ( M3link session FlareStruct.FLARE_H3d cam; if ((newScale < FlareStruct.FLARE_MaxScale) && (curdist < FlareStruct.FLARE_MaxDist)) then M3setObjScale session FlareStruct.FLARE_H3d newScale else M3setObjScale session FlareStruct.FLARE_H3d FlareStruct.FLARE_MaxScale; let (itof px) *. (iw /. (itof iWinW)) -> nx in let (itof py) *. (ih /. (itof iWinH)) -> ny in M3setObjVecF session FlareStruct.FLARE_H3d [nx ny z]; if ((newtransp < FlareStruct.FLARE_minOpacity) && (curdist < FlareStruct.FLARE_MaxDist)) then if (newtransp > FlareStruct.FLARE_maxOpacity) then M3setMaterialTransparency session FlareStruct.FLARE_Mat newtransp else M3setMaterialTransparency session FlareStruct.FLARE_Mat FlareStruct.FLARE_maxOpacity else if (curdist >= FlareStruct.FLARE_MaxDist) then M3setMaterialTransparency session FlareStruct.FLARE_Mat FlareStruct.FLARE_minOpacity else nil; ); ); ); ); 0;; fun cbTime_PlayFlareList (l)= if l == nil then nil else let l -> [elem next] in ( AnimFlare elem; cbTime_PlayFlareList next; ); 0 ;; fun AnimFlares(o, param) = //testOcclusion FlareList; cbTime_PlayFlareList FlareList; 0;; /* ****** */ /* New Ob */ /* ****** */ fun delete(o) = ObCbAnim o nil; 0;; fun AddM3D(x, param) = //_showconsole; match x with (objAnchor [h _ _ _] -> let param -> [o Texture maxDist maxScale minOpacity maxOpacity posX posY posZ] in let M3createTexture session Texture -> newTexture in let M3createShell session -> flareShell in let M3createMaterial session strcat "mat." ObName o -> flareMat in let M3createSpriteF session 50.0 50.0 flareMat 1 -> newflare in let M3getCamera session cam -> [_ _ [clip _ _]] in let M3getFirstSon session shell -> fson in let getSons fson nil -> objl in ( //fooSh3dList objl; M3chgMaterialTexture session flareMat newTexture; M3setType session flareMat MAT_TRANSP|MAT_TEXTURED|(M3getType session flareMat); M3link session flareShell h; M3link session newflare cam; M3setObjVec session flareShell [posX posY posZ]; let getView3dSize w3d -> [iWinW iWinH] in if iWinW <= 0 || iWinH <=0 then nil else ( let (cel.Cel3dfocal)/.(atof "57.29") -> d in let itof clip -> z in let (itof iWinW) /. (itof iWinH) -> dx in let ((z *. (tan d)) *. 4.0) -> iw in let ((z *. (tan d)) *. 4.0) /. dx -> ih in let M3calcProjF session cam flareShell -> [px py fz fr] in let (itof px) *. (iw /. (itof iWinW)) -> nx in let (itof py) *. (ih /. (itof iWinH)) -> ny in M3setObjVecF session newflare [nx ny z]; ); let mkFlare [h flareShell newflare flareMat 1 maxDist maxScale maxOpacity minOpacity posX posY posZ objl] -> nmkflare in set FlareList = nmkflare::FlareList; 0; ) ) |(_->nil); 0 ;; fun CBStart (file, params)= let params -> [o Texture maxDist maxScale minOpacity maxOpacity posX posY posZ] in apply_on_list (ObAnchor o) @AddM3D [o Texture maxDist maxScale minOpacity maxOpacity posX posY posZ]; 0 ;; fun CBStop (o, from, action, linkparam, reply)= 0 ;; fun newOb(o) = let hd UgetParam ObUi o "MaxDist" -> tmp1 in let if (tmp1 == nil) then DefaultMaxDist else atoi tmp1 -> maxDist in let hd UgetParam ObUi o "MaxScale" -> tmp2 in let if (tmp2 == nil) then DefaultMaxScale else atoi tmp2 -> maxScale in let hd UgetParam ObUi o "MinOpacity" -> tmp3 in let if (tmp3 == nil) then DefaultMinOpacity else atoi tmp3 -> minOpacity in let hd UgetParam ObUi o "MaxOpacity" -> tmp4 in let if (tmp4 == nil) then DefaultMaxOpacity else atoi tmp4 -> maxOpacity in let hd UgetParam ObUi o "Texture" -> tmp5 in let if (tmp5 == nil) then DefaultTextureFile else tmp5 -> Texture in let atoi (hd UgetParam ObUi o "posx") -> posX in let atoi (hd UgetParam ObUi o "posy") -> posY in let atoi (hd UgetParam ObUi o "posz") -> posZ in _RSCdownload this Texture Texture mkfun2 @CBStart [o Texture maxDist maxScale minOpacity maxOpacity posX posY posZ] nil; ObCbAnim o mkfun2 @AnimFlares nil; ObCbDestroy o @delete; 0;; /* ************************************************************ */ /* Launching the plugin and downloading the M3D & texture files */ /* ************************************************************ */ fun IniPlug(file) = set class = getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0;;