Beispiel #1
0
        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);
        }
Beispiel #2
0
        public KCL(byte[] file)
        {
            EndianBinaryReader er = new EndianBinaryReader((Stream) new MemoryStream(file), Endianness.LittleEndian);

            this.Header            = new KCL.KCLHeader(er);
            er.BaseStream.Position = (long)this.Header.VertexOffset;
            this.Vertex            = new Vector3[((this.Header.NormalOffset - this.Header.VertexOffset) / 12U)];
            for (int index = 0; (long)index < (long)((this.Header.NormalOffset - this.Header.VertexOffset) / 12U); ++index)
            {
                this.Vertex[index] = new Vector3(er.ReadSingleInt32Exp12(), er.ReadSingleInt32Exp12(), er.ReadSingleInt32Exp12());
            }
            er.BaseStream.Position = (long)this.Header.NormalOffset;
            this.Normals           = new Vector3[((this.Header.PlaneOffset + 16U - this.Header.NormalOffset) / 6U)];
            for (int index = 0; (long)index < (long)((this.Header.PlaneOffset + 16U - this.Header.NormalOffset) / 6U); ++index)
            {
                this.Normals[index] = new Vector3(er.ReadSingleInt16Exp12(), er.ReadSingleInt16Exp12(), er.ReadSingleInt16Exp12());
            }
            er.BaseStream.Position = (long)(this.Header.PlaneOffset + 16U);
            this.Planes            = new KCL.Plane[((this.Header.OctreeOffset - (this.Header.PlaneOffset + 16U)) / 16U)];
            for (int index = 0; (long)index < (long)((this.Header.OctreeOffset - (this.Header.PlaneOffset + 16U)) / 16U); ++index)
            {
                this.Planes[index] = new KCL.Plane(er);
            }
            er.BaseStream.Position = (long)this.Header.OctreeOffset;
            int NrNode = ((~this.Header.Xmask >> this.Header.CoordinateShift) + 1) * ((~this.Header.Ymask >> this.Header.CoordinateShift) + 1) * ((~this.Header.Zmask >> this.Header.CoordinateShift) + 1);

            this.Octree = new KCL.OctreeNode(er, NrNode);
            er.Close();
        }