Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

script camera control

ashtangajoy Kanya
Registered User
Join date: 27 Jan 2009
Posts: 11
05-13-2009 02:16
I am going crazy trying to control the camera. I have made a ride through gardens using predefined route for an av sitting on a box. (Thus not a vehicle and no physics) I can rotate the box (with camera in standard position behind av) so av sees different views but I would also like to change position of camera at various moments. I JUST CANNOT MAKE ANY SENSE of the various camera parameters. Often they seem to do absolutely nothing, sometimes they do what I might expect and others, seemingly out of the blue, something extraordinary. For example although camera attemps are in run_time_permissions on starting to sit the av down the camera whizzes up to look at the sky!The only parameters which I feel slight success with are CAMERA_PITCH, FOCUS_OFFSET and DISTANCE. Here is the sort of experiments I have been trying:


default
{
state_entry()
{
llSay(0, "Hello, Avatar!";);
llSetText( " camera testing " , < 1.0 , 0.0 , 0.0 > , 0.5 ) ;

llSay( 0 , " BOX: pos " + (string)llGetPos( ) + " rot " + (string)llGetRot( ) ) ;

llSitTarget( < 0.0 , 0.0 , 0.6 > , ZERO_ROTATION ) ;
llSetSitText( "sit2test" ) ;



}

touch_start(integer total_number)
{
llSay(0, "Touched.";);
key touchingAvatar = llDetectedKey( 0 ) ;

// vector pos = llGetPos( ) - < 5.0 , 0.0 , 1.0 > ;
// vector foc = llGetPos( ) + < 0.0 , 0.0 , 9.0 > ;

llRequestPermissions( touchingAvatar ,
PERMISSION_CONTROL_CAMERA | PERMISSION_TRACK_CAMERA ) ;

llSay( 0 , "CAMERA AFTER PERM: pos " + (string)llGetCameraPos( ) ) ;
llSay( 0 , "CAMERA AFTER PERM: rot:" + (string)llGetCameraRot( ) ) ;

}

run_time_permissions( integer permissions )
{
llSay( 0 , "in rtp" ) ;
if ( permissions & PERMISSION_CONTROL_CAMERA )
{
llClearCameraParams( ) ;
vector pos = llGetPos( ) - < 0.0 , 6.0 , -1.0 > ;
vector foc = llGetPos( ) ;

vector focusOffset = < 0.0 , -9.0 , 0.0 > ;

// llSetCameraAtOffset( < 0.0 , 0.0 , 45.0 > ) ;

llSetCameraParams( [ CAMERA_ACTIVE , TRUE ,
CAMERA_POSITION , pos ,
CAMERA_FOCUS_OFFSET , focusOffset ,
CAMERA_DISTANCE , 10.0 ,
CAMERA_PITCH , -45.0

] ) ;
vector cameraOffset = llGetCameraPos( ) - llGetPos( ) ;

llSay( 0 , " RTP cameraOffset from box = " + (string)cameraOffset ) ;
llSay( 0 , " RTP region: pos" + (string)llGetCameraPos( ) ) ;
llSay( 0 , " RTP region: rot" + (string)llGetCameraRot( ) ) ;

// llSleep( 2.0 ) ;
// llClearCameraParams( ) ;
}
}
}
RvA Hax
Registered User
Join date: 25 Dec 2007
Posts: 10
Cewl!
05-15-2009 11:27
Great thx
_____________________
llSetText("Hello.\nI am stoned", <1,0,0>, 1.0);
ashtangajoy Kanya
Registered User
Join date: 27 Jan 2009
Posts: 11
thank you
05-17-2009 02:34
I have looked at Dan Linden's camera script and carried out further experiments of my own. Here is one fact I have found out. Two obvious parameters for llSetCameraParams are CAMERA_POSITION and CANMERA_FOCUS. ( position and point looked at) I tried just setting FOCUS only and putting within a loop to change it smoothly. This had the effect that i call Stiff Neck ie supposing focus moves along the y axis then the camera , too, keeps pace with it travelling parrallel - just as if it had a stiff neck. To keep camera fixed set a position for it, obviously - but this did not on its own seem to consistenetly keep it fixed and sometimes i seemed to get stiff neck behaviour. So to guarantee a camera that would swivel as the focus moved one seems to need another parameter CAMERA_POSITION_LOCKED.
TP Spad
Registered User
Join date: 13 Dec 2007
Posts: 5
05-19-2009 12:14
How big is the garden? You don't actually need to move the box...just the avs camera.
ashtangajoy Kanya
Registered User
Join date: 27 Jan 2009
Posts: 11
:-)
05-20-2009 02:59
It was just an excuse to do both as i am new to scripting and it it gives plenty to experiment with :-)