33 lines
830 B
C#
Executable File
33 lines
830 B
C#
Executable File
using System.Collections.Generic;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Jitter.LinearMath;
|
|
using Jitter.Collision;
|
|
using Jitter.Collision.Shapes;
|
|
|
|
namespace KinPortal {
|
|
public enum ShapeType {BOX, SPHERE, TRIANGULATE}
|
|
|
|
public static class ShapeFactory {
|
|
public static Shape CreateShape(Model mdl, ShapeType type) {
|
|
Geometry geo = new Geometry(mdl);
|
|
|
|
if(type == ShapeType.BOX) {
|
|
BoundingBox box = geo.Box;
|
|
JVector vsize = Geometry.GetJitterVector(box.Max - box.Min);
|
|
return new BoxShape(vsize);
|
|
}
|
|
|
|
if(type == ShapeType.SPHERE) {
|
|
return new SphereShape(geo.Sphere.Radius);
|
|
}
|
|
|
|
if(type == ShapeType.TRIANGULATE) {
|
|
return new TriangleMeshShape(new Octree(geo.JVertices, geo.JTriangles));
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|