public void ReInitializeData(Vector3 positionXNA, Material mat, float radius) { this.Radius = radius; this.PositionCenterEngine = MathHelperModule.GetPositionCenter(positionXNA, radius); this.RectangleArea = MathHelperModule.GetSphereRigid2DCoordinatesPositionCenter(this.PositionCenterEngine, (int)radius); InitTorque = 0; InitRotation = 0; this.Radius = radius; //this.color = StaticData.colors[(int)mat]; SetMaterial(mat); SetMass(radius); baseMomentOfInertia = 0.5f * Mass * radius * radius; dAngle = 0; velocity = new Vector3(0, 0, 0); InverseInertiaTensorWorld = new Matrix(); InverseInertiaTensorWorld.M11 = InverseInertiaTensorWorld.M22 = InverseInertiaTensorWorld.M33 = (float)1 / baseMomentOfInertia; InverseInertiaTensorWorld.M44 = 1; vertices = new VertexPositionColor[divisions + 1]; float angleIncrement = (float)(Math.PI * 2 / (divisions - 50)); for (int i = 0; i < vertices.Length; i++) { float angle = angleIncrement * i; Vector3 position1 = this.PositionCenterEngine + new Vector3((float)Math.Sin(angle + 3) * Radius, (float)Math.Cos(angle + 3) * Radius, 0); vertices[i].Position = position1; } }
protected override void UpdateGraphics(GameTime gametime) { this.RectangleArea = MathHelperModule.GetSphereRigid2DCoordinatesPositionCenter(PositionCenterEngine, Radius); }