Beispiel #1
0
 private static Vector3 NearestAlly(Vector3[] allyPositions)
 {
     if (allyPositions.Count() == 0)
         return new Vector3();
     var minimum = float.MaxValue;
     var start = Player.Position;
     Vector3 tempMin = new Vector3();
     foreach (Vector3 ally in allyPositions)
     {
         var path = ObjectManager.Player.GetPath(start, ally);
         var lastPoint = start;
         var d = 0f;
         d = DistanceFromArray(path);
         if (d < minimum)
         {
             minimum = d;
             tempMin = ally;
         }
     }
     return tempMin;
 }
Beispiel #2
0
        private static void PolygonDraw(Vector3 Center, Vector3[] Points, float thickness, Color color)
        {
            for (int i = 0; i < Points.Count() - 1; i++)
            {
                var q = Drawing.WorldToScreen(new Vector3(new Vector2(Points[i].X, Points[i].Y),
                    Points[i].Z));

                var z = Drawing.WorldToScreen(new Vector3(new Vector2(Points[i + 1].X, Points[i + 1].Y),
                    Points[i + 1].Z));

                Drawing.DrawLine(q, z, thickness, color);
            }

            Drawing.DrawLine(Drawing.WorldToScreen(new Vector3(new Vector2(Points[Points.Length - 1].X, Points[Points.Length - 1].Y),
                                Player.Position.Z)), Drawing.WorldToScreen(new Vector3(new Vector2(Points[0].X, Points[0].Y),
                                 Player.Position.Z)), thickness, color);
        }
Beispiel #3
0
        private void AddRangeVector3(Vector3[] v, int level, bool isFirst)
        {
            int N = Vertices2[level].Count - 1;
            int C = v.Count();

            foreach (Vector3 v3 in v)
            {
                DXMEV p = new DXMEV();
                p.P = new Vector4(v3.X, v3.Z, v3.Y, 1);
                Vertices2[level].Add(p);

                BBox.Maximum = Vector3.Max(BBox.Maximum, new Vector3(p.P.X, p.P.Y, p.P.Z));
                BBox.Minimum = Vector3.Min(BBox.Minimum, new Vector3(p.P.X, p.P.Y, p.P.Z));
            }

            if (isFirst) { }
            else
            {
                // Create the triangles
                for (int i = 0; i < C; i++)
                {
                    // first triangle for the "quad"
                    Indices2[level].Add(N - C + 1 + i); Indices2[level].Add(N + i + 1);
                    if (i == C - 1) Indices2[level].Add(N - C + 1); else Indices2[level].Add(N - C + 2 + i);

                    // second triangle for the "quad"
                    if (i == C - 1) Indices2[level].Add(N - C + 1); else Indices2[level].Add(N - C + 2 + i);
                    Indices2[level].Add(N + i + 1);
                    if (i == C - 1) Indices2[level].Add(N + 1); else Indices2[level].Add(N + 2 + i);
                }
            }
        }
        public IConvexHullShapeImp AddConvexHullShape(float3[] points, bool optimized)
        {
            var btPoints = new Vector3[points.Count()];
            for (int i = 0; i < btPoints.Count(); i++)
            {
                var point = Translater.Float3ToBtVector3(points[i]);
                btPoints[i] = point;
            }

            var btConvexHullShape = new ConvexHullShape(btPoints);
            //btConvexHullShape.LocalScaling = new Vector3(3, 3, 3);
            if (optimized == true)
            {
                var btShapeHull = new ShapeHull(btConvexHullShape);
                var margin = btConvexHullShape.Margin;
                btShapeHull.BuildHull(margin);
                ConvexHullShape simplifiedConvexShape = new ConvexHullShape(btShapeHull.Vertices);

                BtCollisionShapes.Add(simplifiedConvexShape);

                var retval = new ConvexHullShapeImp();
                retval.BtConvexHullShape = simplifiedConvexShape;
                simplifiedConvexShape.UserObject = retval;
                return retval;
            }
            else
            {
                BtCollisionShapes.Add(btConvexHullShape);

                var retval = new ConvexHullShapeImp();
                retval.BtConvexHullShape = btConvexHullShape;
                btConvexHullShape.UserObject = retval;
                return retval;
            }
        }
Beispiel #5
0
 public static Vector3 GetNextPoint(Vector3[] positions)
 {
     if(positions.Count()==0)
         return new Vector3();
     var minimum = float.MaxValue;
     var start = Player.Position;
     Vector3 tempMin = new Vector3();
     foreach (Vector3 chime in positions)
     {
         var path = ObjectManager.Player.GetPath(start, chime);
         var lastPoint = start;
         var d = 0f;
         d = DistanceFromArray(path);
         if (d < minimum)
         {
             minimum = d;
             tempMin = chime;
         }
     }
     return tempMin;
 }