Plz Help, How to bank a camera in Script?

butaixianranbutaixianran Posts: 161

How to bank camera in script? Please help.

I created a camera in script like this :

//Add new camera
var cam = new DzBasicCamera();
cam.setName( "cameraName" );
Scene.addNode( cam );
var tick = Scene.getTimeStep();

then, I set the X,Y,Z rotation with Rotation Control (XRotControl, YRotControl and ZRotControl)

But I found that operate ZRotControl is not bank!
And when I banking this camera in DAZ View (ctrl + right click + drag), all the X, Y, Z rotation are changing.

Is there a way to do this in script ?

Thanks!

Comments

  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    Yes, there is... quaternions.

    var oViewportMgr = MainWindow.getViewportMgr();
    var oViewport = oViewportMgr.getActiveViewport();
    var oViewport3D = oViewport.get3DViewport();
    
    var oCamera = oViewport3D.getCamera();
    var quatStart = oCamera.getLocalRot();
    var vecAxis = new DzVec3( 0.0, 0.0, 1.0 );
    var nDegrees = 45;
    var nRadians = nDegrees * 0.0174532925;
    var quatBank = new DzQuat( vecAxis, nRadians );
    
    quatBank = quatBank.multiply( quatStart );
    oCamera.setLocalRot( quatBank );

    -Rob

  • butaixianranbutaixianran Posts: 161
    edited December 1969

    rbtwhiz said:
    Yes, there is... quaternions.

    var oViewportMgr = MainWindow.getViewportMgr();
    var oViewport = oViewportMgr.getActiveViewport();
    var oViewport3D = oViewport.get3DViewport();
    
    var oCamera = oViewport3D.getCamera();
    var quatStart = oCamera.getLocalRot();
    var vecAxis = new DzVec3( 0.0, 0.0, 1.0 );
    var nDegrees = 45;
    var nRadians = nDegrees * 0.0174532925;
    var quatBank = new DzQuat( vecAxis, nRadians );
    
    quatBank = quatBank.multiply( quatStart );
    oCamera.setLocalRot( quatBank );

    -Rob

    Thanks! This helps a lot!

Sign In or Register to comment.