/* change les paramètres de la cellule 3d - by iri : http://www.irizone.net */ /* Plugin CLI3DSETTINGS - part CLIENT - version 1.0 - 08/2004 */ /* Ne modifie les paramètres que chez le client, pas au niveau server */ /* Aucun enregistrement dynamique des modifications de ces paramètres */ typeof class = S;; typeof old_focale = F;; typeof old_darkbase = I;; typeof old_fog = [I I];; typeof old_boxcoll = S;; typeof old_speed = I;; typeof old_gravity = I;; typeof old_backgroundcolor = I;; typeof old_name3d = S;; typeof lastBmpSaved = S;; typeof lAv = [S r1];; typeof initSettings = [S r1];; /* valeurs par défaut : [darkbase::fog::backclipping::inbox::speedav::backgroundcolor::focale::gravity::name::nil] */ /********/ /* SET */ /********/ /* change la focale de la cam */ /* fun[F] I] */ fun chgFocale(val)= let M3getObj session "camera" -> cam in let val /.(atof "57.29") -> d in let M3getCamera session cam -> [_ [sx sy] z] in let ftoi (itof sx)/. tan d -> dx in M3setCamera session cam [[dx dx] [sx sy] z]; set old_focale = cel.Cel3dfocal; set cel.Cel3dfocal = val; /* inutile actuellement car pas de fun dans le C3D3 2.4 pour sa mise à jour dynamique */ 0;; /* change la lumière globale de la scène */ /* fun [S] I */ fun chgDarkbase(val)= set old_darkbase = atoi cel.Cel3ddarkbase; /* C3DsetGlobalLight val 1;*/ /* pour tout le monde */ C3DopSetGlobalLight (itoa val)::nil; /* que chez le client */ 0;; /* Change la distance de début de brouillard */ /* fun [I] I */ fun chgFog(val)= /* = fog & backclipping dans l'éditeur du C3D3 */ let val -> [fog clip] in let M3getObj session "camera" -> cam in ( if clip == nil then nil else let M3getCamera session cam->[dx sx [z0 _ _]] in M3setCamera session cam [dx sx [z0 if fog==nil then clip else fog clip ] ]; set old_fog = [cel.Cel3dfog cel.Cel3dclip]; set cel.Cel3dfog = fog; /* inutile actuellement car pas de fun dans le C3D3 2.4 pour sa mise à jour dynamique */ set cel.Cel3dclip = clip; /* inutile actuellement car pas de fun dans le C3D3 2.4 pour sa mise à jour dynamique */ );; /* Change la boite de collision */ /* fun [S] I */ fun chgBoxColl(o, path)= if path != nil then UsendMessage ObUi o "changeBox" path else 0;; /* fun [S] I */ fun modifyBox(file)= if (_checkpack file) == nil then nil else ( if cel.Cel3dcol == nil then nil else inboxClosing coll; let cel.Cel3dcol -> [_ i j] in set coll = mkInBox [file nil nil i j]; /* [nameIB :S, sIB :SBox, curboxIB :Box, rayonIB :I, gravityIB :I] */ inboxLoading coll; OB_ForceCurrentPos owner session ); 0;; /* fun [S] I */ fun newBox(path)= let cel.Cel3dcol -> [s i j] in ( set old_boxcoll = s; set cel.Cel3dcol = [path i j] ); set cel.Cel3dphysics = 1; _RSCdownload this path path @modifyBox 3; 0;; /* change la vitesse de déplacement de l'avatar, + val est gd + la vitesse est faible ... defaut : 128 */ /* fun [I] I */ fun chgSpeedAv(val)= set old_speed = cel.Cel3dspeed; set cel.Cel3dspeed = val;; /* change la gravité */ /* fun [I] I - les paramètres sont censés être à 1 chez le client */ fun chgGravity(g)= set old_gravity = cel.Cel3dgrav; set cel.Cel3dgrav = if g == nil then 0 else g;; /* Change la couleur de fond de scène */ /* fun [I] I */ fun chgBackgroundColor(c)= set old_backgroundcolor = w3d.V3dfond; ObSetBackground w3d c; 0;; /* change le nom de la cellule courante */ /* fun [S] I */ fun setNameCel3d(name)= set old_name3d = cel.Cel3dname; set cel.Cel3dname = name; 0;; /* réapplique les valeurs par défaut (celles initiales rentrées dans l'éditeur du C3D3) */ /* fun [] I */ fun setInit(o)= chgDarkbase atoi nth_list initSettings 0; let strextr nth_list initSettings 1 -> [[fog _] [[clip _] _]] in chgFog [atoi fog atoi clip]; chgBoxColl o nth_list initSettings 2; chgSpeedAv atoi nth_list initSettings 3; chgBackgroundColor atoi nth_list initSettings 4; chgFocale atof nth_list initSettings 5; chgGravity atoi nth_list initSettings 6; setNameCel3d nth_list initSettings 7;; /********/ /* GET */ /********/ /* retourne le nom de la cellule 3d */ /* fun [] I */ fun getNameCel3d()= _DMSevent this strcat class "getName" _DMSgetName this nil;; /* retourne la liste des avatars présents dans la scène */ // SERVER non ?? /* fun [Ob [S r1]] [S r1] */ fun addlistAv(o, l)= if !o.avOb then nil else let o.pseudoOb -> name in set lAv = name::lAv;; /* fun [Ob] I */ fun getListAv(o)= set lAv = nil; apply_on_list C3DobList @addlistAv nil; _DMSevent this strcat class "getListAv" linebuild lAv nil;; /* retourne la couleur de fond de scène actuelle */ /* fun [] I */ fun getBackgroundColor()= _DMSevent this strcat class "getBackgroundColor" itoa old_backgroundcolor nil;; /* retourne la valeur actuelle de la gravité */ /* fun [] I */ fun getGravity()= _DMSevent this strcat class "getGravity" itoa cel.Cel3dgrav nil;; /* retourne la vitesse de l'avatar ds la cellule */ /* fun [] I */ fun getSpeedAv()= _DMSevent this strcat class "getSpeedAv" itoa cel.Cel3dspeed nil;; /* retourne le chemin relatif de la boite de collision */ /* fun [] I */ fun getBoxcoll()= let cel.Cel3dcol -> [s _ _ ] in _DMSevent this strcat class "getPathInbox" s nil;; /* retourne la valeur du fog */ /* fun [] I */ fun getFog()= _DMSevent this strcat class "getFog" linebuild (itoa cel.Cel3dfog)::(itoa cel.Cel3dclip)::nil nil;; /* retourne la valeur de la lumière globale */ /* fun [] I */ fun getDarkbase()= _DMSevent this strcat class "getDarkbase" cel.Cel3ddarkbase nil;; /* retourne la valeur de la focale de la cam de l'owner */ /* fun [] I */ fun getFocale()= _DMSevent this strcat class "getFocale" ftoa cel.Cel3dfocal nil;; /* retourne les valeurs par défaut (initiales) */ /* fun [] I */ fun getInit()= _DMSevent this strcat class "getInit" linebuild initSettings nil;; /***********/ /* OTHERS */ /***********/ /* la version 4.5 beta tronque l'image obtenue (bug connu de la lib2d et corrigé dans la release) */ fun msgVersion()= _DMSevent this strcat class "errorVersion45b" lastBmpSaved nil;; /* Prend un screenshot de la vue 3d courante et l'enregistre */ /* fun[SaveBox ObjBitmap W] I */ fun cbSaveScreenShot(dlb, bmp, file)= let _PtoScol _WtoP file -> s in let substr s (strlen s)-4 4 -> ext in if strcmp ext ".jpg" then set file = _getmodifypack strcat s ".jpg" else nil; set lastBmpSaved = _PtoScol _WtoP file; _SAVEjpeg bmp file 50; if (_version == 1304) && ((strfind "4.0ap10" _versionname 0) != nil) then msgVersion else nil; _DSbitmap bmp;; /* fun [] I */ fun setScreenShot()= let _GETsurfaceSize w3d.V3dbuf -> [ws hs] in let _FILLbitmap _CRbitmap _channel ws hs make_rgb 150 220 145 -> bmp in let _Surface2Bitmap bmp 0 0 w3d.V3dbuf 0 0 ws hs nil -> bmp in _DLGrflsave _DLGSaveFile _channel w3d.V3dwin nil nil "JPEG\0*.jpg\0\0" @cbSaveScreenShot bmp; 0;; /* retourne le chemin relatif du dernier screenshot */ /* fun [] I */ fun getLastScreenShot()= _DMSevent this strcat class "getScreenShot" lastBmpSaved nil;; /* retourne l'heure locale chez le client */ /* fun [] I */ fun getTimeLocal()= let localtime time -> [s m h _ _ _ _ _] in _DMSevent this strcat class "getLocalTime" linebuild (itoa h)::(itoa m)::(itoa s)::nil nil;; /***********/ /* PLUGIN */ /***********/ fun activate(o, from, action, param, reply)= if !strcmp action strcat class ".chgDarkbase" then if param != nil then chgDarkbase atoi param else 0 else if !strcmp action strcat class ".reverseDarkbase" then if old_darkbase != nil then chgDarkbase old_darkbase else 0 else if !strcmp action strcat class ".chgFog" then let hd strextr param -> [fog _] in let hd tl strextr param -> [clip _] in if param != nil then chgFog [atoi fog atoi clip] else 0 else if !strcmp action strcat class ".reverseFog" then if old_fog != nil then chgFog old_fog else 0 else if !strcmp action strcat class ".chgInbox" then if param != nil then chgBoxColl o param else 0 else if !strcmp action strcat class ".reverseInbox" then if old_boxcoll != nil then chgBoxColl o old_boxcoll else 0 else if !strcmp action strcat class ".chgSpeedAv" then if param != nil then chgSpeedAv atoi param else 0 else if !strcmp action strcat class ".reverseSpeedAv" then if old_speed != nil then chgSpeedAv old_speed else 0 else if !strcmp action strcat class ".chgBackgroundcolor" then if param != nil then chgBackgroundColor atoi param else 0 else if !strcmp action strcat class ".reverseBackgroundcolor" then if old_backgroundcolor != nil then chgBackgroundColor old_backgroundcolor else 0 else if !strcmp action strcat class ".chgFocale" then if param != nil then chgFocale atof param else 0 else if !strcmp action strcat class ".reverseFocale" then if old_focale != nil then chgFocale old_focale else 0 else if !strcmp action strcat class ".chgGravity" then if param != nil then chgGravity atoi param else 0 else if !strcmp action strcat class ".reverseGravity" then if old_gravity != nil then chgGravity old_gravity else 0 else if !strcmp action strcat class ".chgName3d" then if param != nil then setNameCel3d param else 0 else if !strcmp action strcat class ".reverseName3d" then if old_name3d != nil then setNameCel3d old_name3d else 0 else if !strcmp action strcat class ".getDarkbase" then getNameCel3d else if !strcmp action strcat class ".getFog" then getFog else if !strcmp action strcat class ".getInbox" then getBoxcoll else if !strcmp action strcat class ".getSpeedAv" then getSpeedAv else if !strcmp action strcat class ".getBackgroundcolor" then getBackgroundColor else if !strcmp action strcat class ".getFocale" then getFocale else if !strcmp action strcat class ".getGravity" then getGravity else if !strcmp action strcat class ".getName3d" then getNameCel3d else if !strcmp action strcat class ".screenShot" then setScreenShot else if !strcmp action strcat class ".getLastScreenShot" then getLastScreenShot else if !strcmp action strcat class ".getListAv" then getListAv o else if !strcmp action strcat class ".getTimeLocal" then getTimeLocal else if !strcmp action strcat class ".setInit" then setInit o else if !strcmp action strcat class ".getInit" then getInit else 0; 0;; fun cbComm(ui, action, param, o)= if !strcmp action "registered" then ( ObRegisterAction o strcat class ".chgDarkbase" @activate; ObRegisterAction o strcat class ".chgFog" @activate; ObRegisterAction o strcat class ".chgBackClipping" @activate; ObRegisterAction o strcat class ".chgInbox" @activate; ObRegisterAction o strcat class ".chgSpeedAv" @activate; ObRegisterAction o strcat class ".chgBackgroundcolor" @activate; ObRegisterAction o strcat class ".chgFocale" @activate; ObRegisterAction o strcat class ".chgGravity" @activate; ObRegisterAction o strcat class ".chgName3d" @activate; ObRegisterAction o strcat class ".reverseDarkbase" @activate; ObRegisterAction o strcat class ".reverseFog" @activate; ObRegisterAction o strcat class ".reverseBackClipping" @activate; ObRegisterAction o strcat class ".reverseInbox" @activate; ObRegisterAction o strcat class ".reverseSpeedAv" @activate; ObRegisterAction o strcat class ".reverseBackgroundcolor" @activate; ObRegisterAction o strcat class ".reverseFocale" @activate; ObRegisterAction o strcat class ".reverseGravity" @activate; ObRegisterAction o strcat class ".reverseName3d" @activate; ObRegisterAction o strcat class ".getDarkbase" @activate; ObRegisterAction o strcat class ".getFog" @activate; ObRegisterAction o strcat class ".getBackClipping" @activate; ObRegisterAction o strcat class ".getInbox" @activate; ObRegisterAction o strcat class ".getSpeedAv" @activate; ObRegisterAction o strcat class ".getBackgroundcolor" @activate; ObRegisterAction o strcat class ".getFocale" @activate; ObRegisterAction o strcat class ".getGravity" @activate; ObRegisterAction o strcat class ".getName3d" @activate; ObRegisterAction o strcat class ".screenShot" @activate; ObRegisterAction o strcat class ".getLastScreenShot" @activate; ObRegisterAction o strcat class ".getListAv" @activate; ObRegisterAction o strcat class ".getTimeLocal" @activate; ObRegisterAction o strcat class ".setInit" @activate; ObRegisterAction o strcat class ".getInit" @activate; 0 ) else if !strcmp action "boxRegistered" then newBox param else 0;; fun newOb(o)= set initSettings = (cel.Cel3ddarkbase):: (strbuild ((itoa cel.Cel3dfog)::nil)::((itoa cel.Cel3dclip)::nil)::nil):: (let cel.Cel3dcol -> [s _ _ ] in s):: (itoa cel.Cel3dspeed):: (itoa w3d.V3dfond):: (ftoa cel.Cel3dfocal):: (itoa cel.Cel3dgrav):: (cel.Cel3dname):: nil; UcbComm this ObUi o mkfun4 @cbComm o; UsendMessage ObUi o "register" nil; 0;; fun IniPlug(file) = set class = getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0 ;;