Jump to content

Projected light and llGetCameraRot


Paul Hexem
 Share

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

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

Recommended Posts

So, I have a child prim with a projected light.

I want it to look where the camera is looking, using llGetCameraRot.

Unfortunately, projected lights use the bottom of the prim instead of the X axis, and as far as I can tell, there's no way to rotate that child prim up 90 degrees?

Link to comment
Share on other sites

Now see, that says to use llEuler2Rot and make the change there. Which is something I did, adding- <0.0, 270.0^DEGREE_TO_RAD, 0.0> and it still didn't do it.

I'm not asking for hints, I'm way beyond that point. That is not helpful. I'm asking if anyone has managed to do what I'm trying or if what I'm doing is simply impossible with LSL (wouldn't be the first time- link hierarchy comes to mind).

Link to comment
Share on other sites

I don't know what happened to the OP's posts describing what he was trying to do, but both Rolig and Dora provide solutions to what seems to be very similar to your problem in this thread:  light projector points the wrong way with llLookAt..

If that doesn't help, I think people would find it a lot easier to make suggestions if we could see your script.   

Link to comment
Share on other sites

This is not exactly the same problem but it isn't any harder
@Gadget, why should it be impossible?

Here is a full test script:

rotation correction;default{    state_entry()    {        correction = llRotBetween( <0,0,-1>, <1,0,0>);        llRequestPermissions( llGetOwner(), PERMISSION_TRACK_CAMERA);    }    run_time_permissions(integer perm)    {        if ( perm & PERMISSION_TRACK_CAMERA ) llSetTimerEvent(1.0);    }    timer()    {        llSetLinkPrimitiveParams( 2,[ PRIM_ROT_LOCAL, correction*llGetCameraRot()/llGetRootRotation()]);
}}

 Note I used link number 2
This should likely be generalized or changed

:smileysurprised::):smileyvery-happy:

Edit: camera rotation made local

  • Like 2
Link to comment
Share on other sites

What Dora provided looks almost identical to what I had written- except I'd been trying to use llRot2Euler and back to do the correction (which everyone I talked to also suggested). I'll try it with llRotBetween and see if that makes a difference, and update this thread.

EDIT: Tested Dora's script. That does it. I wonder why nobody I talked to clued me into llRotBetween...

Link to comment
Share on other sites

For the sake of completeness I want to add that the llRotBetween() function is not the secret
What is needed is the rotation needed to rotate a prims Down into Forward around the Y-axes
Another, simpler way to find that rotation is:
correction = llEuler2Rot( <0,-90,0>*DEG_TO_RAD);

rotation correction;default{    state_entry()    {        correction = llEuler2Rot( <0,-90,0>*DEG_TO_RAD);        llRequestPermissions( llGetOwner(), PERMISSION_TRACK_CAMERA);    }    run_time_permissions(integer perm)    {        if ( perm & PERMISSION_TRACK_CAMERA ) llSetTimerEvent(1.0);    }    timer()    {        llSetLinkPrimitiveParams( 2,[ PRIM_ROT_LOCAL, correction*llGetCameraRot()/llGetRootRotation()]);    }}

Simplified and optimized:

// Child prim project where camera is looking, script by Dora Gustafson, Studio Dora 2015// v1.2rotation correction = < 0.0, -0.70710678, 0.0, 0.70710678 >;default{    state_entry()    {        llRequestPermissions( llGetOwner(), PERMISSION_TRACK_CAMERA);    }    run_time_permissions(integer perm)    {        if ( perm & PERMISSION_TRACK_CAMERA ) llSetTimerEvent(1.0);    }    timer()    {        llSetLinkPrimitiveParams( 2,[ PRIM_ROT_LOCAL, correction*llGetCameraRot()/llGetRootRotation()]);    }}

:smileysurprised::):smileyvery-happy:

  • Like 1
Link to comment
Share on other sites

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