aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs109
1 files changed, 109 insertions, 0 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs
new file mode 100755
index 0000000..4eeea4d
--- /dev/null
+++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs
@@ -0,0 +1,109 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Collections.Generic;
31using System.Text;
32
33using Nini.Config;
34
35using OpenSim.Framework;
36using OpenSim.Region.PhysicsModules.SharedBase;
37using OpenSim.Region.PhysicsModules.Meshing;
38using OpenSim.Region.Framework.Interfaces;
39
40using OpenMetaverse;
41
42namespace OpenSim.Region.PhysicsModule.BulletS.Tests
43{
44// Utility functions for building up and tearing down the sample physics environments
45public static class BulletSimTestsUtil
46{
47 // 'engineName' is the Bullet engine to use. Either null (for unmanaged), "BulletUnmanaged" or "BulletXNA"
48 // 'params' is a set of keyValue pairs to set in the engine's configuration file (override defaults)
49 // May be 'null' if there are no overrides.
50 public static BSScene CreateBasicPhysicsEngine(Dictionary<string,string> paramOverrides)
51 {
52 IConfigSource openSimINI = new IniConfigSource();
53 IConfig startupConfig = openSimINI.AddConfig("Startup");
54 startupConfig.Set("physics", "BulletSim");
55 startupConfig.Set("meshing", "Meshmerizer");
56 startupConfig.Set("cacheSculptMaps", "false"); // meshmerizer shouldn't save maps
57
58 IConfig bulletSimConfig = openSimINI.AddConfig("BulletSim");
59 // If the caller cares, specify the bullet engine otherwise it will default to "BulletUnmanaged".
60 // bulletSimConfig.Set("BulletEngine", "BulletUnmanaged");
61 // bulletSimConfig.Set("BulletEngine", "BulletXNA");
62 bulletSimConfig.Set("MeshSculptedPrim", "false");
63 bulletSimConfig.Set("ForceSimplePrimMeshing", "true");
64 if (paramOverrides != null)
65 {
66 foreach (KeyValuePair<string, string> kvp in paramOverrides)
67 {
68 bulletSimConfig.Set(kvp.Key, kvp.Value);
69 }
70 }
71
72 // If a special directory exists, put detailed logging therein.
73 // This allows local testing/debugging without having to worry that the build engine will output logs.
74 if (Directory.Exists("physlogs"))
75 {
76 bulletSimConfig.Set("PhysicsLoggingDir","./physlogs");
77 bulletSimConfig.Set("PhysicsLoggingEnabled","True");
78 bulletSimConfig.Set("PhysicsLoggingDoFlush","True");
79 bulletSimConfig.Set("VehicleLoggingEnabled","True");
80 }
81
82 Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
83
84 RegionInfo info = new RegionInfo();
85 info.RegionName = "BSTestRegion";
86 info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize;
87 OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info);
88
89 IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer();
90 INonSharedRegionModule mod = mesher as INonSharedRegionModule;
91 mod.Initialise(openSimINI);
92 mod.AddRegion(scene);
93 mod.RegionLoaded(scene);
94
95 BSScene pScene = new BSScene();
96 mod = (pScene as INonSharedRegionModule);
97 mod.Initialise(openSimINI);
98 mod.AddRegion(scene);
99 mod.RegionLoaded(scene);
100
101 // Since the asset requestor is not initialized, any mesh or sculptie will be a cube.
102 // In the future, add a fake asset fetcher to get meshes and sculpts.
103 // bsScene.RequestAssetMethod = ???;
104
105 return pScene;
106 }
107
108}
109}