public static void ReAddBlowerBubbleRopeTrajectoryMissingAreas(Vector2 posComp, BumperEntityPoly bumperEntity, ref List <List <IntPoint> > delPolys) { var bumpRigid = bumperEntity.CompObj as BumpRigid; var bumpPosXNA = bumpRigid.PositionXNA2D; var bumpPosCenter = bumpRigid.PositionXNACenter2D; Vector2 bP1, bP2; ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2); Vector2 cP1 = posComp, cP2 = posComp; Vector2 interP; MathHelperModule.FindIntersection(bP1, bP2, cP1, cP2, out interP); Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2, posComp); if (!RigidsHelperModule.IsCloseEnough(interP, (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D, 20)) { List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, posComp); EntraDrawer.DrawIntoFile(new List <List <IntPoint> >() { polyInverseCutVertical }); EntraDrawer.DrawIntoFile(delPolys); delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection); EntraDrawer.DrawIntoFile(delPolys); } }
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 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 virtual void Draw(GameTime gameTime, float orientation) { var SpriteBatch = StaticData.EngineManager.Game1.SpriteBatch; Texture2D Texture = TextureManager.GetTextureByType(this.TextureType); SpriteBatch.Begin(); float angleOfRotation = orientation; Vector2 scaleVector = MathHelperModule.ScaleRectByTexture(Texture, RectangleArea); Vector2 pos = new Vector2(this.RectangleArea.X, this.RectangleArea.Y); //Vector2 pos = new Vector2(RectangleArea.X + (Texture.Bounds.Width * scaleVector.X) / 2, // RectangleArea.Y + (Texture.Bounds.Height * scaleVector.Y) / 2); //Vector2 pos = new Vector2(RectangleArea.X, RectangleArea.Y); Vector2 originOfRotation = new Vector2(0, 0);//(float)RectangleArea.Width / 2, (float)RectangleArea.Height / 2); SpriteBatch.Draw(Texture, pos, null, Color.White, angleOfRotation, originOfRotation, scaleVector, SpriteEffects.None, 0); SpriteBatch.End(); }
public static int SetFitnessValueForLevel(String[] args) { GenManager.GenerateGevaLevel(args, null); String levelStr = args[1]; bool isShortestPathOnlyComparsion = args[2] != "0"; DateTime d1 = DateTime.Now; EntraAgentSimple entraAgentSimple = new EntraAgentSimple(); var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager); DateTime d2 = DateTime.Now; int fitness = Int32.MaxValue; int usedNoRopes = -1; int generatedNoRopes = -1; float usageFit = -1; if (res.IsPlayable) { List <List <PolyLog> > chosenPath; EntraPathAgent pathAgent = new EntraPathAgent(entraAgentSimple); GetFitnessUsage(pathAgent.AllPaths, levelStr, isShortestPathOnlyComparsion, out usedNoRopes, out generatedNoRopes, out usageFit); fitness = (int)(40 * 0 + 60 * usageFit); } else { fitness = (int)(40 * MathHelperModule.Normalize((int)res.MinDistToFrog, 200, 50) + 60); } DateTime d3 = DateTime.Now; PrintDataToFiles(d1, d2, d3, res, fitness, args, usageFit, usedNoRopes, generatedNoRopes); return(fitness); }
public static void ReAddInverseCutPolygon(Vector2 posComp, BumperEntityPoly bumperEntity, ref List <List <IntPoint> > delPolys) { var bumpRigid = bumperEntity.CompObj as BumpRigid; var bumpPosXNA = bumpRigid.PositionXNA2D; var bumpPosCenter = bumpRigid.PositionXNACenter2D; Vector2 bP1, bP2; ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2); Vector2 cP1 = posComp, cP2 = posComp; Vector2 interP; MathHelperModule.FindIntersection(bP1, bP2, cP1, cP2, out interP); Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2, posComp); if (!RigidsHelperModule.IsCloseEnough(interP, (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D, 20)) // if the bump is not on the collision course with the rocket { // Rocket is not on a collision course with the bump, so cut down the del poly area vertically List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, posComp); delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection); } }
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; } }
private void ManipulateRotating() { MouseState mouseState = Mouse.GetState(); { if (!_firstTimePressed) { if (mouseState.RightButton == ButtonState.Pressed) { _firstTimePressed = true; _vectorStart = new Vector2(mouseState.X, mouseState.Y); _vectorStart.Normalize(); } } if (_firstTimePressed) { if (mouseState.RightButton == ButtonState.Pressed) { Vector2 vectorEnd = new Vector2(mouseState.X, mouseState.Y); vectorEnd.Normalize(); float angle = MathHelperModule.GetAngleBetweenTwoVectors(_vectorStart, vectorEnd); CurrentVisual2DResize.SetOrientation(angle); } } } }
public override void Draw(GameTime gameTime) { var SpriteBatch = StaticData.EngineManager.Game1.SpriteBatch; Texture2D Texture = TextureManager.GetTextureByType(this.TextureType); SpriteBatch.Begin(); float angleOfRotation = AngleOfRotation; Vector2 scaleVector = MathHelperModule.ScaleRectByTexture(Texture, RectangleArea); Visual2DPositionCenterEngine = new Vector3(RectangleArea.X + (Texture.Bounds.Width * scaleVector.X) / 2, RectangleArea.Y + (Texture.Bounds.Height * scaleVector.Y) / 2, 0); Vector2 Visual2DPositionCenterEngine2D = new Vector2(Visual2DPositionCenterEngine.X, Visual2DPositionCenterEngine.Y); Vector2 originOfRotation = new Vector2((float)Texture.Width / 2, (float)Texture.Height / 2); SpriteBatch.Draw(Texture, Visual2DPositionCenterEngine2D, null, Color.White, angleOfRotation, originOfRotation, scaleVector, SpriteEffects.None, 1); SpriteBatch.End(); }
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 static void IntersectionWithThreePlanes(Vector2 pinP, Vector2 cP, out Vector2 pWithPlane) { var pinCookieVec = Vector2.Subtract(cP, pinP); pinCookieVec.Normalize(); pWithPlane = new Vector2(1000, 1000); for (int i = 2; i < 7; i += 2) { var planeDir = (Direction)i; Vector2 pP1, pP2, pInter; ProjectionHandler.GetPlanePoints(planeDir, out pP1, out pP2); MathHelperModule.FindIntersection(pinP, cP, pP1, pP2, out pInter); if (pInter.X >= 0 && pInter.X <= StaticData.LevelFarWidth && pInter.Y >= 0 && pInter.Y <= StaticData.LevelFarHeight) { // if in the same direction with the pin-cookie vector //Vector2 vec = refP1 - pInter; //vec.Normalize(); //if (MathHelperModule.GetAngleBetweenTwoVectors(pinCookieVec, vec) <= 90) if (pinP.X < cP.X) { if (cP.X < 900) { if (pInter.X > cP.X) { pWithPlane = pInter; } } else { if (pInter.X < cP.X) { pWithPlane = pInter; } } } else { if (cP.X > 0) { if (pInter.X < cP.X) { pWithPlane = pInter; } } else { if (pInter.X > cP.X) { pWithPlane = pInter; } } } } } }
private void ReIntitializeTag4Rectangle(Vector3 positionCenter, float distanceX, BoxRigid rectIn) { (rectIn).ReInitializeData ( MathHelperModule.GetPositionXNA(positionCenter, distanceX / 2, rectIn.GetHalfHeight()), rectIn.GetMaterial(), new Vector3(distanceX / 2, rectIn.GetHalfHeight(), 0) ); }
private void ReIntitializeTag4Circle(Vector3 positionCenter, float distanceX, SphereRigid circleIn) { (circleIn).ReInitializeData ( MathHelperModule.GetPositionXNA(positionCenter, distanceX / 2, circleIn.Radius), circleIn.GetMaterial(), (distanceX / 2) ); }
private void ReIntitializeTag3Rectangle(Vector3 positionCenter, float distanceY, BoxRigid rectIn) { (rectIn).ReInitializeData ( MathHelperModule.GetPositionXNA(positionCenter, rectIn.GetHalfWidth(), distanceY / 2), rectIn.GetMaterial(), new Vector3(rectIn.GetHalfWidth(), distanceY / 2, 0) ); }
public BubbleService(Vector3 positionXNA) : base(MathHelperModule.Get2DRectangleForNonRigids(positionXNA, StaticData.BubbleDimBubble, StaticData.BubbleDimBubble), TextureType.BubbleWithoutCandy) { this._maxDim = StaticData.BubbleDimBubble; this._minDim = _maxDim - (10 * this._maxDim / 100); this.Id = StaticData.EngineManager.BubbleManagerEngine.GetNextServiceId(); this.PositionXNAInitial = this.PositionXNA; }
private List <Vector2> GetIntersection(Vector2 compPos, Vector2 bP1, Vector2 bP2, Vector2 planeP1, Vector2 planeP2) { Vector2 pInter1, pInter2; MathHelperModule.FindIntersection(compPos, bP1, planeP1, planeP2, out pInter1); MathHelperModule.FindIntersection(compPos, bP2, planeP1, planeP2, out pInter2); List <Vector2> shadowPoints = new List <Vector2>() { bP1, bP2, pInter1, pInter2 }; return(shadowPoints); }
private float CalcStdMax(List <int> distances) { var newDists = CreateBiasedDistances(distances); double avg = MathHelperModule.CalcAvg(newDists); double diffs = 0; newDists.ForEach(i => diffs += Math.Pow((i - avg), 2)); double div = diffs / avg; float res = (float)Math.Sqrt(div); return(res); }
public static BoxRigidHardConstraint GetDefaultBoxRigidHardConstraint( Vector3 positionXNA, Material material, Vector3 halfSize, Vector3?acc, Vector3?initialForce, Vector3?initialTorque, float orientationValue = 0, bool obInertia = false) { BoxRigidHardConstraint rectToReturn = new BoxRigidHardConstraint(positionXNA, material, new Vector3(halfSize.X, halfSize.Y, 0)); // Inertia if (obInertia) { rectToReturn.SetObInertia(); // Awaking rectToReturn.SetAwake(true); return(rectToReturn); } // Acc Vector3 accVector = acc ?? new Vector3(0, -StaticData.GravityConstant, 0); rectToReturn.SetAcceleration(accVector); // Force Vector3 forceIn = initialForce ?? new Vector3(0, 0, 0); rectToReturn.AddForce(forceIn); // Torque Vector3 torqueIn = initialTorque ?? new Vector3(0, 0, 0); rectToReturn.AddTorque(torqueIn, MathHelperModule.GetInverseYPosition(rectToReturn.PositionCenterEngine)); // Orientation rectToReturn.SetOrientation(orientationValue); // Awaking rectToReturn.SetAwake(true); return(rectToReturn); }
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 static SphereRigid GetDefaultSphere( Vector3 positionXNA, Material material, float radius, Vector3?acc, Vector3?initialForce, Vector3?initialTorque, float orientationValue = 0, bool obInertia = false) { SphereRigid rectToReturn = new SphereRigid(positionXNA, material, radius); // Inertia if (obInertia) { rectToReturn.SetObInertia(); // Awaking rectToReturn.SetAwake(true); return(rectToReturn); } // Acc Vector3 accVector = acc ?? new Vector3(0, 0, 0); rectToReturn.SetAcceleration(accVector); // Forece Vector3 forceIn = initialForce ?? new Vector3(0, 0, 0); rectToReturn.AddForce(forceIn); // Torque Vector3 torqueIn = initialTorque ?? new Vector3(0, 0, 0); rectToReturn.AddTorque(torqueIn, MathHelperModule.GetInverseYPosition(rectToReturn.PositionCenterEngine)); // Orientation rectToReturn.SetOrientation(orientationValue); // Awaking rectToReturn.SetAwake(true); return(rectToReturn); }
public static void SetFitnessValueForLevelTest(String[] args, int counter) { GenManager.GenerateGevaLevel(args, null); String levelStr = args[1]; bool isShortestPathOnlyComparsion = args[2] != "0"; DateTime d1 = DateTime.Now; EntraAgentSimple entraAgentSimple = new EntraAgentSimple(); var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager); DateTime d2 = DateTime.Now; int fitness = Int32.MaxValue; int usedNoRopes = -1; int generatedNoRopes = -1; float usageFit = -1; if (res.IsPlayable) { EntraPathAgent pathAgent = new EntraPathAgent(entraAgentSimple); GetFitnessUsage(pathAgent.AllPaths, levelStr, isShortestPathOnlyComparsion, out usedNoRopes, out generatedNoRopes, out usageFit); fitness = (int)(40 * 0 + 60 * usageFit); EngineShotsManager shots = new EngineShotsManager(); shots.TakeEngineShot(StaticData.EntraImageInput); pathAgent.DrawShortestPath(counter); } else { fitness = (int)(40 * MathHelperModule.Normalize((int)res.MinDistToFrog, 300, 50) + 60); } DateTime d3 = DateTime.Now; StreamWriter sw = new StreamWriter(@"PolysTesting\test.txt", true); sw.WriteLine(res.IsPlayable + "\t" + fitness + "\t" + usedNoRopes + "\t" + generatedNoRopes + "\t" + String.Format("{0:0.00}", usageFit)); sw.Close(); //PrintDataToFiles(d1, d2, d3, res, fitness, args); }
public static void SetProperHalfFarWidth(SpringService rope, CookieRB cookieRb, out int verticalLineLength, out int halfFarWidth) { var ropeVec = rope.Masses[0].PositionXNACenter2D; var cookieVec = cookieRb.PositionXNACenter2D; var hypotenuseVec = Vector2.Subtract(cookieVec, ropeVec); hypotenuseVec.Normalize(); Vector2 verticalLine = new Vector2(0, 1); float angleRopeHead = MathHelper.ToDegrees(MathHelperModule.GetAngleBetweenTwoVectors(verticalLine, hypotenuseVec)) - 9; angleRopeHead = angleRopeHead < 0 ? 1 : angleRopeHead; float angleElse = 180 - 90 - angleRopeHead; int hypotenuseVecLength = 2000; verticalLineLength = (int)(hypotenuseVecLength * (angleElse / 90)); halfFarWidth = (int)Math.Sqrt(Math.Pow(hypotenuseVecLength, 2) - Math.Pow(verticalLineLength, 2)); }
public static float GetFitness(GenSimAgent agent) { float fitness = 0; if (agent.IsSuccess) { fitness = 0; } else { float pIntersection = agent.IsPathIntersection ? 1 : 0; float pOverlapping = MathHelperModule.Normalize(agent.CompsScatteredSoFar - 1, agent.GetAllComponents().Count, 0); float pEventsExec = 1 - MathHelperModule.Normalize(agent.ActionsSoFar, agent.GetActionsToDo().Count, 0); //fitness = (1 / (float)2) * pEventsExec + // (1 / (float)2) * pIntersection; if (pIntersection == 1) { fitness = 1; } else { if (pEventsExec == 0) { if (pOverlapping == 0) { fitness = 0.1f; } else { fitness = pOverlapping; } } else { fitness = pEventsExec; } } } return(fitness); }
//private void UpdateCookieFrogDistance() //{ // float dist = // (StaticData.EngineManager.CookieRB.PositionXNACenter2D - // StaticData.EngineManager.FrogRB.PositionXNACenter2D).Length(); // if (dist < CookieFrogMinDist) // { // CookieFrogMinDist = (int)dist; // } //} private bool IsPathIntersected() { for (int i = 0; i < _placedCompSoFar.Count - 1; i++) { for (int j = 1; j < _placedCompSoFar.Count - 1; j++) { Vector2 pInter = Vector2.Zero; Vector2 p1 = _placedCompSoFar[i], p2 = _placedCompSoFar[i + 1], p3 = _placedCompSoFar[j], p4 = _placedCompSoFar[j + 1]; if (_placedCompSoFar[i].X > 543 && _placedCompSoFar[i].X < 544) { int lk123 = 10; } if (_placedCompSoFar[j].X > 558 && _placedCompSoFar[j].X < 559) { int lk123 = 10; } if (MathHelperModule.IsIntersecting(p1, p2, p4, p3)) { MathHelperModule.FindIntersection(p1, p2, p3, p4, out pInter); if ((pInter != Vector2.Zero) && (pInter != p1) && (pInter != p2) && (pInter != p3) && (pInter != p4)) { IsPathIntersection = true; //if (IsReallyIntersection(pInter, new Vector2[] { p1, p2, p3, p4 })) return(true); } } } } return(false); }
private List <int> CreateBiasedDistances(List <int> distances) { List <int> newDists = new List <int>(); double total = MathHelperModule.CalcTotal(distances); int nrToAddLast = 0; for (int i = 0; i < distances.Count; i++) { if (distances[i] > 20) { newDists.Add(20); nrToAddLast += distances[i] - 20; } else { newDists.Add(0); nrToAddLast += distances[i]; } } newDists[newDists.Count - 1] = nrToAddLast + newDists[newDists.Count - 1]; return(newDists); }
public static void RemoveRocketsPolysIntersectionWithPlanes(RocketCarrierService rocket, ref List <List <IntPoint> > poly) { Vector2 rP1, rP2; ProjectionHandler.FindRocketTwoBorderPoints(rocket, out rP1, out rP2); Vector2 rPosCenter = new Vector2((rP1.X + rP2.X) / 2, (rP1.Y + rP2.Y) / 2); for (int i = 0; i < 7; i += 2) { var cDir = (Direction)i; //if (CompIsOnDirToBump(compPos, rPosCenter, cDir)) //{ Vector2 planeP1, planeP2; GetPlanePoints(cDir, out planeP1, out planeP2); Vector2 interP; MathHelperModule.FindIntersection(planeP1, planeP2, rP1, rP2, out interP); if (interP.X <= StaticData.LevelFarWidth && interP.X >= 0 && interP.Y <= StaticData.LevelFarHeight && interP.Y >= 0) { // Rocket is not on a collision course with the bump, // so cut down the del poly area vertically List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(interP, rocket.PositionXNACenter2D); EntraDrawer.DrawIntoFile(new List <List <IntPoint> >() { polyInverseCutVertical }); poly = EntraSolver.GetPolySolution(poly, polyInverseCutVertical, ClipType.ctIntersection); EntraDrawer.DrawIntoFile(poly); } // } } }
public static void ReAddRocketTrajectoryMissingAreas(RocketEntityPoly rocketEntityPoly, BumperEntityPoly bumperEntity, ref List <List <IntPoint> > delPolys) { var bumpRigid = bumperEntity.CompObj as BumpRigid; var bumpPosXNA = bumpRigid.PositionXNA2D; var bumpPosCenter = bumpRigid.PositionXNACenter2D; Vector2 bP1, bP2; ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2); Vector2 rP1, rP2; ProjectionHandler.FindRocketTwoBorderPoints(rocketEntityPoly, out rP1, out rP2); Vector2 interP; MathHelperModule.FindIntersection(bP1, bP2, rP1, rP2, out interP); Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2, (rocketEntityPoly.CompObj as RocketCarrierService).PositionXNACenter2D); if (!RigidsHelperModule.IsCloseEnough(interP, (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D, 20)) // if the bump is not on the collision course with the rocket { // Rocket is not on a collision course with the bump, so cut down the del poly area vertically List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, rocketEntityPoly); EntraDrawer.DrawIntoFile(new List <List <IntPoint> >() { polyInverseCutVertical }); delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection); EntraDrawer.DrawIntoFile(delPolys); } }
private void TryRopeCut(Vector2 posPressed, Vector2 posReleased) { try { for (int i = 0; i < StaticData.EngineManager.SpringsManagerEngine.ListOfServices.Count; i++) { SpringService cService = StaticData.EngineManager.SpringsManagerEngine.ListOfServices[i]; Vector2 posRopeStart = new Vector2(cService.Masses[0].PositionXNA.X, cService.Masses[0].PositionXNA.Y); Vector2 posRopeEnd = new Vector2(cService.Masses[cService.Masses.Count - 1].PositionXNA.X, cService.Masses[cService.Masses.Count - 1].PositionXNA.Y); if (MathHelperModule.IsIntersecting(posPressed, posReleased, posRopeStart, posRopeEnd)) { if (!(cService is CatchableRopeService)) { StaticData.EngineManager.SpringsManagerEngine.RemoveService(cService); i--; } else { if ((cService as CatchableRopeService).IsActivated) { StaticData.EngineManager.SpringsManagerEngine.RemoveService(cService); i--; } } } //if (!((posPressed.Y < posRopeStart.Y && posReleased.Y < posRopeStart.Y) // || (posPressed.Y > posRopeEnd.Y && posReleased.Y > posRopeEnd.Y))) //{ // StaticData.EngineManager.SpringsManagerEngine.RemoveService(cService); //} } } catch (Exception) { } }
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; }
public Visual2D(Vector3 positionXNA, int width, int height, TextureType textureType) { this.RectangleArea = MathHelperModule.Get2DRectangleForNonRigids(positionXNA, width, height); this.TextureType = textureType; }