public void ReInitializeData(Vector3 positionXNA, Material mat, Vector3 halfSize) { this.HalfSize = halfSize; this.PositionCenterEngine = MathHelperModule.GetPositionCenter(positionXNA, halfSize.X, halfSize.Y); this.RectangleArea = MathHelperModule.GetBoxRigid2DCoordinatesPositionCenter(this.PositionCenterEngine, halfSize.X, halfSize.Y); XAxis = new Vector3(1, 0, 0); YAxis = new Vector3(0, 1, 0); XAxis.Normalize(); YAxis.Normalize(); SetMaterial(mat); SetMass(HalfSize); this.InvMass = 1 / Mass; baseMomentOfInertia = Mass * Math.Max(HalfSize.X, HalfSize.Y) * Math.Max(HalfSize.X, HalfSize.Y) * 4 / 12f; dAngle = 0; vertices = new VertexPositionColor[5]; velocity = new Vector3(0, 0, 0); InverseInertiaTensorWorld = new Matrix(); InverseInertiaTensorWorld.M11 = InverseInertiaTensorWorld.M22 = InverseInertiaTensorWorld.M33 = (float)1 / baseMomentOfInertia; InverseInertiaTensorWorld.M44 = 1; vertices[0].Position = this.PositionCenterEngine + new Vector3(HalfSize.X, HalfSize.Y, 0); vertices[1].Position = this.PositionCenterEngine + new Vector3(-HalfSize.X, HalfSize.Y, 0); vertices[2].Position = this.PositionCenterEngine + new Vector3(-HalfSize.X, -HalfSize.Y, 0); vertices[3].Position = this.PositionCenterEngine + new Vector3(HalfSize.X, -HalfSize.Y, 0); vertices[4].Position = this.PositionCenterEngine + new Vector3(HalfSize.X, HalfSize.Y, 0); }
public BoxRigid(Vector3 positionXNA, Material mat, Vector3 halfSize) : base( MathHelperModule.GetBoxRigid2DCoordinatesPositionXNA(positionXNA, halfSize.X, halfSize.Y), MathHelperModule.GetPositionCenter(positionXNA, halfSize.X, halfSize.Y), TextureType.DefaultBox) { ReInitializeData(positionXNA, mat, halfSize); }
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; } }
public SphereRigid(Vector3 positionXNA, Material mat, float radius) : base(MathHelperModule.GetSphereRigid2DCoordinatesPositionXNA(positionXNA, radius), MathHelperModule.GetPositionCenter(positionXNA, radius), TextureType.DefaultCircle) { //Texture = StaticData.EngineManager.Content.Load<Texture2D>(@"RigidsTextures/DefaultCircle"); ReInitializeData(positionXNA, mat, radius); }
public SphereRigid(SphereRigid anotherRB) : base(MathHelperModule.GetSphereRigid2DCoordinatesPositionXNA(anotherRB.PositionXNA, anotherRB.Radius), MathHelperModule.GetPositionCenter(anotherRB.PositionXNA, anotherRB.Radius), TextureType.DefaultCircle) { this._positionCenter = anotherRB.PositionXNA; this._positionCenter = anotherRB.PositionCenterEngine; this.Width = anotherRB.Width; this.Height = anotherRB.Height; this.vertices = RigidsHelperModule.MakeNewVPCMatrix(anotherRB.vertices); this.InverseInertiaTensorWorld = anotherRB.InverseInertiaTensorWorld; this.baseMomentOfInertia = anotherRB.baseMomentOfInertia; //this.basicEffect = anotherRB.basicEffect; this.acceleration = anotherRB.acceleration; this.canSleep = anotherRB.canSleep; this.Center = anotherRB.Center; this.dAngle = anotherRB.dAngle; this.torqueAccum = anotherRB.torqueAccum; this.torque = anotherRB.torque; this.EnlargingFactor = anotherRB.EnlargingFactor; this.gravity = anotherRB.gravity; this.Radius = anotherRB.Radius; this.isAwake = anotherRB.isAwake; this.IsCollidable = anotherRB.IsCollidable; this.IsClicked = anotherRB.IsClicked; this.LastFrameAcceleration = anotherRB.LastFrameAcceleration; this.LastFrameVelocity = anotherRB.LastFrameVelocity; this.Mass = anotherRB.Mass; this.InvMass = anotherRB.InvMass; this.material = anotherRB.material; this.motion = anotherRB.motion; this.orientation = anotherRB.orientation; this.RectangleArea = anotherRB.RectangleArea; this.TextureType = anotherRB.TextureType; this.sleepEpsilon = anotherRB.sleepEpsilon; this.angVelocity = anotherRB.angVelocity; this.angAcceleration = anotherRB.angAcceleration; this.divisions = anotherRB.divisions; this.wired = anotherRB.wired; this.InitRotation = anotherRB.InitRotation; this.InitTorque = anotherRB.InitTorque; }
public BoxRigid(BoxRigid anotherRB) : base( MathHelperModule.GetBoxRigid2DCoordinatesPositionXNA(anotherRB.PositionXNA, anotherRB.HalfSize.X, anotherRB.HalfSize.Y), MathHelperModule.GetPositionCenter(anotherRB.PositionXNA, anotherRB.HalfSize.X, anotherRB.HalfSize.Y), TextureType.DefaultBox) { //this.HalfSize = anotherRB.HalfSize; //this.PositionCenterEngine = MathHelperModule.GetPositionCenter(anotherRB.PositionXNA, anotherRB.HalfSize.X, // anotherRB.HalfSize.Y); //this.RectangleArea = MathHelperModule.GetBoxRigid2DCoordinatesPositionCenter(anotherRB.PositionCenterEngine, // anotherRB.HalfSize.X, // anotherRB.HalfSize.Y); //SetMaterial(anotherRB.material); //SetMass(HalfSize); //baseMomentOfInertia = Mass * Math.Max(HalfSize.X, HalfSize.Y) * Math.Max(HalfSize.X, HalfSize.Y) * 4 / 12f; //dAngle = 0; //vertices = new VertexPositionColor[5]; //velocity = new Vector3(0, 0, 0); //InverseInertiaTensorWorld = new Matrix(); //InverseInertiaTensorWorld.M11 = InverseInertiaTensorWorld.M22 = InverseInertiaTensorWorld.M33 = (float)1 / baseMomentOfInertia; //InverseInertiaTensorWorld.M44 = 1; //vertices[0].Position = this.PositionCenterEngine + new Vector3(HalfSize.X, HalfSize.Y, 0); //vertices[1].Position = this.PositionCenterEngine + new Vector3(-HalfSize.X, HalfSize.Y, 0); //vertices[2].Position = this.PositionCenterEngine + new Vector3(-HalfSize.X, -HalfSize.Y, 0); //vertices[3].Position = this.PositionCenterEngine + new Vector3(HalfSize.X, -HalfSize.Y, 0); //vertices[4].Position = this.PositionCenterEngine + new Vector3(HalfSize.X, HalfSize.Y, 0); this._positionCenter = anotherRB.PositionXNA; this._positionCenter = anotherRB.PositionCenterEngine; this.Width = anotherRB.Width; this.Height = anotherRB.Height; this.vertices = RigidsHelperModule.MakeNewVPCMatrix(anotherRB.vertices); this.InverseInertiaTensorWorld = anotherRB.InverseInertiaTensorWorld; this.baseMomentOfInertia = anotherRB.baseMomentOfInertia; //this.basicEffect = anotherRB.basicEffect; this.acceleration = anotherRB.acceleration; this.canSleep = anotherRB.canSleep; this.Center = anotherRB.Center; this.dAngle = anotherRB.dAngle; this.torqueAccum = anotherRB.torqueAccum; this.torque = anotherRB.torque; this.EnlargingFactor = anotherRB.EnlargingFactor; this.gravity = anotherRB.gravity; this.HalfSize = anotherRB.HalfSize; this.isAwake = anotherRB.isAwake; this.IsCollidable = anotherRB.IsCollidable; this.IsClicked = anotherRB.IsClicked; this.LastFrameAcceleration = anotherRB.LastFrameAcceleration; this.LastFrameVelocity = anotherRB.LastFrameVelocity; this.Mass = anotherRB.Mass; this.InvMass = anotherRB.InvMass; this.material = anotherRB.material; this.motion = anotherRB.motion; this.orientation = anotherRB.orientation; this.RectangleArea = anotherRB.RectangleArea; this.TextureType = anotherRB.TextureType; this.sleepEpsilon = anotherRB.sleepEpsilon; this.angVelocity = anotherRB.angVelocity; this.angAcceleration = anotherRB.angVelocity; this.XAxis = anotherRB.XAxis; this.YAxis = anotherRB.YAxis; }