public bool PointInside(Vector3s pos) { var p = pos.Xz; var a = Vertices[0].Xz; var b = Vertices[1].Xz; var c = Vertices[2].Xz; if (Vector2s.PerpDot(a - p, b - a) < 0) { return(false); } if (Vector2s.PerpDot(b - p, c - b) < 0) { return(false); } if (Vector2s.PerpDot(c - p, a - c) < 0) { return(false); } return(true); }
public static void WriteBE(this Stream stream, Vector3s vector) { stream.WriteBE(vector.X); stream.WriteBE(vector.Y); stream.WriteBE(vector.Z); }
public float HeightAt(Vector3s pos) { return(-(pos.X * Normal.X + Normal.Z * pos.Z + OriginOffset) / Normal.Y); }
public void Recalculate() { Normal = Vector3.Normalize(Vector3s.Cross(Vertices[1] - Vertices[0], Vertices[2] - Vertices[1]).ToVector3()); OriginOffset = -Vector3.Dot(Vertices[0].ToVector3(), Normal); }
public Triangle3s(Vector3s a, Vector3s b, Vector3s c) { Vertices = new Vector3s[] { a, b, c }; }