Can I run *.vs3 or *.vc3 in vapor_python?

Hi,

Does the vapor_python provide the function that can run the *.vs3 or *.vc3 files?
I made them in Window system and want to save time for writing the vapor_python script.
Thanks

  • Yi -

Hi,

Vapor can open .vs3 files. I do not believe it can currently read .vc3 camera files though. Below is a script that I use to load a .vs3 file, load its camera settings, and interpolate into the perspective of another vs3’s camera position. Hope that helps.

#!/usr/bin/env python3

from vapor import session, camera

# Acquire the camera settings from an initial session file
ses1 = session.Session()
ses1.Load("/Users/pearse/Data/eastTroublesome/et_1.vs3")
cam1 = ses1.GetCamera()
dir1 = cam1.GetDirection()
pos1 = cam1.GetPosition()
up1 = cam1.GetUp()

# Acquire the camera settings from a secondary session file that we will transition into
ses2 = session.Session()
ses2.Load("/Users/pearse/Data/eastTroublesome/et_2.vs3")
cam2 = ses2.GetCamera()
dir2 = cam2.GetDirection()
pos2 = cam2.GetPosition()
up2 = cam2.GetUp()

# Difference between camera positions on each axis
dPositionX  = (pos2[0] - pos1[0])
dPositionY  = (pos2[1] - pos1[1])
dPositionZ  = (pos2[2] - pos1[2])

# Difference between camera direction vectors on each axis
dDirectionX = (dir2[0] - dir1[0])
dDirectionY = (dir2[1] - dir1[1])
dDirectionZ = (dir2[2] - dir1[2])

# Difference between camera up vectors on each axis
dUpX        = (up2[0] - up1[0])
dUpY        = (up2[1] - up1[1])
dUpZ        = (up2[2] - up1[2])

steps=50
for i in range(0,steps):
    position = [
        pos1[0]+dPositionX*i/steps,
        pos1[1]+dPositionY*i/steps,
        pos1[2]+dPositionZ*i/steps
    ]
    cam1.SetPosition( position )

    direction = [
        dir1[0]+dDirectionX*i/steps,
        dir1[1]+dDirectionY*i/steps,
        dir1[2]+dDirectionZ*i/steps
    ]
    cam1.SetDirection( direction )

    up = [
        up1[0]+dUpX*i/steps,
        up1[1]+dUpY*i/steps,
        up1[2]+dUpZ*i/steps
    ]
    cam1.SetUp( up )
    ses1.Render("/Users/pearse/Data/eastTroublesome/captures/" + str(i) + ".png")
1 Like

Thank you so much for the response, Pearse. :slight_smile:
It was very helpful. It is very applicable script~!!

I could load vc3 script successfully after correcting some of the direction names.

But, cannot be done with saving images. T_T
I found that I need to downgrade for the GLSL 4.10 to under 3.10.
therefore, I am trying to use other ways to save the figures while the GLSL downgraded.

The rendered image can be saved by “plt.savefig”?
There was just no image when I use "plt.savefig(“test.png”).

Thanks