Open .vrscene and export whole keyframe animation for Camera, how?

Hi there,

Trying to figure out how to export WHOLE keyframe animation using Python API.

I did this but it doesn’t work for some reason?

<CODE>
renderView = renderer.classes.RenderView.getInstanceOrCreate()
# renderer.useAnimatedValues = True
for trajectory_name, trajectory in trajectories.items():
print_log(f"Embedding trajectory: {trajectory_name}“)
for transform in trajectory:
updatedTransform = renderView.getValue(‘transform’, 0)
updatedTransform = updatedTransform.replaceOffset(vray.Vector(transfo rm.position.x, transform.position.y, transform.position.z))
renderView.setValue(‘transform’, updatedTransform, current_frame)
print_log(f"Frame {current_frame}: {updatedTransform}”)​

</CODE>

Then renderer.export(“test.vrscene”)

Only frame 0 being exported, why?

Hi Petr,

Do you see something like

// Frame at time 0

RenderView __00000001_RenderView {
transform=interpolate(
    (0, Transform(Matrix(Vector(0, 0, 0), Vector(0, 0, 0), Vector(0, 0, 0)), Vector(0, 0, 0))),
    (1, Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(1, 2, 3))),
    (2, Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(11, 22, 33)))
  );
}

``` in test.vrscene?
Although there is a "Frame at time 0" comment (which is the time at which the scene was exported), there are actually 3 frames at 3 different times wrapped in a single interpolate statement.

BTW, you don't need to set *renderer.useAnimatedValues* when using getValue()/setValue() with explicit time parameter.

Best regards,
Stan​

@stanislav.kirilov Thank you for quick response.

Yes, I see // Frame at time 0

Previously when exporting the scene via 3ds Max script command I saw Frame at time 0, 1, 2, 3, 4 etc. I am wondering if there are some differences when exporting via Maxscript VS AppSDK?

I used the command below and now I want to mimic it via V-Ray AppSDK:

command = f"vrayExportVRScene “{output_dir}\\{scene_name}.vrscene”"
command += f" startFrame:{start_frame}"
command += f" endFrame:{end_frame}"
command += f" exportSetting:true"
command += f" exportGeometry:true"
command += f" exportLights:true"
command += f" exportNodes:true"
command += f" exportMaterials:true"
command += f" exportTextures:true"
command += f" exportBitmaps:true"
command += f" exportRegion:false"

Btw, the command above results in SUPER SLOW export due to number of frames the scene has (>7000 frames). While re-export via V-Ray AppSDK is instantaneous!

Please let me know?​

V-Ray for 3ds max (most probably) uses “incremental” frames export which means, it sets the values for a single frame (at a particular time) and writes a .vrscene-file, then it advances to the next frame, clears the values for the previous frame(s) and sets the values for the new one, then writes again appending to the already created .vrscene-file and so on to the end of the sequence. AppSDK writes the .vrscene-file at once with all frame values set. There should be no difference when both files are read and rendered back.

If you want to mimic the behavior of V-Ray for 3ds max, you can set the values for the first frame and export it passing { ‘currentFrameOnly’: True } to the export function as a second parameter. Then you can use renderer.clearAllPropertyValuesUpToTime(time) (or clearPropertyValuesUpToTime(time, pluginCategories)) to remove the previous values, set the values for the new frame and append to the already existing file passing { ‘currentFrameOnly’: True, ‘incremental’: True} and so on for all subsequent frames.

Or you can use mixed approach e.g. export the first 100 or 1000 frames, clear them and add the next 100 or 1000… :)​

Appreciate your response!

@stanislav.kirilov What is Maxscript alternative for Scene Animation Range?

If you type help(vray.VRayRenderer.export) or help(renderer.export) you’ll be able to see all export settings.
Setting { ‘currentFrameOnly’: True, ‘leftInterval’: startTime-currentTime, ‘rightInterval’: endTime-currentTime } where all times are based on (or can be calculated from) frame numbers and FPS (needed only if the scene FPS != 1 and scene startTime != 0.0).

Unfortunately I still don’t understand how to mimic Scene Animation Range​ value in Maxscript?

Is it 3ds max Python API of App SDK one?
help(vray.VRayRenderer.export) or help(renderer.export)

Here I’m always writing about Python App SDK and the one included in V-Ray for 3ds max should be exactly the same as the full one.
Here is an example file
While writing it, I actually found a bug where exporting e.g. frames 10..19 would actually export frames 9..19. In most cases the resultant file would render the same. Nevertheless, we will fix the bug in the next release. Look at the example to see how to circumvent the issue if needed.
I’m sorry for the bug but I’m happy that you made me find it! So thank you! :slight_smile:
forum-anim.zip (781 Bytes)

Thank you so much!

The bug I mentioned about in my previous comment is already fixed in stable nightly builds (currently version 7.10) so you can check them if you have access to them.