Jump to content

setplayer problem


photo

Recommended Posts

Posted

i use setplayer in update() 

and i grab frames after i call setplayer

i found the frame i grabbed was not changed.

about one or two frames later , the frame changed.

but i want after i call setplayer, the frame change immediately。

is it possible?

 

Posted
20 hours ago, silent said:

Could you please provide a code that you are using? Right now it's hard to say what is going on, without seeing the actual code.

Thanks!

    virtual int update()
    {

        //2 if the first breakpoint is hit and add a breakpoint here to see whether the frame changes or not. sometime it not change
        static int count = 0;
        Game *game = Game::get();
        float time = game->getTime();
        if (count % 50 == 0)
        {

            //1 add a breakpoint here if setplay is called
            float x = 0;// sinf(time * 1.0f) * 4.0f;
            float y = 8;// cosf(time * 1.0f) * 4.0f;
            float z = 1.0f;//2.0f +sinf(time * 3.0f) * 1.0f;
            player->setWorldTransform(setTo(UNIGINE_VEC3(x, y, z), UNIGINE_VEC3(0.0f, 0.0f, 0.0f), vec3(0.0f, 0.0f, 1.0f)));
            //player->setFov(60.0f + sinf(time * 2.0f) * 25.0f);
            game->setPlayer(player->getPlayer());
            Log::message("0 setPlayer %d\n", count);
        }
        else if (count % 50 == 25)
        {
            float x = 1;//sinf(time * 1.0f) * 4.0f;
            float y = 4;// cosf(time * 1.0f) * 4.0f;
            float z = 1.0f;// +sinf(time * 3.0f) * 1.0f;
            player->setWorldTransform(setTo(UNIGINE_VEC3(x, y, z), UNIGINE_VEC3(0.0f, 0.0f, 0.0f), vec3(0.0f, 0.0f, 1.0f)));
            //player->setFov(60.0f + sinf(time * 2.0f) * 25.0f);
            game->setPlayer(player->getPlayer());
            Log::message("1 setPlayer %d\n", count);
        }
        else{
            Log::message("2 setPlayer %d\n", count);
        }
        count++;
        return 1;
    }

 

 

Posted

replace the file in the path :samples\Api\Nodes\Players

and 

1.jpg: before the setplay

2.jpg: the next frame after the setplay called, it not changes although it not appear frequently

3.jpg: the next frame after  the setplay called, it changes.

but i want next frame always change

what should i do?

 1.thumb.jpg.89ccab821dba7381e642131934548093.jpg2.thumb.jpg.bd9148b5de4b06ebd505acb09c314942.jpg

3.thumb.jpg.7cbb54fd21392ecc8c079007ecd9e4b3.jpg

Players.cpp

Posted

Hello, shichao

The behaviour you observing is due asynchronyous nature of GPU. It's not really up to engine what you see on your monitor at this very moment. It's more about complicated interaction between engine, OS and drivers. Try grab screenshot programmatically (like Render/Screenshot sample does). That's guaranteed that camera position at screenshot will be the last one you've set.

Posted
15 minutes ago, andrey-kozlov said:

Hello, shichao

The behaviour you observing is due asynchronyous nature of GPU. It's not really up to engine what you see on your monitor at this very moment. It's more about complicated interaction between engine, OS and drivers. Try grab screenshot programmatically (like Render/Screenshot sample does). That's guaranteed that camera position at screenshot will be the last one you've set.

 

i not found the sample in SDK 2.6

maybe the follow code is right?

while(1){

               engine->update();
                engine->render();

        ImagePtr buffer = Image::create();
        image->create2D(getWidth() * 2, getHeight(), Image::FORMAT_RGB8);
        context->CopySubresourceRegion((ID3D11Texture2D *)texture->getD3D11Texture(), 0, 0, 0, 0, render_targets, 0, NULL);
        texture->getImage(buffer);
        buffer->convertToFormat(Image::FORMAT_RGB8);
        image->copy(buffer, getWidth() 0, 0, 0, getWidth(), getHeight());

               engine->swap();

}       

but grab images in main loop cost a lot time.

what i do now is put the grab code in another thread so cause the problem 

 

Posted

For observing purpose you could catch the situation with breakpoints and then call the function saving image from debugger. At my machine it causes flushing image at screen as well

×
×
  • Create New...