public void AddDustAt(Vector3 position, float amount)
    {
        int   k = 0;
        float temp;

        position.y = 0;

        float totalRatioDistance      = 0;
        List <AdjacencyData> dataList = new List <AdjacencyData>();

        foreach (var item in vertices)
        {
            Vector3 itemflat = item;
            itemflat.y = 0;
            temp       = Vector3.Distance(itemflat, position);
            if (temp <= maxRange)
            {
                AdjacencyData data = new AdjacencyData();
                data.verticeTarget  = k;
                data.ratioDistance  = fallOff.Evaluate(temp / maxRange);
                totalRatioDistance += data.ratioDistance;
                dataList.Add(data);
            }
            k++;
        }

        //need to distribute amount over the datas
        foreach (var item in dataList)
        {
            float newRatio = item.ratioDistance / totalRatioDistance;
            dustAmount[item.verticeTarget] += amount * newRatio;
        }

        UpdateMesh();
    }
Beispiel #2
0
        /**
         * Updates the map, and returns whether there was a change
         */
        public bool SetConnection(Direction direction, AdjacencyData data)
        {
            bool changed = !data.Equals(connections[(int) direction]);
            if (changed)
            {
                connections[(int) direction] = data;
            }

            return changed;
        }
Beispiel #3
0
        public void DeserializeFromByte(byte bytemap)
        {
            BitArray bits = new BitArray(new byte[] { bytemap });
            AdjacencyData[] adjacencyData = new AdjacencyData[8];
            for (int i = 0; i < bits.Length; i++)
            {
                adjacencyData[i] = new AdjacencyData(TileObjectGenericType.None, TileObjectSpecificType.None, bits[i]);
            }

            connections = adjacencyData;
        }
Beispiel #4
0
            public OctreeNode(BinaryReader reader, Dictionary <uint, OctreeNode> existingNodes)
            {
                existingNodes.Add((uint)reader.BaseStream.Position, this);
                Index = reader.ReadUInt16();
                int triangleCount = reader.ReadUInt16(); // 2bytes padding

                TriangleDataOffset = reader.ReadUInt32();
                pPolyList          = reader.ReadUInt32();

                // Read triangles
                long pos = reader.BaseStream.Position;

                reader.BaseStream.Position = TriangleDataOffset;
                for (uint i = 0; i < triangleCount; i++)
                {
                    Triangles.Add(new Triangle(reader));
                }
                reader.BaseStream.Position = pos;

                // Read children
                for (int i = 0; i < 8; i++)
                {
                    uint offset = reader.ReadUInt32();
                    if (offset != 0)
                    {
                        long p = reader.BaseStream.Position;
                        reader.BaseStream.Position = offset;
                        Children[i] = new OctreeNode(reader, existingNodes);
                        reader.BaseStream.Position = p;
                    }
                }

                // Read adjacency data
                uint pAdjacencyData = reader.ReadUInt32();

                if (pAdjacencyData != 0)
                {
                    long oldpos = reader.BaseStream.Position;
                    reader.BaseStream.Position = pAdjacencyData;
                    Adjacency = new AdjacencyData(reader);
                    reader.BaseStream.Position = oldpos;
                }
                //pUnk03 = reader.ReadUInt32();

                Type = (NodeType)reader.ReadByte();
                reader.ReadBytes(3); // 3bytes padding
                Min = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                Max = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            }