Use CLR type names in PhyScalarType.
Update version and year.
This commit is contained in:
Родитель
8e5164df0e
Коммит
6c3cd222d2
|
@ -7,12 +7,12 @@ namespace BulletSharp
|
|||
{
|
||||
public enum PhyScalarType
|
||||
{
|
||||
Float,
|
||||
Single,
|
||||
Double,
|
||||
Integer,
|
||||
Short,
|
||||
Int32,
|
||||
Int16,
|
||||
FixedPoint88,
|
||||
UChar
|
||||
Byte
|
||||
}
|
||||
|
||||
public abstract class ConcaveShape : CollisionShape
|
||||
|
|
|
@ -38,17 +38,17 @@ namespace BulletSharp
|
|||
switch (triangleIndexStride)
|
||||
{
|
||||
case sizeof(byte) * 3:
|
||||
IndexType = PhyScalarType.UChar;
|
||||
IndexType = PhyScalarType.Byte;
|
||||
break;
|
||||
case sizeof(short) * 3:
|
||||
IndexType = PhyScalarType.Short;
|
||||
IndexType = PhyScalarType.Int16;
|
||||
break;
|
||||
case sizeof(int) * 3:
|
||||
default:
|
||||
IndexType = PhyScalarType.Integer;
|
||||
IndexType = PhyScalarType.Int32;
|
||||
break;
|
||||
}
|
||||
VertexType = PhyScalarType.Float;
|
||||
VertexType = PhyScalarType.Single;
|
||||
|
||||
NumTriangles = numTriangles;
|
||||
TriangleIndexBase = Marshal.AllocHGlobal(numTriangles * triangleIndexStride);
|
||||
|
@ -261,7 +261,7 @@ namespace BulletSharp
|
|||
{
|
||||
}
|
||||
|
||||
public void AddIndexedMesh(IndexedMesh mesh, PhyScalarType indexType = PhyScalarType.Integer)
|
||||
public void AddIndexedMesh(IndexedMesh mesh, PhyScalarType indexType = PhyScalarType.Int32)
|
||||
{
|
||||
_meshes.Add(mesh);
|
||||
btTriangleIndexVertexArray_addIndexedMesh(_native, mesh._native, indexType);
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace BulletSharp
|
|||
{
|
||||
}
|
||||
|
||||
public void AddMaterialProperties(MaterialProperties mat, PhyScalarType triangleType = PhyScalarType.Integer)
|
||||
public void AddMaterialProperties(MaterialProperties mat, PhyScalarType triangleType = PhyScalarType.Int32)
|
||||
{
|
||||
btTriangleIndexVertexMaterialArray_addMaterialProperties(_native, mat._native,
|
||||
triangleType);
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BulletSharpPInvoke")]
|
||||
[assembly: AssemblyCopyright("Copyright © Andres Traks 2016")]
|
||||
[assembly: AssemblyCopyright("Copyright © Andres Traks 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.9.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.9.0.0")]
|
||||
[assembly: AssemblyVersion("0.10.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.10.0.0")]
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using SiliconStudio.Core.Mathematics;
|
||||
using System.Drawing;
|
||||
using BulletSharp;
|
||||
using OpenTK;
|
||||
|
|
|
@ -1,61 +1,67 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{085F79E4-C90B-4D62-BE4D-FE5C5E279D39}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BasicDemo</RootNamespace>
|
||||
<AssemblyName>BasicDemo</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{085F79E4-C90B-4D62-BE4D-FE5C5E279D39}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BasicDemo</RootNamespace>
|
||||
<AssemblyName>BasicDemo</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Reference Include="BulletSharp">
|
||||
<HintPath>..\..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BasicDemo.cs" />
|
||||
<Compile Include="Physics.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
</ItemGroup>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Reference Include="BulletSharp">
|
||||
<HintPath>..\..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\OpenTK.2.0.0\lib\net20\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BasicDemo.cs" />
|
||||
<Compile Include="Physics.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="OpenTK.dll.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,25 @@
|
|||
<configuration>
|
||||
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
|
||||
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
|
||||
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
|
||||
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
|
||||
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
|
||||
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
|
||||
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
|
||||
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
|
||||
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
|
||||
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
|
||||
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
|
||||
<!-- XQuartz compatibility (X11 on Mac) -->
|
||||
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
|
||||
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
|
||||
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
|
||||
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
|
||||
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
|
||||
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
|
||||
</configuration>
|
|
@ -1,143 +1,142 @@
|
|||
using SiliconStudio.Core.Mathematics;
|
||||
using System.Collections.Generic;
|
||||
using BulletSharp;
|
||||
using Vector3 = BulletSharp.Math.Vector3;
|
||||
|
||||
namespace BasicDemo
|
||||
{
|
||||
class Physics
|
||||
{
|
||||
///create 125 (5x5x5) dynamic objects
|
||||
int ArraySizeX = 5, ArraySizeY = 5, ArraySizeZ = 5;
|
||||
|
||||
///scaling of the objects (0.1 = 20 centimeter boxes )
|
||||
float StartPosX = -5;
|
||||
float StartPosY = -5;
|
||||
float StartPosZ = -3;
|
||||
|
||||
public DiscreteDynamicsWorld World { get; set; }
|
||||
CollisionDispatcher dispatcher;
|
||||
DbvtBroadphase broadphase;
|
||||
List<CollisionShape> collisionShapes = new List<CollisionShape>();
|
||||
CollisionConfiguration collisionConf;
|
||||
|
||||
public Physics()
|
||||
{
|
||||
// collision configuration contains default setup for memory, collision setup
|
||||
collisionConf = new DefaultCollisionConfiguration();
|
||||
dispatcher = new CollisionDispatcher(collisionConf);
|
||||
|
||||
broadphase = new DbvtBroadphase();
|
||||
World = new DiscreteDynamicsWorld(dispatcher, broadphase, null, collisionConf);
|
||||
World.Gravity = new Vector3(0, -10, 0);
|
||||
|
||||
// create the ground
|
||||
CollisionShape groundShape = new BoxShape(50, 50, 50);
|
||||
using BulletSharp;
|
||||
using BulletSharp.Math;
|
||||
using System.Collections.Generic;
|
||||
using Vector3 = BulletSharp.Math.Vector3;
|
||||
|
||||
namespace BasicDemo
|
||||
{
|
||||
class Physics
|
||||
{
|
||||
///create 125 (5x5x5) dynamic objects
|
||||
int ArraySizeX = 5, ArraySizeY = 5, ArraySizeZ = 5;
|
||||
|
||||
///scaling of the objects (0.1 = 20 centimeter boxes )
|
||||
float StartPosX = -5;
|
||||
float StartPosY = -5;
|
||||
float StartPosZ = -3;
|
||||
|
||||
public DiscreteDynamicsWorld World { get; set; }
|
||||
CollisionDispatcher dispatcher;
|
||||
DbvtBroadphase broadphase;
|
||||
List<CollisionShape> collisionShapes = new List<CollisionShape>();
|
||||
CollisionConfiguration collisionConf;
|
||||
|
||||
public Physics()
|
||||
{
|
||||
// collision configuration contains default setup for memory, collision setup
|
||||
collisionConf = new DefaultCollisionConfiguration();
|
||||
dispatcher = new CollisionDispatcher(collisionConf);
|
||||
|
||||
broadphase = new DbvtBroadphase();
|
||||
World = new DiscreteDynamicsWorld(dispatcher, broadphase, null, collisionConf);
|
||||
|
||||
// create the ground
|
||||
var groundShape = new BoxShape(50, 50, 50);
|
||||
collisionShapes.Add(groundShape);
|
||||
CollisionObject ground = LocalCreateRigidBody(0, BulletSharp.Math.Matrix.Translation(0, -50, 0), groundShape);
|
||||
ground.UserObject = "Ground";
|
||||
|
||||
// create a few dynamic rigidbodies
|
||||
float mass = 1.0f;
|
||||
|
||||
CollisionShape colShape = new BoxShape(1);
|
||||
collisionShapes.Add(colShape);
|
||||
Vector3 localInertia = colShape.CalculateLocalInertia(mass);
|
||||
|
||||
float start_x = StartPosX - ArraySizeX / 2;
|
||||
float start_y = StartPosY;
|
||||
float start_z = StartPosZ - ArraySizeZ / 2;
|
||||
|
||||
int k, i, j;
|
||||
for (k = 0; k < ArraySizeY; k++)
|
||||
{
|
||||
for (i = 0; i < ArraySizeX; i++)
|
||||
{
|
||||
for (j = 0; j < ArraySizeZ; j++)
|
||||
CollisionObject ground = LocalCreateRigidBody(0, Matrix.Translation(0, -50, 0), groundShape);
|
||||
ground.UserObject = "Ground";
|
||||
|
||||
// create a few dynamic rigidbodies
|
||||
float mass = 1.0f;
|
||||
|
||||
var colShape = new BoxShape(1);
|
||||
collisionShapes.Add(colShape);
|
||||
|
||||
var rbInfo = new RigidBodyConstructionInfo(mass, null, colShape);
|
||||
rbInfo.LocalInertia = colShape.CalculateLocalInertia(mass);
|
||||
|
||||
float start_x = StartPosX - ArraySizeX / 2;
|
||||
float start_y = StartPosY;
|
||||
float start_z = StartPosZ - ArraySizeZ / 2;
|
||||
|
||||
for (int y = 0; y < ArraySizeY; y++)
|
||||
{
|
||||
for (int x = 0; x < ArraySizeX; x++)
|
||||
{
|
||||
for (int z = 0; z < ArraySizeZ; z++)
|
||||
{
|
||||
BulletSharp.Math.Matrix startTransform = BulletSharp.Math.Matrix.Translation(
|
||||
new Vector3(
|
||||
2*i + start_x,
|
||||
2*k + start_y,
|
||||
2*j + start_z
|
||||
)
|
||||
);
|
||||
|
||||
// using motionstate is recommended, it provides interpolation capabilities
|
||||
// and only synchronizes 'active' objects
|
||||
DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
|
||||
RigidBodyConstructionInfo rbInfo =
|
||||
new RigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
|
||||
RigidBody body = new RigidBody(rbInfo);
|
||||
|
||||
// make it drop from a height
|
||||
body.Translate(new Vector3(0, 20, 0));
|
||||
|
||||
World.AddRigidBody(body);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Update(float elapsedTime)
|
||||
{
|
||||
World.StepSimulation(elapsedTime);
|
||||
}
|
||||
|
||||
public void ExitPhysics()
|
||||
{
|
||||
//remove/dispose constraints
|
||||
int i;
|
||||
for (i = World.NumConstraints - 1; i >= 0; i--)
|
||||
{
|
||||
TypedConstraint constraint = World.GetConstraint(i);
|
||||
World.RemoveConstraint(constraint);
|
||||
constraint.Dispose(); ;
|
||||
}
|
||||
|
||||
//remove the rigidbodies from the dynamics world and delete them
|
||||
for (i = World.NumCollisionObjects - 1; i >= 0; i--)
|
||||
{
|
||||
CollisionObject obj = World.CollisionObjectArray[i];
|
||||
RigidBody body = obj as RigidBody;
|
||||
if (body != null && body.MotionState != null)
|
||||
{
|
||||
body.MotionState.Dispose();
|
||||
}
|
||||
World.RemoveCollisionObject(obj);
|
||||
obj.Dispose();
|
||||
}
|
||||
|
||||
//delete collision shapes
|
||||
foreach (CollisionShape shape in collisionShapes)
|
||||
shape.Dispose();
|
||||
collisionShapes.Clear();
|
||||
|
||||
World.Dispose();
|
||||
broadphase.Dispose();
|
||||
if (dispatcher != null)
|
||||
{
|
||||
dispatcher.Dispose();
|
||||
}
|
||||
collisionConf.Dispose();
|
||||
Matrix startTransform = Matrix.Translation(
|
||||
new Vector3(
|
||||
2*x + start_x,
|
||||
2*y + start_y,
|
||||
2*z + start_z
|
||||
)
|
||||
);
|
||||
|
||||
// using motionstate is recommended, it provides interpolation capabilities
|
||||
// and only synchronizes 'active' objects
|
||||
rbInfo.MotionState = new DefaultMotionState(startTransform);
|
||||
var body = new RigidBody(rbInfo);
|
||||
|
||||
// make it drop from a height
|
||||
body.Translate(new Vector3(0, 20, 0));
|
||||
|
||||
World.AddRigidBody(body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rbInfo.Dispose();
|
||||
}
|
||||
|
||||
public RigidBody LocalCreateRigidBody(float mass, BulletSharp.Math.Matrix startTransform, CollisionShape shape)
|
||||
{
|
||||
bool isDynamic = (mass != 0.0f);
|
||||
|
||||
Vector3 localInertia = Vector3.Zero;
|
||||
if (isDynamic)
|
||||
shape.CalculateLocalInertia(mass, out localInertia);
|
||||
|
||||
DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
|
||||
|
||||
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
|
||||
RigidBody body = new RigidBody(rbInfo);
|
||||
|
||||
World.AddRigidBody(body);
|
||||
|
||||
return body;
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual void Update(float elapsedTime)
|
||||
{
|
||||
World.StepSimulation(elapsedTime);
|
||||
}
|
||||
|
||||
public void ExitPhysics()
|
||||
{
|
||||
// remove/dispose constraints
|
||||
for (int i = World.NumConstraints - 1; i >= 0; i--)
|
||||
{
|
||||
TypedConstraint constraint = World.GetConstraint(i);
|
||||
World.RemoveConstraint(constraint);
|
||||
constraint.Dispose(); ;
|
||||
}
|
||||
|
||||
// remove the rigidbodies from the dynamics world and delete them
|
||||
for (int i = World.NumCollisionObjects - 1; i >= 0; i--)
|
||||
{
|
||||
CollisionObject obj = World.CollisionObjectArray[i];
|
||||
RigidBody body = obj as RigidBody;
|
||||
if (body != null && body.MotionState != null)
|
||||
{
|
||||
body.MotionState.Dispose();
|
||||
}
|
||||
World.RemoveCollisionObject(obj);
|
||||
obj.Dispose();
|
||||
}
|
||||
|
||||
// delete collision shapes
|
||||
foreach (CollisionShape shape in collisionShapes)
|
||||
shape.Dispose();
|
||||
collisionShapes.Clear();
|
||||
|
||||
World.Dispose();
|
||||
broadphase.Dispose();
|
||||
if (dispatcher != null)
|
||||
{
|
||||
dispatcher.Dispose();
|
||||
}
|
||||
collisionConf.Dispose();
|
||||
}
|
||||
|
||||
public RigidBody LocalCreateRigidBody(float mass, Matrix startTransform, CollisionShape shape)
|
||||
{
|
||||
bool isDynamic = (mass != 0.0f);
|
||||
|
||||
Vector3 localInertia = Vector3.Zero;
|
||||
if (isDynamic)
|
||||
shape.CalculateLocalInertia(mass, out localInertia);
|
||||
|
||||
var myMotionState = new DefaultMotionState(startTransform);
|
||||
|
||||
using (var rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia))
|
||||
{
|
||||
var body = new RigidBody(rbInfo);
|
||||
World.AddRigidBody(body);
|
||||
return body;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using SiliconStudio.Core.Mathematics;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
@ -12,17 +11,6 @@ namespace BasicDemo
|
|||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Assembly.Load("OpenTK");
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("OpenTK not found." +
|
||||
"Please download it from http://www.opentk.com.", "Error!");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Assembly.Load("BulletSharp");
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="OpenTK" version="2.0.0" targetFramework="net40-client" />
|
||||
</packages>
|
|
@ -259,7 +259,7 @@ namespace VehicleDemo
|
|||
const float heightScale = maxHeight / 256.0f;
|
||||
const int width = 128, length = 128;
|
||||
const int dataLength = width * length * sizeof(byte);
|
||||
const PhyScalarType scalarType = PhyScalarType.UChar;
|
||||
const PhyScalarType scalarType = PhyScalarType.Byte;
|
||||
|
||||
var scale = new Vector3(5.0f, maxHeight, 5.0f);
|
||||
|
||||
|
@ -300,7 +300,7 @@ namespace VehicleDemo
|
|||
const float heightScale = maxHeight / 256.0f;
|
||||
const int width = 64, length = 64;
|
||||
const int dataLength = width * length * sizeof(float);
|
||||
const PhyScalarType scalarType = PhyScalarType.Float;
|
||||
const PhyScalarType scalarType = PhyScalarType.Single;
|
||||
|
||||
var scale = new Vector3(15.0f, maxHeight, 15.0f);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2013-2016 Andres Traks
|
||||
Copyright (c) 2013-2017 Andres Traks
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2013-2016 Andres Traks
|
||||
Copyright (c) 2013-2017 Andres Traks
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
|
Загрузка…
Ссылка в новой задаче