예제 #1
0
/**
 * Main application entry point.
 *
 * @param argc The number of command line arguments
 * @param argv The array of command line arguments.
 *
 * usage:   gameplay-encoder[options] <file_list>
 * example: gameplay-encoder C:/assets/seymour.dae
 * example: gameplay-encoder -i boy seymour.dae
 *
 * @stod: Improve argument parsing.
 */
int main(int argc, const char** argv)
{
    EncoderArguments arguments(argc, argv);

    if (arguments.parseErrorOccured())
    {
        arguments.printUsage();
        return 0;
    }

    // Check if the file exists.
    if (!arguments.fileExists())
    {
        LOG(1, "Error: File not found: %s\n", arguments.getFilePathPointer());
        return -1;
    }

    // File exists
    LOG(1, "Encoding file: %s\n", arguments.getFilePathPointer());

    switch (arguments.getFileFormat())
    {
    case EncoderArguments::FILEFORMAT_DAE:
        {
            std::string realpath(arguments.getFilePath());
            DAESceneEncoder daeEncoder;
            daeEncoder.write(realpath, arguments);
            break;
        }
    case EncoderArguments::FILEFORMAT_FBX:
        {
#ifdef USE_FBX
            std::string realpath(arguments.getFilePath());
            FBXSceneEncoder fbxEncoder;
            fbxEncoder.write(realpath, arguments);
            break;
#else
            LOG(1, "Error: FBX not enabled. Install the FBX SDK and use the preprocessor definition USE_FBX.\n");
            return -1;
#endif
        }
    case EncoderArguments::FILEFORMAT_TTF:
        {
            unsigned int fontSize = arguments.getFontSize();
            if (fontSize == 0)
            {
                fontSize = promptUserFontSize();
            }
            std::string id = getBaseName(arguments.getFilePath());
            writeFont(arguments.getFilePath().c_str(), arguments.getOutputFilePath().c_str(), fontSize, id.c_str(), arguments.fontPreviewEnabled());
            break;
        }
    case EncoderArguments::FILEFORMAT_GPB:
        {
            std::string realpath(arguments.getFilePath());
            GPBDecoder decoder;
            decoder.readBinary(realpath);
            break;
        }
    case EncoderArguments::FILEFORMAT_PNG:
    case EncoderArguments::FILEFORMAT_RAW:
        {
            if (arguments.normalMapGeneration())
            {
                int x, y;
                arguments.getHeightmapResolution(&x, &y);
                NormalMapGenerator generator(arguments.getFilePath().c_str(), arguments.getOutputFilePath().c_str(), x, y, arguments.getHeightmapWorldSize());
                generator.generate();
            }
            else
            {
                LOG(1, "Error: Nothing to do for specified file format. Did you forget an option?\n");
                return -1;
            }
            break;
        }
   default:
        {
            LOG(1, "Error: Unsupported file format: %s\n", arguments.getFilePathPointer());
            return -1;
        }
    }

    return 0;
}
예제 #2
0
파일: main.cpp 프로젝트: 03050903/GamePlay
/**
 * Main application entry point.
 *
 * @param argc The number of command line arguments
 * @param argv The array of command line arguments.
 *
 * usage:   gameplay-encoder[options] <file_list>
 * example: gameplay-encoder C:/assets/duck.fbx
 * example: gameplay-encoder -i boy duck.fbx
 *
 * @stod: Improve argument parsing.
 */
int main(int argc, const char** argv)
{
    EncoderArguments arguments(argc, argv);

    if (arguments.parseErrorOccured())
    {
        arguments.printUsage();
        return 0;
    }

    // Check if the file exists.
    if (!arguments.fileExists())
    {
        LOG(1, "Error: File not found: %s\n", arguments.getFilePathPointer());
        return -1;
    }

    // File exists
    LOG(1, "Encoding file: %s\n", arguments.getFilePathPointer());

    switch (arguments.getFileFormat())
    {
    case EncoderArguments::FILEFORMAT_FBX:
        {
            std::string realpath(arguments.getFilePath());
            FBXSceneEncoder fbxEncoder;
            fbxEncoder.write(realpath, arguments);
            break;
        }
    case EncoderArguments::FILEFORMAT_TMX:
        {
            TMXSceneEncoder tmxEncoder;
            tmxEncoder.write(arguments);
            break;
        }
    case EncoderArguments::FILEFORMAT_TTF:
    case EncoderArguments::FILEFORMAT_OTF:
        {
            std::vector<unsigned int> fontSizes = arguments.getFontSizes();
            
            Font::FontFormat fontFormat = arguments.getFontFormat();
            if (fontFormat == Font::BITMAP)
            {
                if (fontSizes.size() == 0)
                {
                    fontSizes = promptUserFontSize();
                }
            }
            else
            {
                // Distance fields use size
                if (fontSizes.size() == 0)
                {
                    fontSizes.push_back(FONT_SIZE_DISTANCEFIELD);
                }
            }
            std::string id = getBaseName(arguments.getFilePath());
            writeFont(arguments.getFilePath().c_str(), arguments.getOutputFilePath().c_str(), fontSizes, id.c_str(), arguments.fontPreviewEnabled(), fontFormat);
            break;
        }
    case EncoderArguments::FILEFORMAT_GPB:
        {
            std::string realpath(arguments.getFilePath());
            GPBDecoder decoder;
            decoder.readBinary(realpath);
            break;
        }
    case EncoderArguments::FILEFORMAT_PNG:
    case EncoderArguments::FILEFORMAT_RAW:
        {
            if (arguments.normalMapGeneration())
            {
                int x, y;
                arguments.getHeightmapResolution(&x, &y);
                NormalMapGenerator generator(arguments.getFilePath().c_str(), arguments.getOutputFilePath().c_str(), x, y, arguments.getHeightmapWorldSize());
                generator.generate();
            }
            else
            {
                LOG(1, "Error: Nothing to do for specified file format. Did you forget an option?\n");
                return -1;
            }
            break;
        }
   default:
        {
            LOG(1, "Error: Unsupported file format: %s\n", arguments.getFilePathPointer());
            return -1;
        }
    }

    return 0;
}
예제 #3
0
/**
 * Main application entry point.
 *
 * @param argc The number of command line arguments
 * @param argv The array of command line arguments.
 *
 * usage:   gameplay-encoder[options] <file_list>
 * example: gameplay-encoder C:/assets/seymour.dae
 * example: gameplay-encoder -i boy seymour.dae
 *
 * @stod: Improve argument parsing.
 */
int main(int argc, const char** argv)
{
    EncoderArguments arguments(argc, argv);

    if (arguments.parseErrorOccured())
    {
        arguments.printUsage();
        return 0;
    }

    // Check if the file exists.
    if (!arguments.fileExists())
    {
        fprintf(stderr, "Error: File not found: %s\n", arguments.getFilePathPointer());
        return -1;
    }

    // File exists
    fprintf(stderr, "Encoding file: %s\n", arguments.getFilePathPointer());

    switch (arguments.getFileFormat())
    {
    case EncoderArguments::FILEFORMAT_DAE:
        {
            std::string realpath(arguments.getFilePath());
            DAESceneEncoder daeEncoder;
            daeEncoder.write(realpath, arguments);
            break;
        }
    case EncoderArguments::FILEFORMAT_FBX:
        {
#ifdef USE_FBX
            std::string realpath(arguments.getFilePath());
            FBXSceneEncoder fbxEncoder;
            fbxEncoder.write(realpath, arguments);
            break;
#else
            fprintf(stderr, "Error: FBX not enabled. Install the FBX SDK and use the preprocessor definition USE_FBX.\n");
            return -1;
#endif
        }
    case EncoderArguments::FILEFORMAT_TTF:
        {
            unsigned int fontSize = arguments.getFontSize();
            if (fontSize == 0)
            {
                fontSize = promptUserFontSize();
            }
            std::string id = getBaseName(arguments.getFilePath());
            writeFont(arguments.getFilePath().c_str(), arguments.getOutputFilePath().c_str(), fontSize, id.c_str(), arguments.fontPreviewEnabled());
            break;
        }
    case EncoderArguments::FILEFORMAT_GPB:
        {
            std::string realpath(arguments.getFilePath());
            GPBDecoder decoder;
            decoder.readBinary(realpath);
            break;
        }
   default:
        {
            fprintf(stderr, "Error: Unsupported file format: %s\n", arguments.getFilePathPointer());
            return -1;
        }
    }

    return 0;
}