private static bool MKDSCollisionCheck(KCL k, Vector3 Point) { int num1 = (int)((double)Point.X - (double)k.Header.SpatialGridX); if ((num1 & k.Header.Xmask) != 0) { return(false); } int num2 = (int)((double)Point.Y - (double)k.Header.SpatialGridY); if ((num2 & k.Header.Ymask) != 0) { return(false); } int num3 = (int)((double)Point.Z - (double)k.Header.SpatialGridZ); if ((num3 & k.Header.Zmask) != 0) { return(false); } int index1 = num3 >> k.Header.CoordinateShift << k.Header.ZShift | num2 >> k.Header.CoordinateShift << k.Header.YShift | num1 >> k.Header.CoordinateShift; int coordinateShift = k.Header.CoordinateShift; int index2; for (KCL.OctreeNode childNode = k.Octree.ChildNodes[index1]; !childNode.Leaf; childNode = childNode.ChildNodes[index2]) { --coordinateShift; index2 = (num3 >> coordinateShift & 1) << 2 | (num2 >> coordinateShift & 1) << 1 | num1 >> coordinateShift & 1; } return(false); }
public void Render(bool picking = false) { int PlaneIdx = 0; foreach (KCL.Plane plane in this.Planes) { Vector3 PositionA; Vector3 PositionB; Vector3 PositionC; Vector3 Normal; KCL.GetTriangle(this, PlaneIdx, out PositionA, out PositionB, out PositionC, out Normal); Color color = this.GetColor(plane.Type); if (picking && color.A != (byte)0) { color = Color.FromArgb(PlaneIdx + 1 | -16777216); } Gl.glColor4f((float)color.R / (float)byte.MaxValue, (float)color.G / (float)byte.MaxValue, (float)color.B / (float)byte.MaxValue, (float)color.A / (float)byte.MaxValue); Gl.glBegin(4); Gl.glNormal3f(Normal.X, Normal.Y, Normal.Z); Gl.glVertex3f(PositionA.X, PositionA.Z, PositionA.Y); Gl.glVertex3f(PositionB.X, PositionB.Z, PositionB.Y); Gl.glVertex3f(PositionC.X, PositionC.Z, PositionC.Y); Gl.glEnd(); ++PlaneIdx; } }
public static void GetTriangle( KCL k, int PlaneIdx, out Vector3 PositionA, out Vector3 PositionB, out Vector3 PositionC) { KCL.GetTriangle(k, PlaneIdx, out PositionA, out PositionB, out PositionC, out Vector3 _); }
public static void GetTriangle( KCL k, int PlaneIdx, out Vector3 PositionA, out Vector3 PositionB, out Vector3 PositionC, out Vector3 Normal) { KCL.Plane plane = k.Planes[PlaneIdx]; PositionA = k.Vertex[(int)plane.VertexIndex]; Vector3 right = Normal = k.Normals[(int)plane.NormalIndex]; Vector3 normal1 = k.Normals[(int)plane.NormalAIndex]; Vector3 normal2 = k.Normals[(int)plane.NormalBIndex]; Vector3 normal3 = k.Normals[(int)plane.NormalCIndex]; Vector3 left1 = Vector3.Cross(normal1, right); Vector3 left2 = Vector3.Cross(normal2, right); PositionB = PositionA + left2 * (plane.Length / Vector3.Dot(left2, normal3)); PositionC = PositionA + left1 * (plane.Length / Vector3.Dot(left1, normal3)); }