/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ struct PlugTree = [ PTE_instance : PInstance, PTE_contstr : VUIcontainer, PTE_liststr : VUIList, PTE_lthemeelts : [S r1], PTE_posstr : InterfacePos, PTE_tMargin : [I I], PTE_tLevelOffset : [I I], PTE_bBackground : I, PTE_bNodes : I, PTE_bObjects : I, PTE_bCameras : I, PTE_bLights : I, PTE_bBones : I, PTE_bGroups : I ]mkPlugTree;; fun deleteOb(inst, obstr)= VUIdestroyContainer obstr.PTE_contstr; 0;; fun cbHide(inst, from, action, param, reply, obstr)= VUIshowContainer obstr.PTE_contstr 0; SendPluginEvent inst "Hidden" nil nil; 0;; fun cbShow(inst, from, action, param, reply, obstr)= VUIshowContainer obstr.PTE_contstr 1; SendPluginEvent inst "Shown" nil nil; 0;; fun cbObjectSelected(listeltstr, obstr)= SendPluginEvent obstr.PTE_instance ("Object selected") listeltstr.VUILE_sValue nil; 0;; fun loadSceneTree(l, treeparent, obstr)= while l != nil do ( let hd l -> obj in let SO3ObjectGetName obj -> name in let SO3ObjectGetType obj -> type in let SO3ObjectGetFlags obj -> flags in ( if ((flags & iNodeFlagScene) && (!(flags & iNodeFlagGroup) || obstr.PTE_bGroups)) && (((type == SO3_TYPE_NODE) && obstr.PTE_bNodes) || ((type == SO3_TYPE_ENTITY) && obstr.PTE_bObjects) || ((type == SO3_TYPE_CAMERA) && obstr.PTE_bCameras) || ((type == SO3_TYPE_LIGHT) && obstr.PTE_bLights) || ((type == SO3_TYPE_BONE) && obstr.PTE_bBones)) then let VUIaddListElement obstr.PTE_liststr treeparent name (itoa type) 0 -> listeltstr in ( VUIsetListElementCbSelect listeltstr mkfun2 @cbObjectSelected obstr; if !(obstr.PTE_bBones) then nil else loadSceneTree (SO3GetRootBonesFromMesh obj) listeltstr obstr; loadSceneTree (SO3ObjectGetChildren obj) listeltstr obstr; ) else if (flags & iNodeFlagGroup && !obstr.PTE_bGroups) then nil else loadSceneTree (SO3ObjectGetChildren obj) treeparent obstr; ); set l = tl l; ); 0;; fun cbRefresh(inst, from, action, param, reply, obstr)= VUIdestroyList obstr.PTE_liststr; set obstr.PTE_liststr = VUIcreateList obstr.PTE_contstr nil [0.0 0.0] [100.0 100.0] [0 0 1 1 0 0 0 0] [0 0] obstr.PTE_tMargin 0 obstr.PTE_tLevelOffset; let SO3ObjectGetChildren (SO3ObjectGetSceneRoot V3DgetSession c3dXsession) -> lscenerootchildren in loadSceneTree lscenerootchildren nil obstr; if !obstr.PTE_bBackground then nil else VUIsetElementResource obstr.PTE_liststr.VUIL_element nil nil nil nil nil nil nil nil nil; SendPluginEvent inst "Refreshed" nil nil; 0;; fun createTree(inst, start, obstr)= set obstr.PTE_contstr = crInterfacePosContainer inst obstr.PTE_posstr c3dXsession; set obstr.PTE_liststr = VUIcreateListExt obstr.PTE_contstr nil [0.0 0.0] [100.0 100.0] [0 0 1 1 0 0 0 0] [0 0] obstr.PTE_tMargin 0 obstr.PTE_tLevelOffset (hd obstr.PTE_lthemeelts); let if start != nil then start else SO3ObjectGetSceneRoot V3DgetSession c3dXsession -> root in let SO3ObjectGetChildren root -> lscenerootchildren in loadSceneTree lscenerootchildren nil obstr; if !obstr.PTE_bBackground then nil else ( VUIsetContainerBackground obstr.PTE_contstr nil nil nil nil nil nil nil nil; VUIsetElementResource obstr.PTE_liststr.VUIL_element nil nil nil nil nil nil nil nil nil; ); 0;; fun newOb(inst)= let loadInterfacePos inst c3dXsession -> posstr in let getPluginInstanceParam inst "objname" -> objname in let if (objname == nil) then "" else objname -> objname in let atoi (getPluginInstanceParam inst "xmargin") -> xmargin in let if (xmargin == nil) then 5 else xmargin -> xmargin in let atoi (getPluginInstanceParam inst "ymargin") -> ymargin in let if (ymargin == nil) then 5 else ymargin -> ymargin in let atoi (getPluginInstanceParam inst "levelxoffset") -> levelxoffset in let if (levelxoffset == nil) then 10 else levelxoffset -> levelxoffset in let atoi (getPluginInstanceParam inst "levelyoffset") -> levelyoffset in let if (levelyoffset == nil) then 0 else levelyoffset -> levelyoffset in let atoi (getPluginInstanceParam inst "background") -> background in let if (background == nil) then 0 else background -> background in let atoi (getPluginInstanceParam inst "nodes") -> nodes in let if (nodes == nil) then 1 else nodes -> nodes in let atoi (getPluginInstanceParam inst "objects") -> objects in let if (objects == nil) then 1 else objects -> objects in let atoi (getPluginInstanceParam inst "cameras") -> cameras in let if (cameras == nil) then 0 else cameras -> cameras in let atoi (getPluginInstanceParam inst "lights") -> lights in let if (lights == nil) then 0 else lights -> lights in let atoi (getPluginInstanceParam inst "bones") -> bones in let if (bones == nil) then 0 else bones -> bones in let atoi (getPluginInstanceParam inst "groups") -> groups in let if (groups == nil) then 0 else groups -> groups in let loadThemeEltSelectorValues inst "list"::nil -> lthemeelts in let atoi (getPluginInstanceParam inst "show") -> show in let if (show == nil) then 1 else show -> show in let SO3SceneGetObject (V3DgetSession c3dXsession) objname -> obj in let mkPlugTree [inst nil nil lthemeelts posstr [xmargin ymargin] [levelxoffset levelyoffset] background nodes objects cameras lights bones groups] -> obstr in ( createTree inst obj obstr; if !show then nil else cbShow inst nil nil nil nil obstr; PluginRegisterAction inst "Show" mkfun6 @cbShow obstr; PluginRegisterAction inst "Hide" mkfun6 @cbHide obstr; PluginRegisterAction inst "Refresh" mkfun6 @cbRefresh obstr; setPluginInstanceCbDel inst mkfun2 @deleteOb obstr; ); 0;; fun IniPlug(file)= VUIsetEnable c3dXsession 1; PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;