All pastes #732421 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-10-10 23:29 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.DirectX;

namespace BEngine.Physics.Shapes
{
    public class Rectangle : PointMassSystem
    {
        public Rectangle( float x, float y, float width, float height, float totalMass )
        {
            float massPerPoint = totalMass / 4;

            this.CreatePoint( new Vector2( x, y ), massPerPoint );
            this.CreatePoint( new Vector2( x + width, y ), massPerPoint );
            this.CreatePoint( new Vector2( x + width, y + height ), massPerPoint );
            this.CreatePoint( new Vector2( x, y + height ), massPerPoint );

            //TODO: RIG CONTRAINT FROM FIRST TO LAST.

            PointMassSystem.RigidConstrain( this.Points[ 0 ], this.Points[ 1 ] );
            PointMassSystem.RigidConstrain( this.Points[ 1 ], this.Points[ 2 ] );
            PointMassSystem.RigidConstrain( this.Points[ 2 ], this.Points[ 3 ] );
            PointMassSystem.RigidConstrain( this.Points[ 3 ], this.Points[ 0 ] );
            PointMassSystem.RigidConstrain( this.Points[ 0 ], this.Points[ 2 ] );
        }
    }
}