public Vector3 Collision(Model model, float angle, Vector3 posi, string mesh) { model.Meshes[mesh].VertexBuffer.GetData(vertex); this.posi = posi; this.posi.Y = CheckVertex(); return this.posi; } private float CheckVertex() { int count2 = 0; for (int count = 0; count < vertex.Length; count++) { if (count > 0) { for (count2 = 0; count2 < 3; count2++) { if (four[count2] == Vector3.Zero) four[count2] = vertex[count]; else if (Math.Abs(Math.Sqrt((Math.Pow((vertex[count].X - posi.X), 2) + Math.Pow((vertex[count].Z - posi.Z), 2)))) <= Math.Abs(Math.Sqrt((Math.Pow((four[count2].X - posi.X), 2) + Math.Pow((four[count2].Z - posi.Z), 2))))) { four[count2] = vertex[count]; count2 = 3; } } } else four[0] = vertex[0]; count2 = 0; } inter = Intersect(); return 2; }