Пример #1
0
        private void GenerateSphereCollider()
        {
            RenderGeometryComponent geometry = ParentObject.GetComponent <RenderGeometryComponent>();
            List <Vector3>          verts    = geometry.GetVertices();
            BoundingSphere          sphere   = BoundingSphere.CreateFromPoints(verts);

            PhysicsEntity = new Sphere(MonoMathHelper.Translate(ParentObject.Transform.AbsoluteTransform.Translation),
                                       sphere.Radius, 1);
            PhysicsEntity.Tag = ParentObject;
        }
Пример #2
0
        private void GenerateBoxCollider()
        {
            RenderGeometryComponent geometry = ParentObject.GetComponent <RenderGeometryComponent>();
            List <Vector3>          verts    = geometry.GetVertices();
            BoundingBox             testBox  = BoundingBox.CreateFromPoints(verts);
            float width  = testBox.Max.X - testBox.Min.X;
            float height = testBox.Max.Y - testBox.Min.Y;
            float depth  = testBox.Max.Z - testBox.Min.Z;

            PhysicsEntity = new Box(new BEPUutilities.Vector3(ParentObject.Transform.AbsoluteTransform.Translation.X,
                                                              ParentObject.Transform.AbsoluteTransform.Translation.X,
                                                              ParentObject.Transform.AbsoluteTransform.Translation.X), width, height, depth, 1);
        }