/* av3d browser - by Sebastien DENEUX - January 00 */ /* rev - September 2001 - by sebastien DENEUX */ /*avatar view zone*/ typeof winAvatarView=ObjWin;; typeof cameraAvatarView=H3d;; typeof avatarViewObj=H3d;; typeof sessionAvatarView=S3d;; typeof shellAvatarView=H3d;; typeof bufferAvatarView=ObjBitmap;; typeof winAvatarView_w=I;; typeof winAvatarView_h=I;; /*--------------*/ fun cbPaintE2(wn,b)= _BLTbitmap wn bufPhoto 0 0;; /*--------------*/ fun cbDestroyE(wn,z)= let z -> [sessionAvInterfView _ _ _ bufferAvInterfView] in (_DSbitmap bufferAvInterfView; M3destroy sessionAvInterfView); set winInterface=nil; _DSbitmap bufPhoto; 0;; /*--------------*/ fun cbCancel(wn,z)= let z -> [sessionAvInterfView _ _ _ bufferAvInterfView] in (_DSbitmap bufferAvInterfView; M3destroy sessionAvInterfView); _DSwindow winInterface; set winInterface=nil; _DSbitmap bufPhoto; 0;; /*--------------*/ fun cbClockAv3dView(t,b)= let b -> [key] in if winAvatarView==nil then _deltimer t else ( M3setAnimKey sessionAvatarView avatarViewObj key; let if key newKey in mutate b <- [newKey]; if meshDownloading && winInterface==nil then let _GETbitmapSize loadingBitmap -> [bw bh] in (_STBLTbitmap winAvatarView 0 0 winAvatarView_w winAvatarView_h loadingBitmap 0 0 bw bh;0) else (M3scanline sessionAvatarView bufferAvatarView cameraAvatarView 0 0 0; _CPWbitmap winAvatarView 0 0 bufferAvatarView 0 0 winAvatarView_w winAvatarView_h;0); 0 );; /*--------------*/ fun cbDestroyB(wn,b)= set winAvatarView=nil; set winAvatarView_w=0; set winAvatarView_h=0; if sessionAvatarView!=nil then (M3destroy sessionAvatarView; set sessionAvatarView=nil) else nil; _DSbitmap bufferAvatarView; set bufferAvatarView=nil; _DMSreleaseZone this "AvatarView"; 0;; /*--------------*/ fun cbEndB(s)= set winAvatarView=nil; set winAvatarView_w=0; set winAvatarView_h=0; if sessionAvatarView!=nil then (M3destroy sessionAvatarView; set sessionAvatarView=nil) else nil; _DSbitmap bufferAvatarView; set bufferAvatarView=nil; _DMSreleaseZone this "AvatarView"; 0;; /*--------------*/ fun cbRecoverB(s)= _DSwindow winAvatarView; cbEndB nil; 0;; /*--------------*/ fun cbResizeB(x,b)= let x->[wn x y w h] in ( if winAvatarView_w==w && winAvatarView_h==h then nil else ( set winAvatarView_w = if w>256 then 256 else w; set winAvatarView_h = if h>256 then 256 else h; _SIZEwindow winAvatarView winAvatarView_w winAvatarView_h x y; _DSbitmap bufferAvatarView; set bufferAvatarView=_CRbitmap _channel winAvatarView_w+1 winAvatarView_h+1; let M3getCamera sessionAvatarView cameraAvatarView -> [[d _] [x _] z] in M3setCamera sessionAvatarView cameraAvatarView [[d*(winAvatarView_w>>1)/x d*(winAvatarView_w>>1)/x] [winAvatarView_w>>1 winAvatarView_h>>1] z]; 0));; /*--------------*/ /*change current mesh*/ fun changeAvatarViewMesh()= M3delObj sessionAvatarView avatarViewObj; M3freeMemory sessionAvatarView; M3load sessionAvatarView avfile shellAvatarView; M3recursFillMatObj sessionAvatarView shellAvatarView; set avatarViewObj = M3getObj sessionAvatarView "avatar"; applyface sessionAvatarView photo avatarViewObj flag; /*apply photo on avatar*/ 0;; /*--------------*/ fun cbOk(x,b)= let b -> [trans z] in let z -> [sessionAvInterfView _ _ _ bufferAvInterfView] in let _GETcheck trans -> f in (_DSbitmap bufferAvInterfView; M3destroy sessionAvInterfView; _DSwindow winInterface; set winInterface=nil; _DSbitmap bufPhoto; set flag=f; if currentAvListPos==-1 then set avfile=avDefaultFile else if currentAvListPos==-2 then nil else set avfile=nth_list defaultAvatarsList currentAvListPos; /*modif sd : pb cookie resolu*/ set avpos=currentAvListPos; updateAvatar;/*inform server*/ if winAvatarView!=nil then changeAvatarViewMesh else let _DMSgetZone this "AvatarView" @cbRecoverB @cbResizeB @cbEndB ->[wn x y w h] in if wn==nil then nil else ( set bufferAvatarView=_CRbitmap _channel w+1 h+1; set sessionAvatarView = M3create _channel 256 256 256 256 256*256; set shellAvatarView=M3createShell sessionAvatarView; M3load sessionAvatarView "Dms/Avatar/av3d/camviewer.m3d" shellAvatarView; M3load sessionAvatarView avfile shellAvatarView; M3recursFillMatObj sessionAvatarView shellAvatarView; set cameraAvatarView= M3getObj sessionAvatarView "camera"; set avatarViewObj=M3getObj sessionAvatarView "avatar"; set winAvatarView= _CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER "avatarView"; _CBwinDestroy winInterface @cbDestroyB nil; cbResizeB [nil x y w h] nil; applyface sessionAvatarView photo avatarViewObj flag; /*apply photo on avatar*/ _rfltimer _starttimer _channel 200 @cbClockAv3dView [anim_stop_begin+1]; cbClockAv3dView nil [anim_stop_begin]; 0 ) );; /*--------------*/ fun cbOpenFile (d,b,p)= let b -> [text winPhoto z] in let z -> [sessionAvInterfView _ av3dViewObj _ _] in ( if p==nil then nil else let _PtoScol p -> s in if s==nil then (_SETtext text _loc this "AV_WARNING" nil;0) else if (_fileSize p)>16384 then (_SETtext text _loc this "AV_WARNING2" nil;0) else let _LDbitmap _channel p -> imagebmp in let if imagebmp==nil then _LDjpeg _channel p else imagebmp -> image in if image==nil then (_SETtext text _loc this "AV_WARNING3" nil;0) else let _GETbitmapSize image -> [w h] in (set photo=s; applyface sessionAvInterfView photo av3dViewObj flag; /*apply new photo on avatar*/ _SCPbitmap bufPhoto 0 0 63 63 image 0 0 w-1 h-1 nil; _DSbitmap image; 0); cbPaintE2 winPhoto nil );; /*--------------*/ fun cbChoosebitmap(x,b)= let b -> [text _ _] in ( _SETtext text _loc this "AV_CHOOSE" nil; _DLGrflopen (_DLGOpenFile _channel winInterface nil nil "bitmap (*.bmp,*.jpg)\0*.BMP;*.JPG;*.JPEG\0\0") @cbOpenFile b; 0 ) ;; /*--------------*/ fun cbCheckTrans(a,z,newFlag)= let z -> [sessionAvInterfView _ av3dViewObj _ _] in applyface sessionAvInterfView photo av3dViewObj newFlag;; /*apply new trans state on avatar*/ /*--------------*/ fun cbClockInterfView(t,b)= let b -> [winAvatar key z] in let z -> [sessionAvInterfView _ av3dViewObj cameraAvatarView bufferAvInterfView] in if winInterface==nil then _deltimer t else ( M3rotateObj sessionAvInterfView av3dViewObj [0 0 300]; M3setAnimKey sessionAvInterfView av3dViewObj key; let if key newKey in mutate b <- [_ newKey _]; if meshDownloading then _CPWbitmap winAvatar 0 0 loadingBitmap 0 0 96 96 else (M3scanline sessionAvInterfView bufferAvInterfView cameraAvatarView 0 0 0; _CPWbitmap winAvatar 0 0 bufferAvInterfView 0 0 96 96); 0 );; /*--------------*/ fun cbNext(nextBT,b)= let b -> [trans previousBT z] in let z -> [sessionAvInterfView shellAv3dView av3dViewObj _ _] in let (sizelist defaultAvatarsList) -> size in let if ((currentAvListPos==-1)||(currentAvListPos==-2)) && size!=0 then 0 else if currentAvListPos newPos in let if newPos==-1 then avDefaultFile else nth_list defaultAvatarsList newPos -> avFileName in ( set currentAvListPos=newPos; _ENbutton previousBT 0; _ENbutton nextBT 0; set meshDownloading=1; downloadM3D avFileName "browser" [trans nextBT previousBT z]; 0 );; /*--------------*/ fun cbPrevious(previousBT,b)= let b -> [trans nextBT z] in let z -> [sessionAvInterfView shellAv3dView av3dViewObj _ _] in let (sizelist defaultAvatarsList) -> size in let if ((currentAvListPos==-1)||(currentAvListPos==-2)) && size!=0 then size-1 else if currentAvListPos>=1 then currentAvListPos-1 else -1 -> newPos in let if newPos==-1 then avDefaultFile else nth_list defaultAvatarsList newPos -> avFileName in ( set currentAvListPos=newPos; _ENbutton previousBT 0; _ENbutton nextBT 0; set meshDownloading=1; downloadM3D avFileName "browser" [trans previousBT nextBT z]; 0 );; /*--------------*/ fun showInterface()= if winInterface!=nil then nil else let _DMSgetZone this "Av3dInterface" nil nil nil ->[wn x y w h] in ( if wn!=nil then set winInterface=_CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER "av3d" else set winInterface=_CRwindow _channel DMSwin 200 100 400 168 WN_MENU+WN_MINBOX "av3d"; let _CRwindow _channel winInterface 32 42 64 64 WN_CHILDINSIDE|WN_NOCAPTION|WN_DOWN "" -> winPhoto in let _CRtext _channel winInterface 5 5 390 20 ET_BORDER _loc this "AV_CHOOSE" nil -> text in let _CRwindow _channel winInterface 166 32 96 96 WN_CHILDINSIDE|WN_NOCAPTION|WN_DOWN "" -> winAvatar in let _CRbutton _channel winInterface 146 143 65 20 0 _loc this "AV_PREV" nil -> previous in let _CRbutton _channel winInterface 216 143 65 20 0 _loc this "AV_NEXT" nil -> next in let _CRcheck _channel winInterface 25 113 100 20 0 _loc this "AV_TRANS" nil -> trans in let _CRbutton _channel winInterface 15 143 100 20 0 _loc this "AV_CHANGE" nil -> chg in let _CRbutton _channel winInterface 330 113 60 20 0 _loc this "AV_OK" nil -> ok in let _CRbutton _channel winInterface 330 143 60 20 0 _loc this "AV_CANCEL" nil -> cancel in let _CRbitmap _channel 96 96 -> bufferAvInterfView in let M3create _channel 256 256 256 256 256*256 -> sessionAvInterfView in let M3createShell sessionAvInterfView -> shellAv3dView in ( set photo=if photo!=nil then photo else "logo.bmp"; set avfile=if avfile!=nil then avfile else avDefaultFile; set currentAvListPos=avpos; M3load sessionAvInterfView "Dms/Avatar/av3d/camviewer.m3d" shellAv3dView; M3load sessionAvInterfView avDefaultFile shellAv3dView; /*to do : ne pas charger de suite, mais quand download mesh ok*/ M3recursFillMatObj sessionAvInterfView shellAv3dView; let M3getObj sessionAvInterfView "avatar" -> av3dViewObj in let M3getObj sessionAvInterfView "camera" -> cameraAvatarView in let sizelist defaultAvatarsList -> size in let [sessionAvInterfView shellAv3dView av3dViewObj cameraAvatarView bufferAvInterfView] -> z in ( _SETcheck trans flag; _CBcheck trans @cbCheckTrans z; _CBbutton chg @cbChoosebitmap [text winPhoto z]; _CBbutton cancel @cbCancel z; _CBbutton ok @cbOk [trans z]; if size>1 then (_CBbutton previous @cbPrevious [trans next z]; _CBbutton next @cbNext [trans previous z];0) else nil; _ENbutton next 0;/*hide next-previous button*/ _ENbutton previous 0; _CBwinDestroy winInterface @cbDestroyE z; _CBwinPaint winPhoto @cbPaintE2 nil; set bufPhoto = _CRbitmap _channel 64 64; _FILLbitmap bufPhoto 0; cbOpenFile nil [text winPhoto z] _checkpack photo; /*show photo on interface, apply photo on avatar*/ cbPaintE2 winPhoto nil; set meshDownloading = 1; downloadM3D avfile "browser" [trans next previous z]; _rfltimer _starttimer _channel 100 @cbClockInterfView [winAvatar anim_stop_begin+1 z]; cbClockInterfView nil [winAvatar anim_stop_begin z]; 0 ); ); );;