Jump to content

Simple script to make an avatar look at one something?


Domitan Redenblack
 Share

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

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

Recommended Posts

Are you asking for a script that does something like the viewer's "zoom" function?

  1. It points the camera at the clicked object
  2. then it moves the camera towards the object for to show it in a appropriate size

(the "zoom" function does not zoom at all. It moves the camera closer, so the name is badly chosen)

If you know your own and the objects positions it is possible to move the camera towards the object and make it face the object.

Link to comment
Share on other sites

First look at http://wiki.secondlife.com/wiki/Rotation and calculate the [(offset * rotation) = position] where the camera should be.

Use CAMERA_ACTIVE in http://wiki.secondlife.com/wiki/LlSetCameraParams set that camera position with CAMERA_POSITION and the object's X, Y, Z as CAMERA_FOCUS to look at it.  There are no scripted zoom controls as far as I know.

Link to comment
Share on other sites


Dora Gustafson wrote:

Are you asking for a script that does something like the viewer's "zoom" function?
  1. It points the camera at the clicked object
  2. then it moves the camera towards the object for to show it in a appropriate size

(the "zoom" function does not zoom at all. It moves the camera closer, so the name is badly chosen)

If you know your own and the objects positions it is possible to move the camera towards the object and make it face the object.

 

Yes, exactly. Is there a "demo script" etc to do this off the shelf? I don't do this kind of thing normally, so investing in learning how would be lost after a month or two...

Thanks.

 

Link to comment
Share on other sites

It is not that complicated.
Basically this script will do it:

default
{
    //---some event---//
    {
        llRequestPermissions( avatarKey , PERMISSION_CONTROL_CAMERA);
    }
    run_time_permissions(integer perm)
    {
        if ( perm & PERMISSION_CONTROL_CAMERA )
        {
            llClearCameraParams(); // reset camera to default
            llSetCameraParams([
                CAMERA_ACTIVE, TRUE, // (TRUE or FALSE)
                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)
            ]);
        }
    }
}

 You have to supply three parameters:

  1. avatarKey, which will be llGetOwner(), if you want to control the owners camera
  2. camPos; camera position in region coordinates
  3. camFocus; global coordinates for the object you want to look at
Link to comment
Share on other sites

Dora, thanks.

If I click on a tv monitor (which contains the camera script) that I want to show "full screen" etc, how do I get the camPos, i.e. from the center of the tv "3m" away, on-axis?

(If I can get this working, I will put the results as an example in the Wiki)

 

Oh, Wait... I can put an invisble prim on-axis, and get the loc of that... Then it does not matter what orientation the tv screen is in, yes?

 

 

Link to comment
Share on other sites

vector gvMainPos;vector gvViewPos;default{    state_entry()    {        gvViewPos = llList2Vector( llGetLinkPrimitiveParams(2, [PRIM_POSITION]), 0);        llSay(0, "Viewpoint at " + (string)gvViewPos);                gvMainPos = llGetRootPosition( );        llSay(0, "I am at " + (string)gvMainPos);    }    touch_start(integer total_number)    {        llRequestPermissions( llDetectedKey(0) , PERMISSION_CONTROL_CAMERA);    }        run_time_permissions(integer perm)    {        if ( perm & PERMISSION_CONTROL_CAMERA )        {            llClearCameraParams(); // reset camera to default            llSetCameraParams([                CAMERA_ACTIVE, TRUE, // (TRUE or FALSE)                CAMERA_FOCUS, gvMainPos, // region relative position                CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)                CAMERA_POSITION, gvViewPos, // region relative position                CAMERA_POSITION_LOCKED, TRUE // (TRUE or FALSE)            ]);        }    } }

 ERROR: Object: Camera control currently only supported for attachments and objects on which you are sitting.

 

 

Screen_and_Viewpoint.jpg

 

Link to comment
Share on other sites


PeterCanessa Oh wrote:

Am i muted, or are you just ignoring my post which told you exactly how to calculate the position?

*sarcasm flies over my head* Huh?

Isn't that what I've done?

(Your post link about rotations is NOT "exactly how to do it"... That page is full of *very* complicated math & things that apply to MANY different situations, and its not clear which situation is mine. Just pointing at very complicated pages is NOT "exactly anything", and even now, I won't mute you);

 

Do I need to be sitting on the item with the script to do the viewing?

 

 

Link to comment
Share on other sites

(It was the posts after mine where you were asking Dora for what I'd already written that were making me think you'd missed it.  "calculate the [(offset * rotation) = position] where the camera should be" was meant to be something more than a gentle hint ^^)

You don't need to be sitting on the object but if not then it needs to be an attachment http://wiki.secondlife.com/wiki/LlSetCameraParams

ETA: Check out that rotation page, by the way.  Although it does go through all the math it also has 'exactly' what to use for all sorts of different situations at the bottom.  So just skip the bits you don't want and look-up what you do.  I can never remember if it's (offset * rotation) or (rotation * offset) but I do know it's 'position of object rotated around a relative point' when I rush past the part that looks like hard work.)

Oh, I was trying to dig this out too, it may help: http://community.secondlife.com/t5/LSL-Scripting/Need-help-with-a-camera-tracking-an-object/td-p/1450567

Link to comment
Share on other sites

Ah, I don't want to have to give the viewer anything they have to wear (and then find in their inventory -some have trouble- and then have to possibly kick something else already worn off, or have to figure out another place to attach it etc, either on body or HUD)

Neither do I want to have to have a pose ball the user must sit on, but I suppose that's better than requiring them to accept an item and then wear it...

<rant>But on the upside, LL did invest in Viewer 2, and is reaping the "rewards" from that "community of support" blunder.</rant>

You can Cam around in your viewer to do this, so you should be able to in LSL as well.

As for "permissions" I am happy to have a blue (or whatever V2) dialog pop up to ask permission to move their cam around...

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4401 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...