public ModelEntity(Model model, IRigidBody body, EntityGeometryData geoData) { this.body = body; this.Model = model; this.GeometryData = geoData; DebugCompass = new DebugCompass(this.CenterOfMass); DebugCompass.LoadContent(null); }
public ModelEntity CreateCube(Vector3 position, float mass, float dimension) { Model model = Models[CollideType.Box]; float size = dimension; RigidBody body = new RigidBody(position); body.LinearDamping = LinearDamping; body.AngularDamping = AngularDamping; body.Awake = true; body.Mass = mass; body.InertiaTensor = InertiaTensorFactory.Cubiod(mass, size, size, size); float halfSize = size; Box prim = new Box(body, Matrix.Identity, new Vector3(halfSize, halfSize, halfSize)); EntityGeometryData geoData = new EntityGeometryData(); geoData.Prim = prim; geoData.BoundingSphere = new BoundingSphere(Vector3.Zero, halfSize * TrickyMath.Sqrt(2f)); return new ModelEntity(model, body, geoData); }
public ModelEntity CreateDefaultFromModel(Model model, Vector3 pos) { AABBTree tree = AABBFactory.AABBTree(model); BoundingBox box = tree.Root.BBox; float radius = BoundingSphere.CreateFromBoundingBox(box).Radius; float mass = 1f; RigidBody body = new RigidBody(pos); body.LinearDamping = LinearDamping; body.AngularDamping = AngularDamping; body.Awake = true; body.Mass = mass; body.InertiaTensor = InertiaTensorFactory.Sphere(mass, radius); Sphere prim = new Sphere(body, Matrix.Identity, radius); EntityGeometryData geoData = new EntityGeometryData(); geoData.BoundingSphere = new BoundingSphere(Vector3.Zero, radius); geoData.Prim = prim; return new ModelEntity(model, body, geoData); }
public ModelEntity CreateSphere(Vector3 position, float mass, float dimension) { Model model = Models[CollideType.Sphere]; float radius = dimension; RigidBody body = new RigidBody(position); body.LinearDamping = LinearDamping; body.AngularDamping = AngularDamping; body.Awake = true; body.Mass = mass; body.InertiaTensor = InertiaTensorFactory.Sphere(mass, radius); Sphere prim = new Sphere(body, Matrix.Identity, radius); EntityGeometryData geoData = new EntityGeometryData(); geoData.Prim = prim; geoData.BoundingSphere = new BoundingSphere(Vector3.Zero, prim.Radius); return new ModelEntity(model, body, geoData); }