Esempio n. 1
0
        private bool parseMapPatchDef(MapEntity e, bool bPatchDef3)
        {
            if (!p.isAtToken("{"))
            {
                showParseError("Expected '{' at the beginning of patchDef2 at line " + p.getCurrentLineNumber());
                return(true);
            }
            // patch info
            string matName;

            if (p.readToken(out matName))
            {
                showParseError("Failed to read material name of patchDef2 at line " + p.getCurrentLineNumber());
                return(true);
            }
            int w, h;

            if (!p.isAtToken("("))
            {
                showParseError("Expected '(' at the beginning of patchDef2 at line " + p.getCurrentLineNumber());
                return(true);
            }
            if (p.readInt(out w))
            {
                showParseError("Failed to read width of patchDef2 at line " + p.getCurrentLineNumber());
                return(true);
            }
            if (p.readInt(out h))
            {
                showParseError("Failed to read height of patchDef2 at line " + p.getCurrentLineNumber());
                return(true);
            }
            int a, b, c;

            if (p.readInt(out a))
            {
                showParseError("Failed to read third parm of patchDef2 at line " + p.getCurrentLineNumber());
                return(true);
            }
            if (p.readInt(out b))
            {
                showParseError("Failed to read 4th parm of patchDef2 at line " + p.getCurrentLineNumber());
                return(true);
            }
            if (p.readInt(out c))
            {
                showParseError("Failed to read 5th parm of patchDef2 at line " + p.getCurrentLineNumber());
                return(true);
            }
            if (bPatchDef3)
            {
                int g, f;
                if (p.readInt(out f))
                {
                    showParseError("Failed to read 6th parm of patchDef2 at line " + p.getCurrentLineNumber());
                    return(true);
                }
                if (p.readInt(out g))
                {
                    showParseError("Failed to read 7th parm of patchDef2 at line " + p.getCurrentLineNumber());
                    return(true);
                }
            }
            while (true)
            {
                if (p.isAtToken("+surfaceParm"))
                {
                    string parmName;
                    p.readString(out parmName);
                }
                else if (p.isAtToken("subdivisions"))
                {
                    float subdivisions;
                    p.readFloat(out subdivisions);
                }
                else
                {
                    break;
                }
            }
            if (!p.isAtToken(")"))
            {
                showParseError("Expected ')' after patchDef2 info block at line " + p.getCurrentLineNumber());
                return(true);
            }
            if (!p.isAtToken("("))
            {
                showParseError("Expected '(' at the beginning of patchDef2 vertices block at line " + p.getCurrentLineNumber());
                return(true);
            }
            MapPatch patch = new MapPatch();

            patch.setSizes(w, h);
            patch.setMatName(matName);
            for (int i = 0; i < w; i++)
            {
                if (!p.isAtToken("("))
                {
                    showParseError("Expected '(' at the beginning of patchDef2 vertices row " + i + " at line " + p.getCurrentLineNumber());
                    return(true);
                }
                for (int j = 0; j < h; j++)
                {
                    if (!p.isAtToken("("))
                    {
                        showParseError("Expected '(' at the beginning of patchDef2 vertex " + i + "/" + j + " at line " + p.getCurrentLineNumber());
                        return(true);
                    }
                    Vec3 position;
                    if (p.readVec3(out position))
                    {
                        showParseError("Failed to read position of patchDef2 vertex " + i + "/" + j + " at line " + p.getCurrentLineNumber());
                        return(true);
                    }
                    Vec2 texCoords;
                    if (p.readVec2(out texCoords))
                    {
                        showParseError("Failed to read texCoord of patchDef2 vertex " + i + "/" + j + " at line " + p.getCurrentLineNumber());
                        return(true);
                    }
                    if (!p.isAtToken(")"))
                    {
                        showParseError("Expected ')' at the end of patchDef2 vertex " + i + "/" + j + " at line " + p.getCurrentLineNumber());
                        return(true);
                    }
                    patch.setVertex(i, j, position, texCoords);
                }
                if (!p.isAtToken(")"))
                {
                    showParseError("Expected ')' at the end of patchDef2 vertices row " + i + " at line " + p.getCurrentLineNumber());
                    return(true);
                }
            }
            if (!p.isAtToken(")"))
            {
                showParseError("Expected ')' after patchDef2 vertices block at line " + p.getCurrentLineNumber());
                return(true);
            }
            if (!p.isAtToken("}"))
            {
                showParseError("Expected '}' at the end of patchDef2 block at line " + p.getCurrentLineNumber());
                return(true);
            }
            if (!p.isAtToken("}"))
            {
                showParseError("Expected '}' at the end of patchDef2 block at line " + p.getCurrentLineNumber());
                return(true);
            }
            e.addPatch(patch);
            return(false);
        }
Esempio n. 2
0
 public void addPatch(MapPatch b)
 {
     patches.Add(b);
 }