From 95e45e5b6379ffece7c51ec1f59822c473b7b859 Mon Sep 17 00:00:00 2001 From: gareth Date: Mon, 26 Mar 2007 00:27:22 +0000 Subject: Added height field building to ODE plugin --- OpenSim.Physics/OdePlugin/OdePlugin.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'OpenSim.Physics/OdePlugin') diff --git a/OpenSim.Physics/OdePlugin/OdePlugin.cs b/OpenSim.Physics/OdePlugin/OdePlugin.cs index cb96533..3337a37 100644 --- a/OpenSim.Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim.Physics/OdePlugin/OdePlugin.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; using OpenSim.Physics.Manager; +using Ode.NET; namespace OpenSim.Physics.OdePlugin { @@ -69,10 +70,21 @@ namespace OpenSim.Physics.OdePlugin public class OdeScene :PhysicsScene { - + private IntPtr world; + private IntPtr space; + private IntPtr contactgroup; + private double[] _heightmap; + public OdeScene() { - + world = d.WorldCreate(); + space = d.HashSpaceCreate(IntPtr.Zero); + contactgroup = d.JointGroupCreate(0); + d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f); + d.WorldSetCFM(world, 1e-5f); + d.WorldSetAutoDisableFlag(world, true); + d.WorldSetContactMaxCorrectingVel(world, 0.1f); + d.WorldSetContactSurfaceLayer(world, 0.001f); } public override PhysicsActor AddAvatar(PhysicsVector position) @@ -117,6 +129,12 @@ namespace OpenSim.Physics.OdePlugin public override void SetTerrain(float[] heightMap) { + for(int i=0; i<65536; i++) { + this._heightmap[i]=(double)heightMap[i]; + } + IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); + d.GeomHeightfieldDataBuildDouble(HeightmapData,_heightmap,1,256,256,256,256,1.0f,0.0f,2.0f,0); + d.CreateHeightfield(space, HeightmapData, 0); } } -- cgit v1.1