Ejemplo n.º 1
0
    static void ParseFluid(MegaFlowFrame flow, MegaFlowXMLNode node)
    {
        for (int i = 0; i < node.values.Count; i++)
        {
            MegaFlowXMLValue val = node.values[i];

            switch (val.name)
            {
            case "grid":
            {
                string[] vals = val.value.Split(',');
                flow.gridDim2[0] = int.Parse(vals[0]);
                flow.gridDim2[1] = int.Parse(vals[1]);
                flow.gridDim2[2] = int.Parse(vals[2]);
                break;
            }

            case "size":
            {
                string[] vals = val.value.Split(',');
                index = 0;
                Vector3 bmin = ReadV3(vals);
                Vector3 bmax = ReadV3(vals);

                flow.size  = bmax - bmin;
                flow.gsize = flow.size;

                // griddim should have a name change
                flow.spacing.x = flow.size.x / flow.gridDim2[0];
                flow.spacing.y = flow.size.y / flow.gridDim2[1];
                flow.spacing.z = flow.size.z / flow.gridDim2[2];
                flow.oos.x     = 1.0f / flow.spacing.x;
                flow.oos.y     = 1.0f / flow.spacing.y;
                flow.oos.z     = 1.0f / flow.spacing.z;
                break;
            }

            default: Debug.Log("Unknown Fluid attribute " + val.name); break;
            }
        }

        for (int i = 0; i < node.children.Count; i++)
        {
            MegaFlowXMLNode n = (MegaFlowXMLNode)node.children[i];
            switch (n.tagName)
            {
            case "Vel":
                ParseVel(flow, n);
                break;

            case "Force":
                break;

            case "Density":
                break;

            default: Debug.Log("Unknown Fluid node " + n.tagName); break;
            }
        }
    }
Ejemplo n.º 2
0
    public MegaFlowXMLNode parseAttributes(String xmlTag, MegaFlowXMLNode node)
    {
        int index         = 0;
        int attrNameIndex = 0;
        int lastIndex     = 0;

        while (true)
        {
            index = xmlTag.IndexOf(BEGIN_QUOTE, lastIndex);
            if (index < 0 || index > xmlTag.Length)
            {
                break;
            }

            attrNameIndex = xmlTag.LastIndexOf(SPACE, index);
            if (attrNameIndex < 0 || attrNameIndex > xmlTag.Length)
            {
                break;
            }

            attrNameIndex++;
            String attrName = xmlTag.Substring(attrNameIndex, index - attrNameIndex);

            index += 2;

            lastIndex = xmlTag.IndexOf(QUOTE, index);
            if (lastIndex < 0 || lastIndex > xmlTag.Length)
            {
                break;
            }

            int    tagLength = lastIndex - index;
            String attrValue = xmlTag.Substring(index, tagLength);

            MegaFlowXMLValue val = new MegaFlowXMLValue();
            val.name  = attrName;
            val.value = attrValue;
            node.values.Add(val);
        }

        return(node);
    }
Ejemplo n.º 3
0
    static void ParseVel(MegaFlowFrame flow, MegaFlowXMLNode node)
    {
        for (int i = 0; i < node.values.Count; i++)
        {
            MegaFlowXMLValue val = node.values[i];

            switch (val.name)
            {
            case "data":
            {
                string[] vals = val.value.Split(',');
                index = 0;

                //int len = vals.Length / 3;

                flow.vel.Clear();

                Vector3[] vels = new Vector3[flow.gridDim2[0] * flow.gridDim2[1] * flow.gridDim2[2]];

                for (int z = 0; z < flow.gridDim2[2]; z++)
                {
                    for (int y = 0; y < flow.gridDim2[1]; y++)
                    {
                        for (int x = 0; x < flow.gridDim2[0]; x++)
                        {
                            vels[(x * flow.gridDim2[2] * flow.gridDim2[1]) + ((flow.gridDim2[2] - z - 1) * flow.gridDim2[1]) + y] = ReadV3Adj(vals);
                        }
                    }
                }

                flow.framenumber = 0;
                flow.vel.AddRange(vels);
                break;
            }

            default: Debug.Log("Unknown Vel attribute " + val.name); break;
            }
        }
    }
Ejemplo n.º 4
0
	public MegaFlowXMLNode parseAttributes(String xmlTag, MegaFlowXMLNode node)
	{
		int index = 0;
		int attrNameIndex = 0;
		int lastIndex = 0;

		while ( true )
		{
			index = xmlTag.IndexOf(BEGIN_QUOTE, lastIndex);
			if ( index < 0 || index > xmlTag.Length )
				break;

			attrNameIndex = xmlTag.LastIndexOf(SPACE, index);
			if ( attrNameIndex < 0 || attrNameIndex > xmlTag.Length )
				break;

			attrNameIndex++;
			String attrName = xmlTag.Substring(attrNameIndex, index - attrNameIndex);

			index += 2;

			lastIndex = xmlTag.IndexOf(QUOTE, index);
			if ( lastIndex < 0 || lastIndex > xmlTag.Length )
			{
				break;
			}

			int tagLength = lastIndex - index;
			String attrValue = xmlTag.Substring(index, tagLength);

			MegaFlowXMLValue val = new MegaFlowXMLValue();
			val.name = attrName;
			val.value = attrValue;
			node.values.Add(val);
		}

		return node;
	}