Jump to content

Setting/ Editing properties of a viewport using Get/set ViewMatrix

Recommended Posts

I I would like to duplicate a viewport (linked to a camera) and change the rotation of the camera in the new viewport

From the reference I have found VS:GetViewMatrix and VS:SetViewMatrix and managed to get, change and set the rotationXAng parameter but it doesn't change the direction of the camera. 


Hoffset = 0.117236
Y =0
viewport = vs.FSActLayer()
VPparams = vs.GetViewMatrix(viewport)
VPparamsList = list (VPparams)
Myoffset = VPparamsList[1]
MyrotationXAng = VPparamsList[2]
MyrotationYAng = VPparamsList[3]
MyrotationZAng = VPparamsList[4]
MyrotationYAng = 45
VpCylR1 = vs.HDuplicate(viewport,Hoffset,Y)
vs.SetViewMatrix(VpCylR1, Myoffset, MyrotationXAng, MyrotationYAng, MyrotationZAng)
VpCylR2 =vs.HDuplicate(viewport,Hoffset*2,Y)
VpCylR3 =vs.HDuplicate(viewport,Hoffset*3,Y)
VpCylL1 =vs.HDuplicate(viewport,0-Hoffset,Y)
VpCylL2 =vs.HDuplicate(viewport,0-Hoffset*2,Y)
VpCylL2 =vs.HDuplicate(viewport,0-Hoffset*3,Y)




Link to comment

It is very likely there is a one way link between the camera and the viewport. Changing the viewport will likely not make changes to the camera.


I played with it a little, but I did not find the proper incantation to get the viewport to update based on scripted changes to the camera.


You can get a handle to the camera using

def  vs.GetVPGroup(viewportHandle, groupType):

   return HANDLE


with a groupType of 10. 


Using the handle to that object you can change the settings of the camera, but the Viewport does not update until you manually select the Edit Camera option. I have tried all the tricks I know about resetting objects from the Camera all the way up and nothing has worked.


Good Luck.




Link to comment

Thanks for trying, I can't see how I would ever have found vs.GetVPGroup would get a handle to the cameras - shame the view doesn't update. 


I have been trying to use vs.SetViewMatrix with the cameras deleted which does update and I can make incremental changes to the views but I haven't figured out how to make a simple 20degree rotation. I did the rotations manually then checked the parameters and it seems it isn't just the Y Rotation angle that changes. 

The sequence of parameters below are for a set of cameras rotated 20 degrees - I can't figure out why the offsets (X,Y,Z) change 


RotX=-90.0RotY=90.0RotZ=0.0X=415369.5  Y=94456.215 Z=105.2183062590922

RotX=90.0RotY=70.0RotZ=180.0X=415341.2491173034  Y=94456.215 Z=66.99958883375739

RotX=90.0RotY=50.00000000000002RotZ=180.0X=415301.6304000912  Y=94456.215 Z=40.748113042233484

RotX=90.0RotY=30.000000000000018RotZ=180.0X=415255.4224503691  Y=94456.215 Z=29.630194295498455

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...