/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ /************************************************** OpenSpace 3D Editor Tools Author: Bastien BOURINEAU / I-maginer Last update: 11.16.2010 **************************************************/ /* ********************************************************************************************* / Os tools / ********************************************************************************************* */ proto setGraphItemInitState = fun [S I] I;; fun isPathInGroup(groupmark, varname, path)= let XMLgetMarkByValueFromMarkSons groupmark "graph" -> grmark in if (XMLgetMarkByValueAndParamValueFromMark grmark "mesh" varname path) != nil then 1 else 0;; fun getTupListElemByValue(l, val)= let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while (i < size) && (ndata == nil) do ( let nth_list l i -> elem in let elem -> [item _] in if val == item then ( set ndata = elem; ) else nil; set i = i + 1; ); ndata; );; fun fillMaterialTextureSelector(viewstr, ctrlselect, mat, tech, pass)= if mat == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3MaterialNumberOfTexturesByTechniqueAndPass mat tech pass -> size in let 0 -> i in let nil -> lmatname in ( while i < size do ( let SO3MaterialTextureUnitGetNameByIndex mat tech pass i -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; ); 0;; fun fillMaterialPassSelector(viewstr, p, mat, tech)= let p -> [ctrlselect ctrlmatname ctrlmattech ctrlmattex] in if mat == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3MaterialNumberOfPassesByTechnique mat tech -> size in let 0 -> i in let nil -> lmatname in ( while i < size do ( let SO3MaterialPassGetNameByIndex mat tech i -> matname in let if (!strcmp matname "") then (itoa i) else matname -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; fillMaterialTextureSelector viewstr ctrlmattex mat tech 0; ); 0;; fun fillMaterialTechSelector(viewstr, p, mat)= let p -> [ctrlselect ctrlmatname ctrlmatpass ctrlmattex] in if mat == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3MaterialNumberOfTechniques mat -> size in let 0 -> i in let nil -> lmatname in ( while i < size do ( let SO3MaterialTechniqueGetNameByIndex mat i -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; fillMaterialPassSelector viewstr [ctrlmatpass ctrlmatname ctrlselect ctrlmattex] mat 0; ); 0;; fun fillMaterialSelector(viewstr, resgroup, ctrlselect, ctrlmattech, ctrlmatpass, ctrlmattex)= let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneParseMaterialsFromGroup (V3DgetSession sessionstr) resgroup -> l in let sizelist l -> size in let nil -> lmats in let 0 -> i in ( while i < size do ( let nth_list l i -> mat in let SO3MaterialGetName mat -> name in set lmats = name::lmats; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmats; fillMaterialTechSelector viewstr [ctrlmattech ctrlselect ctrlmatpass ctrlmattex] (SO3SceneGetMaterial (V3DgetSession sessionstr) resgroup (hd lmats)); ); 0;; fun getGroupByName(name)= let sizelist lGroups -> size in let nil -> group in let 0 -> i in ( while i < size do ( let nth_list lGroups i -> elem in let elem -> [_ groupstr] in if strcmp name groupstr.GRP_sName then nil else set group = groupstr; set i = i + 1; ); group; );;