I am trying to create small boxes using a Transformable entity using a box shape with the following code:
Code: Select all
Matrix3x3 transform = Matrix3x3.CreateFromAxisAngle(new Vector3(1,0,0), PI / 4);
var transformable = new TransformableEntity (new Vector3 (0, 0, 0), new BoxShape (0.1f, 0.1f, 0.1f), transform, 0.1f);
Space.Add (transformable);
Code: Select all
public void UpdateConvexShapeInfo()
{
//Compute the volume distribution.
var samples = CommonResources.GetVectorList();
if (samples.Capacity < InertiaHelper.SampleDirections.Length)
samples.Capacity = InertiaHelper.SampleDirections.Length;
samples.Count = InertiaHelper.SampleDirections.Length;
for (int i = 0; i < InertiaHelper.SampleDirections.Length; ++i)
{
shape.GetLocalExtremePointWithoutMargin(ref InertiaHelper.SampleDirections[i], out samples.Elements[i]);
}
var triangles = CommonResources.GetIntList();
ConvexHullHelper.GetConvexHull(samples, triangles);
float volume;
InertiaHelper.ComputeShapeDistribution(samples, triangles, out volume, out volumeDistribution);
Volume = volume;
//Estimate the minimum radius based on the surface mesh.
MinimumRadius = InertiaHelper.ComputeMinimumRadius(samples, triangles, ref Toolbox.ZeroVector) + collisionMargin;
MaximumRadius = ComputeMaximumRadius();
CommonResources.GiveBack(samples);
CommonResources.GiveBack(triangles);
}
Thanks