/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ typeof winPhysicSetup = EdWindow;; typeof winPhysicBodySetup = [SO3_OBJECT EdWindow];; // refresh physic materials used in xml fun updateScenePhysicsMaterialList()= set lPhysicMaterial = "default"::"avatar"::nil; let XMLgetMarksByValue xmlEditSceneFile "body" -> lbodymarks in while (lbodymarks != nil) do ( let hd lbodymarks -> bodystr in let XMLgetParam bodystr "material" -> bodymatname in set lPhysicMaterial = bodymatname::lPhysicMaterial; set lbodymarks = tl lbodymarks; ); set lPhysicMaterial = quicksort lPhysicMaterial @suppDoublon; 0;; fun addPhysicMaterial(matname)= if (isStringInListi lPhysicMaterial matname) then nil else ( set lPhysicMaterial = quicksort matname::lPhysicMaterial @suppDoublon; let XMLgetMarkByValue xmlEditSceneFile "scene" -> scenemark in let XMLgetMarkByValueFromMarkSons scenemark "environment" -> envstr in let XMLgetMarkByValueFromMarkSons envstr "physic" -> physicstr in let XMLgetMarkByValueFromMarkSons physicstr "materials" -> physicmaterialsstr in ( XMLaddMark xmlEditSceneFile "material" physicmaterialsstr ["name" matname]::nil nil; ); ); 0;; fun removePhysicMaterial(matname)= if (!isStringInListi lPhysicMaterial matname) then nil else ( set lPhysicMaterial = remove_string_from_list lPhysicMaterial matname; let XMLgetMarkByValue xmlEditSceneFile "scene" -> scenemark in let XMLgetMarkByValueFromMarkSons scenemark "environment" -> envstr in let XMLgetMarkByValueFromMarkSons envstr "physic" -> physicstr in let XMLgetMarkByValueFromMarkSons physicstr "materials" -> physicmaterialsstr in let XMLgetMarkByValueAndParamValueFromMarkSons physicmaterialsstr "material" "name" matname -> matmark in ( XMLdelMark xmlEditSceneFile matmark; //reset material on bodies let XMLgetMarksByValue xmlEditSceneFile "body" -> lbodymarks in while (lbodymarks != nil) do ( let hd lbodymarks -> bodystr in let XMLgetParam bodystr "material" -> bodymatname in if (strcmpi bodymatname matname) then nil else ( // todo reset material on SO3PhysicBody too XMLsetParam bodystr "material" "default"; ); set lbodymarks = tl lbodymarks; ); ); ); 0;; fun updatePhysicsBody(sessionstr, markstr, mesh)= let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let XMLgetBoolParam markstr "staticGeometry" -> nodestaticgeometry in let XMLgetParam bodystr "type" -> bodytype in let XMLgetParam bodystr "material" -> bodymatname in let atof XMLgetParam bodystr "mass" -> bodymass in let XMLgetBoolParam bodystr "enable" -> bodyenable in let XMLgetBoolParam bodystr "autoSleep" -> bodyautosleep in let XMLgetBoolParam bodystr "continuousColl" -> bodycontinuous in let XMLgetBoolParam bodystr "fluid" -> bodyfluid in let atof XMLgetParam bodystr "fluidVolume" -> bodyfluidvolume in let XMLgetMarkByValueFromMarkSons bodystr "damping" -> dampingstr in let atof XMLgetParam dampingstr "linear" -> bodydampingl in let atof XMLgetParam dampingstr "x" -> bodydampingx in let atof XMLgetParam dampingstr "y" -> bodydampingy in let atof XMLgetParam dampingstr "z" -> bodydampingz in let XMLgetMarkByValueFromMarkSons bodystr "centerOfMass" -> centermassstr in let if centermassstr == nil then 1 else XMLgetBoolParam centermassstr "auto" -> centermassauto in let atof XMLgetParam centermassstr "x" -> centermassx in let atof XMLgetParam centermassstr "y" -> centermassy in let atof XMLgetParam centermassstr "z" -> centermassz in let XMLgetMarkByValueFromMarkSons bodystr "bodySize" -> bodysizestr in let atof XMLgetParam bodysizestr "x" -> sizex in let atof XMLgetParam bodysizestr "y" -> sizey in let atof XMLgetParam bodysizestr "z" -> sizez in let XMLgetMarkByValueFromMarkSons bodystr "bodyOffset" -> offsetstr in let atof XMLgetParam offsetstr "px" -> offsetpx in let atof XMLgetParam offsetstr "py" -> offsetpy in let atof XMLgetParam offsetstr "pz" -> offsetpz in let atof XMLgetParam offsetstr "ax" -> offsetax in let atof XMLgetParam offsetstr "ay" -> offsetay in let atof XMLgetParam offsetstr "az" -> offsetaz in ( // physics if bodystr == nil then nil else ( SO3BodyDestroy (SO3SceneNodeGetBody mesh); if (!nodestaticgeometry) then nil else SO3ObjectSetAsStaticGeometry mesh 1; let if (!strcmpi bodytype "collisionTree") then // remove hd when engine updated SO3BodyCreateCollisionTree mesh 1 else if (!strcmpi bodytype "ellipsoid") then V3DphysCreateBodyEllipsoidExt mesh (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "box") then V3DphysCreateBodyBoxExt mesh (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "shape") then SO3BodyCreateShape mesh 0.0 else if (!strcmpi bodytype "concave") then SO3BodyCreateConcaveShape mesh 0.0 else if (!strcmpi bodytype "cylinder") then V3DphysCreateBodyCylinderExt mesh (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "chamfer cylinder") then V3DphysCreateBodyChamferCylinderExt mesh (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "capsule") then V3DphysCreateBodyCapsuleExt mesh (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "cone") then V3DphysCreateBodyConeExt mesh (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "pyramid") then V3DphysCreateBodyPyramidExt mesh (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else nil -> body in if body == nil then nil else ( if (strcmpi bodytype "collisionTree") then nil else SO3BodySetType body 4; V3DphysSetBodyMaterial sessionstr body bodymatname; SO3BodySetMass body bodymass; SO3BodySetContiniousCollisionMode body bodycontinuous; SO3BodySetAutoSleep body bodyautosleep; SO3BodySetCenterOfMass body if centermassauto then SO3BodyCalculateOffset body else [centermassx centermassy centermassz]; SO3BodySetFluid body bodyfluid; if dampingstr == nil then nil else ( SO3BodySetLinearDamping body bodydampingl; SO3BodySetAngularDamping body [bodydampingx bodydampingy bodydampingz]; ); V3DphysFreezeBody body bodyenable; let winPhysicBodySetup -> [enode _] in if (mesh != enode) then nil else SO3BodyShowDebug body 1; ); if (!nodestaticgeometry) then nil else SO3ObjectSetAsStaticGeometry mesh 0; ); ); 0;; fun updateSonsPhysicsBody(sessionstr, markstr, node)= //search a parent with static geometry while (markstr != nil && (!XMLgetBoolParam markstr "staticGeometry")) do set markstr = markstr.XMLfather; if ((markstr == nil) || (!XMLgetBoolParam markstr "staticGeometry")) then nil else ( let XMLgetParam markstr "id" -> fid in let XMLgetParam markstr "name" -> fname in let if fid == nil || fname == nil then nil else V3DgetObjectByName sessionstr strcatn fid::"."::fname::nil -> node in //update static geometry body updatePhysicsBody sessionstr markstr node; ); 0;; fun physicsInitScene(xmlfilestr, envstr, sessionstr)= let XMLaddMark xmlfilestr "physic" envstr /*["architectureModel" (V3DphysGetArchitectureModeName sessionstr)]::*/["solverModel" (V3DphysGetSolverModeName sessionstr)]::["framerate" itoa (V3DphysGetFps sessionstr)]::["enable" XMLgetBoolString (V3DphysGetState sessionstr)]::nil nil -> physicstr in let V3DphysGetGravity sessionstr -> [gx gy gz] in ( XMLaddMark xmlfilestr "gravity" physicstr ["x" (XMLgetShortFloatToString gx)]::["y" (XMLgetShortFloatToString gy)]::["z" (XMLgetShortFloatToString gz)]::nil nil; let XMLaddMark xmlfilestr "materials" physicstr nil nil -> matstr in ( XMLaddMark xmlfilestr "material" matstr ["name" "default"]::nil nil; XMLaddMark xmlfilestr "material" matstr ["name" "avatar"]::nil nil; set lPhysicMaterial = "default"::"avatar"::nil; ); ); 0;; fun physicsLoadEnv(envstr, targetenvironmentstr, sessionstr)= let XMLgetMarkByValueFromMarkSons envstr "physic" -> physicstr in //let XMLgetParam physicstr "architectureModel" -> physicarch in let XMLgetParam physicstr "solverModel" -> physicsolver in let atoi XMLgetParam physicstr "framerate" -> physicfps in let XMLgetBoolParam physicstr "enable" -> physicenable in let XMLgetMarkByValueFromMarkSons physicstr "materials" -> physicmaterialsstr in let XMLgetMarksByValueFromMarkSons physicmaterialsstr "material" -> lmaterials in let atof XMLgetParam physicstr "gravity" -> physicgravity in let XMLgetMarkByValueFromMarkSons physicstr "gravity" -> gravitystr in let atof XMLgetParam gravitystr "x" -> gx in let atof XMLgetParam gravitystr "y" -> gy in let atof XMLgetParam gravitystr "z" -> gz in let if gravitystr == nil then [0.0 (-.physicgravity) 0.0] else [gx gy gz] -> [gx gy gz] in ( if physicstr == nil then nil else ( //V3DphysSetArchitectureModeByName sessionstr physicarch; V3DphysSetSolverModeByName sessionstr physicsolver; V3DphysSetFps sessionstr physicfps; V3DphysSetGravity sessionstr [gx gy gz]; //V3DphysEnablePhysic sessionstr physicenable; set bPhysicOnPlay = physicenable; V3DphysShowDebug sessionstr bShowInfos; let XMLgetMarkByValueFromMarkSons targetenvironmentstr "physic" -> physictargetstr in let XMLgetMarkByValueFromMarkSons physictargetstr "gravity" -> worldgravitytargetstr in let XMLgetMarkByValueFromMarkSons physictargetstr "materials" -> worldmaterialstargetstr in ( //XMLsetParam physictargetstr "architectureModel" physicarch; XMLsetParam physictargetstr "solverModel" physicsolver; XMLsetParam physictargetstr "framerate" (itoa physicfps); XMLsetParam physictargetstr "enable" (XMLgetBoolString physicenable); XMLsetParam worldgravitytargetstr "x" (XMLgetShortFloatToString gx); XMLsetParam worldgravitytargetstr "y" (XMLgetShortFloatToString gy); XMLsetParam worldgravitytargetstr "z" (XMLgetShortFloatToString gz); while (lmaterials != nil) do ( let (XMLgetParam hd lmaterials "name") -> matname in if (isStringInListi lPhysicMaterial matname) then nil else ( XMLaddMark xmlEditSceneFile "material" worldmaterialstargetstr ["name" matname]::nil nil; set lPhysicMaterial = quicksort matname::lPhysicMaterial @suppDoublon; ); set lmaterials = tl lmaterials; ); ); ); ); 0;; fun physicsRefreshSceneGraph(envstr, sessionstr)= let XMLgetMarkByValueFromMarkSons envstr "physic" -> physicstr in //let XMLgetParam physicstr "architectureModel" -> physicarch in let XMLgetParam physicstr "solverModel" -> physicsolver in let atoi XMLgetParam physicstr "framerate" -> physicfps in let XMLgetBoolParam physicstr "enable" -> physicenable in let XMLgetMarkByValueFromMarkSons physicstr "gravity" -> gravitystr in let atof XMLgetParam gravitystr "x" -> gx in let atof XMLgetParam gravitystr "y" -> gy in let atof XMLgetParam gravitystr "z" -> gz in ( if physicstr == nil then nil else ( //V3DphysSetArchitectureModeByName sessionstr physicarch; V3DphysSetSolverModeByName sessionstr physicsolver; V3DphysSetFps sessionstr physicfps; V3DphysSetGravity sessionstr [gx gy gz]; V3DphysShowDebug sessionstr bShowInfos; ); ); 0;; fun physicsRefreshNodeGraph(emark, node, sessionstr)= let XMLgetMarkByValueFromMarkSons emark "body" -> bodystr in let XMLgetParam bodystr "type" -> bodytype in let XMLgetParam bodystr "material" -> bodymatname in let atof XMLgetParam bodystr "mass" -> bodymass in let XMLgetBoolParam bodystr "enable" -> bodyenable in let XMLgetBoolParam bodystr "autoSleep" -> bodyautosleep in let XMLgetBoolParam bodystr "continuousColl" -> bodycontinuous in let XMLgetBoolParam bodystr "fluid" -> bodyfluid in let atof XMLgetParam bodystr "fluidVolume" -> bodyfluidvolume in let if (bodyfluidvolume == nil) then 0.9 else bodyfluidvolume -> bodyfluidvolume in let XMLgetMarkByValueFromMarkSons bodystr "damping" -> dampingstr in let atof XMLgetParam dampingstr "linear" -> bodydampingl in let atof XMLgetParam dampingstr "x" -> bodydampingx in let atof XMLgetParam dampingstr "y" -> bodydampingy in let atof XMLgetParam dampingstr "z" -> bodydampingz in let XMLgetMarkByValueFromMarkSons bodystr "centerOfMass" -> centermassstr in let if centermassstr == nil then 1 else XMLgetBoolParam centermassstr "auto" -> centermassauto in let atof XMLgetParam centermassstr "x" -> centermassx in let atof XMLgetParam centermassstr "y" -> centermassy in let atof XMLgetParam centermassstr "z" -> centermassz in ( let SO3SceneNodeGetBody node -> body in ( V3DphysSetBodyMaterial sessionstr body bodymatname; SO3BodySetMass body bodymass; SO3BodySetIgnoreCollision body 0; SO3BodySetContiniousCollisionMode body bodycontinuous; SO3BodySetAutoSleep body bodyautosleep; SO3BodySetCenterOfMass body if centermassauto then SO3BodyCalculateOffset body else [centermassx centermassy centermassz]; SO3BodySetFluid body bodyfluid; SO3BodySetFluidVolumeRatio body bodyfluidvolume; if dampingstr == nil then nil else ( SO3BodySetLinearDamping body bodydampingl; SO3BodySetAngularDamping body [bodydampingx bodydampingy bodydampingz]; ); V3DphysFreezeBody body bodyenable; ); ); 0;; fun physicsLoadOsNode(srcnodestr, destnodestr, node, sessionstr)= let XMLgetMarkByValueFromMarkSons srcnodestr "body" -> bodystr in let XMLgetBoolParam srcnodestr "staticGeometry" -> nodestaticgeometry in let XMLgetParam bodystr "type" -> bodytype in let XMLgetParam bodystr "material" -> bodymatname in let atof XMLgetParam bodystr "mass" -> bodymass in let XMLgetBoolParam bodystr "enable" -> bodyenable in let if ((XMLgetParam bodystr "autoSleep") == nil) then 1 else XMLgetBoolParam bodystr "autoSleep" -> bodyautosleep in let XMLgetBoolParam bodystr "continuousColl" -> bodycontinuous in let XMLgetBoolParam bodystr "fluid" -> bodyfluid in let atof XMLgetParam bodystr "fluidVolume" -> bodyfluidvolume in let if (bodyfluidvolume == nil) then 0.9 else bodyfluidvolume -> bodyfluidvolume in let XMLgetMarkByValueFromMarkSons bodystr "damping" -> dampingstr in let atof XMLgetParam dampingstr "linear" -> bodydampingl in let atof XMLgetParam dampingstr "x" -> bodydampingx in let atof XMLgetParam dampingstr "y" -> bodydampingy in let atof XMLgetParam dampingstr "z" -> bodydampingz in let XMLgetMarkByValueFromMarkSons bodystr "centerOfMass" -> centermassstr in let if centermassstr == nil then 1 else XMLgetBoolParam centermassstr "auto" -> centermassauto in let atof XMLgetParam centermassstr "x" -> centermassx in let if centermassx == nil then 0.0 else centermassx -> centermassx in let atof XMLgetParam centermassstr "y" -> centermassy in let if centermassy == nil then 0.0 else centermassy -> centermassy in let atof XMLgetParam centermassstr "z" -> centermassz in let if centermassz == nil then 0.0 else centermassz -> centermassz in let XMLgetMarkByValueFromMarkSons bodystr "bodySize" -> bodysizestr in let atof XMLgetParam bodysizestr "x" -> sizex in let atof XMLgetParam bodysizestr "y" -> sizey in let atof XMLgetParam bodysizestr "z" -> sizez in let XMLgetMarkByValueFromMarkSons bodystr "bodyOffset" -> offsetstr in let atof XMLgetParam offsetstr "px" -> offsetpx in let atof XMLgetParam offsetstr "py" -> offsetpy in let atof XMLgetParam offsetstr "pz" -> offsetpz in let atof XMLgetParam offsetstr "ax" -> offsetax in let atof XMLgetParam offsetstr "ay" -> offsetay in let atof XMLgetParam offsetstr "az" -> offsetaz in ( if bodystr == nil then nil else ( if (!nodestaticgeometry) then nil else SO3ObjectSetAsStaticGeometry node 1; let if (!strcmpi bodytype "collisionTree") then // remove hd when engine updated SO3BodyCreateCollisionTree node 1 else if (!strcmpi bodytype "ellipsoid") then V3DphysCreateBodyEllipsoidExt node (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "box") then V3DphysCreateBodyBoxExt node (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "shape") then SO3BodyCreateShape node 0.0 else if (!strcmpi bodytype "concave") then SO3BodyCreateConcaveShape node 0.0 else if (!strcmpi bodytype "cylinder") then V3DphysCreateBodyCylinderExt node (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "chamfer cylinder") then V3DphysCreateBodyChamferCylinderExt node (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "capsule") then V3DphysCreateBodyCapsuleExt node (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "cone") then V3DphysCreateBodyConeExt node (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else if (!strcmpi bodytype "pyramid") then V3DphysCreateBodyPyramidExt node (if bodysizestr == nil then nil else [sizex sizey sizez]) (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]) else nil -> body in if body == nil then nil else ( if (strcmpi bodytype "collisionTree") then nil else SO3BodySetType body 4; addPhysicMaterial bodymatname; V3DphysSetBodyMaterial sessionstr body bodymatname; SO3BodySetMass body bodymass; SO3BodySetContiniousCollisionMode body bodycontinuous; SO3BodySetAutoSleep body bodyautosleep; SO3BodySetCenterOfMass body if centermassauto then SO3BodyCalculateOffset body else [centermassx centermassy centermassz]; SO3BodySetFluid body bodyfluid; SO3BodySetFluidVolumeRatio body bodyfluidvolume; if dampingstr == nil then nil else ( SO3BodySetLinearDamping body bodydampingl; SO3BodySetAngularDamping body [bodydampingx bodydampingy bodydampingz]; ); V3DphysFreezeBody body bodyenable; ); if (!nodestaticgeometry) then nil else SO3ObjectSetAsStaticGeometry node 0; if destnodestr == nil then nil else ( let XMLaddMark xmlEditSceneFile "body" destnodestr ["type" bodytype]::["material" bodymatname]::["mass" (XMLgetShortFloatToString bodymass)]::["continuousColl" (XMLgetBoolString bodycontinuous)]::["fluid" (XMLgetBoolString bodyfluid)]::["fluidVolume" (XMLgetShortFloatToString bodyfluidvolume)]::["autoSleep" (XMLgetBoolString bodyautosleep)]::["enable" (XMLgetBoolString bodyenable)]::nil nil -> newbodystr in ( XMLaddMark xmlEditSceneFile "damping" newbodystr ["linear" (XMLgetShortFloatToString bodydampingl)]::["x" (XMLgetShortFloatToString bodydampingx)]::["y" (XMLgetShortFloatToString bodydampingy)]::["z" (XMLgetShortFloatToString bodydampingz)]::nil nil; XMLaddMark xmlEditSceneFile "centerOfMass" newbodystr ["auto" (XMLgetBoolString centermassauto)]::["x" (XMLgetShortFloatToString centermassx)]::["y" (XMLgetShortFloatToString centermassy)]::["z" (XMLgetShortFloatToString centermassz)]::nil nil; if (bodysizestr == nil) then nil else XMLaddMark xmlEditSceneFile "bodySize" newbodystr ["x" (XMLgetShortFloatToString sizex)]::["y" (XMLgetShortFloatToString sizey)]::["z" (XMLgetShortFloatToString sizez)]::nil nil; if (offsetstr == nil) then nil else XMLaddMark xmlEditSceneFile "bodyOffset" newbodystr ["px" (XMLgetShortFloatToString offsetpx)]::["py" (XMLgetShortFloatToString offsetpy)]::["pz" (XMLgetShortFloatToString offsetpz)]::["ax" (XMLgetShortFloatToString offsetax)]::["ay" (XMLgetShortFloatToString offsetay)]::["az" (XMLgetShortFloatToString offsetaz)]::nil nil; ); ); ); ); 0;; /* ********************************************************************************************* / Physics setting / ********************************************************************************************* */ fun destroyPhysicSetting()= dsEdWindow winPhysicSetup; set winPhysicSetup = nil; 0;; /* fun cbPhysicSetupArchMode(ctrl, pos, elem, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let XMLgetMarkByValueFromMarkSons markstr "environment" -> envmark in let XMLgetMarkByValueFromMarkSons envmark "physic" -> physicmark in ( XMLsetParam physicmark "architectureModel" elem; V3DphysSetArchitectureModeByName sessionstr elem; ); 0;; */ fun cbPhysicSetupSolverMode(ctrl, pos, elem, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let XMLgetMarkByValueFromMarkSons markstr "environment" -> envmark in let XMLgetMarkByValueFromMarkSons envmark "physic" -> physicmark in ( XMLsetParam physicmark "solverModel" elem; V3DphysSetSolverModeByName sessionstr elem; ); 0;; fun cbPhysicSetupWorldFps(ctrl, value, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let XMLgetMarkByValueFromMarkSons markstr "environment" -> envmark in let XMLgetMarkByValueFromMarkSons envmark "physic" -> physicmark in ( XMLsetParam physicmark "framerate" (XMLgetShortFloatToString value); V3DphysSetFps sessionstr ftoi value; ); 0;; fun cbPhysicSetupWorldGravityX(ctrl, value, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let V3DphysGetGravity sessionstr -> [gx gy gz] in let XMLgetMarkByValueFromMarkSons markstr "environment" -> envmark in let XMLgetMarkByValueFromMarkSons envmark "physic" -> physicmark in let XMLgetMarkByValueFromMarkSons physicmark "gravity" -> gravitymark in ( XMLsetParam gravitymark "x" (XMLgetShortFloatToString value); V3DphysSetGravity sessionstr [value gy gz]; ); 0;; fun cbPhysicSetupWorldGravityY(ctrl, value, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let V3DphysGetGravity sessionstr -> [gx gy gz] in let XMLgetMarkByValueFromMarkSons markstr "environment" -> envmark in let XMLgetMarkByValueFromMarkSons envmark "physic" -> physicmark in let XMLgetMarkByValueFromMarkSons physicmark "gravity" -> gravitymark in ( XMLsetParam gravitymark "y" (XMLgetShortFloatToString value); V3DphysSetGravity sessionstr [gx value gz]; ); 0;; fun cbPhysicSetupWorldGravityZ(ctrl, value, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let V3DphysGetGravity sessionstr -> [gx gy gz] in let XMLgetMarkByValueFromMarkSons markstr "environment" -> envmark in let XMLgetMarkByValueFromMarkSons envmark "physic" -> physicmark in let XMLgetMarkByValueFromMarkSons physicmark "gravity" -> gravitymark in ( XMLsetParam gravitymark "z" (XMLgetShortFloatToString value); V3DphysSetGravity sessionstr [gx gy value]; ); 0;; fun cbPhysicSetupEnable(ctrl, state, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let XMLgetMarkByValueFromMarkSons markstr "environment" -> envmark in let XMLgetMarkByValueFromMarkSons envmark "physic" -> physicmark in ( XMLsetParam physicmark "enable" (XMLgetBoolString state); set bPhysicOnPlay = state; ); 0;; fun cbPhysicSetupGenerateCollisions(ctrl, viewstr)= let V3DgetDefaultSession viewstr -> sessionstr in let getGraphItemsByType iTypeEntity -> lentity in let 0 -> i in ( while (lentity != nil) do ( let hd lentity -> [val [treenode type alias markstr path destgroup initstate staticgeometry]] in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in ( if (bodystr == nil) then ( let V3DphysGetUniformBoundingBox node -> [bx by bz] in let XMLaddMark xmlEditSceneFile "body" markstr ["type" "collisionTree"]::["material" "default"]::["mass" (XMLgetShortFloatToString 0.0)]::["continuousColl" (XMLgetBoolString 0)]::["fluid" (XMLgetBoolString 0)]::["fluidVolume" (XMLgetShortFloatToString 0.9)]::["autoSleep" (XMLgetBoolString 1)]::["enable" (XMLgetBoolString 0)]::nil nil -> newbodystr in ( XMLaddMark xmlEditSceneFile "damping" newbodystr ["linear" (XMLgetShortFloatToString 0.1)]::["x" (XMLgetShortFloatToString 0.1)]::["y" (XMLgetShortFloatToString 0.1)]::["z" (XMLgetShortFloatToString 0.1)]::nil nil; XMLaddMark xmlEditSceneFile "centerOfMass" newbodystr ["auto" (XMLgetBoolString 1)]::["x" "0"]::["y" "0"]::["z" "0"]::nil nil; XMLaddMark xmlEditSceneFile "bodySize" newbodystr ["x" (XMLgetShortFloatToString bx)]::["y" (XMLgetShortFloatToString by)]::["z" (XMLgetShortFloatToString bz)]::nil nil; SO3BodySetType (SO3BodyCreateCollisionTree node 1) 4; set i = i + 1; ); 0; ) else if (!strcmpi (XMLgetParam bodystr "type") "none") then ( XMLsetParam bodystr "type" "collisionTree"; SO3BodySetType (SO3BodyCreateCollisionTree node 1) 4; set i = i + 1; 0; ) else nil; ); set lentity = tl lentity; ); if (i != 0) then _DLGMessageBox _channel mainInterf.MINT_winMain.EDW_win (loc "OS3D_0207") strcatn (itoa i)::" "::(loc "OS3D_0002")::nil 0 else _DLGMessageBox _channel mainInterf.MINT_winMain.EDW_win (loc "OS3D_0207") (loc "OS3D_0274") 0; ); 0;; /** cbDestroyPhysicSetupWin [EdWindow] I * callback on destroy physic window * * private * * return 0 **/ fun cbDestroyPhysicSetupWin(winstr)= set winPhysicSetup = nil; 0;; fun cbTreeMenuSetPhysicSetup(mnuitem, p)= if winPhysicSetup == nil then nil else ( dsEdWindow winPhysicSetup; set winPhysicSetup = nil; ); let p -> [viewstr val type markstr] in let [400 140] -> [iw ih] in let _GETdesktopSize -> [sw sh] in let _GETscreenPos -> [mx my] in let [(if ((mx + iw) > sw) then (sw - iw) else mx) (if ((my + ih) > sh) then (sh - ih) else my)] -> [x y] in let V3DgetDefaultSession viewstr -> sessionstr in let XMLgetMarkByValueFromMarkSons markstr "environment" -> envmark in let XMLgetMarkByValueFromMarkSons envmark "physic" -> physicmark in let XMLgetBoolParam physicmark "enable" -> physstate in let atof XMLgetParam physicmark "framerate" -> physfps in let if physfps == nil then 120.0 else physfps ->physfps in //let XMLgetParam physicmark "architectureModel" -> archmodel in //let if archmodel == nil then (V3DphysGetArchitectureModeName sessionstr) else archmodel -> archmodel in let XMLgetParam physicmark "solverModel" -> solvermodel in let if solvermodel == nil then (V3DphysGetSolverModeName sessionstr) else solvermodel -> solvermodel in let XMLgetMarkByValueFromMarkSons physicmark "gravity" -> gravitymark in let atof XMLgetParam gravitymark "x" -> gx in let atof XMLgetParam gravitymark "y" -> gy in let atof XMLgetParam gravitymark "z" -> gz in let if gravitymark == nil then (V3DphysGetGravity sessionstr) else [gx gy gz] -> [gx gy gz] in let setEdWindowIcon (crEdDialogWindow _channel mainInterf.MINT_winMain x y iw ih WN_NOSCOL|WN_MENU nil (loc "OS3D_0298")) sWinDlgIcon -> dwinstr in let crEdWindow _channel dwinstr 0 0 iw ih WN_CHILDINSIDE|WN_NOBORDER nil nil "" -> winstr in let 10 -> ypos in //let crEdCtrlLabel winstr 10 ypos + 2 160 20 (loc "OS3D_0052") nil -> labelarch in //let crEdCtrlSelect winstr 180 ypos 190 120 EDWIN_RESIZE_MW -> ctrlarch in let crEdCtrlLabel winstr 10 (ypos + 2) 160 20 (loc "OS3D_0403") nil -> labelsolver in let crEdCtrlSelect winstr 180 ypos 190 120 EDWIN_RESIZE_MW -> ctrlsolver in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3D_0295") nil -> labelfps in let crEdCtrlFloat winstr 180 ypos 100 20 physfps 120.0 600.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlfps in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3D_0178") nil -> labelgravity in let crEdCtrlFloat winstr 180 ypos 65 20 gx (-.1000000.0) 1000000.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlgx in let crEdCtrlFloat winstr 250 ypos 65 20 gy (-.1000000.0) 1000000.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlgy in let crEdCtrlFloat winstr 320 ypos 65 20 gz (-.1000000.0) 1000000.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlgz in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) (iw - 20) 20 (loc "OS3D_0138") EDWIN_RESIZE_MW -> ctrlenable in let crEdCtrlButton winstr ((iw / 2) - 115) (set ypos = ypos + 25) 230 20 (loc "OS3D_0175") EDWIN_RESIZE_MW -> ctrlGenerateCollisions in ( set winPhysicSetup = dwinstr; //fillEdCtrlSelect ctrlarch "default"::"medium"::"best"::nil; fillEdCtrlSelect ctrlsolver "exact"::"iterative one passes"::"iterative two passes"::"iterative four pass"::"iterative eight pass"::nil; setEdCtrlCheckState ctrlenable physstate; //selectEdCtrlSelect ctrlarch archmodel; selectEdCtrlSelect ctrlsolver if (!strcmpi solvermodel "adaptative") then "iterative one passes" else solvermodel; //setEdCtrlSelectCb ctrlarch mkfun4 @cbPhysicSetupArchMode p; setEdCtrlSelectCb ctrlsolver mkfun4 @cbPhysicSetupSolverMode p; setEdCtrlFloatCbChange ctrlfps mkfun3 @cbPhysicSetupWorldFps p; setEdCtrlFloatCbChange ctrlgx mkfun3 @cbPhysicSetupWorldGravityX p; setEdCtrlFloatCbChange ctrlgy mkfun3 @cbPhysicSetupWorldGravityY p; setEdCtrlFloatCbChange ctrlgz mkfun3 @cbPhysicSetupWorldGravityZ p; setEdCtrlCheckCbState ctrlenable mkfun3 @cbPhysicSetupEnable p; setEdCtrlButtonCb ctrlGenerateCollisions mkfun2 @cbPhysicSetupGenerateCollisions viewstr; setEdwindowCbDestroy winPhysicSetup @cbDestroyPhysicSetupWin; 0; ); 0;; /* ********************************************************************************************* / Physic bodies / ********************************************************************************************* */ fun cbPhysicBodySetupType(ctrl, pos, elem, p)= let p -> [[viewstr val type markstr] nodestaticgeometry ctrlax ctrlay ctrlaz ctrlldumping ctrlcentermassauto ctrlcmx ctrlcmy ctrlcmz ctrlmass ctrlcontinuous ctrlmatname ctrladdmat ctrlbtnaddmat ctrlautosleep ctrlenable ctrlbx ctrlby ctrlbz ctrlopx ctrlopy ctrlopz ctrloax ctrloay ctrloaz ctrlbtnresetsize ctrlfluid ctrlfluidratio] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let V3DphysGetUniformBoundingBox node -> [bx by bz] in ( if bodystr == nil then ( let XMLaddMark xmlEditSceneFile "body" markstr ["type" elem]::["material" "default"]::["mass" (XMLgetShortFloatToString 0.0)]::["continuousColl" (XMLgetBoolString 0)]::["fluid" (XMLgetBoolString 0)]::["fluidVolume" (XMLgetShortFloatToString 0.9)]::["autoSleep" (XMLgetBoolString 1)]::["enable" (XMLgetBoolString 0)]::nil nil -> newbodystr in ( XMLaddMark xmlEditSceneFile "damping" newbodystr ["linear" (XMLgetShortFloatToString 0.1)]::["x" (XMLgetShortFloatToString 0.1)]::["y" (XMLgetShortFloatToString 0.1)]::["z" (XMLgetShortFloatToString 0.1)]::nil nil; XMLaddMark xmlEditSceneFile "centerOfMass" newbodystr ["auto" (XMLgetBoolString 1)]::["x" "0"]::["y" "0"]::["z" "0"]::nil nil; XMLaddMark xmlEditSceneFile "bodySize" newbodystr ["x" (XMLgetShortFloatToString bx)]::["y" (XMLgetShortFloatToString by)]::["z" (XMLgetShortFloatToString bz)]::nil nil; XMLaddMark xmlEditSceneFile "bodyOffset" newbodystr ["px" (XMLgetShortFloatToString 0.0)]::["py" (XMLgetShortFloatToString 0.0)]::["pz" (XMLgetShortFloatToString 0.0)]::["ax" (XMLgetShortFloatToString 0.0)]::["ay" (XMLgetShortFloatToString 0.0)]::["az" (XMLgetShortFloatToString 0.0)]::nil nil; set bodystr = newbodystr; ); 0; ) else ( XMLsetParam bodystr "type" elem; let XMLgetMarkByValueFromMarkSons bodystr "bodySize" -> bodysizestr in if (bodysizestr != nil) then nil else ( XMLaddMark xmlEditSceneFile "bodySize" bodystr ["x" (XMLgetShortFloatToString bx)]::["y" (XMLgetShortFloatToString by)]::["z" (XMLgetShortFloatToString bz)]::nil nil; ); let XMLgetMarkByValueFromMarkSons bodystr "bodyOffset" -> offsetstr in if (offsetstr != nil) then nil else ( XMLaddMark xmlEditSceneFile "bodyOffset" bodystr ["px" (XMLgetShortFloatToString 0.0)]::["py" (XMLgetShortFloatToString 0.0)]::["pz" (XMLgetShortFloatToString 0.0)]::["ax" (XMLgetShortFloatToString 0.0)]::["ay" (XMLgetShortFloatToString 0.0)]::["az" (XMLgetShortFloatToString 0.0)]::nil nil; ); 0; ); if (!nodestaticgeometry) then nil else SO3ObjectSetAsStaticGeometry node 1; let XMLgetMarkByValueFromMarkSons bodystr "bodySize" -> bodysizestr in let atof XMLgetParam bodysizestr "x" -> sizex in let atof XMLgetParam bodysizestr "y" -> sizey in let atof XMLgetParam bodysizestr "z" -> sizez in let XMLgetMarkByValueFromMarkSons bodystr "bodyOffset" -> offsetstr in let atof XMLgetParam offsetstr "px" -> offsetpx in let atof XMLgetParam offsetstr "py" -> offsetpy in let atof XMLgetParam offsetstr "pz" -> offsetpz in let atof XMLgetParam offsetstr "ax" -> offsetax in let atof XMLgetParam offsetstr "ay" -> offsetay in let atof XMLgetParam offsetstr "az" -> offsetaz in if (!strcmpi elem "none") then ( SO3BodyDestroy (SO3SceneNodeGetBody node); 0; ) else if (!strcmpi elem "collisionTree") then ( SO3BodySetType (SO3BodyCreateCollisionTree node 1) 4; 0; ) else if (!strcmpi elem "ellipsoid") then ( if ((V3DphysCreateBodyEllipsoidExt node [sizex sizey sizez] (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz])) != nil) then nil else ( _DLGMessageBox _channel mainInterf.MINT_winMain.EDW_win (loc "OS3D_0155") (loc "OS3D_0429") 0; set elem = "none"; selectEdCtrlSelect ctrl "none"; ); 0; ) else if (!strcmpi elem "box") then ( V3DphysCreateBodyBoxExt node [sizex sizey sizez] (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]); 0; ) else if (!strcmpi elem "shape") then ( if ((SO3BodyCreateShape node 0.0) != nil) then nil else ( _DLGMessageBox _channel mainInterf.MINT_winMain.EDW_win (loc "OS3D_0155") (loc "OS3D_0429") 0; set elem = "none"; selectEdCtrlSelect ctrl "none"; ); 0; ) else if (!strcmpi elem "concave") then ( if ((SO3BodyCreateConcaveShape node 0.0) != nil) then nil else ( _DLGMessageBox _channel mainInterf.MINT_winMain.EDW_win (loc "OS3D_0155") (loc "OS3D_0429") 0; set elem = "none"; selectEdCtrlSelect ctrl "none"; ); 0; ) else if (!strcmpi elem "cylinder") then ( V3DphysCreateBodyCylinderExt node [sizex sizey sizez] (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]); 0; ) else if (!strcmpi elem "chamfer cylinder") then ( V3DphysCreateBodyChamferCylinderExt node [sizex sizey sizez] (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]); 0; ) else if (!strcmpi elem "capsule") then ( V3DphysCreateBodyCapsuleExt node [sizex sizey sizez] (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]); 0; ) else if (!strcmpi elem "cone") then ( V3DphysCreateBodyConeExt node [sizex sizey sizez] (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]); 0; ) else if (!strcmpi elem "pyramid") then ( V3DphysCreateBodyPyramidExt node [sizex sizey sizez] (if offsetstr == nil then nil else [offsetpx offsetpy offsetpz]) (if offsetstr == nil then nil else [offsetax offsetay offsetaz]); 0; ) else nil; if (!nodestaticgeometry) then nil else SO3ObjectSetAsStaticGeometry node 0; if (!strcmpi elem "none") then nil else ( let XMLgetParam bodystr "material" -> bodymatname in let atof XMLgetParam bodystr "mass" -> bodymass in let XMLgetBoolParam bodystr "enable" -> bodyenable in let XMLgetBoolParam bodystr "autoSleep" -> bodyautosleep in let XMLgetBoolParam bodystr "continuousColl" -> bodycontinuous in let XMLgetBoolParam bodystr "fluid" -> bodyfluid in let atof XMLgetParam bodystr "fluidVolume" -> bodyfluidvolume in let XMLgetMarkByValueFromMarkSons bodystr "damping" -> dampingstr in let atof XMLgetParam dampingstr "linear" -> bodydampingl in let atof XMLgetParam dampingstr "x" -> bodydampingx in let atof XMLgetParam dampingstr "y" -> bodydampingy in let atof XMLgetParam dampingstr "z" -> bodydampingz in let XMLgetMarkByValueFromMarkSons bodystr "centerOfMass" -> centermassstr in let if centermassstr == nil then 1 else XMLgetBoolParam centermassstr "auto" -> centermassauto in let atof XMLgetParam centermassstr "x" -> centermassx in let atof XMLgetParam centermassstr "y" -> centermassy in let atof XMLgetParam centermassstr "z" -> centermassz in let (SO3SceneNodeGetBody node) -> body in ( V3DphysSetBodyMaterial sessionstr body bodymatname; addPhysicMaterial bodymatname; SO3BodySetMass body bodymass; SO3BodySetContiniousCollisionMode body bodycontinuous; SO3BodySetAutoSleep body bodyautosleep; SO3BodySetCenterOfMass body if centermassauto then SO3BodyCalculateOffset body else [centermassx centermassy centermassz]; SO3BodySetFluid body bodyfluid; SO3BodySetFluidVolumeRatio body bodyfluidvolume; if dampingstr == nil then nil else ( SO3BodySetLinearDamping body bodydampingl; SO3BodySetAngularDamping body [bodydampingx bodydampingy bodydampingz]; ); V3DphysFreezeBody body bodyenable; ); ); if (strcmpi elem "none") then ( setEdCtrlListEnable ctrlmatname 1; setEdCtrlCheckEnable ctrlcontinuous 1; setEdCtrlCheckEnable ctrlenable 1; setEdCtrlCheckEnable ctrlautosleep 1; setEdCtrlTextLineEnable ctrladdmat 1; setEdCtrlButtonEnable ctrlbtnaddmat 1; setEdCtrlFloatEnable ctrlax 1; setEdCtrlFloatEnable ctrlay 1; setEdCtrlFloatEnable ctrlaz 1; setEdCtrlFloatEnable ctrlldumping 1; setEdCtrlFloatEnable ctrlmass 1; setEdCtrlCheckEnable ctrlcentermassauto 1; setEdCtrlCheckEnable ctrlfluid 1; let getEdCtrlCheckState ctrlfluid -> fluid in setEdCtrlFloatEnable ctrlfluidratio fluid; let getEdCtrlCheckState ctrlcentermassauto -> auto in ( setEdCtrlFloatEnable ctrlcmx auto; setEdCtrlFloatEnable ctrlcmy auto; setEdCtrlFloatEnable ctrlcmz auto; ); let if ((!strcmpi elem "collisionTree") || (!strcmpi elem "shape") || (!strcmpi elem "concave")) then 0 else 1 -> btype in ( setEdCtrlFloatEnable ctrlbx btype; setEdCtrlFloatEnable ctrlby btype; setEdCtrlFloatEnable ctrlbz btype; setEdCtrlFloatEnable ctrlopx btype; setEdCtrlFloatEnable ctrlopy btype; setEdCtrlFloatEnable ctrlopz btype; setEdCtrlFloatEnable ctrloax btype; setEdCtrlFloatEnable ctrloay btype; setEdCtrlFloatEnable ctrloaz btype; setEdCtrlButtonEnable ctrlbtnresetsize btype; ); 0; ) else ( setEdCtrlListEnable ctrlmatname 0; setEdCtrlCheckEnable ctrlcontinuous 0; setEdCtrlCheckEnable ctrlenable 0; setEdCtrlCheckEnable ctrlautosleep 0; setEdCtrlTextLineEnable ctrladdmat 0; setEdCtrlButtonEnable ctrlbtnaddmat 0; setEdCtrlFloatEnable ctrlax 0; setEdCtrlFloatEnable ctrlay 0; setEdCtrlFloatEnable ctrlaz 0; setEdCtrlFloatEnable ctrlldumping 0; setEdCtrlFloatEnable ctrlmass 0; setEdCtrlCheckEnable ctrlcentermassauto 0; setEdCtrlFloatEnable ctrlcmx 0; setEdCtrlFloatEnable ctrlcmy 0; setEdCtrlFloatEnable ctrlcmz 0; setEdCtrlFloatEnable ctrlbx 0; setEdCtrlFloatEnable ctrlby 0; setEdCtrlFloatEnable ctrlbz 0; setEdCtrlFloatEnable ctrlopx 0; setEdCtrlFloatEnable ctrlopy 0; setEdCtrlFloatEnable ctrlopz 0; setEdCtrlFloatEnable ctrloax 0; setEdCtrlFloatEnable ctrloay 0; setEdCtrlFloatEnable ctrloaz 0; setEdCtrlButtonEnable ctrlbtnresetsize 0; setEdCtrlCheckEnable ctrlfluid 0; setEdCtrlFloatEnable ctrlfluidratio 0; 0; ); SO3BodyShowDebug (SO3SceneNodeGetBody node) 1; ); 0;; fun cbPhysicBodySetupdampingAng(ctrl, value, p)= let p -> [[viewstr val type markstr] ctrlax ctrlay ctrlaz] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let XMLgetMarkByValueFromMarkSons bodystr "damping" -> dampingstr in let getEdCtrlFloatValue ctrlax -> ax in let getEdCtrlFloatValue ctrlay -> ay in let getEdCtrlFloatValue ctrlaz -> az in ( XMLsetParam dampingstr "x" (XMLgetShortFloatToString ax); XMLsetParam dampingstr "y" (XMLgetShortFloatToString ay); XMLsetParam dampingstr "z" (XMLgetShortFloatToString az); SO3BodySetAngularDamping (SO3SceneNodeGetBody node) [ax ay az]; ); 0;; fun cbPhysicBodySetupDampingLinear(ctrl, value, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let XMLgetMarkByValueFromMarkSons bodystr "damping" -> dampingstr in ( XMLsetParam dampingstr "linear" (XMLgetShortFloatToString value); SO3BodySetLinearDamping (SO3SceneNodeGetBody node) value; ); 0;; fun cbPhysicBodySetupAutoCenterOfMass(ctrl, state, p)= let p -> [[viewstr val type markstr] ctrlcmx ctrlcmy ctrlcmz] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let XMLgetMarkByValueFromMarkSons bodystr "centerOfMass" -> centerofmassstr in let getEdCtrlFloatValue ctrlcmx -> x in let getEdCtrlFloatValue ctrlcmy -> y in let getEdCtrlFloatValue ctrlcmz -> z in ( XMLsetParam centerofmassstr "auto" (XMLgetBoolString !state); SO3BodySetCenterOfMass (SO3SceneNodeGetBody node) if !state then SO3BodyCalculateOffset (SO3SceneNodeGetBody node) else [x y z]; setEdCtrlFloatEnable ctrlcmx state; setEdCtrlFloatEnable ctrlcmy state; setEdCtrlFloatEnable ctrlcmz state; ); 0;; fun cbPhysicBodySetupCenterOfMass(ctrl, value, p)= let p -> [[viewstr val type markstr] ctrlauto ctrlcmx ctrlcmy ctrlcmz] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let XMLgetMarkByValueFromMarkSons bodystr "centerOfMass" -> centerofmassstr in let getEdCtrlCheckState ctrlauto -> state in let getEdCtrlFloatValue ctrlcmx -> x in let getEdCtrlFloatValue ctrlcmy -> y in let getEdCtrlFloatValue ctrlcmz -> z in ( XMLsetParam centerofmassstr "x" (XMLgetShortFloatToString x); XMLsetParam centerofmassstr "y" (XMLgetShortFloatToString y); XMLsetParam centerofmassstr "z" (XMLgetShortFloatToString z); SO3BodySetCenterOfMass (SO3SceneNodeGetBody node) if !state then SO3BodyCalculateOffset (SO3SceneNodeGetBody node) else [x y z]; ); 0;; fun cbPhysicBodySetupSize(ctrl, value, p)= let p -> [[viewstr val type markstr] ctrlcmx ctrlcmy ctrlcmz] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let XMLgetMarkByValueFromMarkSons bodystr "bodySize" -> bodysizestr in let getEdCtrlFloatValue ctrlcmx -> x in let getEdCtrlFloatValue ctrlcmy -> y in let getEdCtrlFloatValue ctrlcmz -> z in ( if (bodysizestr == nil) then ( XMLaddMark xmlEditSceneFile "bodySize" bodystr ["x" (XMLgetShortFloatToString x)]::["y" (XMLgetShortFloatToString y)]::["z" (XMLgetShortFloatToString z)]::nil nil; 0; ) else ( XMLsetParam bodysizestr "x" (XMLgetShortFloatToString x); XMLsetParam bodysizestr "y" (XMLgetShortFloatToString y); XMLsetParam bodysizestr "z" (XMLgetShortFloatToString z); ); updatePhysicsBody sessionstr markstr node; ); 0;; fun cbPhysicBodySetupOffset(ctrl, value, p)= let p -> [[viewstr val type markstr] ctrlopx ctrlopy ctrlopz ctrloax ctrloay ctrloaz] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let XMLgetMarkByValueFromMarkSons bodystr "bodyOffset" -> offsetstr in let getEdCtrlFloatValue ctrlopx -> x in let getEdCtrlFloatValue ctrlopy -> y in let getEdCtrlFloatValue ctrlopz -> z in let getEdCtrlFloatValue ctrloax -> ax in let getEdCtrlFloatValue ctrloay -> ay in let getEdCtrlFloatValue ctrloaz -> az in ( if (offsetstr == nil) then ( XMLaddMark xmlEditSceneFile "bodyOffset" bodystr ["px" (XMLgetShortFloatToString x)]::["py" (XMLgetShortFloatToString y)]::["pz" (XMLgetShortFloatToString z)]::["ax" (XMLgetShortFloatToString ax)]::["ay" (XMLgetShortFloatToString ay)]::["az" (XMLgetShortFloatToString az)]::nil nil; 0; ) else ( XMLsetParam offsetstr "px" (XMLgetShortFloatToString x); XMLsetParam offsetstr "py" (XMLgetShortFloatToString y); XMLsetParam offsetstr "pz" (XMLgetShortFloatToString z); XMLsetParam offsetstr "ax" (XMLgetShortFloatToString ax); XMLsetParam offsetstr "ay" (XMLgetShortFloatToString ay); XMLsetParam offsetstr "az" (XMLgetShortFloatToString az); ); updatePhysicsBody sessionstr markstr node; ); 0;; fun cbPhysicBodySetupMaterial(ctrlstr, pos, value, lval, type, p)= let p -> [[viewstr val type markstr] ctrlbtnremovemat] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let if ((value == nil) || (!strcmp "" (strtrim value))) then "default" else value -> value in ( XMLsetParam bodystr "material" value; V3DphysSetBodyMaterial sessionstr (SO3SceneNodeGetBody node) value; //set lPhysicMaterial = quicksort value::lPhysicMaterial @suppDoublon; //updateScenePhysicsMaterialList; fillEdCtrlList ctrlstr lPhysicMaterial; selectEdCtrlList ctrlstr value; if (strcmpi "default" value) && (strcmpi "avatar" value) then setEdCtrlButtonEnable ctrlbtnremovemat 1 else setEdCtrlButtonEnable ctrlbtnremovemat 0; ); 0;; fun cbPhysicBodySetupBtnAddMaterial(ctrlstr, p)= let p -> [np ctrlmatname ctrladdmat ctrlbtnremovemat] in let getEdCtrlTextLineValue ctrladdmat -> value in if (!strcmp "" (strtrim value)) then nil else ( addPhysicMaterial value; cbPhysicBodySetupMaterial ctrlmatname nil value nil nil [np ctrlbtnremovemat]; setEdCtrlTextLineValue ctrladdmat ""; ); 0;; fun cbPhysicBodySetupBtnRemoveMaterial(ctrlstr, p)= let p -> [np ctrlmatname ctrladdmat ctrlbtnremovemat] in let getSelectedEdCtrlList ctrlmatname -> [value _ _] in let (strtrim value) -> value in if (!strcmp "" value) || (!strcmpi "default" value) || (!strcmpi "avatar" value) then nil else ( removePhysicMaterial(value); cbPhysicBodySetupMaterial ctrlmatname nil "default" nil nil [np ctrlbtnremovemat]; setEdCtrlTextLineValue ctrladdmat ""; ); 0;; fun cbPhysicBodySetupAddMaterial(ctrlstr, value, p)= let p -> [np ctrlmatname ctrlbtnremovemat] in if (!strcmp "" (strtrim value)) then nil else ( addPhysicMaterial value; cbPhysicBodySetupMaterial ctrlmatname nil value nil nil [np ctrlbtnremovemat]; setEdCtrlTextLineValue ctrlstr ""; ); 0;; fun cbPhysicBodySetupMass(ctrl, value, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in ( XMLsetParam bodystr "mass" (XMLgetShortFloatToString value); SO3BodySetMass (SO3SceneNodeGetBody node) value; ); 0;; fun cbPhysicBodySetupContinuous(ctrl, state, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in ( XMLsetParam bodystr "continuousColl" (XMLgetBoolString state); SO3BodySetContiniousCollisionMode (SO3SceneNodeGetBody node) state; ); 0;; fun cbPhysicBodySetupFluid(ctrl, state, p)= let p -> [[viewstr val type markstr] ctrlfluidratio] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in ( XMLsetParam bodystr "fluid" (XMLgetBoolString state); SO3BodySetFluid (SO3SceneNodeGetBody node) state; setEdCtrlFloatEnable ctrlfluidratio state; ); 0;; fun cbPhysicBodySetupFluidRatio(ctrl, value, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in ( XMLsetParam bodystr "fluidVolume" (XMLgetShortFloatToString value); SO3BodySetFluidVolumeRatio (SO3SceneNodeGetBody node) value; ); 0;; fun cbPhysicBodySetupAutoSleep(ctrl, state, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in ( XMLsetParam bodystr "autoSleep" (XMLgetBoolString state); SO3BodySetAutoSleep (SO3SceneNodeGetBody node) state; ); 0;; fun cbPhysicBodySetupEnable(ctrl, state, p)= let p -> [viewstr val type markstr] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in ( XMLsetParam bodystr "enable" (XMLgetBoolString !state); V3DphysFreezeBody (SO3SceneNodeGetBody node) !state; setGraphItemInitState val !state; ); 0;; fun cbPhysicBodySetupBtnResetSize(ctrl, p)= let p -> [[viewstr val type markstr] ctrlcmx ctrlcmy ctrlcmz] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let XMLgetMarkByValueFromMarkSons bodystr "bodySize" -> bodysizestr in let V3DphysGetUniformBoundingBox node -> [x y z] in ( setEdCtrlFloatValue ctrlcmx x; setEdCtrlFloatValue ctrlcmy y; setEdCtrlFloatValue ctrlcmz z; if (bodysizestr == nil) then ( XMLaddMark xmlEditSceneFile "bodySize" bodystr ["x" (XMLgetShortFloatToString x)]::["y" (XMLgetShortFloatToString y)]::["z" (XMLgetShortFloatToString z)]::nil nil; 0; ) else ( XMLsetParam bodysizestr "x" (XMLgetShortFloatToString x); XMLsetParam bodysizestr "y" (XMLgetShortFloatToString y); XMLsetParam bodysizestr "z" (XMLgetShortFloatToString z); ); updatePhysicsBody sessionstr markstr node; ); 0;; /** cbDestroyPhysicSetupWin [EdWindow] I * callback on destroy physic body window * * private * * return 0 **/ fun cbDestroyPhysicBodySetupWin(winstr)= let winPhysicBodySetup -> [node _] in SO3BodyShowDebug (SO3SceneNodeGetBody node) 0; set winPhysicBodySetup = nil; 0;; fun cbTreeMenuSetPhysicBodySetup(mnuitem, p)= if winPhysicBodySetup == nil then nil else ( let winPhysicBodySetup -> [_ winstr] in dsEdWindow winstr; set winPhysicBodySetup = nil; ); let p -> [viewstr val type markstr] in let [400 410] -> [iw ih] in let 10 -> ypos in let _GETWorkingAreaSize -> [sw sh] in let _GETscreenPos -> [mx my] in let [(if ((mx + iw) > sw) then (sw - iw) else mx) (if ((my + ih) > sh) then (sh - ih) else my)] -> [x y] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> node in let XMLgetBoolParam markstr "staticGeometry" -> nodestaticgeometry in let XMLgetMarkByValueFromMarkSons markstr "body" -> bodystr in let XMLgetParam bodystr "type" -> bodytype in let XMLgetParam bodystr "material" -> bodymatname in let XMLgetMarkByValueFromMarkSons bodystr "bodyOffset" -> offsetstr in let atof XMLgetParam offsetstr "px" -> offsetpx in let atof XMLgetParam offsetstr "py" -> offsetpy in let atof XMLgetParam offsetstr "pz" -> offsetpz in let atof XMLgetParam offsetstr "ax" -> offsetax in let atof XMLgetParam offsetstr "ay" -> offsetay in let atof XMLgetParam offsetstr "az" -> offsetaz in let atof XMLgetParam bodystr "mass" -> bodymass in let XMLgetBoolParam bodystr "enable" -> bodyenable in let if ((XMLgetParam bodystr "autoSleep") == nil) then 1 else XMLgetBoolParam bodystr "autoSleep" -> bodyautosleep in let XMLgetBoolParam bodystr "continuousColl" -> bodycontinuous in let XMLgetBoolParam bodystr "fluid" -> bodyfluid in let atof XMLgetParam bodystr "fluidVolume" -> bodyfluidvolume in let if bodyfluidvolume == nil then 0.9 else bodyfluidvolume -> bodyfluidvolume in let XMLgetMarkByValueFromMarkSons bodystr "damping" -> dampingstr in let atof XMLgetParam dampingstr "linear" -> bodydampingl in let atof XMLgetParam dampingstr "x" -> bodydampingx in let atof XMLgetParam dampingstr "y" -> bodydampingy in let atof XMLgetParam dampingstr "z" -> bodydampingz in let XMLgetMarkByValueFromMarkSons bodystr "centerOfMass" -> centermassstr in let if centermassstr == nil then 1 else XMLgetBoolParam centermassstr "auto" -> centermassauto in let atof XMLgetParam centermassstr "x" -> centermassx in let atof XMLgetParam centermassstr "y" -> centermassy in let atof XMLgetParam centermassstr "z" -> centermassz in let XMLgetMarkByValueFromMarkSons bodystr "bodySize" -> bodysizestr in let atof XMLgetParam bodysizestr "x" -> sizex in let atof XMLgetParam bodysizestr "y" -> sizey in let atof XMLgetParam bodysizestr "z" -> sizez in let if (bodysizestr != nil) then [sizex sizey sizez] else V3DphysGetUniformBoundingBox node -> [sizex sizey sizez] in let if bodymatname == nil then "default" else bodymatname -> bodymatname in let if bodydampingl == nil then 0.1 else bodydampingl -> bodydampingl in let if bodydampingx == nil then 0.1 else bodydampingx -> bodydampingx in let if bodydampingy == nil then 0.1 else bodydampingy -> bodydampingy in let if bodydampingz == nil then 0.1 else bodydampingz -> bodydampingz in let setEdWindowIcon (crEdDialogWindow _channel mainInterf.MINT_winMain x y iw ih WN_NOSCOL|WN_MENU nil strcat (strcat (loc "OS3D_0297") " ") val) sWinDlgIcon -> dwinstr in let crEdWindow _channel dwinstr 0 0 iw ih WN_CHILDINSIDE|WN_NOBORDER nil nil "" -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3D_0078") nil -> labeltype in let crEdCtrlSelect winstr 180 ypos 210 120 EDWIN_RESIZE_MW -> ctrltype in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3D_0296") nil -> labelobj in let crEdCtrlList winstr 180 ypos 210 60 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlmatname in let crEdCtrlTextLine winstr 180 ((set ypos = ypos + 65) + 2) 160 20 nil nil EDWIN_RESIZE_MW -> ctrladdmat in let crEdCtrlButton winstr 345 ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnaddmat in let crEdCtrlButton winstr 370 ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtnremovemat in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3D_0077") nil -> labelsize in let crEdCtrlFloat winstr 180 ypos 65 20 sizex 0.001 1000000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlbx in let crEdCtrlFloat winstr 250 ypos 65 20 sizey 0.001 1000000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlby in let crEdCtrlFloat winstr 320 ypos 65 20 sizez 0.001 1000000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlbz in let crEdCtrlButton winstr 385 ypos 15 20 "R" EDWIN_RESIZE_MW -> ctrlbtnresetsize in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3D_0676") nil -> labeloffsetp in let crEdCtrlFloat winstr 180 ypos 65 20 offsetpx (-.1000000.0) 1000000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlopx in let crEdCtrlFloat winstr 250 ypos 65 20 offsetpy (-.1000000.0) 1000000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlopy in let crEdCtrlFloat winstr 320 ypos 65 20 offsetpz (-.1000000.0) 1000000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlopz in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3D_0677") nil -> labeloffseta in let crEdCtrlFloat winstr 180 ypos 65 20 offsetax (-.180.0) 180.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrloax in let crEdCtrlFloat winstr 250 ypos 65 20 offsetay (-.180.0) 180.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrloay in let crEdCtrlFloat winstr 320 ypos 65 20 offsetaz (-.180.0) 180.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrloaz in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 30) + 2) 160 20 (loc "OS3D_0045") nil -> labelangular in let crEdCtrlFloat winstr 180 ypos 65 20 bodydampingx 0.0 1.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlax in let crEdCtrlFloat winstr 250 ypos 65 20 bodydampingy 0.0 1.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlay in let crEdCtrlFloat winstr 320 ypos 65 20 bodydampingz 0.0 1.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlaz in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3D_0225") nil -> labellinear in let crEdCtrlFloat winstr 180 ypos 100 20 bodydampingl 0.0 1.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlldumping in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3D_0238") nil -> labelmass in let crEdCtrlFloat winstr 180 ypos 100 20 bodymass 0.0 10000000.0 0.1 3 nil EDWIN_RESIZE_MW -> ctrlmass in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 160 20 (loc "OS3D_0237") EDWIN_RESIZE_MW -> ctrlcentermassauto in let crEdCtrlFloat winstr 180 ypos 65 20 centermassx (-.1000000.0) 1000000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlcmx in let crEdCtrlFloat winstr 250 ypos 65 20 centermassy (-.1000000.0) 1000000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlcmy in let crEdCtrlFloat winstr 320 ypos 65 20 centermassz (-.1000000.0) 1000000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlcmz in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 275 20 (loc "OS3D_0018") EDWIN_RESIZE_MW -> ctrlfluid in let crEdCtrlFloat winstr 320 ypos 65 20 bodyfluidvolume 0.0 1.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlfluidratio in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 190 20 (loc "OS3D_0100") EDWIN_RESIZE_MW -> ctrlcontinuous in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 190 20 (loc "OS3D_0072") EDWIN_RESIZE_MW -> ctrlautosleep in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 190 20 (loc "OS3D_0171") EDWIN_RESIZE_MW -> ctrlenable in ( fillEdCtrlList ctrlmatname lPhysicMaterial; selectEdCtrlList ctrlmatname bodymatname; if (strcmpi "default" bodymatname) && (strcmpi "avatar" bodymatname) then setEdCtrlButtonEnable ctrlbtnremovemat 1 else setEdCtrlButtonEnable ctrlbtnremovemat 0; set winPhysicBodySetup = [node dwinstr]; //show physic shape SO3BodyShowDebug (SO3SceneNodeGetBody node) 1; if (strcmpi bodytype "none") && (bodytype != nil) then ( setEdCtrlListEnable ctrlmatname 1; setEdCtrlCheckEnable ctrlcontinuous 1; setEdCtrlCheckEnable ctrlenable 1; setEdCtrlCheckEnable ctrlautosleep 1; setEdCtrlTextLineEnable ctrladdmat 1; setEdCtrlButtonEnable ctrlbtnaddmat 1; setEdCtrlFloatEnable ctrlax 1; setEdCtrlFloatEnable ctrlay 1; setEdCtrlFloatEnable ctrlaz 1; setEdCtrlFloatEnable ctrlldumping 1; setEdCtrlFloatEnable ctrlmass 1; setEdCtrlCheckEnable ctrlcentermassauto 1; setEdCtrlFloatEnable ctrlcmx !centermassauto; setEdCtrlFloatEnable ctrlcmy !centermassauto; setEdCtrlFloatEnable ctrlcmz !centermassauto; setEdCtrlCheckEnable ctrlfluid 1; setEdCtrlFloatEnable ctrlfluidratio bodyfluid; let if ((!strcmpi bodytype "collisionTree") || (!strcmpi bodytype "shape") || (!strcmpi bodytype "concave")) then 0 else 1 -> btype in ( setEdCtrlFloatEnable ctrlbx btype; setEdCtrlFloatEnable ctrlby btype; setEdCtrlFloatEnable ctrlbz btype; setEdCtrlFloatEnable ctrlopx btype; setEdCtrlFloatEnable ctrlopy btype; setEdCtrlFloatEnable ctrlopz btype; setEdCtrlFloatEnable ctrloax btype; setEdCtrlFloatEnable ctrloay btype; setEdCtrlFloatEnable ctrloaz btype; setEdCtrlButtonEnable ctrlbtnresetsize btype; ); 0; ) else ( setEdCtrlListEnable ctrlmatname 0; setEdCtrlCheckEnable ctrlcontinuous 0; setEdCtrlCheckEnable ctrlenable 0; setEdCtrlCheckEnable ctrlautosleep 0; setEdCtrlTextLineEnable ctrladdmat 0; setEdCtrlButtonEnable ctrlbtnaddmat 0; setEdCtrlFloatEnable ctrlax 0; setEdCtrlFloatEnable ctrlay 0; setEdCtrlFloatEnable ctrlaz 0; setEdCtrlFloatEnable ctrlldumping 0; setEdCtrlFloatEnable ctrlmass 0; setEdCtrlCheckEnable ctrlcentermassauto 0; setEdCtrlFloatEnable ctrlcmx 0; setEdCtrlFloatEnable ctrlcmy 0; setEdCtrlFloatEnable ctrlcmz 0; setEdCtrlFloatEnable ctrlbx 0; setEdCtrlFloatEnable ctrlby 0; setEdCtrlFloatEnable ctrlbz 0; setEdCtrlFloatEnable ctrlopx 0; setEdCtrlFloatEnable ctrlopy 0; setEdCtrlFloatEnable ctrlopz 0; setEdCtrlFloatEnable ctrloax 0; setEdCtrlFloatEnable ctrloay 0; setEdCtrlFloatEnable ctrloaz 0; setEdCtrlButtonEnable ctrlbtnresetsize 0; setEdCtrlCheckEnable ctrlfluid 0; setEdCtrlFloatEnable ctrlfluidratio 0; 0; ); if ((type == iTypeNode) && nodestaticgeometry) then fillEdCtrlSelect ctrltype "none"::"collisionTree"::"ellipsoid"::"box"::"cylinder"::"chamfer cylinder"::"capsule"::"cone"::"pyramid"::nil else if (type == iTypeNode) then fillEdCtrlSelect ctrltype "none"::"ellipsoid"::"box"::"cylinder"::"chamfer cylinder"::"capsule"::"cone"::"pyramid"::nil else fillEdCtrlSelect ctrltype "none"::"collisionTree"::"shape"::"concave"::"ellipsoid"::"box"::"cylinder"::"chamfer cylinder"::"capsule"::"cone"::"pyramid"::nil; selectEdCtrlSelect ctrltype bodytype; setEdCtrlCheckState ctrlcontinuous bodycontinuous; setEdCtrlCheckState ctrlenable !bodyenable; setEdCtrlCheckState ctrlautosleep bodyautosleep; setEdCtrlCheckState ctrlcentermassauto !centermassauto; setEdCtrlCheckState ctrlfluid bodyfluid; setEdCtrlSelectCb ctrltype mkfun4 @cbPhysicBodySetupType [p nodestaticgeometry ctrlax ctrlay ctrlaz ctrlldumping ctrlcentermassauto ctrlcmx ctrlcmy ctrlcmz ctrlmass ctrlcontinuous ctrlmatname ctrladdmat ctrlbtnaddmat ctrlenable ctrlautosleep ctrlbx ctrlby ctrlbz ctrlopx ctrlopy ctrlopz ctrloax ctrloay ctrloaz ctrlbtnresetsize ctrlfluid ctrlfluidratio]; setEdCtrlListCbClick ctrlmatname mkfun6 @cbPhysicBodySetupMaterial [p ctrlbtnremovemat]; setEdCtrlButtonCb ctrlbtnaddmat mkfun2 @cbPhysicBodySetupBtnAddMaterial [p ctrlmatname ctrladdmat ctrlbtnremovemat]; setEdCtrlButtonCb ctrlbtnremovemat mkfun2 @cbPhysicBodySetupBtnRemoveMaterial [p ctrlmatname ctrladdmat ctrlbtnremovemat]; setEdCtrlTextLineCbValidate ctrladdmat mkfun3 @cbPhysicBodySetupAddMaterial [p ctrlmatname ctrlbtnremovemat]; setEdCtrlFloatCbChange ctrlax mkfun3 @cbPhysicBodySetupdampingAng [p ctrlax ctrlay ctrlaz]; setEdCtrlFloatCbChange ctrlay mkfun3 @cbPhysicBodySetupdampingAng [p ctrlax ctrlay ctrlaz]; setEdCtrlFloatCbChange ctrlaz mkfun3 @cbPhysicBodySetupdampingAng [p ctrlax ctrlay ctrlaz]; setEdCtrlFloatCbChange ctrlldumping mkfun3 @cbPhysicBodySetupDampingLinear p; setEdCtrlFloatCbChange ctrlmass mkfun3 @cbPhysicBodySetupMass p; setEdCtrlCheckCbState ctrlcontinuous mkfun3 @cbPhysicBodySetupContinuous p; setEdCtrlCheckCbState ctrlenable mkfun3 @cbPhysicBodySetupEnable p; setEdCtrlCheckCbState ctrlautosleep mkfun3 @cbPhysicBodySetupAutoSleep p; setEdCtrlCheckCbState ctrlcentermassauto mkfun3 @cbPhysicBodySetupAutoCenterOfMass [p ctrlcmx ctrlcmy ctrlcmz]; setEdCtrlCheckCbState ctrlfluid mkfun3 @cbPhysicBodySetupFluid [p ctrlfluidratio]; setEdCtrlFloatCbChange ctrlfluidratio mkfun3 @cbPhysicBodySetupFluidRatio p; setEdCtrlFloatCbChange ctrlcmx mkfun3 @cbPhysicBodySetupCenterOfMass [p ctrlcentermassauto ctrlcmx ctrlcmy ctrlcmz]; setEdCtrlFloatCbChange ctrlcmy mkfun3 @cbPhysicBodySetupCenterOfMass [p ctrlcentermassauto ctrlcmx ctrlcmy ctrlcmz]; setEdCtrlFloatCbChange ctrlcmz mkfun3 @cbPhysicBodySetupCenterOfMass [p ctrlcentermassauto ctrlcmx ctrlcmy ctrlcmz]; setEdCtrlFloatCbChange ctrlbx mkfun3 @cbPhysicBodySetupSize [p ctrlbx ctrlby ctrlbz]; setEdCtrlFloatCbChange ctrlby mkfun3 @cbPhysicBodySetupSize [p ctrlbx ctrlby ctrlbz]; setEdCtrlFloatCbChange ctrlbz mkfun3 @cbPhysicBodySetupSize [p ctrlbx ctrlby ctrlbz]; setEdCtrlFloatCbChange ctrlopx mkfun3 @cbPhysicBodySetupOffset [p ctrlopx ctrlopy ctrlopz ctrloax ctrloay ctrloaz]; setEdCtrlFloatCbChange ctrlopy mkfun3 @cbPhysicBodySetupOffset [p ctrlopx ctrlopy ctrlopz ctrloax ctrloay ctrloaz]; setEdCtrlFloatCbChange ctrlopz mkfun3 @cbPhysicBodySetupOffset [p ctrlopx ctrlopy ctrlopz ctrloax ctrloay ctrloaz]; setEdCtrlFloatCbChange ctrloax mkfun3 @cbPhysicBodySetupOffset [p ctrlopx ctrlopy ctrlopz ctrloax ctrloay ctrloaz]; setEdCtrlFloatCbChange ctrloay mkfun3 @cbPhysicBodySetupOffset [p ctrlopx ctrlopy ctrlopz ctrloax ctrloay ctrloaz]; setEdCtrlFloatCbChange ctrloaz mkfun3 @cbPhysicBodySetupOffset [p ctrlopx ctrlopy ctrlopz ctrloax ctrloay ctrloaz]; setEdCtrlButtonCb ctrlbtnresetsize mkfun2 @cbPhysicBodySetupBtnResetSize [p ctrlbx ctrlby ctrlbz]; setEdwindowCbDestroy dwinstr @cbDestroyPhysicBodySetupWin; 0; ); 0;; fun physicsDestroySetting()= dsEdWindow winPhysicSetup; set winPhysicSetup = nil; let winPhysicBodySetup -> [node winstr] in ( SO3BodyShowDebug (SO3SceneNodeGetBody node) 0; dsEdWindow winstr; ); set winPhysicBodySetup = nil; 0;; fun physicsDestroyNodeSetting(node)= let winPhysicBodySetup -> [lobj swinstr] in if node != lobj then nil else ( SO3BodyShowDebug (SO3SceneNodeGetBody node) 0; dsEdWindow swinstr; set winPhysicBodySetup = nil; ); 0;;