コード例 #1
0
ファイル: OgreCommon.cpp プロジェクト: jjiezheng/pap_full
    int findCommandLineOpts(int numargs, char** argv, UnaryOptionList& unaryOptList, 
        BinaryOptionList& binOptList)
    {
        int startIndex = 1;
        for (int i = 1; i < numargs; ++i)
        {
            String tmp(argv[i]);
            if (StringUtil::startsWith(tmp, "-"))
            {
                UnaryOptionList::iterator ui = unaryOptList.find(argv[i]);
                if(ui != unaryOptList.end())
                {
                    ui->second = true;
                    ++startIndex;
                    continue;
                }
                BinaryOptionList::iterator bi = binOptList.find(argv[i]);
                if(bi != binOptList.end())
                {
                    bi->second = argv[i+1];
                    startIndex += 2;
                    ++i;
                    continue;
                }

                // Invalid option
                LogManager::getSingleton().logMessage("Invalid option " + tmp);

            }
        }
        return startIndex;
    }
コード例 #2
0
ファイル: main.cpp プロジェクト: MrLobo/El-Rayo-de-Zeus
void parseOpts(UnaryOptionList& unOpts, BinaryOptionList& binOpts)
{
	opts.interactive = false;
	opts.suppressEdgeLists = false;
	opts.generateTangents = false;
	opts.tangentSemantic = VES_TANGENT;
	opts.tangentUseParity = false;
	opts.tangentSplitMirrored = false;
	opts.tangentSplitRotated = false;
	opts.dontReorganise = false;
	opts.endian = Serializer::ENDIAN_NATIVE;
	opts.destColourFormatSet = false;
	opts.srcColourFormatSet = false;

	opts.lodDist = 500;
	opts.lodFixed = 0;
	opts.lodPercent = 20;
	opts.numLods = 0;
	opts.usePercent = true;
	opts.recalcBounds = false;


	UnaryOptionList::iterator ui = unOpts.find("-e");
	opts.suppressEdgeLists = ui->second;
	ui = unOpts.find("-t");
	opts.generateTangents = ui->second;
	ui = unOpts.find("-tm");
	opts.tangentSplitMirrored = ui->second;
	ui = unOpts.find("-tr");
	opts.tangentSplitRotated = ui->second;

	ui = unOpts.find("-i");
	opts.interactive = ui->second;
	ui = unOpts.find("-r");
	opts.dontReorganise = ui->second;
	ui = unOpts.find("-d3d");
	if (ui->second)
	{
		opts.destColourFormatSet = true;
		opts.destColourFormat = VET_COLOUR_ARGB;
	}
	ui = unOpts.find("-gl");
	if (ui->second)
	{
		opts.destColourFormatSet = true;
		opts.destColourFormat = VET_COLOUR_ABGR;
	}
	ui = unOpts.find("-srcd3d");
	if (ui->second)
	{
		opts.srcColourFormatSet = true;
		opts.srcColourFormat = VET_COLOUR_ARGB;
	}
	ui = unOpts.find("-srcgl");
	if (ui->second)
	{
		opts.srcColourFormatSet = true;
		opts.srcColourFormat = VET_COLOUR_ABGR;
	}
	ui = unOpts.find("-b");
	if (ui->second)
	{
		opts.recalcBounds = true;
	}


	BinaryOptionList::iterator bi = binOpts.find("-l");
	if (!bi->second.empty())
	{
		opts.numLods = StringConverter::parseInt(bi->second);
	}

	bi = binOpts.find("-d");
	if (!bi->second.empty())
	{
		opts.lodDist = StringConverter::parseReal(bi->second);
	}

	bi = binOpts.find("-p");
	if (!bi->second.empty())
	{
		opts.lodPercent = StringConverter::parseReal(bi->second);
		opts.usePercent = true;
	}


	bi = binOpts.find("-f");
	if (!bi->second.empty())
	{
		opts.lodFixed = StringConverter::parseInt(bi->second);
		opts.usePercent = false;
	}

	bi = binOpts.find("-E");
	if (!bi->second.empty())
	{
	    if (bi->second == "big")
            opts.endian = Serializer::ENDIAN_BIG;
	    else if (bi->second == "little")
            opts.endian = Serializer::ENDIAN_LITTLE;
	    else 
            opts.endian = Serializer::ENDIAN_NATIVE;
    }
	bi = binOpts.find("-td");
	if (!bi->second.empty())
	{
		if (bi->second == "uvw")
			opts.tangentSemantic = VES_TEXTURE_COORDINATES;
		else // if (bi->second == "tangent"), or anything else
			opts.tangentSemantic = VES_TANGENT;
	}
	bi = binOpts.find("-ts");
	if (!bi->second.empty())
	{
		if (bi->second == "4")
			opts.tangentUseParity = true;
	}
}
コード例 #3
0
ファイル: main.cpp プロジェクト: OGRECave/ogre
XmlOptions parseArgs(int numArgs, char **args)
{
    XmlOptions opts;

    //opts.interactiveMode = false;
    //opts.lodValue = 250000;
    //opts.lodFixed = 0;
    //opts.lodPercent = 20;
    //opts.numLods = 0;
    opts.nuextremityPoints = 0;
    opts.mergeTexcoordResult = 0;
    opts.mergeTexcoordToDestroy = 0;
    opts.usePercent = true;
    //opts.generateEdgeLists = true;
    //opts.generateTangents = false;
    //opts.tangentSemantic = VES_TANGENT;
    //opts.tangentUseParity = false;
    //opts.tangentSplitMirrored = false;
    //opts.tangentSplitRotated = false;
    //opts.reorganiseBuffers = true;
    opts.optimiseAnimations = true;
    opts.quietMode = false;
    opts.endian = Serializer::ENDIAN_NATIVE;

    // ignore program name
    char* source = 0;
    char* dest = 0;

    // Set up options
    UnaryOptionList unOpt;
    BinaryOptionList binOpt;

    //unOpt["-i"] = false;
    //unOpt["-e"] = false;
    unOpt["-r"] = false;
    //unOpt["-t"] = false;
    unOpt["-tm"] = false;
    unOpt["-tr"] = false;
    unOpt["-o"] = false;
    unOpt["-q"] = false;
    unOpt["-d3d"] = false;
    unOpt["-gl"] = false;
    unOpt["-h"] = false;
    unOpt["-v"] = false;
    //binOpt["-l"] = "";
    //binOpt["-s"] = "Distance";
    //binOpt["-p"] = "";
    //binOpt["-f"] = "";
    binOpt["-E"] = "";
    binOpt["-x"] = "";
    binOpt["-log"] = "OgreXMLConverter.log";
    binOpt["-td"] = "";
    binOpt["-ts"] = "";
    binOpt["-merge"] = "0,0";

    int startIndex = findCommandLineOpts(numArgs, args, unOpt, binOpt);
    UnaryOptionList::iterator ui;
    BinaryOptionList::iterator bi;

    ui = unOpt.find("-v");
    if (ui->second)
    {
        print_version();
        exit(0);
    }

    ui = unOpt.find("-h");
    if (ui->second)
    {
        help();
        exit(1);
    }

    ui = unOpt.find("-q");
    if (ui->second)
    {
        opts.quietMode = true;
    }

    ui = unOpt.find("-o");
    if (ui->second)
    {
        opts.optimiseAnimations = false;
    }

    bi = binOpt.find("-merge");
    if (!bi->second.empty())
    {
        String::size_type separator = bi->second.find_first_of( "," );
        if( separator == String::npos )
        {
            //Input format was "-merge 2"
            //Assume we want to merge 2 with 3
            opts.mergeTexcoordResult    = StringConverter::parseInt( bi->second, 0 );
            opts.mergeTexcoordToDestroy = opts.mergeTexcoordResult + 1;
        }
        else if( separator + 1 < bi->second.size() )
        {
            //Input format was "-merge 1,2"
            //We want to merge 1 with 2
            opts.mergeTexcoordResult    = StringConverter::parseInt(
                                              bi->second.substr( 0, separator ), 0 );
            opts.mergeTexcoordToDestroy = StringConverter::parseInt(
                                              bi->second.substr( separator+1,
                                                      bi->second.size() ), 1 );
        }
    }
    else
    {
        //Very rare to reach here.
        //Input format was "-merge"
        //Assume we want to merge 0 with 1
        opts.mergeTexcoordResult = 0;
        opts.mergeTexcoordResult = 1;
    }

    bi = binOpt.find("-x");
    if (!bi->second.empty())
    {
        opts.nuextremityPoints = StringConverter::parseInt(bi->second);
    }

    bi = binOpt.find("-log");
    if (!bi->second.empty())
    {
        opts.logFile = bi->second;
    }

    bi = binOpt.find("-E");
    if (!bi->second.empty())
    {
        if (bi->second == "big")
            opts.endian = Serializer::ENDIAN_BIG;
        else if (bi->second == "little")
            opts.endian = Serializer::ENDIAN_LITTLE;
        else
            opts.endian = Serializer::ENDIAN_NATIVE;
    }

    ui = unOpt.find("-d3d");
    if (ui->second)
    {
        opts.d3d = true;
    }

    ui = unOpt.find("-gl");
    if (ui->second)
    {
        opts.gl = true;
        opts.d3d = false;
    }

    // Source / dest
    if (numArgs > startIndex)
        source = args[startIndex];
    if (numArgs > startIndex+1)
        dest = args[startIndex+1];
    if (numArgs > startIndex+2) {
        cout << "Too many command-line arguments supplied - abort. " << endl;
        help();
        exit(1);
    }

    if (!source)
    {
        cout << "Missing source file - abort. " << endl;
        help();
        exit(1);
    }
    // Work out what kind of conversion this is
    opts.source = source;
    Ogre::vector<String>::type srcparts = StringUtil::split(opts.source, ".");
    String& ext = srcparts.back();
    StringUtil::toLowerCase(ext);
    opts.sourceExt = ext;

    if (!dest)
    {
        if (opts.sourceExt == "xml")
        {
            // dest is source minus .xml
            opts.dest = opts.source.substr(0, opts.source.size() - 4);
        }
        else
        {
            // dest is source + .xml
            opts.dest = opts.source;
            opts.dest.append(".xml");
        }

    }
    else
    {
        opts.dest = dest;
    }
    Ogre::vector<String>::type dstparts = StringUtil::split(opts.dest, ".");
    ext = dstparts.back();
    StringUtil::toLowerCase(ext);
    opts.destExt = ext;

    if (!opts.quietMode)
    {
        cout << endl;
        cout << "-- OPTIONS --" << endl;
        cout << "source file      = " << opts.source << endl;
        cout << "destination file = " << opts.dest << endl;
        cout << "log file         = " << opts.logFile << endl;
        if (opts.nuextremityPoints)
            cout << "Generate extremes per submesh = " << opts.nuextremityPoints << endl;
        cout << " semantic = " << (opts.tangentSemantic == VES_TANGENT? "TANGENT" : "TEXCOORD") << endl;
        cout << " parity = " << opts.tangentUseParity << endl;
        cout << " split mirror = " << opts.tangentSplitMirrored << endl;
        cout << " split rotated = " << opts.tangentSplitRotated << endl;

        cout << "-- END OPTIONS --" << endl;
        cout << endl;
    }


    return opts;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: OGRECave/ogre
void parseOpts(UnaryOptionList& unOpts, BinaryOptionList& binOpts)
{
    opts.interactive = false;
    opts.suppressEdgeLists = false;
    opts.generateTangents = false;
    opts.tangentSemantic = VES_TANGENT;
    opts.tangentUseParity = false;
    opts.tangentSplitMirrored = false;
    opts.tangentSplitRotated = false;
    opts.dontReorganise = false;
    opts.endian = Serializer::ENDIAN_NATIVE;
    opts.destColourFormatSet = false;
    opts.srcColourFormatSet = false;

    opts.lodAutoconfigure = false;
    opts.lodDist = 500;
    opts.lodFixed = 0;
    opts.lodPercent = 20;
    opts.numLods = 0;
    opts.usePercent = true;
    opts.recalcBounds = false;
    opts.targetVersion = MESH_VERSION_LATEST;


    UnaryOptionList::iterator ui = unOpts.find("-e");
    opts.suppressEdgeLists = ui->second;
    ui = unOpts.find("-t");
    opts.generateTangents = ui->second;
    ui = unOpts.find("-tm");
    opts.tangentSplitMirrored = ui->second;
    ui = unOpts.find("-tr");
    opts.tangentSplitRotated = ui->second;

    ui = unOpts.find("-autogen");
    opts.lodAutoconfigure = ui->second;

    ui = unOpts.find("-i");
    opts.interactive = ui->second;
    ui = unOpts.find("-r");
    opts.dontReorganise = ui->second;
    ui = unOpts.find("-d3d");
    if (ui->second) {
        opts.destColourFormatSet = true;
        opts.destColourFormat = VET_COLOUR_ARGB;
    }
    ui = unOpts.find("-gl");
    if (ui->second) {
        opts.destColourFormatSet = true;
        opts.destColourFormat = VET_COLOUR_ABGR;
    }
    ui = unOpts.find("-srcd3d");
    if (ui->second) {
        opts.srcColourFormatSet = true;
        opts.srcColourFormat = VET_COLOUR_ARGB;
    }
    ui = unOpts.find("-srcgl");
    if (ui->second) {
        opts.srcColourFormatSet = true;
        opts.srcColourFormat = VET_COLOUR_ABGR;
    }
    ui = unOpts.find("-b");
    if (ui->second) {
        opts.recalcBounds = true;
    }


    BinaryOptionList::iterator bi = binOpts.find("-l");
    if (!bi->second.empty()) {
        opts.numLods = StringConverter::parseInt(bi->second);
    }

    bi = binOpts.find("-d");
    if (!bi->second.empty()) {
        opts.lodDist = StringConverter::parseReal(bi->second);
    }

    bi = binOpts.find("-p");
    if (!bi->second.empty()) {
        opts.lodPercent = StringConverter::parseReal(bi->second);
        opts.usePercent = true;
    }


    bi = binOpts.find("-f");
    if (!bi->second.empty()) {
        opts.lodFixed = StringConverter::parseInt(bi->second);
        opts.usePercent = false;
    }

    bi = binOpts.find("-E");
    if (!bi->second.empty()) {
        if (bi->second == "big") {
            opts.endian = Serializer::ENDIAN_BIG;
        } else if (bi->second == "little") {
            opts.endian = Serializer::ENDIAN_LITTLE;
        } else {
            opts.endian = Serializer::ENDIAN_NATIVE;
    }
    }
    bi = binOpts.find("-td");
    if (!bi->second.empty()) {
        if (bi->second == "uvw") {
            opts.tangentSemantic = VES_TEXTURE_COORDINATES;
        } else { // if (bi->second == "tangent"), or anything else
            opts.tangentSemantic = VES_TANGENT;
    }
    }
    bi = binOpts.find("-ts");
    if (!bi->second.empty()) {
        if (bi->second == "4") {
            opts.tangentUseParity = true;
    }
    }
    
    bi = binOpts.find("-V");
    if (!bi->second.empty()) {
        if (bi->second == "1.10") {
            opts.targetVersion = MESH_VERSION_1_10;
        } else if (bi->second == "1.8") {
            opts.targetVersion = MESH_VERSION_1_8;
        } else if (bi->second == "1.7") {
            opts.targetVersion = MESH_VERSION_1_7;
        } else if (bi->second == "1.4") {
            opts.targetVersion = MESH_VERSION_1_4;
        } else if (bi->second == "1.0") {
            opts.targetVersion = MESH_VERSION_1_0;
        } else {
            logMgr->stream() << "Unrecognised target mesh version '" << bi->second << "'";          
    }
    }
    
}
コード例 #5
0
ファイル: main.cpp プロジェクト: MrLobo/El-Rayo-de-Zeus
XmlOptions parseArgs(int numArgs, char **args)
{
    XmlOptions opts;

    opts.interactiveMode = false;
    opts.lodValue = 250000;
    opts.lodFixed = 0;
    opts.lodPercent = 20;
    opts.numLods = 0;
    opts.nuextremityPoints = 0;
    opts.usePercent = true;
    opts.generateEdgeLists = true;
    opts.generateTangents = false;
	opts.tangentSemantic = VES_TANGENT;
	opts.tangentUseParity = false;
	opts.tangentSplitMirrored = false;
	opts.tangentSplitRotated = false;
    opts.reorganiseBuffers = true;
	opts.optimiseAnimations = true;
    opts.quietMode = false;
	opts.endian = Serializer::ENDIAN_NATIVE;

    // ignore program name
    char* source = 0;
    char* dest = 0;

    // Set up options
    UnaryOptionList unOpt;
    BinaryOptionList binOpt;

    unOpt["-i"] = false;
    unOpt["-e"] = false;
    unOpt["-r"] = false;
    unOpt["-t"] = false;
	unOpt["-tm"] = false;
	unOpt["-tr"] = false;
    unOpt["-o"] = false;
	unOpt["-q"] = false;
	unOpt["-d3d"] = false;
	unOpt["-gl"] = false;
    binOpt["-l"] = "";
    binOpt["-v"] = "";
    binOpt["-s"] = "Distance";
    binOpt["-p"] = "";
    binOpt["-f"] = "";
    binOpt["-E"] = "";
    binOpt["-x"] = "";
    binOpt["-log"] = "OgreXMLConverter.log";
	binOpt["-td"] = "";
	binOpt["-ts"] = "";

    int startIndex = findCommandLineOpts(numArgs, args, unOpt, binOpt);
    UnaryOptionList::iterator ui;
    BinaryOptionList::iterator bi;

	ui = unOpt.find("-q");
	if (ui->second)
	{
		opts.quietMode = true;
	}

	ui = unOpt.find("-i");
    if (ui->second)
    {
        opts.interactiveMode = true;
    }
    else
    {
        ui = unOpt.find("-e");
        if (ui->second)
        {
            opts.generateEdgeLists = false;
        }
    
        ui = unOpt.find("-r");
        if (ui->second)
        {
            opts.reorganiseBuffers = false;
        }

        ui = unOpt.find("-t");
        if (ui->second)
        {
            opts.generateTangents = true;
        }
		ui = unOpt.find("-tm");
		if (ui->second)
		{
			opts.tangentSplitMirrored = true;
		}
		ui = unOpt.find("-tr");
		if (ui->second)
		{
			opts.tangentSplitRotated = true;
		}

		bi = binOpt.find("-td");
		if (!bi->second.empty())
		{
			if (bi->second == "uvw")
				opts.tangentSemantic = VES_TEXTURE_COORDINATES;
			else
				opts.tangentSemantic = VES_TANGENT;
		}
		bi = binOpt.find("-ts");
		if (!bi->second.empty())
		{
			if (bi->second == "4")
				opts.tangentUseParity = true;
		}

        ui = unOpt.find("-o");
        if (ui->second)
        {
            opts.optimiseAnimations = false;
        }

		bi = binOpt.find("-l");
        if (!bi->second.empty())
        {
            opts.numLods = StringConverter::parseInt(bi->second);
        }

        bi = binOpt.find("-v");
        if (!bi->second.empty())
        {
            opts.lodValue = StringConverter::parseReal(bi->second);
        }

        bi = binOpt.find("-s");
        if (!bi->second.empty())
        {
            opts.lodStrategy = bi->second;
        }

        bi = binOpt.find("-p");
        if (!bi->second.empty())
        {
            opts.lodPercent = StringConverter::parseReal(bi->second);
            opts.usePercent = true;
        }


        bi = binOpt.find("-f");
        if (!bi->second.empty())
        {
            opts.lodFixed = StringConverter::parseInt(bi->second);
            opts.usePercent = false;
        }

        bi = binOpt.find("-x");
        if (!bi->second.empty())
        {
            opts.nuextremityPoints = StringConverter::parseInt(bi->second);
        }

        bi = binOpt.find("-log");
        if (!bi->second.empty())
        {
            opts.logFile = bi->second;
        }

        bi = binOpt.find("-E");
        if (!bi->second.empty())
        {
            if (bi->second == "big")
                opts.endian = Serializer::ENDIAN_BIG;
            else if (bi->second == "little")
                opts.endian = Serializer::ENDIAN_LITTLE;
            else 
                opts.endian = Serializer::ENDIAN_NATIVE;
        }

		ui = unOpt.find("-d3d");
		if (ui->second)
		{
			opts.d3d = true;
		}

		ui = unOpt.find("-gl");
		if (ui->second)
		{
			opts.gl = true;
			opts.d3d = false;
		}

	}
    // Source / dest
    if (numArgs > startIndex)
        source = args[startIndex];
    if (numArgs > startIndex+1)
        dest = args[startIndex+1];

    if (!source)
    {
        cout << "Missing source file - abort. " << endl;
        help();
        exit(1);
    }
    // Work out what kind of conversion this is
    opts.source = source;
	Ogre::vector<String>::type srcparts = StringUtil::split(opts.source, ".");
    String& ext = srcparts.back();
	StringUtil::toLowerCase(ext);
    opts.sourceExt = ext;

    if (!dest)
    {
        if (opts.sourceExt == "xml")
        {
            // dest is source minus .xml
            opts.dest = opts.source.substr(0, opts.source.size() - 4);
        }
        else
        {
            // dest is source + .xml
            opts.dest = opts.source;
            opts.dest.append(".xml");
        }

    }
    else
    {
        opts.dest = dest;
    }
	Ogre::vector<String>::type dstparts = StringUtil::split(opts.dest, ".");
    ext = dstparts.back();
	StringUtil::toLowerCase(ext);
    opts.destExt = ext;

    if (!opts.quietMode) 
	{
        cout << endl;
        cout << "-- OPTIONS --" << endl;
        cout << "source file      = " << opts.source << endl;
        cout << "destination file = " << opts.dest << endl;
            cout << "log file         = " << opts.logFile << endl;
        cout << "interactive mode = " << StringConverter::toString(opts.interactiveMode) << endl;
        if (opts.numLods == 0)
        {
            cout << "lod levels       = none (or use existing)" << endl;
        }
        else
        {
            cout << "lod levels       = " << opts.numLods << endl;
            cout << "lod value     = " << opts.lodValue << endl;
            cout << "lod strategy     = " << opts.lodStrategy << endl;
            if (opts.usePercent)
            {
                cout << "lod reduction    = " << opts.lodPercent << "%" << endl;
            }
            else
            {
                cout << "lod reduction    = " << opts.lodFixed << " verts" << endl;
            }
        }
        if (opts.nuextremityPoints)
            cout << "Generate extremes per submesh = " << opts.nuextremityPoints << endl;
        cout << "Generate edge lists  = " << opts.generateEdgeLists << endl;
        cout << "Generate tangents = " << opts.generateTangents << endl;
		cout << " semantic = " << (opts.tangentSemantic == VES_TANGENT? "TANGENT" : "TEXCOORD") << endl;
		cout << " parity = " << opts.tangentUseParity << endl;
		cout << " split mirror = " << opts.tangentSplitMirrored << endl;
		cout << " split rotated = " << opts.tangentSplitRotated << endl;
        cout << "Reorganise vertex buffers = " << opts.reorganiseBuffers << endl;
    	cout << "Optimise animations = " << opts.optimiseAnimations << endl;
    	
        cout << "-- END OPTIONS --" << endl;
        cout << endl;
    }


    return opts;
}