Change font size
It is currently Thu Jun 21, 2018 8:22 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 3 posts ]
Author Message
 Post subject: Cam Lock Hud
PostPosted: Sun Oct 16, 2011 2:28 am 
Site Admin

Joined: Sun Nov 28, 2010 5:09 pm
Posts: 365
I have been looking for a way to lock my cam especially when I am working on a small object or project. And even when building things, it gets frustrating when the cam jumps and you were trying to adjust two prims together. So I found a script on the internet which did work. However I found that it required me to type in commands to lock and unlock the cam. So I rewrote the script so that it uses just a simple dialog menu. You can basically lock any camera postion, and unlock it, or you can toggle it off and on by using the "switch" button. I also added a timer to turn off the listener after 10 seconds to reduce lag. This will also be helpful when taking photos in a lot of cases. I have placed a copy now in the Wright Plaza Freebie building on the right wall top. And a copy of the full hud can be gotten at austeria9 in my freebie warehouse there. But for those that want to set up their own hud here is the script:

{L_CODE}:
//lsl
////////////////////////////////////////////////////////////////////////
// Script Name:Modified Camera Lock Hud
// Author: albertlr Landar 10/15/11
// This is a modified camera lock hud by Moriash Morean 12/17/06  The original hud
// required chat commands to set the locked camera position, and the listener was
// kept running.  I have set a 10 second timeout for the listener.
//
// You may use this script for whatever purpose you like, provided it's legal
// and doesn't violate the SL TOS.  Be excellent to each other.  Party on.

// Instructions:
// Insert this script in a small prim.  Attach the prim to any convenient HUD position. Click on yes to grant permissions - if you click on no it will have to be reset.  Maneuver your camera to the desired camera position to lock (see F1 Help->Basic Help->Camera Controls).  Choose "Lock" to store your position or "Unlock" to move the cam to a new position.  Click on "Switch" to toggle between current postion and the stored lock position.  For a new locked postion maneuver to a new postion, and click "Lock" once more. Note that your avatar must be within approximately 50 meter of the stored camera position for the camera lock to function properly.

// This program is free software; you can redistribute it and/or modify it.
// License information must be included in any script you give out or use.
// This script is licensed under the Creative Commons Attribution-Share Alike 3.0
// License from http://creativecommons.org/licenses/by-sa/3.0 unless licenses are
// included in the script or comments by the original author,in which case
// the authors license must be followed.

// Please leave any authors credits intact in any script you use or publish.
///////////////////////////////////////////////////////////////////////////////

// INTERNAL VARIABLES
integer Toggle;
integer Listener;
vector CamPos;
rotation CamRot;
vector CamFoc;
integer channel;
float Timeout=10.0;
integer handle;
key ToucherID;

list buttons = [ "Lock", "Switch", "Unlock" ];

// Ask for permissions.  Start up the Listen again (to deal with changes in ownership).

Init()
{
    llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA | PERMISSION_ATTACH | PERMISSION_TRACK_CAMERA );
    llListenRemove(Listener);
    Listener = llListen(channel, "", llGetOwner() , "" );
    Toggle = FALSE;
    llSetColor(<0,1,0>,ALL_SIDES);
}

// Toggle the camera lock on and off.
CamToggle(){
    if (Toggle)
    {
        llClearCameraParams();
        llSetColor(<0,1,0>,ALL_SIDES);
        llOwnerSay("Releasing camera control.");
        Toggle = FALSE;
    }
    else
    {
        Toggle = TRUE;
        llSetColor(<1,0,0>,ALL_SIDES);
        llOwnerSay("Returning to locked camera position.");
        llSetCameraParams([
            CAMERA_ACTIVE, TRUE,
            CAMERA_FOCUS, CamFoc,
            CAMERA_FOCUS_LOCKED, TRUE,
            CAMERA_POSITION, CamPos,
            CAMERA_POSITION_LOCKED, TRUE
                ]);
    }
}

default
{
    state_entry()
    {
        Init();
        //   listen_handle = llListen(0, "", llGetOwner(), "");

    }
    attach(key ToucherID)
    {
        // If we're detaching, clear the camera.
        if (ToucherID == NULL_KEY)
        {
            if (llGetPermissions() & PERMISSION_CONTROL_CAMERA)
            {
                llClearCameraParams();
            }
        }
        // If we're attaching, initialize the camera lock.
        else
        {
            Init();

        }
    }
    // Sort through required permissions.
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_CONTROL_CAMERA | PERMISSION_ATTACH | PERMISSION_TRACK_CAMERA )
        {
            llOwnerSay("Camera control enabled.");
        }
        else
        {
            llOwnerSay("Camera control refused.  Detaching.");
            llDetachFromAvatar();
        }
    }

    // Turn the camera lock on and off.
    touch_start(integer total_number)
    {
        ToucherID = llGetOwner();
        channel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
        handle = llListen(channel, "", ToucherID, ""); // listen for dialog answers (from the user)
        llListenControl(handle, TRUE); // ...enable listen
        llSetTimerEvent(Timeout);
        //llOwnerSay("Listener Turned On");
        llDialog(llDetectedKey(0),"Make A Choice.", buttons, channel);


    }
    listen(integer channel, string name, key id, string message )
    {

        // Respond to menu selections
        if (message == "Lock")
        {
            llOwnerSay("Locking current camera position.");
            CamPos = llGetCameraPos();
            CamRot = llGetCameraRot();
            CamFoc = CamPos + llRot2Fwd(CamRot);
            llClearCameraParams();
            Toggle = FALSE;
            CamToggle();
        }

        else if (message == "Switch") // If locked, then unlock it, if unlocked then lock it.
        {
            CamToggle();
        }

        // Read and store the current camera position.
        if (message == "Unlock")
        {
            llOwnerSay("Unlocking current camera position.");
            CamPos = llGetCameraPos();
            CamRot = llGetCameraRot();
            CamFoc = CamPos + llRot2Fwd(CamRot);
            Toggle = TRUE;
            CamToggle();
        }
    }
    timer() {
        //llOwnerSay("Listener Turned off");
        llListenControl(handle, FALSE);
        llSetTimerEvent(0);
        state default;}
}


Instructions:
Insert this script in a small prim. Attach the prim to any convenient HUD position. Click on yes to grant permissions - if you click on no it will have to be reset. Maneuver your camera to the desired camera position to lock. Choose "Lock" to store your position or "Unlock" to move the cam to a new position. Click on "Switch" to toggle between current postion and the stored lock position. For a new locked position maneuver to a new postion, and click "Lock" once more. Note that your avatar must be within approximately 50 meter of the stored camera position for the camera lock to function properly unless you have your scripts set to operate at a greater distance. You can do this in the opensim.ini file.


Last edited by albertlr Landar on Mon Oct 17, 2011 10:22 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Cam Lock Hud
PostPosted: Mon Oct 17, 2011 1:52 pm 

Joined: Sat Jul 24, 2010 5:07 pm
Posts: 20
This looks very nice, and it does seem to work.

Did you consider creating gestures, saying "Lock" and "Unlock"? You may know that you can bind a key to a gesture. Like F10 for "Lock", and F11 for "Unlock", making (un)locking as easy as hitting a function key, without having to move your mouse from the object that you are editing, or trying to take a snapshot of, etc.

Just an idea though...


Top
 Profile  
 
 Post subject: Re: Cam Lock Hud
PostPosted: Mon Oct 17, 2011 2:01 pm 
Site Admin

Joined: Sun Nov 28, 2010 5:09 pm
Posts: 365
Well I noticed that when having to type in the commands in chat that it did not always respond, and I wanted a more simple method that did not require me to use the keyboard. Especially when building I have my hand on my mouse more often than on the keyboard, and by being able to access the off and on for the hud and by using the mouse it seemed much more builder friendly. I am about to post another camera hud which has a lot more camera postitions based on one that one of the lindens released a few years ago. But I have expanded it with several of my own, as well as one for a large avatar and a tiny avatar. I have also included part of the code for the locking of positions in it too.

And thanks for the suggestion about the gestures, had not considered that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 3 posts ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net