Example #1
0
//-*****************************************************************************
void RenderIt()
{
    const char *templ = "/var/tmp/SimpleAbcViewer_camera.XXXXXX";
    char *buffer = new char[strlen( templ ) + 1];
    strcpy( buffer, templ );
#ifndef PLATFORM_WINDOWS
    mkstemp( buffer );
#endif
    std::string cameraFileName = buffer;
#ifdef PLATFORM_WINDOWS
    cameraFileName = "SimpleAbcViewer_camera.XXXXXX";
#endif

    float shutterOpenTime = -0.25f; // + ( float )g_transport->getCurrentFrame();
    float shutterCloseTime = 0.25f; //+ ( float )g_transport->getCurrentFrame();
    float openTime = -0.5f + ( float )g_transport->getCurrentFrame();
    float closeTime = 1.0f + openTime;

    std::ofstream camFile( cameraFileName.c_str() );
    camFile << g_state.scene.cam.RIB();
    camFile.close();

    Box3d bnd( g_transport->getBounds() );
    std::string boundStr;
    if ( ! bnd.isEmpty() )
    {
        std::ostringstream boundStream;
        boundStream << "["
                    << bnd.min[0] << " "
                    << bnd.max[0] << " "
                    << bnd.min[1] << " "
                    << bnd.max[1] << " "
                    << bnd.min[2] << " "
                    << bnd.max[2]
                    << "]";
        boundStr = boundStream.str();
    }
    else { boundStr = ""; }

    std::ostringstream cmdStream;
    cmdStream << 
        " --shutteropen=" << shutterOpenTime <<
        " --shutterclose=" << shutterCloseTime <<
        " -C " << cameraFileName <<
        " -P " << g_state.AlembicRiPluginDsoPath <<
        " -a " << g_state.abcFileName <<
        " --sample1=" << openTime <<
        " --sample2=" << closeTime <<
        " -B \"%s\"" << boundStr;
    std::string cmdArgs = cmdStream.str();
    std::string cmd = g_state.RenderScript;
    cmd += " ";
    cmd += cmdArgs;
    system( cmd.c_str() );

    delete[] buffer;
}
Example #2
0
void ExtractCameraFiles(int locale, bool basicLocale)
{
    printf("Extracting camera files...\n");
    DBCFile camdbc("DBFilesClient\\CinematicCamera.dbc");

    if (!camdbc.open())
    {
        printf("Unable to open CinematicCamera.dbc. Camera extract aborted.\n");
        return;
    }

    // get camera file list from DBC
    std::vector<std::string> camerafiles;
    size_t cam_count = camdbc.getRecordCount();

    for (size_t i = 0; i < cam_count; ++i)
    {
        std::string camFile(camdbc.getRecord(i).getString(1));
        size_t loc = camFile.find(".mdx");
        if (loc != std::string::npos)
            camFile.replace(loc, 4, ".m2");
        camerafiles.push_back(std::string(camFile));
    }

    std::string path = output_path;
    path += "/Cameras/";
    CreateDir(path);
    if (!basicLocale)
    {
        path += langs[locale];
        path += "/";
        CreateDir(path);
    }

    // extract M2s
    uint32 count = 0;
    for (std::string thisFile : camerafiles)
    {
        std::string filename = path;
        filename += (thisFile.c_str() + strlen("Cameras\\"));

        if (boost::filesystem::exists(filename))
            continue;

        if (ExtractFile(thisFile.c_str(), filename))
            ++count;
    }
    printf("Extracted %u camera files\n", count);
}