/* Snapshot Plugin - DMS - september 99 - by Sylvain HUET */ /* rev. Arpil 00 - by Sébastien DENEUX */ var avfile="Dms/3d/Plugins/SnapShot/x.m3d";; typeof class=S;; typeof dev=Video;; typeof win=ObjWin;; typeof lastone=ObjBitmap;; typeof newone=ObjBitmap;; typeof text=ObjText;; typeof lastbmp=S;; typeof lastsent=S;; var vw=128;; var vh=128;; var quality=40;; var compress=1;; typeof loop=ObjCheck;; var ackvideo=1;; typeof curvideo=Ob;; fun endcapt()= if dev==nil then nil else (_SETcapVideoStop dev; _DScapWindow dev); set dev=nil;; fun destroyPho(o)= endcapt; _DSbitmap lastone; _DSbitmap newone; _DSwindow win; 0;; fun _paintevent(a,b)=_BLTbitmap win lastone 0 0;; fun applytx(x,t)= match x with (objAnchor [_ m _ _] -> (M3chgMaterialTexture session m t; M3setType session m (M3getType session m)|1)) |(_->nil);; proto applyface=fun[S [Ob S S S HTx3d]] I;; fun applyface(f,z)= let z->[o _ _ _ txt] in let _getpack _checkpack f -> s in if s==nil then nil else /* let _c32to15 _JDecomp s vh vw quality -> fs in else*/ let if (nth_char s 0)=='Z then _c32to15 _JDecomp (substr s 1 strlen s) vh vw quality else (substr s 1 strlen s) -> fs in (if lastone==nil then nil else (_SETbitmap lastone fs; _paintevent nil nil; nil); let _CRbitmap _channel vw vh -> image in (_SETbitmap image fs; M3blitTexture16 session txt image; apply_on_list ObAnchor o @applytx txt; _DSbitmap image; 0) ); let z->[o _ nxt file _] in (if o==curvideo then set ackvideo=1 else nil; if nxt==nil then (mutate z<-[_ nil nil _ _];0) else (mutate z<-[_ nxt nil _ _]; _RSCdownload this file strcatn file::"_"::(itoa DMSid)::".sav"::nil mknode @applyface z 3;0)) /*id necessary if more than one connection from same scol engine*/ ;; fun _event(a,o)= _SETbitmap newone lastbmp; set lastsent=_FILEbitmap newone; if lastbmp==nil then nil else let if compress then (_JCompInit quality; strcat "Z" _JComp (_c15to32 lastbmp) vw vh) else strcat "N" lastbmp -> fs in /*let (_JCompInit quality;_JComp (_c15to32 lastbmp) vw vh) -> fs in*/ let mzip fs -> s in (let 0->i in while i temp in let if temp==nil || temp==-1 then 0 else temp -> vid in (set dev=_CRcapWindow _channel win vid 272 0 vw vh 1 500000; if (dev!=nil) then _SETcapVideoStart dev @capfun o else nil) else (endcapt; nil); _SETbuttonName a if dev==nil then (_loc this "SNAP_START" nil) else (_loc this "SNAP_STOP" nil);; fun _destroyevent(a,b)= endcapt; _DSbitmap lastone; _DSbitmap newone; set win=nil; set lastone=nil; 0;; /* save / load */ typeof oldpath=S;; fun lastslash(s)= let 0-> i in let 0-> l in (while i s in if s==nil then nil else (set oldpath=substr s 0 lastslash s; _storepack b s);; fun _save(a,b)= _DLGrflsave (_DLGSaveFile _channel win oldpath nil "Bitmap (*.bmp)\0*.BMP\0\0") @_SaveSnap lastsent;; fun _OpenSnap(d,o,s)= let _PtoScol s -> name in if name==nil then nil else (set oldpath=substr name 0 lastslash name; let _LDbitmap _channel s-> xx in let if xx==nil then _LDjpeg _channel s else xx ->x in if x==nil then nil else let _GETbitmapSize x-> [w h] in (_SCPbitmap lastone 0 0 vw-1 vh-1 x 0 0 w-1 h-1 nil; set lastbmp=_GETbitmap lastone; _DSbitmap x; _event nil o) );; fun _load(a,o)= _DLGrflopen (_DLGOpenFile _channel win oldpath nil "Bitmap (*.bmp,*.jpg)\0*.BMP;*.JPG\0\0") @_OpenSnap o;; /* interface */ fun createbutton(o)= let _DMSgetZone this "SnapShotInterface" nil nil nil ->[wn x y w h] in (if wn!=nil then set win=_CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER "SnapShotInterface" else set win=_CRwindow _channel nil 200 100 400 148 WN_MENU+WN_MINBOX "Snapshot"; _CBwinDestroy win @_destroyevent 0; set text=_CRtext _channel win 150 125 100 20 ET_DOWN ""; set newone=_CRbitmap _channel vw vh; set lastone=_CRbitmap _channel vw vh; _FILLbitmap lastone 0xc0; _CBwinPaint win @_paintevent 0; _CBbutton (_CRbutton _channel win 150 20 100 20 0 (_loc this "SNAP_SNAPSHOT" nil)) @_event o; _CBbutton (_CRbutton _channel win 150 40 100 20 0 (_loc this "SNAP_START" nil)) @_startstop o; _CBbutton (_CRbutton _channel win 150 60 100 20 0 (_loc this "SNAP_SAVE" nil)) @_save o; _CBbutton (_CRbutton _channel win 150 80 100 20 0 (_loc this "SNAP_LOAD" nil)) @_load o; _SETcheck (_CBcheck (_CRcheck _channel win 150 100 100 20 0 (_loc this "SNAP_COMPRESSION" nil)) @_chgcom o) 1; if !strcmpi hd UgetParam ObUi o "loop" "yes" then set loop=_CRcheck _channel win 150 0 100 18 0 "Loop" else nil; _paintevent nil nil; 0);; fun cbcomm(ui,action,param,z)= let z->[o cur nxt file _] in if !strcmp action "PhotoChg" then if param==nil then nil else if cur==nil then (mutate z<-[_ param nil _ _]; _RSCdownload this file strcatn file::"_"::(itoa DMSid)::".sav"::nil mknode @applyface z 3; /*id necessary if more than one connection from same scol engine*/ 0) else (mutate z<-[_ _ param _ _]; 0) else if !strcmp action "registered" then (UsendSrv this ui "Photo?" nil;0) else if !strcmp action "setName" then (mutate z <- [_ _ _ param _]; UsendSrv this ui "Photo?" nil; 0) else nil;; fun activate(o,from,action,param,rep)= if win==nil then createbutton o else nil; 0;; fun newOb(o)= M3load session avfile nil; ObRegisterAction o strcat ObName o ".modify" @activate; ObCbDestroy o @destroyPho; let M3copyMaterialTexture session M3getMat session "snapmater" -> txt in UcbComm this ObUi o mkfun4 @cbcomm [o nil nil nil txt]; UsendSrv this ObUi o "Name?" nil; 0;; fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0;;