XNA to render 3D video (fixed FPS!)

i have to develop an application in wich the final step is to export a video (or a single frame) of a 3D animation generated by my software calculating the user input parameters.

I want to use XNA and for this. i need that the software can export FIXED FPS video (or also all single frames of the video separately). It's not a matter the LIVE FPS. I don't need to view on the screen the frames at a fixed fps. As the animation could be very complex, i could accept if the software take 1 minute for each frame.

The important is that i can see the frame while it render and that is not skipped any frame. eg. if the video is 1 minute long, it have to export 24 frames at 24fps also if it will take 20secs to render each frame. After rendered the first frame (so after 20sec) it haven't to render the frame at 21sec. it have to render the frame [2/24 of the first minute]

How can i obtain this?



Here is the method for doing this for XNA 4.0, described in code for your Game class (because it's easy for me):

protected override void Update(GameTime gameTime)
    // Do Nothing!

void RealUpdate()
    const float deltaTime = 1f/60f; // Fixed 60 FPS     
    // Update your scene here

RenderTarget2D screenshot;

protected override void LoadContent()
    screenshot = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Color, null);

protected override void UnloadContent()

int i = 0;

protected override void Draw(GameTime)
    RealUpdate(); // Do the update once before drawing each frame.

    GraphicsDevice.SetRenderTarget(screenshot); // rendering to the render target
    // Render your scene here
    GraphicsDevice.SetRenderTarget(null); // finished with render target

    using(FileStream fs = new FileStream(@"screenshot"+(i++)+@".png", FileMode.OpenOrCreate)
        screenshot.SaveAsPng(fs, width, height); // save render target to disk

    // Optionally you could render your render target to the screen as well so you can see the result!


Note: I wrote this without compiling or testing - so there might be a minor error or two.

Need Your Help

How can I make an instance of a block of Blockly with Javascript?

javascript blockly

I have done the following block with Blockly in a customBlocks.js file:

how accurate is the altitude measurement in mobile phones

iphone android windows-phone-7 gps mobile-phones

How accurate is the altitude measurement from a mobile phone's GPS? I've gathered that the lat/long can vary by hundreds of meters but is that same level of uncertainty present in the altitude val...