Jump to content

Dolly zoom camera scripts


dk201
 Share

You are about to reply to a thread that has been inactive for 728 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi SL residents, I am trying to write a script allow me to make dolly zoom effect (https://en.wikipedia.org/wiki/Dolly_zoom) in SL. However, I met 2 questions:

1) I can not force camera to be in front of my avatar. (which i believe is a know issue with LSL, correct me  if i am wrong)

2) I can not adjust camera view angle via LSL scripts.

Those i can do a screen record and create dolly zoom effect in video editing software, however I will loose some video quality and i would like to avoid that.

Anyone has advice?

Edited by dk201
Link to comment
Share on other sites

Hmmm... Your first observation is not true.  Try taking the example script in the LSL wiki page for llSetCameraEyeOffset (https://wiki.secondlife.com/wiki/LlSetCameraEyeOffset#Examples) and modifying it just slightly so that it looks like this

// Sit the avatar looking at an arbitrary direction
// Look over the avatar's shoulders from behind once it sits down

back_view(float degrees)
{
     rotation sitRot = llAxisAngle2Rot(<0, 0, 1>, degrees * DEG_TO_RAD);
    
     llSitTarget(<0, 0, 0.1>, sitRot);
        
     llSetCameraEyeOffset(<2, 0, 1> * sitRot);  // Removed the minus sign on the X dimension, thus placing the camera in front of the av 
     llSetCameraAtOffset(<6, 0, 1> * sitRot);	// Increased the focal position from 2 to 6 m
}

default
{
    state_entry()
    {
        back_view( 208 );
        llSay(0, "Please sit down");
    }
}

You can change the angle passed to the back_view function, but the script will always do as it should ... put the camera in front of you, looking forward.

  • Like 2
Link to comment
Share on other sites

And, in fact, you can achieve the same result by using llSetCameraParams.  Again, take the first example function in the LSL Wiki for llSetCameraParams (https://wiki.secondlife.com/wiki/LlSetCameraParams#Examples) and built it into a script like this:

lookAtMe( integer perms )
{
    if ( perms & PERMISSION_CONTROL_CAMERA )
    {
        vector camPos = llGetPos() + (relCamP * llGetRot() * turnOnChair) ;
        vector camFocus = llGetPos() + (<6.0, 0.0, 2.0> * llGetRot() * turnOnChair);  // Camera focus is 6 m in front of the seat and angled up 
        llClearCameraParams(); // reset camera to default
        llSetCameraParams([
            CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
            CAMERA_FOCUS, camFocus, // region relative position
            CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
            CAMERA_POSITION, camPos, // region relative position
            CAMERA_POSITION_LOCKED, TRUE // (TRUE or FALSE)
        ]);
    }
}

vector relCamP;
rotation turnOnChair;

default
{
    state_entry()
    {
        llSitTarget(<0,0,0.1>,ZERO_ROTATION);
        relCamP = < 2.0, 0.0, 1.0>;   // Camera position is 2 m in front of the seat on which the av sits
        turnOnChair = ZERO_ROTATION;
    }
    
    changed (integer change)
    {
        if (change & CHANGED_LINK)
        {
            key Av = llAvatarOnSitTarget();
            if ( Av )
            {
                llRequestPermissions(Av,PERMISSION_CONTROL_CAMERA);
            }
        }
    }
    
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_CONTROL_CAMERA)
        {
            lookAtMe( perm);
        }
    }
}

Notice that in this case, I have angled the camera up a bit by adjusting the Z parameter in the vector controlling the camera's focus.  

Link to comment
Share on other sites

10 hours ago, Rolig Loon said:

And, in fact, you can achieve the same result by using llSetCameraParams.  Again, take the first example function in the LSL Wiki for llSetCameraParams (https://wiki.secondlife.com/wiki/LlSetCameraParams#Examples) and built it into a script like this:

lookAtMe( integer perms )
{
    if ( perms & PERMISSION_CONTROL_CAMERA )
    {
        vector camPos = llGetPos() + (relCamP * llGetRot() * turnOnChair) ;
        vector camFocus = llGetPos() + (<6.0, 0.0, 2.0> * llGetRot() * turnOnChair);  // Camera focus is 6 m in front of the seat and angled up 
        llClearCameraParams(); // reset camera to default
        llSetCameraParams([
            CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
            CAMERA_FOCUS, camFocus, // region relative position
            CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
            CAMERA_POSITION, camPos, // region relative position
            CAMERA_POSITION_LOCKED, TRUE // (TRUE or FALSE)
        ]);
    }
}

vector relCamP;
rotation turnOnChair;

default
{
    state_entry()
    {
        llSitTarget(<0,0,0.1>,ZERO_ROTATION);
        relCamP = < 2.0, 0.0, 1.0>;   // Camera position is 2 m in front of the seat on which the av sits
        turnOnChair = ZERO_ROTATION;
    }
    
    changed (integer change)
    {
        if (change & CHANGED_LINK)
        {
            key Av = llAvatarOnSitTarget();
            if ( Av )
            {
                llRequestPermissions(Av,PERMISSION_CONTROL_CAMERA);
            }
        }
    }
    
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_CONTROL_CAMERA)
        {
            lookAtMe( perm);
        }
    }
}

Notice that in this case, I have angled the camera up a bit by adjusting the Z parameter in the vector controlling the camera's focus.  

Appreciated! I will do some test. My avatar is not sit on an object, but this will be a good solution! Why dont i just sit on something transparent and adjust camera!? It would be much easier! Thanks a lot

  • Like 1
Link to comment
Share on other sites

13 hours ago, dk201 said:

Hi SL residents, I am trying to write a script allow me to make dolly zoom effect (https://en.wikipedia.org/wiki/Dolly_zoom) in SL

Anyone has advice?

Unfortunately, a Dolly Zoom effect simply isn't possible through LSL as we don't have any control over the camera's FOV value. You can make a script which can smoothly move the camera around, but you cannot manipulate anything more than the camera's position and rotation (and the focal point).

  • Thanks 1
Link to comment
Share on other sites

26 minutes ago, Jenna Huntsman said:

Unfortunately, a Dolly Zoom effect simply isn't possible through LSL as we don't have any control over the camera's FOV value. You can make a script which can smoothly move the camera around, but you cannot manipulate anything more than the camera's position and rotation (and the focal point).

What if you have your camera (manually) following let's say, an avatar (it keeps following last I checked when that avatar moves), who happens to be seated on a prim that is scripted to be moving?

Or more simply, if you sit on a prim that is scripted to be moving?

Would either of those simulate a "zoom" if you have the scripted item to go in the right direction?

Link to comment
Share on other sites

5 minutes ago, Love Zhaoying said:

What if you have your camera (manually) following let's say, an avatar (it keeps following last I checked when that avatar moves), who happens to be seated on a prim that is scripted to be moving?

Or more simply, if you sit on a prim that is scripted to be moving?

Would either of those simulate a "zoom" if you have the scripted item to go in the right direction?

I see what you mean, but unfortunately not - Zoom is a function of FOV.

The kind of effect you'd get there is called a Snorricam shot, i.e. the camera rigidly attached to the subject moving through a scene.

Moving both the subject and the camera simultaneously (but separately) wouldn't work either, as the Dolly Zoom has the subject's scale appear not to change, while any objects in the foreground or background seem to scale independently.

  • Like 1
  • Thanks 3
Link to comment
Share on other sites

Thanks. There's a lot more to the world of cinematography than I realized.  You're right, Jenna.  We have no way to change a camera's field of view with LSL.  The solutions I posted work well for us amateurs, but are not adequate for pros.

Link to comment
Share on other sites

Not 100% relevant to the discussion, but I'd like to point out that LSL camera control is built with the assumption that the thing you're looking at is your own avatar or vehicle. Sending camera position updates to the viewer via LSL is inherently "choppy" because of the code running server-side. Best practice solutions are:

  • Ride a vehicle, which you then control via LSL.
  • Use fixed camera positions/angles.
  • Buy a 3d mouse or learn to use advanced camera control inputs (see your viewer's controls/input settings)
  • See if your viewer supports client-side camera scripting (I'm too lazy to research. CoolVL's lua scripting might have some things.)
  • Like 1
Link to comment
Share on other sites

I guess this has to be done the old-fashioned way, as in Vertigo and Jaws, with at least some manual input. Fortunately you can script the camera movement, and focusing isn't an issue in SL, meaning you can do away with three or four assistants, leaving you to adjust just the FOV (zoom; camera angle in SL viewers) manually.

The smoothest way of doing this that I can see would be to use Quick Preferences in Firestorm, tying the debug setting CameraAngle to a slider with a very fine increment. Unfortunately this control takes up some screen space, so for this shot you'd have to crop the video image to edit it out. By putting the control at the top of the quick preferences window and sliding the rest of it off-screen you could minimise the intrusion. And I guess you'd have to have at least some of the user interface showing, too.

And then practice a bit. I can't image the dolly-zoom shots in either Jaws or Vertigo being done in just one take.

Edited by KT Kingsley
  • Like 1
Link to comment
Share on other sites

19 minutes ago, KT Kingsley said:

I guess this has to be done the old-fashioned way, as in Vertigo and Jaws, with at least some manual input. Fortunately you can script the camera movement, and focusing isn't an issue in SL, meaning you can do away with three or four assistants, leaving you to adjust just the FOV (zoom; camera angle in SL viewers) manually.

The smoothest way of doing this that I can see would be to use Quick Preferences in Firestorm, tying the debug setting CameraAngle to a slider with a very fine increment. Unfortunately this control takes up some screen space, so for this shot you'd have to crop the video image to edit it out. By putting the control at the top of the quick preferences window and sliding the rest of it off-screen you could minimise the intrusion. And I guess you'd have to have at least some of the user interface showing, too.

And then practice a bit. I can't image the dolly-zoom shots in either Jaws or Vertigo being done in just one take.

If you were going to go that far, I'd recommend swapping to a viewer with some more comprehensive machinima tools (Black Dragon is the one that comes to my mind, as that allows for full camera control and keyframing) and dump the LSL side altogether.

As Quistess said, any LSL implementation won't be the smoothest thing ever (I somewhat disagree with the 'choppy' characterization, as some of the LSL camera control and movement scripts that I've done work pretty damn well but are inherently affected by simulator script load and network conditions) and more than likely not 100% reliable.

  • Like 2
Link to comment
Share on other sites

Regarding smoothness of camera movement, the way I'd be thinking about doing this shot would be to have an alt operating the camera while sitting on an object that's scripted to move using KFM. Whether this is a viable option depends, I guess, on what the main subject is doing. If they're standing still (even if animated) it's all relatively easy, but if they have to be moving, it'll get complicated. In that case I'd start thinking about having them also sit on a KFM scripted object that also plays the appropriate animations.

Which is a heck of a palaver for a single shot. But that's movies for you.

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

18 hours ago, dk201 said:

Hi SL residents, I am trying to write a script allow me to make dolly zoom effect (https://en.wikipedia.org/wiki/Dolly_zoom) in SL. However, I met 2 questions:

1) I can not force camera to be in front of my avatar. (which i believe is a know issue with LSL, correct me  if i am wrong)

2) I can not adjust camera view angle via LSL scripts.

Those i can do a screen record and create dolly zoom effect in video editing software, however I will loose some video quality and i would like to avoid that.

Anyone has advice?

See the camera commands we added to RLVa 

https://wiki.catznip.com/index.php?title=Camera_Commands

  • Like 3
  • Thanks 3
Link to comment
Share on other sites

1 hour ago, dk201 said:

in a smooth way

FWIW, about the smoothest LSL-based camera movement can be seen in the demo item at this location:

https://maps.secondlife.com/secondlife/Crooked Posse/190/230/2001

It's not perfect but it can work, although again, if you're using it for machinima, viewer-based tools always work best.

Regarding use of RLV - Unless this script is purely for personal use, be sure that it works under both RLV implementations (Marine's RLV and RLVa). You don't want to ship a product which is broken to some of your users.

  • Thanks 1
Link to comment
Share on other sites

3 hours ago, dk201 said:

Wow, this looks very promising! If RLV allows me to change fov in a smooth way, dolly zoom might be feasible! Thanks for advice.

The intent behind these controls was repeatable photography and machinima (and if people used it to make better naughty toys, good for them). If it doesn't do what you need it to do, please do get in touch.

 

  • Like 1
Link to comment
Share on other sites

19 minutes ago, Coffee Pancake said:

 and machinima.

If it doesn't do what you need it to do, please do get in touch.

Looking at the spec for those commands, a tween parameter would definitely be useful for that. (Similar to the parameter seen in the SetSphere command set).

(i.e. the ability to issue a single command to smoothly transition between the current and desired FoV values (for that matter, tween would be useful for all camera params, but obvs a lot of work) by issuing a single RLV command, rather than having to use a fast timer to repeatedly send commands to the viewer).

  • Like 2
Link to comment
Share on other sites

5 minutes ago, Coffee Pancake said:

The intent behind these controls was repeatable photography and machinima (and if people used it to make better naughty toys, good for them). If it doesn't do what you need it to do, please do get in touch.

 

I actually want to make a video clip with dolly zoom effect. RLV solution worked as magic with a loop to change fov as long as in a low-laggy sim.

  • Like 1
Link to comment
Share on other sites

51 minutes ago, Jenna Huntsman said:

Looking at the spec for those commands, a tween parameter would definitely be useful for that. (Similar to the parameter seen in the SetSphere command set).

(i.e. the ability to issue a single command to smoothly transition between the current and desired FoV values (for that matter, tween would be useful for all camera params, but obvs a lot of work) by issuing a single RLV command, rather than having to use a fast timer to repeatedly send commands to the viewer).

I will try this.

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 728 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...