/* ----------------------------------------------------------------------------- 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 ObjInfoStr = [ POBI_father : SO3_OBJECT, POBI_iObjMode : I ]mkObjInfoStr;; fun deleteOb(inst, obstr)= 0;; fun cbGetVertices(inst, from, action, param, reply, obstr)= let SO3ObjectGetVerticesCount obstr.POBI_father -> nbVert in SendPluginEvent inst "Vertices count" (itoa nbVert) nil; 0;; fun cbGetPolygons(inst, from, action, param, reply, obstr)= let SO3ObjectGetPolygonCount obstr.POBI_father -> nbPoly in SendPluginEvent inst "Polygons count" (itoa nbPoly) nil; 0;; fun cbGetBoundingBox(inst, from, action, param, reply, obstr)= let SO3ObjectGetBoundingBoxInfo obstr.POBI_father 0 -> [[sx sy sz] pos quat] in SendPluginEvent inst "Bounding box size" strcatn (ftoa sx)::" "::(ftoa sy)::" "::(ftoa sz)::nil nil; 0;; fun cbChangeCamera(inst, viewstr, sessionstr, camera, obstr)= let V3DgetCameraByType sessionstr camera obstr.POBI_iObjMode -> nobject in set obstr.POBI_father = nobject; 0;; fun cbGetAllInfos(inst, from, action, param, reply, obstr)= if (obstr.POBI_father == nil) then nil else ( let SO3ObjectGetVerticesCount obstr.POBI_father -> nbVert in let SO3ObjectGetPolygonCount obstr.POBI_father -> nbPoly in let SO3ObjectGetBoundingBoxInfo obstr.POBI_father 0 -> [[sx sy sz] pos quat] in let strcatn (loc "OS3DOBJECTINFO_C0003")::" "::(itoa nbVert)::"\n":: (loc "OS3DOBJECTINFO_C0004")::" "::(itoa nbPoly)::"\n"::"\n":: (loc "OS3DOBJECTINFO_C0005")::"\n":: (loc "OS3DOBJECTINFO_C0006")::" "::(ftoa sx)::" "::(loc "OS3DOBJECTINFO_C0009")::"\n":: (loc "OS3DOBJECTINFO_C0007")::" "::(ftoa sy)::" "::(loc "OS3DOBJECTINFO_C0009")::"\n":: (loc "OS3DOBJECTINFO_C0008")::" "::(ftoa sz)::" "::(loc "OS3DOBJECTINFO_C0009")::"\n"::nil -> text in SendPluginEvent inst "All infos" text nil; ); 0;; fun cbSetObject(inst, from, action, param, reply, obstr)= if param == nil then nil else ( let V3DgetObjectByName c3dXsession param -> object in let V3DgetObjectTypeByName param -> iobjmode in ( set obstr.POBI_father = object; set obstr.POBI_iObjMode = iobjmode; if !iobjmode then nil else setPluginInstanceCbCameraChange inst mkfun5 @cbChangeCamera obstr; ); SendPluginEvent inst "Object changed" nil nil; ); 0;; fun newOb(inst)= let (getPluginInstanceParam inst "object") -> objname in // for compatibility let if ((atoi (getPluginInstanceParam inst "iscamera")) == 1) then "Current camera" else objname -> objname in let V3DgetObjectByName c3dXsession objname -> object in let V3DgetObjectTypeByName objname -> iobjmode in let mkObjInfoStr [object iobjmode] -> obstr in ( PluginRegisterAction inst "Get vertices number" mkfun6 @cbGetVertices obstr; PluginRegisterAction inst "Get polygons number" mkfun6 @cbGetPolygons obstr; PluginRegisterAction inst "Get bounding box size" mkfun6 @cbGetBoundingBox obstr; PluginRegisterAction inst "Set object" mkfun6 @cbSetObject obstr; PluginRegisterAction inst "Get all infos" mkfun6 @cbGetAllInfos obstr; if !iobjmode then nil else setPluginInstanceCbCameraChange inst mkfun5 @cbChangeCamera obstr; setPluginInstanceCbDel inst mkfun2 @deleteOb obstr; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;