37 public partial class PhysicsObject
52 Vector2D v =
Body.State.Position.Linear;
53 return new Vector( v.X, v.Y );
55 set {
Body.State.Position.Linear =
new Vector2D( value.X, value.Y ); }
70 Body.Shape = CreatePhysicsShape( base.Shape, value );
82 set {
Body.State.Position.Angular = value.Radians; }
90 get {
return base.Shape; }
93 SetShape( value, GetDefaultParameters(
Width,
Height ) );
100 Body.Shape = CreatePhysicsShape( shape,
Size, parameters );
103 internal static IShape CreatePhysicsShape(
Shape shape,
Vector size )
105 return CreatePhysicsShape( shape, size, GetDefaultParameters( size.
X, size.
Y ) );
117 RaySegment raySegment = (RaySegment)shape;
122 return new RaySegmentsShape( singleSegment );
128 double smaller = Math.Min( size.
X, size.
Y );
129 double bigger = Math.Max( size.
X, size.
Y );
131 double r = smaller / 2 + ( bigger - smaller ) / 2;
132 int vertexCount = (int)Math.Ceiling( ( 2 * Math.PI * r ) / parameters.
MaxVertexDistance );
134 if ( Math.Abs( size.
X - size.
Y ) <=
double.Epsilon )
140 return new CircleShape( r, vertexCount );
144 Vector2D[] vertexes =
new Vector2D[vertexCount];
146 double a = 0.5 * size.
X;
147 double b = 0.5 * size.
Y;
149 for (
int i = 0; i < vertexCount; i++ )
151 double t = ( i * 2 * Math.PI ) / vertexCount;
152 double x = a * Math.Cos( t );
153 double y = b * Math.Sin( t );
154 vertexes[i] =
new Vector2D( x, y );
162 Vector2D[] originalVertexes =
new Vector2D[shape.Cache.
OutlineVertices.Length];
171 originalVertexes[i] =
new Vector2D( v.
X, v.
Y );
174 Vector2D[] polyVertexes = VertexHelper.Subdivide( originalVertexes, parameters.
MaxVertexDistance );
readonly Vector [] OutlineVertices
Ulkoreunan verteksit, lueteltuna vastapäivään.
Suuntakulma (rajoitettu -180 ja 180 asteen välille) asteina ja radiaaneina. Tietoja kulmasta: http://...
double DistanceGridSpacing
override Vector Size
Olion koko (x on leveys, y on korkeus).
Törmäyskuvion laatuun vaikuttavat parametrit.
static Angle FromRadians(double radian)
Luo kulman annettujen radiaanien mukaan.
Body Body
Fysiikkamoottorin käyttämä tietorakenne.
override Vector Position
Olion paikka koordinaatistossa. Käsittää sekä X- että Y-koordinaatin.
double Width
Olion leveys (X-suunnassa, leveimmässä kohdassa).
abstract bool IsUnitSize
If true, the shape must be scaled by the size of the object that has the shape. Typically, an unit-sized object has width and height of 1.0.
double Height
Olion korkeus (Y-suunnassa, korkeimmassa kohdassa).