Beispiel #1
0
        public NodeLocation(Vector3 worldLoc, int depth)
        {
            myChunk = new ChunkKey(worldLoc);
            Vector3 local = worldLoc - myChunk.myLocation;
            UInt32  lx, ly, lz;

            lx = (UInt32)(local.X * WorldParameters.theLeafRatio);
            ly = (UInt32)(local.Y * WorldParameters.theLeafRatio);
            lz = (UInt32)(local.Z * WorldParameters.theLeafRatio);

            myNode = NodeKey.combineCode(lx, ly, lz, depth);

            updateInternalValues();
        }
Beispiel #2
0
        public void adjustVert(NodeKey nk, int edge, int vert, int amount)
        {
            changeNumber++;
            Node n = myRoot.getOrCreateNode(nk);

            int[]   ie  = Node.edgeIndices(edge);
            EdgeEnd end = vert == ie[0] ? EdgeEnd.START : EdgeEnd.END;
            int     edgeValue;

            if (end == EdgeEnd.START)
            {
                edgeValue = (int)n.edgeStart(edge);
                n.setEdgeStart(edge, edgeValue + amount);
            }
            else
            {
                edgeValue = (int)n.edgeStop(edge);
                n.setEdgeStop(edge, edgeValue + amount);
            }

            setDirty();
        }
Beispiel #3
0
        public bool deserialize(byte[] data)
        {
            //reset the chunk
            reset();

            if (data.Length > 0)
            {
                MemoryStream ms      = new MemoryStream(data);
                BinaryReader reader  = new BinaryReader(ms);
                int          version = reader.ReadInt32();
                if (version != 1)
                {
                    return(false);
                }

                mySize = reader.ReadSingle();

                int leafCount = reader.ReadInt32();
                for (int i = 0; i < leafCount; i++)
                {
                    UInt32  nk             = reader.ReadUInt32();
                    NodeKey nodeKey        = new NodeKey(nk);
                    UInt32  matId          = reader.ReadUInt32();
                    byte[]  edges          = reader.ReadBytes(12);
                    byte    faceVisibility = reader.ReadByte();

                    Node n = myRoot.getOrCreateNode(nodeKey);
                    n.materialId      = matId;
                    n.myEdgeSpans     = edges;
                    n.myFaceVisibilty = faceVisibility;
                }

                nodeCount = leafCount;
            }

            return(true);
        }
Beispiel #4
0
 public Node findNodeContaining(NodeKey nodekey)
 {
     return(myRoot.findNodeContaining(nodekey));
 }
Beispiel #5
0
 public Node findNode(NodeKey nodeKey)
 {
     return(myRoot.findNode(nodeKey));
 }
Beispiel #6
0
 //copy a key
 public NodeKey(NodeKey orig)
 {
     myValue          = orig.myValue;
     myCachedDepth    = orig.myCachedDepth;
     myCachedLocation = orig.myCachedLocation;
 }