Пример #1
0
int main(int argc, char *argv[]) {
    if (argc<2) {
        printf("No output file name prefixgiven.\n");
        printf("Use:\n\t%s output_prefix\n\n", argv[0]);
        exit(1);
    }

    /* const size_t NUM_FRAMES = 10; */

    RiBegin(RI_NULL);

    scene_info_t scene;

    scene.cam.location[0] = 20;
    scene.cam.location[1] = 20;
    scene.cam.location[2] = 20;

    scene.cam.look_at[0]= 0.0;
    scene.cam.look_at[1]= 0.0;
    scene.cam.look_at[2]= 0.0;
    scene.cam.roll = 0.0;
    
    scene.fprefix = argv[1];

    size_t cur_frame = 0;
    
    for (size_t fnum = 0; fnum <= 20; ++fnum) {
        doFrame(cur_frame, &scene);
        scene.cam.location[0] -= 2;
        cur_frame += 1;
    }
    for (size_t fnum = 0; fnum <= 20; ++fnum) {
        doFrame(cur_frame, &scene);
        scene.cam.location[1] -= 2;
        cur_frame += 1;
    }
    for (size_t fnum = 0; fnum <= 20; ++fnum) {
        doFrame(cur_frame, &scene);
        scene.cam.location[0] += 2;
        cur_frame += 1;
    }
    for (size_t fnum = 0; fnum <= 20; ++fnum) {
        doFrame(cur_frame, &scene);
        scene.cam.location[1] += 2;
        cur_frame += 1;
    }

    RiEnd();

    return 0;
}
    void createContent(int width, int height, TestCanvas& canvas) override {
        container = TestUtils::createNode(0, 0, width, height, nullptr);
        doFrame(0); // update container

        canvas.drawColor(Color::White, SkXfermode::kSrcOver_Mode);
        canvas.drawRenderNode(container.get());
    }
Пример #3
0
void MohawkEngine_Riven::delay(uint32 ms) {
	uint32 startTime = _system->getMillis();

	while (_system->getMillis() < startTime + ms && !hasGameEnded()) {
		doFrame();
	}
}
Пример #4
0
int main(int argc, char *argv[]) {
    FILE *inf;
    wave_object_t obj;
    const size_t NUM_FRAMES = 360;
    RtInt md = 4;
    scene_info_t scene;
    double rad = 20;
    double t = 0.0;
    double dt = 2.0*PI/(NUM_FRAMES-1);
    size_t fnum;

    if (argc <3) {
        printf("No input and output file names given!\n");
        return 1;
    }
    
    inf = fopen(argv[1], "rt");
    if (inf == NULL) {
        printf("Could not open \"%s\"\n", argv[1]);
        return 1;

    }
    init_object(&obj);
    read_object(inf, &obj);
    
    
    printf("Object file has:\n  %zu vertices\n  %zu normals\n  %zu texture coordinates\n  %zu faces\n  %d objects\n",
           obj.num_verts, obj.num_norms, obj.num_texts, obj.num_faces, 1);

    RiBegin(RI_NULL);
    RiOption("trace", "maxdepth", &md, RI_NULL);
    RiSides(2);


    scene.cam.location[0] = rad;
    scene.cam.location[1] = rad;
    scene.cam.location[2] = rad;

    scene.cam.look_at[0]= 0.0;
    scene.cam.look_at[1]= 0.0;
    scene.cam.look_at[2]= 0.0;
    scene.cam.roll = 0.0;
    
    scene.fprefix = argv[2];

    for (fnum = 0; fnum < NUM_FRAMES; ++fnum) {
        scene.cam.location[0] = rad * sin(t);
        scene.cam.location[2] = rad * cos(t);
        t += dt;
        printf("Rendering frame %lu\n", fnum);
        doFrame(fnum, &scene, &obj);
    }
    RiEnd();

    free_object(&obj);

    fclose(inf);
    return 0;
}
Пример #5
0
void doDefault(struct sqlConnection *conn, boolean newSearch)
/* Put up default page - if there is no specific do variable. */
{
char *listSpec = cartUsualString(cart, hgpListSpec, "");
listSpec = skipLeadingSpaces(listSpec);
if (listSpec[0] == 0)
    doInitialPage();
else
    doFrame(conn, newSearch);
}
Пример #6
0
void Scene::loop() {
    while (!_vm->shouldQuit() && !_reloadSceneFlag && (_nextSceneId == _currentSceneId)) {
        // Handle drawing a game frame
        doFrame();

        // Wait for the next frame
        _vm->_events->waitForNextFrame();

        if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_trigger
                && _vm->_game->_player._stepEnabled)
            _reloadSceneFlag = true;
    }
}
Пример #7
0
int main(int argc, char *argv[])
{
    if (argc<2) {
        std::cerr << "No filename given.\n";
        return 1;
    }
    int i;
    RiBegin(RI_NULL);

    for (i=1;i<=360; ++i) {
        doFrame(i, argv[1]);
    }
  
    RiEnd();
}
Пример #8
0
void SystemClass::run()
{
	MSG Message;
	bool Done = false;

	ZeroMemory(&Message, sizeof MSG);

	while (!Done) {
		if (PeekMessage(&Message, NULL, 0, 0, PM_REMOVE)) {
			TranslateMessage(&Message);
			DispatchMessage(&Message);
		}

		if (Message.message == WM_QUIT || !doFrame())
			Done = true;

		if (InputManager->isKeyPressed(DIK_ESCAPE))
			Done = true;
	}
}
Пример #9
0
	void gameLoop()
	{
		frameNum++;

		//LOG("doFrame()...");
		doFrame();

		h3dSetNodeTransform(cam,
				//0, 0, 0,
				0, 10, 10,
				_rx ,_ry, 0,
				1, 1, 1
				);

		//LOG("h3dRender(cam)...");
		h3dRender(cam);

		//LOG("h3dutShowFrameStats(fontMatRes, panelMatRes, 2)...");
		h3dutShowFrameStats(fontMatRes, panelMatRes, 2);

#if 0
		//int n = snprintf(text, textLen - 1, "Frame %d: %f ms", frameNum, msSinceLastFrame());
		//int n = snprintf(text, textLen - 1, "Frame %d", frameNum % 32);
		int n = snprintf(text, textLen - 1, "Frame %d", frameNum);

		LOG("Showing text \"%s\" (wrote %d chars) with color (%d, %d, %d)", text, n, frameNum % 2, (frameNum >> 1) % 2, (frameNum >> 2) % 2);
		h3dutShowText(text,
				0.5, 0.5,   // Position
				0.05,       // Size (scale)
				frameNum % 2, (frameNum >> 1) % 2, (frameNum >> 2) % 2, // Color (RGB)
				fontMatRes  // Font material
				);
#endif

		//LOG("h3dFinalizeFrame()...");
		h3dFinalizeFrame();

		//LOG("Frame finished.");
	} // end gameLoop
Пример #10
0
void doEmptyDialog (
		char *lpTitle,
		bool bShowTotalProgress,
		COORD &c
		)
{
	int Diff = 0;
	CONSOLE_SCREEN_BUFFER_INFO SInfo;

	GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE), &SInfo);

	c.X = SInfo.dwSize.X/2-28;
	c.Y = SInfo.dwSize.Y/2-9;

	if ( bShowTotalProgress)
	{
		Diff = 2;
		c.Y = SInfo.dwSize.Y/2-9;
	}

	doFrame (c.X, c.Y, 55, 10+Diff, lpTitle, true);
}
Пример #11
0
int main(int argc, char **argv)
{
    //parse command line
    strcpy(autoip,"");
    for(int j=0; j<argc; j++)
    {
        if(strcmp(argv[j],"-full")==0)
            fullscreen=1;
        else if(strstr(argv[j],"-join")!=0)
            sscanf(argv[j],"-join:%s", autoip);
        else if(strstr(argv[j],"-port")!=0)
            sscanf(argv[j],"-port:%ld", &SERVER_PORT);
    }
    //strcpy(autoip,"127.0.0.1");//testing

    //init graphics
    initializeSystem();

    //setup
    setupClient();

    //startup
    term.newLine("^cMystera Legends Beta %.3f ^b- ^OZircon Release",client_version);
    //only for testing
    //initTestingMode();

    //checking for newer version or showing servers
    //if(!checkVer())showServers();
    //get available servers
    //initialize socket library
    if(!debug)
    {
        if(strlen(autoip)>2)
        {
            /*dialog=-1;
            //char show[128];
            cstate=1;
             //sprintf(show,"--- Attempting to connect to %s",autoip);
             //term.newLine(show);
             //term.render(0,480,246);
             //Renderer::Swap();
            if(!nc.connect(autoip,SERVER_PORT))
            	term.newLine("--- Error connecting. CTRL-Q to quit.");
            else
            {
            	term.newLine("--- Connected to %s.",autoip);
            	connected=1;
            }*/
            sips.size(1);
            strcpy(sips[0].ip,autoip);
            sprintf(sips[0].name,"^W%s",autoip);
            strcpy(sips[0].players," ");
            vDialog[0].w[2].addList(sips[0].name);
            dialog=0;
        }
        else
            showServers();
    }

    unsigned long loopnum   = 0;
    unsigned long lastsec   = 0;
    unsigned long loopdif   = 0;
    long second    = time(0);
    unsigned long sleeptime = 0;
    const long FPS = 50;

    //buildMapLayers();
    //application loop
    while(!done)
    {

        Input::Update();
        doFrame();

        if(time(0) == second + 1)
        {
            loopdif = loopnum - lastsec;
            lastsec = loopnum;
            sleeptime = float(1000/FPS);
            sleeptime -= loopdif/1000;
            second++;
        }

        loopnum++;
        Sleep(sleeptime);

        if(connected)
        {
            //term.newLine("I really am connected you know.");
            if(udpTimer.tick(1500))
            {
                //send udp packet
                char u=NULL_MSG;
                nc.send((unsigned char *)&u,1,SEND_NON_GUARANTEED);
            }

            int res = nc.update();
            if(res==-1 || servTimer.tick(1000000))
            {
                me=-1;
                player.size(0);
                player.size(10);
                world.size(0);
                world.size(10);
                item.size(0);
                term.newLine("--- Connection closed.");
                connected=0;
                servTimer.reset();
                dialog=0;

                Renderer::SetTitle("Mystera Legends Beta");
                nc.shutdown();
            }
        }
    }
    //shutdown
    fclose(chatLog);

    nc.shutdown();
    Mix_CloseAudio();

    Renderer::Shutdown();
    //if(restart)
    //	doRestart();

    return 0;
}
Пример #12
0
int main(int argc, char *argv[]) {
    if (argc<2) {
        printf("No file names given.\n");
        printf("Use:\n\t%s audio_file output_prefix\n\n", argv[0]);
        exit(1);
    }
    av_register_all();

    audio_data_t snd_data;
    read_audio(argv[1], &snd_data);

    int per_frame = snd_data.sample_rate/30;

    int32_t maxVal = 0;
    switch (snd_data.sample_size) {
    case 1:
        maxVal = 1<<6;
        break;
    case 2:
        maxVal = 1<<12;
        break;
    default:
        maxVal = 1<<28;
    }
    const int N = 120;

    fftw_complex *fft_in  __attribute__ ((aligned (16)));
    fftw_complex **fft_out  __attribute__ ((aligned (16)));

    fftw_plan fft_plan  __attribute__ ((aligned (16)));

    fft_in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
    fft_out = (fftw_complex**) fftw_malloc(sizeof(fftw_complex*) * N);

    for (int i=0; i<N; ++i) {
        fft_out[i] = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
    }

    fft_plan = fftw_plan_dft_1d(N, fft_in, fft_out[0], FFTW_FORWARD, FFTW_ESTIMATE);

    size_t fnum, cur_out;

    for (size_t i=0; i<N; ++i) {
        fft_in[i] = 0.0;
        for (size_t j=0; j<N; ++j) {
            fft_out[i][j] = 0.0;
        }
    }
    show_audio_info(&snd_data);
    
    RiBegin(RI_NULL);
    
    size_t num_frames = (snd_data.num_samples-per_frame)/per_frame;
    for (size_t i = 0, cur_out = 0, fnum = 1; i<(snd_data.num_samples-per_frame); i+= per_frame, ++fnum) {

        size_t j_size = N/2;
        size_t stp = per_frame/(j_size);
        size_t ci = per_frame*15+i;
        for (size_t j=0; j< j_size;++j) {
            
            fft_in[j] = (double)get_sample(&snd_data, ci, 0)/(double)maxVal;
            ci += stp;
        }

        fftw_execute_dft(fft_plan, fft_in, fft_out[cur_out]);

        printf("Calling doFrame %lu of %lu\n", fnum, num_frames);

        doFrame(fnum,
                cur_out, N, fft_out,
                argv[2]);

        cur_out += 1;
        if (cur_out == N) {
            cur_out = 0;
        }
    }

    RiEnd();
    for (size_t i=0; i<N; ++i) {
        fftw_free(fft_out[i]);
    }
    fftw_destroy_plan(fft_plan);
    fftw_free(fft_out);
    fftw_free(fft_in);
    fftw_cleanup();
    free(snd_data.samples);

    return 0;
}
int Narrator::script(int st, PRNG &prng)
{
    static ChaosParticles chaosA(flow, runner.config["chaosParticles"]);
    static ChaosParticles chaosB(flow, runner.config["chaosParticles"]);
    static OrderParticles orderParticles(flow, runner.config["orderParticles"]);
    static Precursor precursor(flow, runner.config["precursor"]);
    static RingsEffect ringsA(flow, runner.config["ringsA"]);
    static RingsEffect ringsB(flow, runner.config["ringsB"]);
    static RingsEffect ringsC(flow, runner.config["ringsC"]);
    static PartnerDance partnerDance(flow, runner.config["partnerDance"]);
    static CameraFlowDebugEffect flowDebugEffect(flow, runner.config["flowDebugEffect"]);
    static Forest forest(flow, runner.config["forest"]);
    static DarknessEffect darkness;

    rapidjson::Value& config = runner.config["narrator"];
    Sampler s(prng.uniform32());

    switch (st) {

        //////////////////////////////////////////////////////////////////////////////////////////////
        // Special states

        case 1: {
            // Darkness only ("off")
            crossfade(&darkness, 1);
            delayForever();
        }

        case 2: {
            // Precursor only (sleep mode)            
            precursor.reseed(prng.uniform32());
            crossfade(&precursor, 1);
            delayForever();
        }

        case 3: {
            // Debugging the computer vision system
            crossfade(&flowDebugEffect, 1);
            delayForever();
        }

        //////////////////////////////////////////////////////////////////////////////////////////////
        // Opening sequence

        case 0: {
            // Darkness until opening

            crossfade(&darkness, 1);
            delayUntilDate(config["opening"]["date"]);
            return config["opening"]["nextState"].GetInt();
        }

        //////////////////////////////////////////////////////////////////////////////////////////////
        // Cyclic states

        default: {
            endCycle();
            return 10;
        }

        case 10: {
            // Order trying to form out of the tiniest sparks; runs for an unpredictable time, fails.
            precursor.reseed(prng.uniform32());
            crossfade(&precursor, s.value(config["precursorCrossfade"]));

            // Bootstrap
            delay(s.value(config["precursorBootstrap"]));

            // Wait for darkness
            while (!precursor.isDone) {
                doFrame();
            }
            return 20;
        }

        case 20: {
            // Bang. Explosive energy, hints of self-organization

            ChaosParticles *pChaosA = &chaosA;
            ChaosParticles *pChaosB = &chaosB;
            
            int bangCount = s.value(config["bangCount"]);
            for (int i = 0; i < bangCount; i++) {
                pChaosA->reseed(prng.circularVector() * s.value(config["bangSeedRadius"]), prng.uniform32());
                crossfade(pChaosA, s.value(config["bangCrossfadeDuration"]));
                delay((1 << i) * s.value(config["bangDelayBasis"]));
                std::swap(pChaosA, pChaosB);
            }

            attention(s, config["bangAttention"]);

            return 30;
        }

        case 30: {
            // Textures of light, exploring something formless. Slow crossfade in
            ringsA.reseed(prng.uniform32());
            crossfade(&ringsA, s.value(config["ringsA-Crossfade"]));
            attention(s, config["ringsA-Attention"]);
            return 40;
        }

        case 40: {
            // Add energy, explore another layer.
            ringsB.reseed(prng.uniform32());
            crossfade(&ringsB, s.value(config["ringsB-Crossfade"]));
            attention(s, config["ringsB-Attention"]);
            return 50;
        }

        case 50: {
            // Biology happens, order emerges. Cellular look, emergent order.

            orderParticles.reseed(prng.uniform32());
            orderParticles.symmetry = 10;
            crossfade(&orderParticles, s.value(config["orderCrossfade"]));
            while (orderParticles.symmetry > 4) {
                attention(s, config["orderStepAttention"]);
                orderParticles.symmetry--;
            }
            attention(s, config["orderStepAttention"]);
            return 60;
        }

        case 60: {
            // Two partners, populations of particles.
            // Spiralling inwards. Depression. Beauty on the edge of destruction,
            // pressing forward until nothing remains.

            partnerDance.reseed(prng.uniform32());
            crossfade(&partnerDance, s.value(config["partnerCrossfade"]));
            attention(s, config["partnerAttention"]);
            return 70;
        }

        case 70: {
            // Sinking deeper. Interlude before a change.

            ringsC.reseed(prng.uniform32());
            crossfade(&ringsC, s.value(config["ringsC-Crossfade"]));
            attention(s, config["ringsC-Attention"]);
            return 80;
        }

        case 80: {
            // Continuous renewal and regrowth. Destruction happens unintentionally,
            // regrowth is quick and generative. The only way to lose is to stagnate.

            forest.reseed(prng.uniform32());
            crossfade(&forest, s.value(config["forestCrossfade"]));
            attention(s, config["forestAttention"]);
            return 90;
        }
    }
}
Пример #14
0
Common::Error MohawkEngine_Riven::run() {
	MohawkEngine::run();

	// Let's try to open the installer file (it holds extras.mhk)
	// Though, we set a low priority to prefer the extracted version
	if (_installerArchive.open("arcriven.z"))
		SearchMan.add("arcriven.z", &_installerArchive, 0, false);

	_gfx = new RivenGraphics(this);
	_video = new RivenVideoManager(this);
	_sound = new RivenSoundManager(this);
	_console = new RivenConsole(this);
	_saveLoad = new RivenSaveLoad(this, _saveFileMan);
	_optionsDialog = new RivenOptionsDialog(this);
	_scriptMan = new RivenScriptManager(this);
	_inventory = new RivenInventory(this);

	_rnd = new Common::RandomSource("riven");

	// Create the cursor manager
	if (Common::File::exists("rivendmo.exe"))
		_cursor = new PECursorManager("rivendmo.exe");
	else if (Common::File::exists("riven.exe"))
		_cursor = new PECursorManager("riven.exe");
	else // last resort: try the Mac executable
		_cursor = new MacCursorManager("Riven");

	initVars();

	// Check the user has copied all the required datafiles
	if (!checkDatafiles()) {
		return Common::kNoGameDataFoundError;
	}

	// We need to have a cursor source, or the game won't work
	if (!_cursor->hasSource()) {
		Common::String message = _("You're missing a Riven executable. The Windows executable is 'riven.exe' or 'rivendmo.exe'. ");
		message += _("Using the 'arcriven.z' installer file also works. In addition, you can use the Mac 'Riven' executable.");
		GUIErrorMessage(message);
		warning("%s", message.c_str());
		return Common::kNoGameDataFoundError;
	}

	// Open extras.mhk for common images
	_extrasFile = new MohawkArchive();

	// We need extras.mhk for inventory images, marble images, and credits images
	if (!_extrasFile->openFile("extras.mhk")) {
		Common::String message = _("You're missing 'extras.mhk'. Using the 'arcriven.z' installer file also works.");
		GUIErrorMessage(message);
		warning("%s", message.c_str());
		return Common::kNoGameDataFoundError;
	}

	// Set the transition speed
	_gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]);

	// Start at main cursor
	_cursor->setCursor(kRivenMainCursor);
	_cursor->showCursor();

	// Let's begin, shall we?
	if (getFeatures() & GF_DEMO) {
		// Start the demo off with the videos
		changeToStack(kStackAspit);
		changeToCard(6);
	} else if (ConfMan.hasKey("save_slot")) {
		// Load game from launcher/command line if requested
		int gameToLoad = ConfMan.getInt("save_slot");

		// Attempt to load the game.
		Common::Error loadError = _saveLoad->loadGame(gameToLoad);
		if (loadError.getCode() != Common::kNoError) {
			return loadError;
		}
	} else {
		// Otherwise, start us off at aspit's card 1 (the main menu)
		changeToStack(kStackAspit);
		changeToCard(1);
	}


	while (!hasGameEnded())
		doFrame();

	return Common::kNoError;
}
Пример #15
0
void OperationDialog::Show()
{
	CONSOLE_SCREEN_BUFFER_INFO SInfo;

	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &SInfo);

	SHORT sWidth = SInfo.srWindow.Right-SInfo.srWindow.Left+1;
	SHORT sHeight = SInfo.srWindow.Bottom-SInfo.srWindow.Top+1;

	int X = sWidth/2-28;
	int Y = sHeight/2-5;

	Info.Text(0, 0, 0, nullptr);

	string strTitle;

	switch ( m_nOperation ) {

	case OPERATION_ADD:
		strTitle = _T("Adding");
		break;

	case OPERATION_EXTRACT:
		strTitle = _T("Extracting");
		break;
	};


	if ( m_bShowSingleFileProgress )
		doFrame(X, Y, 55, 10, strTitle, true);
	else
		doFrame(X, Y, 55, 8, strTitle, true);

	string strStage;

	switch ( m_nStage ) {

	case STAGE_EXTRACTING:
		strStage = _T("Extracting file...");
		break;
	
	case STAGE_SKIPPING:
		strStage = _T("Skipping file...");
		break;

	case STAGE_ADDING:
		strStage = _T("Adding file...");
		break;

	case STAGE_UPDATING:
		strStage = _T("Updating file...");
		break;
	}

	Info.Text(X+5, Y+2, FarGetColor(COL_DIALOGTEXT), strStage);

	string strSrc = m_strSrcFileName;
	farTruncPathStr(strSrc, 45);

	string strDest = m_strDestFileName;
	farTruncPathStr(strDest, 45);

	string strTemp;

	strTemp.Format(_T("%-45s"), strSrc.GetString());
	Info.Text(X+5, Y+3, FarGetColor(COL_DIALOGTEXT), strTemp);

	if ( m_nStage != STAGE_SKIPPING )
	{
		Info.Text(X+5, Y+4, FarGetColor(COL_DIALOGTEXT), _M(MProcessFileTo));

		strTemp.Format(_T("%-45s"), strDest.GetString());
		Info.Text(X+5, Y+5, FarGetColor(COL_DIALOGTEXT), strTemp);
	}

	if ( m_bShowSingleFileProgress )
	{
		doIndicator(X+5, Y+6, 40, m_dPercent);
		doIndicator(X+5, Y+8, 40, m_dTotalPercent);
	}
	else
		doIndicator(X+5, Y+6, 40, m_dTotalPercent);

	Info.Text(0, 0, 0, nullptr);
}
Пример #16
0
JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_nativeDrawframe( JNIEnv * env, jobject obj,  jint width, jint height )
{
    doFrame( width, height );
}