/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ /******************************************************************************* Plugin Picture Picture Player permettant de lire des media reconnus par Picture Client part Version: 4.0 Author: Bastien BOURINEAU Date: 21/01/2007 Last update: 02/04/2009 *******************************************************************************/ struct GalleryElem = [ GELEM_iPos : I, GELEM_sPath : S, GELEM_sParam : S, GELEM_abitmap : AlphaBitmap, GELEM_plane : SO3_OBJECT, GELEM_material : SO3_MATERIAL, GELEM_texture : SO3_TEXTURE, GELEM_vSize : [F F], GELEM_vPosition : [F F F], GELEM_bLoaded : I, GELEM_Request : ObjCURL ] MkGalleryElem;; struct PlugGallery = [ GALL_instance : PInstance, GALL_sGroupName : S, GALL_parent : SO3_OBJECT, GALL_shell : SO3_OBJECT, GALL_shellPos : SO3_OBJECT, GALL_lElem : [GalleryElem r1], GALL_lSearchElem : [[SO3_OBJECT GalleryElem] r1], GALL_eLastHover : GalleryElem, GALL_eSelected : GalleryElem, GALL_iLastInputId : I, GALL_iLastElemId : I, GALL_iLastElemPos : [F F], GALL_sPath : S, GALL_iNbPerPage : I, GALL_iNbPerRow : I, GALL_iNbPages : I, GALL_iCurrentPages : I, GALL_fElemSize : F, GALL_fPageSize : F, GALL_tMargin : [F F], GALL_fScale : F, GALL_vInitPosition : [F F F], GALL_vCurPosition : [[F F F] [F F F] F], GALL_vDestPosition : [[F F F] [F F F] F], GALL_tAngleTransition : [[[F F F] [F F F] F] r1], GALL_fTransitionSpeed : F, GALL_fTransitionAngle : F, GALL_fTransitionCoef : F, GALL_tLastCursorPos : [I I], GALL_fOrientationCoef : F, GALL_bShowOnlyCurrent : I, GALL_bShow : I, GALL_bMode : I ] MkPlugGallery;; var sTmpDownloadPath = "tmp/gallery/";; // 2t3 - 3t2 + 1 fun H1(coef)= (2.0 *. (pow coef 3.0)) -. (3.0 *. (pow coef 2.0)) +. 1.0;; // -2t3 + 3t2 fun H2(coef)= (-. 2.0 *. (pow coef 3.0)) +. (3.0 *. (pow coef 2.0));; // t3 - 2t2 +t fun H3(coef)= (pow coef 3.0) -. (2.0 *. (pow coef 2.0)) +. coef;; // t3 - t2 fun H4(coef)= (pow coef 3.0) -. (pow coef 2.0);; fun getInterpolateCurve(vec1, vec2, ang1, ang2, coef)= let vec1 -> [x1 y1 z1] in let vec2 -> [x2 y2 z2] in let ang1 -> [ax1 ay1 az1] in let ang2 -> [ax2 ay2 az2] in let ((H1 coef) *. x1) +. ((H2 coef) *. x2) +. ((H3 coef) *. ax1) +. ((H4 coef) *. ax2) -> x in let ((H1 coef) *. y1) +. ((H2 coef) *. y2) +. ((H3 coef) *. ay1) +. ((H4 coef) *. ay2) -> y in let ((H1 coef) *. z1) +. ((H2 coef) *. z2) +. ((H3 coef) *. az1) +. ((H4 coef) *. az2) -> z in [x y z] ;; fun getPosTime(pos)= let pos -> [[x y z] [t c b] ti] in ti;; fun getPosTension(pos)= let pos -> [[x y z] [t c b] ti] in t;; fun getPosContinuity(pos)= let pos -> [[x y z] [t c b] ti] in c;; fun getPosBias(pos)= let pos -> [[x y z] [t c b] ti] in b;; fun getPosX(pos)= let pos -> [[x y z] [t c b] ti] in x;; fun getPosY(pos)= let pos -> [[x y z] [t c b] ti] in y;; fun getPosZ(pos)= let pos -> [[x y z] [t c b] ti] in z;; fun getPosXYZ(pos)= let pos -> [[x y z] [t c b] ti] in [x y z];; fun getInterpolateTCB(lpos, t)= let sizelist lpos -> size in let size - 1 -> sizeminus in let 0 -> i in let nil -> outvec in ( while i < size && outvec == nil do ( let nth_list lpos i -> nextpos in if t <. (getPosTime nextpos) then ( let if i == 0 then nth_list lpos (sizeminus - 1) else nth_list lpos (i - 1) -> curpos in let if i == 0 then nth_list lpos (sizeminus - 2) else if i == 1 then nth_list lpos (sizeminus - 1) else nth_list lpos (i - 2) -> prevpos in let if i == sizeminus then nth_list lpos 0 else nth_list lpos (i + 1) -> nextnextpos in let ((t -. (getPosTime curpos)) /. ((getPosTime nextpos) -. (getPosTime curpos))) -> coef in //Update values from TCB let (1.0 -. (getPosTension curpos)) -> OneMinusTension in let (1.0 -. (getPosContinuity curpos)) -> OneMinusContinuity in let (1.0 +. (getPosContinuity curpos)) -> OnePlusContinuity in let (1.0 -. (getPosBias curpos)) -> OneMinusBias in let (1.0 +. (getPosBias curpos)) -> OnePlusBias in let 0.5 *. ((OneMinusTension *. OneMinusContinuity *. OneMinusBias *. ((getPosX nextpos) -. (getPosX curpos) )) +. (OneMinusTension *. OnePlusContinuity *. OnePlusBias *. ( (getPosX curpos) -. (getPosX prevpos) ))) -> tancurposx in let 0.5 *. ((OneMinusTension *. OneMinusContinuity *. OneMinusBias *. ((getPosY nextpos) -. (getPosY curpos) )) +. (OneMinusTension *. OnePlusContinuity *. OnePlusBias *. ( (getPosY curpos) -. (getPosY prevpos) ))) -> tancurposy in let 0.5 *. ((OneMinusTension *. OneMinusContinuity *. OneMinusBias *. ((getPosZ nextpos) -. (getPosZ curpos) )) +. (OneMinusTension *. OnePlusContinuity *. OnePlusBias *. ( (getPosZ curpos) -. (getPosZ prevpos) ))) -> tancurposz in let 0.5 *. ((OneMinusTension *. OnePlusContinuity *. OneMinusBias *. ((getPosX nextpos) -. (getPosX curpos) )) +. (OneMinusTension *. OneMinusContinuity *. OnePlusBias *. ( (getPosX nextnextpos) -. (getPosX nextpos) ))) -> tannextposx in let 0.5 *. ((OneMinusTension *. OnePlusContinuity *. OneMinusBias *. ((getPosY nextpos) -. (getPosY curpos) )) +. (OneMinusTension *. OneMinusContinuity *. OnePlusBias *. ( (getPosY nextnextpos) -. (getPosY nextpos) ))) -> tannextposy in let 0.5 *. ((OneMinusTension *. OnePlusContinuity *. OneMinusBias *. ((getPosZ nextpos) -. (getPosZ curpos) )) +. (OneMinusTension *. OneMinusContinuity *. OnePlusBias *. ( (getPosZ nextnextpos) -. (getPosZ nextpos) ))) -> tannextposz in let getInterpolateCurve (getPosXYZ curpos) (getPosXYZ nextpos) [tancurposx tancurposy tancurposz] [tannextposx tannextposy tannextposz] coef -> [x y z] in set outvec = [i [x y z]]; 0; ) else nil; set i = i + 1; ); outvec; );; fun getElemById(gallerystr, id)= if (id == nil) then nil else let nil -> elem in ( let sizelist gallerystr.GALL_lElem -> size in let 0 -> i in while ((i < size) && (elem == nil)) do ( let nth_list gallerystr.GALL_lElem i -> elt in if (elt.GELEM_iPos != id) then nil else set elem = elt; set i = i + 1; ); elem; );; fun hoverElem(obj, gallerystr)= let switch gallerystr.GALL_lSearchElem obj -> elemstr in if (elemstr == gallerystr.GALL_eLastHover) then nil else ( if (gallerystr.GALL_eLastHover == gallerystr.GALL_eSelected) then nil else ( //reposition the last element SO3ObjectSetPosition gallerystr.GALL_eLastHover.GELEM_plane gallerystr.GALL_eLastHover.GELEM_vPosition; SO3ObjectSetOrientation gallerystr.GALL_eLastHover.GELEM_plane SO3MathsEulerXYZToQuat [(SO3MathsDegreeToRadian (-.180.0)) (SO3MathsDegreeToRadian 90.0) 0.0]; SO3ObjectSetScale gallerystr.GALL_eLastHover.GELEM_plane [1.0 1.0 1.0]; ); //move the new if (elemstr == gallerystr.GALL_eSelected) then nil else ( SO3ObjectTranslate elemstr.GELEM_plane [0.0 0.0005 0.0] SO3_LOCAL_TS; SO3ObjectSetScale elemstr.GELEM_plane [1.2 1.2 1.2]; ); set gallerystr.GALL_eLastHover = elemstr; ); 0;; fun selectElem(obj, gallerystr)= let switch gallerystr.GALL_lSearchElem obj -> elemstr in if (gallerystr.GALL_eSelected == gallerystr.GALL_eLastHover) then nil else ( //previous element let gallerystr.GALL_eSelected -> oelemstr in let gallerystr.GALL_eLastHover -> lastelem in ( SO3ObjectSetPosition oelemstr.GELEM_plane oelemstr.GELEM_vPosition; //turn 90° on X SO3ObjectSetOrientation oelemstr.GELEM_plane SO3MathsEulerXYZToQuat [(SO3MathsDegreeToRadian (-.180.0)) (SO3MathsDegreeToRadian 90.0) 0.0]; SO3ObjectSetScale oelemstr.GELEM_plane [1.0 1.0 1.0]; SO3ObjectTranslate gallerystr.GALL_eLastHover.GELEM_plane [0.0 0.0002 0.0] SO3_LOCAL_TS; set gallerystr.GALL_eSelected = gallerystr.GALL_eLastHover; SendPluginEvent gallerystr.GALL_instance "Selected" (itoa elemstr.GELEM_iPos) nil; if (lastelem == nil) then SendPluginEvent gallerystr.GALL_instance "Unfocused" nil nil else if (oelemstr == nil) then SendPluginEvent gallerystr.GALL_instance "Focused" nil nil else nil; ); ); 0;; fun hideOtherPages(gallerystr)= let (gallerystr.GALL_iCurrentPages * gallerystr.GALL_iNbPerPage)-> pos in let sizelist gallerystr.GALL_lElem -> size in let 0 -> i in while (i < size) do ( let nth_list gallerystr.GALL_lElem i -> elemstr in let if i < pos || i >= pos + gallerystr.GALL_iNbPerPage then 0 else 1 -> state in SO3ObjectSetVisible elemstr.GELEM_plane state 1; set i = i + 1; ); 0;; fun showAllElems(gallerystr)= let sizelist gallerystr.GALL_lElem -> size in let 0 -> i in while (i < size) do ( let nth_list gallerystr.GALL_lElem i -> elemstr in SO3ObjectSetVisible elemstr.GELEM_plane 1 1; set i = i + 1; ); 0;; fun cbControlPreRender(inst, sessionstr, etime, gallerystr)= let gallerystr.GALL_vCurPosition -> [cvec _ _] in let gallerystr.GALL_vDestPosition -> [dvec _ _] in let if etime > 100000 then 1000 else etime -> etime in let maxf 0.001 ((itof etime) *. 0.001) -> ftime in if ((!gallerystr.GALL_bShow) || (vectorEqual cvec dvec)) then nil else ( if (gallerystr.GALL_fTransitionCoef >. 1.0) then ( mutate gallerystr.GALL_vCurPosition <- [dvec _ _]; SO3ObjectSetPosition gallerystr.GALL_shellPos dvec; SO3ObjectSetOrientation gallerystr.GALL_shell [0.0 0.0 0.0 1.0]; set gallerystr.GALL_fOrientationCoef = 0.0; //hide other pages if (!gallerystr.GALL_bShowOnlyCurrent) then nil else hideOtherPages gallerystr; 0; ) else ( set gallerystr.GALL_fTransitionCoef = if (gallerystr.GALL_fTransitionCoef >. 1.0) then 1.0 else gallerystr.GALL_fTransitionCoef +. ((gallerystr.GALL_fTransitionSpeed *. 0.001) *. ftime); set gallerystr.GALL_fOrientationCoef = if (gallerystr.GALL_fOrientationCoef >. 1.0) then 1.0 else gallerystr.GALL_fOrientationCoef +. ((gallerystr.GALL_fTransitionSpeed *. 0.001) *. ftime); let getInterpolateTCB gallerystr.GALL_vCurPosition::gallerystr.GALL_vDestPosition::nil gallerystr.GALL_fTransitionCoef -> [_ tvec] in let getInterpolateTCB gallerystr.GALL_tAngleTransition gallerystr.GALL_fTransitionCoef -> [_ tang] in ( SO3ObjectSetPosition gallerystr.GALL_shellPos tvec; SO3ObjectSetOrientation gallerystr.GALL_shell SO3MathsEulerXYZToQuat tang; 0; ); ); ); 0;; fun cbInputClick(inst, viewstr, id, x, y, btn, pdata, gallerystr)= if ((gallerystr.GALL_iLastInputId != nil) && (id != gallerystr.GALL_iLastInputId)) then nil else let pdata -> [obj mat _ _ _ _] in ( hoverElem obj gallerystr; selectElem obj gallerystr; if (gallerystr.GALL_eLastHover == nil) then nil else set gallerystr.GALL_iLastInputId = id; ); 0;; fun cbInputUnClick(inst, viewstr, id, x, y, btn, pdata, gallerystr)= if (id != gallerystr.GALL_iLastInputId) then nil else set gallerystr.GALL_iLastInputId = nil; 0;; fun cbInputUpdate(inst, viewstr, id, x, y, btn, pdata, gallerystr)= if ((gallerystr.GALL_iLastInputId != nil) && (id != gallerystr.GALL_iLastInputId)) then nil else ( let pdata -> [obj mat _ _ _ _] in hoverElem obj gallerystr; if (gallerystr.GALL_eLastHover == nil) then nil else set gallerystr.GALL_iLastInputId = id; if (btn != 1) then nil else let gallerystr.GALL_eSelected -> elemstr in ( if gallerystr.GALL_tLastCursorPos == nil then nil else let gallerystr.GALL_tLastCursorPos -> [px py] in let [(x - px) (y - py)] -> [mx my] in let V3DgetDefaultCamera c3dXsession -> camera in let SO3CameraGetNearClipDistance camera -> coff in let SO3CameraGetFOVy camera -> fovy in let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in let (((tan ((SO3MathsDegreeToRadian 57.29) /. 2.0)) *. 0.05) *. 2.0) +. coff -> unitsize in let ((unitsize *. (itof vw) /. (itof vh)) *. (itof mx)) /. (itof vw) -> vx in let (unitsize *. (itof my)) /. (itof vh) -> vy in ( SO3ObjectTranslate elemstr.GELEM_plane [vx (-.vy) 0.0] SO3_PARENT_TS; 0; ); ); set gallerystr.GALL_tLastCursorPos = [x y]; ); 0;; fun cbCursorWheel(inst, viewstr, x, y, delta, btn, gallerystr)= if (gallerystr.GALL_eSelected == nil) then nil else let gallerystr.GALL_eSelected -> elemstr in let SO3ObjectGetScale elemstr.GELEM_plane -> [sx sy sz] in let 0.3 *. (itof delta) -> ns in ( if ((sx +. ns) <=. 1.2) then SO3ObjectSetScale elemstr.GELEM_plane [1.2 1.2 1.2] else SO3ObjectSetScale elemstr.GELEM_plane [(sx +. ns) (sy +. ns) (sz +. ns)]; ); 0;; fun cbShow(inst, from, action, param, reply, gallerystr)= if (!gallerystr.GALL_bMode) || (gallerystr.GALL_parent == nil) then ( //V3DenableNavigate c3dXsession 0; let V3DgetDefaultCamera c3dXsession -> camera in let SO3CameraGetFOVy camera -> fovy in let SO3CameraGetNearClipDistance camera -> coff in ( SO3ObjectLink gallerystr.GALL_shell camera; SO3ObjectSetGlobalScale gallerystr.GALL_shell [1.0 1.0 1.0]; SO3ObjectSetPosition gallerystr.GALL_shell [0.0 0.0 (((SO3MathsDegreeToRadian 57.29) *. (-.0.05)) /. fovy) -. coff]; ); 0; ) else ( SO3ObjectLink gallerystr.GALL_shell gallerystr.GALL_parent; SO3ObjectSetGlobalScale gallerystr.GALL_shell [(gallerystr.GALL_fScale *. 50.0) (gallerystr.GALL_fScale *. 50.0) (gallerystr.GALL_fScale *. 50.0)]; SO3ObjectSetPosition gallerystr.GALL_shell [0.0 0.0 0.0]; 0; ); set gallerystr.GALL_bShow = 1; SO3ObjectSetVisible gallerystr.GALL_shell gallerystr.GALL_bShow 1; if (!gallerystr.GALL_bShowOnlyCurrent) then nil else hideOtherPages gallerystr; setPluginInstanceCbInputClick inst mkfun8 @cbInputClick gallerystr; setPluginInstanceCbInputUnClick inst mkfun8 @cbInputUnClick gallerystr; setPluginInstanceCbInputUpdate inst mkfun8 @cbInputUpdate gallerystr; setPluginInstanceCbWheel inst mkfun7 @cbCursorWheel gallerystr; 0;; fun cbHide(inst, from, action, param, reply, gallerystr)= set gallerystr.GALL_bShow = 0; SO3ObjectSetVisible gallerystr.GALL_shell gallerystr.GALL_bShow 1; setPluginInstanceCbInputClick inst nil; setPluginInstanceCbInputUnClick inst nil; setPluginInstanceCbInputUpdate inst nil; setPluginInstanceCbWheel inst nil; //V3DenableNavigate c3dXsession 1; 0;; fun loadElemData(gallerystr, elemstr, path)= if elemstr.GELEM_bLoaded then nil else let G2DloadAlphaBmp _channel path -> abmp in let strcatn (getPluginInstanceName gallerystr.GALL_instance)::"."::(itoa elemstr.GELEM_iPos)::nil -> name in if (abmp == nil) then nil else ( let _GETalphaBitmapSize abmp -> [bw bh] in let if bh > bw then ((itof bh) /. (itof bw)) else ((itof bw) /. (itof bh)) -> ratio in let if bh > bw then gallerystr.GALL_fElemSize /. ratio else gallerystr.GALL_fElemSize -> fw in let if bh > bw then gallerystr.GALL_fElemSize else gallerystr.GALL_fElemSize /. ratio -> fh in let [fw fh] -> psize in let SO3MaterialCreate (V3DgetSession c3dXsession) (strcat name ".material") gallerystr.GALL_sGroupName -> mat in let SO3TextureCreate (V3DgetSession c3dXsession) (strcat name ".texture") nil gallerystr.GALL_sGroupName bw bh -> tex in let SO3PlaneCreate (V3DgetSession c3dXsession) gallerystr.GALL_sGroupName name psize nil nil -> plane in ( set elemstr.GELEM_plane = plane; set elemstr.GELEM_material = mat; set elemstr.GELEM_texture = tex; SO3MaterialIsLighting mat 0; SO3MaterialSetTexture mat tex 0 0 0; SO3EntitySetMaterial plane mat 0; SO3TextureBlitAlpha tex abmp; SO3ObjectLink plane gallerystr.GALL_shellPos; SO3ObjectSetPosition plane elemstr.GELEM_vPosition; //turn 90° on X SO3ObjectSetOrientation plane SO3MathsEulerXYZToQuat [(SO3MathsDegreeToRadian (-.180.0)) (SO3MathsDegreeToRadian 90.0) 0.0]; set gallerystr.GALL_lSearchElem = [plane elemstr]::gallerystr.GALL_lSearchElem; //TODO verify the visible status for the current page let (gallerystr.GALL_iCurrentPages * gallerystr.GALL_iNbPerPage)-> pos in let if (!gallerystr.GALL_bShowOnlyCurrent && gallerystr.GALL_bShow) then 1 else if (!gallerystr.GALL_bShow) || (elemstr.GELEM_iPos < pos || elemstr.GELEM_iPos >= pos + gallerystr.GALL_iNbPerPage) then 0 else 1 -> visible in SO3ObjectSetVisible elemstr.GELEM_plane visible 1; ); _DSalphaBitmap abmp; set elemstr.GELEM_bLoaded = 1; ); 0;; fun cbDownloaded(file, data, p)= if data == nil then nil else let p -> [gallerystr elemstr] in let strcatn sTmpDownloadPath::(getPluginInstanceName gallerystr.GALL_instance)::(itoa elemstr.GELEM_iPos)::".tmp"::nil -> tmpfile in ( set elemstr.GELEM_Request = nil; _storepack data tmpfile; loadElemData gallerystr elemstr tmpfile; _deletepack _checkpack tmpfile; ); 0;; fun loadElem(gallerystr, elemstr)= if (elemstr.GELEM_bLoaded) then nil else ( if (strIsUrl elemstr.GELEM_sPath) then ( set elemstr.GELEM_Request = downloadFile elemstr.GELEM_sPath mkfun3 @cbDownloaded [gallerystr elemstr]; 0; ) else ( loadElemData gallerystr elemstr elemstr.GELEM_sPath; 0; ); ); 0;; fun showPage(gallerystr, page, idx)= let (page * gallerystr.GALL_iNbPerPage) + idx -> pos in let nth_list gallerystr.GALL_lElem pos -> elemstr in if ((elemstr == nil) || (idx >= gallerystr.GALL_iNbPerPage)) then ( SendPluginEvent gallerystr.GALL_instance "Page loaded" (itoa page) nil; 0; ) else ( loadElem gallerystr elemstr; showPage gallerystr page (idx + 1); 0; ); 0;; fun cbRestoreSelected(inst, from, action, param, reply, gallerystr)= if (gallerystr.GALL_eSelected == nil) then nil else let gallerystr.GALL_eSelected -> elemstr in ( SO3ObjectSetPosition elemstr.GELEM_plane elemstr.GELEM_vPosition; //turn 90° on X SO3ObjectSetOrientation elemstr.GELEM_plane SO3MathsEulerXYZToQuat [(SO3MathsDegreeToRadian (-.180.0)) (SO3MathsDegreeToRadian 90.0) 0.0]; SO3ObjectSetScale elemstr.GELEM_plane [1.0 1.0 1.0]; set gallerystr.GALL_eSelected = nil; set gallerystr.GALL_eLastHover = nil; SendPluginEvent gallerystr.GALL_instance "Unfocused" nil nil ); 0;; fun cbClear(inst, from, action, param, reply, gallerystr)= let sizelist gallerystr.GALL_lElem -> size in let 0 -> i in while (i < size) do ( let nth_list gallerystr.GALL_lElem i -> elemstr in ( SO3ObjectDestroy elemstr.GELEM_plane; SO3MaterialDestroy elemstr.GELEM_material; SO3TextureDestroy elemstr.GELEM_texture; ); set i = i + 1; ); set gallerystr.GALL_iLastElemId = 0; let gallerystr.GALL_tMargin -> [xmargin ymargin] in set gallerystr.GALL_iLastElemPos = [(xmargin /. 2.0) (ymargin /. 2.0)]; set gallerystr.GALL_iCurrentPages = 0; set gallerystr.GALL_lElem = nil; set gallerystr.GALL_lSearchElem = nil; set gallerystr.GALL_eLastHover = nil; set gallerystr.GALL_eSelected = nil; 0;; fun cbGotoPage(inst, from, action, param, reply, gallerystr)= let atoi param -> npage in if (npage > gallerystr.GALL_iNbPages) || (npage == nil) || (!gallerystr.GALL_bShow) then nil else ( set gallerystr.GALL_iCurrentPages = if (npage <= 1) then 0 else npage - 1; showPage gallerystr gallerystr.GALL_iCurrentPages 0; let gallerystr.GALL_vInitPosition -> [px py pz] in let px -. (gallerystr.GALL_fPageSize *. (itof gallerystr.GALL_iCurrentPages)) -> npx in let [npx py pz] -> dvec in ( mutate gallerystr.GALL_vDestPosition <- [dvec _ 1.0]; if (gallerystr.GALL_fTransitionSpeed == 0.0) then ( mutate gallerystr.GALL_vCurPosition <- [dvec _ _]; SO3ObjectSetPosition gallerystr.GALL_shellPos dvec; SO3ObjectSetOrientation gallerystr.GALL_shell [0.0 0.0 0.0 1.0]; set gallerystr.GALL_fOrientationCoef = 0.0; cbRestoreSelected inst from action param reply gallerystr; //hide other pages if (!gallerystr.GALL_bShowOnlyCurrent) then nil else hideOtherPages gallerystr; 0; ) else ( mutate gallerystr.GALL_vCurPosition <- [(SO3ObjectGetPosition gallerystr.GALL_shellPos) _ 0.0]; set gallerystr.GALL_tAngleTransition = [SO3MathsQuatToEulerXYZ (SO3ObjectGetOrientation gallerystr.GALL_shell) [0.8 0.5 0.8] 0.0]::[[(SO3MathsDegreeToRadian gallerystr.GALL_fTransitionAngle) 0.0 0.0] [0.8 0.5 0.8] 0.5]::[[0.0 0.0 0.0] [0.8 0.5 0.8] 1.0]::nil; set gallerystr.GALL_fTransitionCoef = 0.0; cbRestoreSelected inst from action param reply gallerystr; if (!gallerystr.GALL_bShowOnlyCurrent) then nil else showAllElems gallerystr; 0; ); ); ); 0;; fun cbNextPage(inst, from, action, param, reply, gallerystr)= let (sizelist gallerystr.GALL_lElem) / gallerystr.GALL_iNbPerPage + if (mod (sizelist gallerystr.GALL_lElem) gallerystr.GALL_iNbPerPage) > 0 then 1 else 0 -> nbpages in if ((gallerystr.GALL_iCurrentPages + 1) >= nbpages) || (!gallerystr.GALL_bShow) then nil else ( set gallerystr.GALL_iCurrentPages = gallerystr.GALL_iCurrentPages + 1; showPage gallerystr gallerystr.GALL_iCurrentPages 0; let gallerystr.GALL_vInitPosition -> [px py pz] in let px -. (gallerystr.GALL_fPageSize *. (itof gallerystr.GALL_iCurrentPages)) -> npx in let [npx py pz] -> dvec in ( mutate gallerystr.GALL_vDestPosition <- [dvec _ 1.0]; if (gallerystr.GALL_fTransitionSpeed == 0.0) then ( mutate gallerystr.GALL_vCurPosition <- [dvec _ _]; SO3ObjectSetPosition gallerystr.GALL_shellPos dvec; SO3ObjectSetOrientation gallerystr.GALL_shell [0.0 0.0 0.0 1.0]; set gallerystr.GALL_fOrientationCoef = 0.0; cbRestoreSelected inst from action param reply gallerystr; //hide other pages if (!gallerystr.GALL_bShowOnlyCurrent) then nil else hideOtherPages gallerystr; 0; ) else ( mutate gallerystr.GALL_vCurPosition <- [(SO3ObjectGetPosition gallerystr.GALL_shellPos) _ 0.0]; set gallerystr.GALL_tAngleTransition = [SO3MathsQuatToEulerXYZ (SO3ObjectGetOrientation gallerystr.GALL_shell) [0.8 0.5 0.8] 0.0]::[[(SO3MathsDegreeToRadian gallerystr.GALL_fTransitionAngle) 0.0 0.0] [0.8 0.5 0.8] 0.5]::[[0.0 0.0 0.0] [0.8 0.5 0.8] 1.0]::nil; set gallerystr.GALL_fTransitionCoef = 0.0; cbRestoreSelected inst from action param reply gallerystr; if (!gallerystr.GALL_bShowOnlyCurrent) then nil else showAllElems gallerystr; 0; ); ); SendPluginEvent inst "Current page" (itoa gallerystr.GALL_iCurrentPages) nil; ); 0;; fun cbPrevPage(inst, from, action, param, reply, gallerystr)= if ((gallerystr.GALL_iCurrentPages - 1) < 0) || (!gallerystr.GALL_bShow) then nil else ( set gallerystr.GALL_iCurrentPages = gallerystr.GALL_iCurrentPages - 1; showPage gallerystr gallerystr.GALL_iCurrentPages 0; let gallerystr.GALL_vInitPosition -> [px py pz] in let px -. (gallerystr.GALL_fPageSize *. (itof gallerystr.GALL_iCurrentPages)) -> npx in let [npx py pz] -> dvec in ( mutate gallerystr.GALL_vDestPosition <- [dvec _ 1.0]; if (gallerystr.GALL_fTransitionSpeed == 0.0) then ( mutate gallerystr.GALL_vCurPosition <- [dvec _ _]; SO3ObjectSetPosition gallerystr.GALL_shellPos dvec; SO3ObjectSetOrientation gallerystr.GALL_shell [0.0 0.0 0.0 1.0]; set gallerystr.GALL_fOrientationCoef = 0.0; cbRestoreSelected inst from action param reply gallerystr; //hide other pages if (!gallerystr.GALL_bShowOnlyCurrent) then nil else hideOtherPages gallerystr; 0; ) else ( mutate gallerystr.GALL_vCurPosition <- [(SO3ObjectGetPosition gallerystr.GALL_shellPos) _ 0.0]; set gallerystr.GALL_tAngleTransition = [SO3MathsQuatToEulerXYZ (SO3ObjectGetOrientation gallerystr.GALL_shell) [0.8 0.5 0.8] 0.0]::[[(SO3MathsDegreeToRadian (-.gallerystr.GALL_fTransitionAngle)) 0.0 0.0] [0.8 0.5 0.8] 0.5]::[[0.0 0.0 0.0] [0.8 0.5 0.8] 1.0]::nil; set gallerystr.GALL_fTransitionCoef = 0.0; cbRestoreSelected inst from action param reply gallerystr; if (!gallerystr.GALL_bShowOnlyCurrent) then nil else showAllElems gallerystr; 0; ); ); SendPluginEvent inst "Current page" (itoa gallerystr.GALL_iCurrentPages) nil; ); 0;; fun cbMoveSelected(inst, from, action, param, reply, gallerystr)= if (param == nil) || (gallerystr.GALL_eSelected == nil) || (!gallerystr.GALL_bShow) then nil else let strextr param -> lp in let atof hd (hd lp) -> px in let atof hd tl (hd lp) -> py in let gallerystr.GALL_eSelected -> elemstr in let V3DgetDefaultCamera c3dXsession -> camera in let SO3CameraGetNearClipDistance camera -> coff in let SO3CameraGetFOVy camera -> fovy in let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in let (((tan ((SO3MathsDegreeToRadian 57.29) /. 2.0)) *. 0.05) *. 2.0) +. coff -> unitsize in let (((unitsize *. (itof vw)) /. (itof vh)) *. px) /. (itof vw) *. 2.0 -> px in let (unitsize *. py) /. (itof vh) -> py in ( SO3ObjectTranslate elemstr.GELEM_plane [(-.px) py 0.0] SO3_PARENT_TS; 0; ); 0;; fun cbCenterSelected(inst, from, action, param, reply, gallerystr)= if (gallerystr.GALL_eSelected == nil) || (!gallerystr.GALL_bShow) then nil else ( let gallerystr.GALL_tMargin -> [xmargin ymargin] in let ((itof gallerystr.GALL_iNbPerPage) /. (itof gallerystr.GALL_iNbPerRow)) -> nbRow in let gallerystr.GALL_fPageSize *. (itof (gallerystr.GALL_iCurrentPages)) +. (gallerystr.GALL_fPageSize /. 2.0) -. (gallerystr.GALL_fElemSize /. 2.0) +. (xmargin /. 4.0) -> xpos in let -.((gallerystr.GALL_fElemSize *. nbRow) /. 2.0) +. (gallerystr.GALL_fElemSize /. 2.0) -> ypos in SO3ObjectSetPosition gallerystr.GALL_eSelected.GELEM_plane [xpos ypos 0.0001]; SO3ObjectSetScale gallerystr.GALL_eSelected.GELEM_plane [(itof gallerystr.GALL_iNbPerRow) (itof gallerystr.GALL_iNbPerRow) (itof gallerystr.GALL_iNbPerRow)]; 0; ); 0;; fun cbScaleSelected(inst, from, action, param, reply, gallerystr)= if (param == nil) || (gallerystr.GALL_eSelected == nil) || (!gallerystr.GALL_bShow) then nil else let strextr param -> lp in let atof hd (hd lp) -> ps in let gallerystr.GALL_eSelected -> elemstr in let SO3ObjectGetScale elemstr.GELEM_plane -> [sx sy sz] in ( if ((sx +. ps) <=. 1.2) then SO3ObjectSetScale elemstr.GELEM_plane [1.2 1.2 1.2] else SO3ObjectSetScale elemstr.GELEM_plane [(sx +. ps) (sy +. ps) (sz +. ps)]; ); 0;; fun cbRotateSelected(inst, from, action, param, reply, gallerystr)= if (param == nil) || (gallerystr.GALL_eSelected == nil) || (!gallerystr.GALL_bShow) then nil else let strextr param -> lp in let atof hd (hd lp) -> px in let atof hd tl (hd lp) -> py in let atof hd tl tl (hd lp) -> pz in let gallerystr.GALL_eSelected -> elemstr in let SO3MathsEulerZXYToQuat [(SO3MathsDegreeToRadian px) (SO3MathsDegreeToRadian py) (SO3MathsDegreeToRadian pz)] -> rquat in let SO3ObjectGetOrientation elemstr.GELEM_plane -> iquat in ( SO3ObjectSetOrientation elemstr.GELEM_plane SO3MathsQuatAdd iquat rquat; ); 0;; fun cbSelect(inst, from, action, param, reply, gallerystr)= let gallerystr.GALL_eSelected -> elemstr in ( SO3ObjectSetPosition elemstr.GELEM_plane elemstr.GELEM_vPosition; //turn 90° on X SO3ObjectSetOrientation elemstr.GELEM_plane SO3MathsEulerXYZToQuat [(SO3MathsDegreeToRadian (-.180.0)) (SO3MathsDegreeToRadian 90.0) 0.0]; SO3ObjectSetScale elemstr.GELEM_plane [1.0 1.0 1.0]; ); set gallerystr.GALL_eSelected = gallerystr.GALL_eLastHover; 0;; fun loadGallery(gallerystr, files, elemid, pos, param)= if (files == nil) then nil else let pos -> [xpos ypos] in let files -> [file next] in let gallerystr.GALL_tMargin -> [xmargin ymargin] in ( if ((_checkpack file) == nil) && (!strIsUrl file) then nil else ( let MkGalleryElem [elemid file param nil nil nil nil nil [xpos ypos 0.0] 0 nil] -> gelemstr in ( if ((mod (elemid - (gallerystr.GALL_iNbPages * gallerystr.GALL_iNbPerPage) + 1) gallerystr.GALL_iNbPerPage) != 0) then ( if ((mod (elemid - (gallerystr.GALL_iNbPages * gallerystr.GALL_iNbPerPage) + 1) gallerystr.GALL_iNbPerRow) != 0) then ( set xpos = xpos +. gallerystr.GALL_fElemSize +. (xmargin /. 2.0); ) else ( set xpos = ((itof gallerystr.GALL_iNbPages) *. gallerystr.GALL_fPageSize) +. (xmargin /. 2.0); set ypos = (ypos -. (gallerystr.GALL_fElemSize +. ymargin)); ); ) else ( set gallerystr.GALL_iNbPages = gallerystr.GALL_iNbPages + 1; set xpos = ((itof gallerystr.GALL_iNbPages) *. gallerystr.GALL_fPageSize) +. (xmargin /. 2.0); set ypos = (ymargin /. 2.0); ); set gallerystr.GALL_lElem = lcat gallerystr.GALL_lElem gelemstr::nil; set elemid = elemid + 1; ); ); set gallerystr.GALL_iLastElemPos = [xpos ypos]; set gallerystr.GALL_iLastElemId = elemid; loadGallery gallerystr next gallerystr.GALL_iLastElemId gallerystr.GALL_iLastElemPos param; ); 0;; fun cbAddPicture(inst, from, action, param, reply, gallerystr)= if (param == nil) then nil else let strextr param -> lp in let nth_list lp 0 -> lp in let hd lp -> path in let strcatnSep tl lp " " -> p in let if (strIsUrl path) || ((getFileExt path) != nil) then path::nil else getFilesFromDir path "jpg"::"bmp"::"png"::"tga"::nil -> files in let if (gallerystr.GALL_iCurrentPages != gallerystr.GALL_iNbPages) then 0 else 1 -> reload in ( loadGallery gallerystr files gallerystr.GALL_iLastElemId gallerystr.GALL_iLastElemPos p; if (!reload) then nil else showPage gallerystr gallerystr.GALL_iCurrentPages 0; ); 0;; fun cbSwitch3dMode(inst, from, action, param, reply, gallerystr)= set gallerystr.GALL_bMode = !gallerystr.GALL_bMode; if (!gallerystr.GALL_bShow) then nil else cbShow inst from action param reply gallerystr; 0;; fun cbGetParam(inst, from, action, param, reply, gallerystr)= if (param == nil) then nil else let getElemById gallerystr (atoi param) -> elemstr in SendPluginEvent gallerystr.GALL_instance "Picture param" elemstr.GELEM_sParam nil; 0;; fun cbSetParam(inst, from, action, param, reply, gallerystr)= let strextr param -> lp in let nth_list lp 0 -> lp in let atoi hd lp -> id in let strcatnSep tl lp " " -> p in let getElemById gallerystr id -> elemstr in set elemstr.GELEM_sParam = p; 0;; fun cbGetTotalPages(inst, from, action, param, reply, gallerystr)= SendPluginEvent gallerystr.GALL_instance "Total pages" (itoa gallerystr.GALL_iNbPages) nil; 0;; fun cbGetCurrentPage(inst, from, action, param, reply, gallerystr)= SendPluginEvent gallerystr.GALL_instance "Current page" (itoa gallerystr.GALL_iCurrentPages) nil; 0;; fun cbSelectNext(inst, from, action, param, reply, gallerystr)= let (gallerystr.GALL_iCurrentPages * gallerystr.GALL_iNbPerPage) -> startpos in let if (gallerystr.GALL_eLastHover == nil) then startpos else gallerystr.GALL_eLastHover.GELEM_iPos + 1 -> elempos in //let if elempos >= (startpos + gallerystr.GALL_iNbPerPage) then (startpos + gallerystr.GALL_iNbPerPage) - 1 else if elempos < startpos then startpos else elempos -> elempos in let nth_list gallerystr.GALL_lElem elempos -> elemstr in if (elemstr == nil) then nil else ( if (elempos < (startpos + gallerystr.GALL_iNbPerPage)) then nil else cbNextPage inst from action param reply gallerystr; hoverElem elemstr.GELEM_plane gallerystr; selectElem elemstr.GELEM_plane gallerystr; ); 0;; fun cbSelectPrev(inst, from, action, param, reply, gallerystr)= let (gallerystr.GALL_iCurrentPages * gallerystr.GALL_iNbPerPage) -> startpos in let if (gallerystr.GALL_eLastHover == nil) then startpos else gallerystr.GALL_eLastHover.GELEM_iPos - 1 -> elempos in //let if elempos >= (startpos + gallerystr.GALL_iNbPerPage) then (startpos + gallerystr.GALL_iNbPerPage) - 1 else if elempos < startpos then startpos else elempos -> elempos in let nth_list gallerystr.GALL_lElem elempos -> elemstr in if (elemstr == nil) then nil else ( if (elempos >= startpos) then nil else cbPrevPage inst from action param reply gallerystr; hoverElem elemstr.GELEM_plane gallerystr; selectElem elemstr.GELEM_plane gallerystr; ); 0;; fun cbSelectUp(inst, from, action, param, reply, gallerystr)= let (gallerystr.GALL_iCurrentPages * gallerystr.GALL_iNbPerPage) -> startpos in let if (gallerystr.GALL_eLastHover == nil) then startpos else gallerystr.GALL_eLastHover.GELEM_iPos - gallerystr.GALL_iNbPerRow -> elempos in let if elempos >= (startpos + gallerystr.GALL_iNbPerPage) then nil else if elempos < startpos then nil else elempos -> elempos in let nth_list gallerystr.GALL_lElem elempos -> elemstr in if (elemstr == nil) then nil else ( hoverElem elemstr.GELEM_plane gallerystr; selectElem elemstr.GELEM_plane gallerystr; ); 0;; fun cbSelectDown(inst, from, action, param, reply, gallerystr)= let (gallerystr.GALL_iCurrentPages * gallerystr.GALL_iNbPerPage) -> startpos in let if (gallerystr.GALL_eLastHover == nil) then startpos else gallerystr.GALL_eLastHover.GELEM_iPos + gallerystr.GALL_iNbPerRow -> elempos in let if elempos >= (startpos + gallerystr.GALL_iNbPerPage) then nil else if elempos < startpos then nil else elempos -> elempos in let nth_list gallerystr.GALL_lElem elempos -> elemstr in if (elemstr == nil) then nil else ( hoverElem elemstr.GELEM_plane gallerystr; selectElem elemstr.GELEM_plane gallerystr; ); 0;; fun cbSelectFirst(inst, from, action, param, reply, gallerystr)= let (gallerystr.GALL_iCurrentPages * gallerystr.GALL_iNbPerPage) -> startpos in let nth_list gallerystr.GALL_lElem startpos -> elemstr in ( hoverElem elemstr.GELEM_plane gallerystr; selectElem elemstr.GELEM_plane gallerystr; ); 0;; // Destroy instance fun deleteOb(inst, gallerystr)= setPluginInstanceCbScenePreRender inst nil; let sizelist gallerystr.GALL_lElem -> size in let 0 -> i in while (i < size) do ( let nth_list gallerystr.GALL_lElem i -> elemstr in ( killHttpRequest elemstr.GELEM_Request; SO3ObjectDestroy elemstr.GELEM_plane; SO3MaterialDestroy elemstr.GELEM_material; SO3TextureDestroy elemstr.GELEM_texture; ); set i = i + 1; ); SO3ObjectDestroy gallerystr.GALL_shellPos; SO3ObjectDestroy gallerystr.GALL_shell; set gallerystr.GALL_shell = nil; set gallerystr.GALL_shellPos = nil; SO3GroupDelete (V3DgetSession c3dXsession) gallerystr.GALL_sGroupName; set gallerystr.GALL_lElem = nil; set gallerystr.GALL_lSearchElem = nil; set gallerystr.GALL_eLastHover = nil; set gallerystr.GALL_eSelected = nil; //V3DenableNavigate c3dXsession 1; 0;; fun cbChangeCamera(inst, viewstr, sessionstr, camera, gallerystr)= if ((gallerystr.GALL_bMode) && (gallerystr.GALL_parent != nil)) then nil else let SO3CameraGetFOVy camera -> fovy in let SO3CameraGetNearClipDistance camera -> coff in ( SO3ObjectLink gallerystr.GALL_shell camera; SO3ObjectSetPosition gallerystr.GALL_shell [0.0 0.0 (((SO3MathsDegreeToRadian 57.29) *. (-.0.05)) /. fovy) -. coff]; ); 0;; fun cbNewOb(inst)= let (getPluginInstanceParam inst "path") -> path in let (getPluginInstanceParam inst "parent") -> objname in let atoi (getPluginInstanceParam inst "show") -> show in let if (show == nil) then 1 else show -> show in let atof (getPluginInstanceParam inst "scale") -> scale in let if (scale == nil) then 1.0 else scale -> scale in let atof (getPluginInstanceParam inst "margin") -> margin in let if (margin == nil) then 2.0 else margin -> margin in let atof (getPluginInstanceParam inst "marginx") -> marginx in let if (marginx == nil) then margin else marginx -> marginx in let atof (getPluginInstanceParam inst "marginy") -> marginy in let if (marginy == nil) then margin else marginy -> marginy in let atoi (getPluginInstanceParam inst "nbperrow") -> nbperrow in let if (nbperrow == nil) then 3 else nbperrow -> nbperrow in let atoi (getPluginInstanceParam inst "nbperpage") -> nbperpage in let if (nbperpage == nil) then 9 else nbperpage -> nbperpage in let atof (getPluginInstanceParam inst "transspeed") -> transspeed in let if (transspeed == nil) then 1.0 else transspeed -> transspeed in let atof (getPluginInstanceParam inst "transangle") -> transangle in let if (transangle == nil) then 15.0 else transangle -> transangle in let atoi (getPluginInstanceParam inst "showcurrent") -> showcurrent in let if (showcurrent == nil) then 0 else showcurrent -> showcurrent in let V3DgetObjectByName c3dXsession objname -> father in let MkPlugGallery [inst nil father nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil showcurrent show 1] -> gallerystr in ( set gallerystr.GALL_sGroupName = strcat (getPluginInstanceName inst) "_Group"; set gallerystr.GALL_fScale = scale; set gallerystr.GALL_fTransitionSpeed = transspeed; set gallerystr.GALL_fTransitionAngle = transangle; set gallerystr.GALL_iNbPerPage = nbperpage; set gallerystr.GALL_iNbPerRow = nbperrow; set gallerystr.GALL_tMargin = [0.0 0.0]; set gallerystr.GALL_iNbPages = 0; set gallerystr.GALL_iCurrentPages = 0; set gallerystr.GALL_fTransitionCoef = 0.0; set gallerystr.GALL_fOrientationCoef = 0.0; set gallerystr.GALL_sPath = path; set gallerystr.GALL_shell = SO3SceneNodeCreate (V3DgetSession c3dXsession) (strcat (getPluginInstanceName inst) ".shell"); set gallerystr.GALL_shellPos = SO3SceneNodeCreate (V3DgetSession c3dXsession) (strcat (getPluginInstanceName inst) ".shellPos"); set gallerystr.GALL_iLastElemId = 0; SO3GroupCreate (V3DgetSession c3dXsession) gallerystr.GALL_sGroupName; let V3DgetDefaultCamera c3dXsession -> camera in let SO3CameraGetFOVy camera -> fovy in let SO3CameraGetNearClipDistance camera -> coff in let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in let (((tan ((SO3MathsDegreeToRadian 57.29) /. 2.0)) *. 0.05) *. 2.0) +. coff -> unitsize in ( set gallerystr.GALL_tMargin = [(unitsize /. 100.0 *. marginx) (unitsize /. 100.0 *. marginy)]; SO3ObjectLink gallerystr.GALL_shell camera; SO3ObjectSetPosition gallerystr.GALL_shell [0.0 0.0 (((SO3MathsDegreeToRadian 57.29) *. (-.0.05)) /. fovy) -. coff]; SO3ObjectLink gallerystr.GALL_shellPos gallerystr.GALL_shell; let gallerystr.GALL_tMargin -> [xmargin ymargin] in let (gallerystr.GALL_iNbPerPage / gallerystr.GALL_iNbPerRow) + if (mod gallerystr.GALL_iNbPerPage gallerystr.GALL_iNbPerRow) > 0 then 1 else 0 -> nbRow in let (unitsize /. (itof max nbRow gallerystr.GALL_iNbPerRow)) -. xmargin -> eltsize in let (((eltsize +. xmargin) *. (itof gallerystr.GALL_iNbPerRow)) /. 2.0) -. ((eltsize +. xmargin) /. 2.0) -> xpos in let (((eltsize +. xmargin) *. (itof nbRow)) /. 2.0) -. ((eltsize +. xmargin) /. 2.0) -. (xmargin /. 2.0) -> ypos in ( set gallerystr.GALL_fElemSize = eltsize; set gallerystr.GALL_fPageSize = (eltsize *. (itof gallerystr.GALL_iNbPerRow) +. ((xmargin /. 2.0) *. (itof gallerystr.GALL_iNbPerRow))); set gallerystr.GALL_vInitPosition = [(-.xpos) ypos 0.0]; SO3ObjectSetPosition gallerystr.GALL_shellPos [(-.xpos) (ypos) 0.0]; set gallerystr.GALL_vCurPosition = [[(-.xpos) (ypos) 0.0] [0.4 0.5 0.8] 0.0]; set gallerystr.GALL_vDestPosition = [[(-.xpos) (ypos) 0.0] [0.4 0.5 0.8] 1.0]; set gallerystr.GALL_iLastElemPos = [(xmargin /. 2.0) (ymargin /. 2.0)]; let if (strIsUrl gallerystr.GALL_sPath) || ((getFileExt gallerystr.GALL_sPath) != nil) then gallerystr.GALL_sPath::nil else getFilesFromDir gallerystr.GALL_sPath "jpg"::"bmp"::"png"::"tga"::nil -> files in loadGallery gallerystr files gallerystr.GALL_iLastElemId gallerystr.GALL_iLastElemPos nil; showPage gallerystr gallerystr.GALL_iCurrentPages 0; ); ); //init visible state if (!gallerystr.GALL_bShow) then cbHide inst nil nil nil nil gallerystr else cbShow inst nil nil nil nil gallerystr; PluginRegisterAction inst "Show" mkfun6 @cbShow gallerystr; PluginRegisterAction inst "Hide" mkfun6 @cbHide gallerystr; PluginRegisterAction inst "Next page" mkfun6 @cbNextPage gallerystr; PluginRegisterAction inst "Prev page" mkfun6 @cbPrevPage gallerystr; PluginRegisterAction inst "Select" mkfun6 @cbSelect gallerystr; PluginRegisterAction inst "Move selected" mkfun6 @cbMoveSelected gallerystr; PluginRegisterAction inst "Rotate selected" mkfun6 @cbRotateSelected gallerystr; PluginRegisterAction inst "Scale selected" mkfun6 @cbScaleSelected gallerystr; PluginRegisterAction inst "Restore selected" mkfun6 @cbRestoreSelected gallerystr; PluginRegisterAction inst "Goto page" mkfun6 @cbGotoPage gallerystr; PluginRegisterAction inst "Clear" mkfun6 @cbClear gallerystr; PluginRegisterAction inst "Add picture" mkfun6 @cbAddPicture gallerystr; PluginRegisterAction inst "Switch 3d mode" mkfun6 @cbSwitch3dMode gallerystr; PluginRegisterAction inst "Get picture param" mkfun6 @cbGetParam gallerystr; PluginRegisterAction inst "Set picture param" mkfun6 @cbSetParam gallerystr; PluginRegisterAction inst "Get current page" mkfun6 @cbGetCurrentPage gallerystr; PluginRegisterAction inst "Get total pages" mkfun6 @cbGetTotalPages gallerystr; PluginRegisterAction inst "Select next" mkfun6 @cbSelectNext gallerystr; PluginRegisterAction inst "Select previous" mkfun6 @cbSelectPrev gallerystr; PluginRegisterAction inst "Select up" mkfun6 @cbSelectUp gallerystr; PluginRegisterAction inst "Select down" mkfun6 @cbSelectDown gallerystr; PluginRegisterAction inst "Select first" mkfun6 @cbSelectFirst gallerystr; PluginRegisterAction inst "Center selected" mkfun6 @cbCenterSelected gallerystr; setPluginInstanceCbCameraChange inst mkfun5 @cbChangeCamera gallerystr; setPluginInstanceCbScenePreRender inst mkfun4 @cbControlPreRender gallerystr; setPluginInstanceCbDel inst mkfun2 @deleteOb gallerystr; ); 0;; fun IniPlug(file) = PlugRegister @cbNewOb nil; setPluginEditor @dynamicedit; 0;;