Ejemplo n.º 1
0
        protected internal override void OnLoad()
        {
            base.OnLoad();

            Physics.CollisionShape shape = null;
            if (mesh == null && colMesh == null)
            {
                shape = Bullet.CreateBoxShape(Vector3.Zero);
            }
            else if (colMesh != null)
            {
                shape = Bullet.CreateMeshShape(colMesh.Vertices, colMesh.Indices);
            }
            else
            {
                var indices = new List <int>();
                for (var i = 0; i < mesh.SubMeshCount; i++)
                {
                    indices.AddRange(mesh.subMeshes[i].indices);
                }
                shape = Bullet.CreateMeshShape(mesh.Vertices, indices.ToArray());
            }
            collisionObject     = Bullet.CreateCollisionObject(shape, CollideGroup, CollideMask);
            collisionObject.tag = this;
        }
Ejemplo n.º 2
0
        private Physics.Shapes.CompoundShape CreateCollisionShape()
        {
            var cols = GameObject.GetComponents <Collider>();

            if (cols == null)
            {
                return(null);
            }
            var shapes     = new Physics.CollisionShape[cols.Length];
            var transforms = new Matrix4[cols.Length];

            for (var i = 0; i < cols.Length; i++)
            {
                shapes[i] = cols[i].collisionObject.Shape;
                cols[i].collisionObject.tag = this;
                transforms[i] = cols[i].ColliderTransform;
            }
            return(Bullet.CreateCompoundShape(shapes, transforms));
        }