Ejemplo n.º 1
0
        public void AddBody(SoftBody body)
        {
            if (body == null)
            {
                throw new ArgumentNullException("body", "body can't be null.");
            }
            if (softbodies.Contains(body))
            {
                throw new ArgumentException("The body was already added to the world.", "body");
            }

            this.softbodies.Add(body);
            this.CollisionSystem.AddEntity(body);

            events.RaiseAddedSoftBody(body);

            foreach (Constraint constraint in body.EdgeSprings)
            {
                CBFrame.Utils.Logger.Debug("line260 body2.linearVelocity:" + constraint.body2.linearVelocity + ",body1.linearVelocity:" + constraint.body1.linearVelocity);
                AddConstraint(constraint);
            }

            foreach (SoftBody.MassPoint massPoint in body.VertexBodies)
            {
                events.RaiseAddedRigidBody(massPoint);
                rigidBodies.Add(massPoint);
            }
        }
Ejemplo n.º 2
0
        public void AddBody(SoftBody body)
        {
            if (body == null)
            {
                throw new ArgumentNullException("body", "body can't be null.");
            }
            if (softbodies.Contains(body))
            {
                throw new ArgumentException("The body was already added to the world.", "body");
            }

            this.softbodies.Add(body);
            this.CollisionSystem.AddEntity(body);

            events.RaiseAddedSoftBody(body);

            foreach (Constraint constraint in body.EdgeSprings)
            {
                AddConstraint(constraint);
            }

            foreach (SoftBody.MassPoint massPoint in body.VertexBodies)
            {
                events.RaiseAddedRigidBody(massPoint);
                rigidBodies.Add(massPoint);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a <see cref="RigidBody"/> to the world.
        /// </summary>
        /// <param name="body">The body which should be added.</param>
        public void AddBody(RigidBody body)
        {
            if (body == null)
            {
                throw new ArgumentNullException("body", "body can't be null.");
            }
            if (rigidBodies.Contains(body))
            {
                throw new ArgumentException("The body was already added to the world.", "body");
            }

            events.RaiseAddedRigidBody(body);

            this.CollisionSystem.AddEntity(body);

            rigidBodies.Add(body);
        }