Jump to content

Lighthouse beam rotation


Tattooshop
 Share

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

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

Recommended Posts

Hello! ;)

How to make the rotation effect of the lighthouse beam if it is part of a linkset? If the beam protrudes strongly forward, naturally the center is displaced. And the rotation will take place in the middle of the beam ...

( Except adding an invisible triangle mesh at the opposite end of the beam. )

LIGHTHOUSE-1.png

Link to comment
Share on other sites

Yeah, if it must be a mesh, it's least laggy to add that tri at the opposite end to get the center to be the axis of rotation. If it can be a simple tapered cylinder, just slice it so the center is where you want it. Either way, you'll use llTargetOmega to avoid the more complex (and much laggier) constant adjustment of rotation about an axis offset from the link's center. (That's certainly possible, but not something to do constantly if you can avoid it, as you can here.)

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

I agree with Qie that llTargetOmega is much better if you can use it, but setting a links rotation and position based on a non-root center of rotation is occasionally useful for other things (not a constantly rotating lighthouse light) and not /that/ difficult:

// Global Variables:
vector Center_of_Rotation; // in local coords, or for global just modify llSLPPF a little.
vector Offset = <position of linked prim when at zero rotation>-Center_of_Rotation;
rotation g_rot; // set this to different rotatitons, or multiply it a marginal ammount on a timer.

//...
//on a timer or whatever:
llSLPPF(link,[PRIM_POS_LOCAL,Center_of_rotation+Offset*g_rot,PRIM_ROT_LOCAL,g_rot]);

 

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

4 hours ago, Qie Niangao said:

Yeah, if it must be a mesh, it's least laggy to add that tri at the opposite end to get the center to be the axis of rotation. If it can be a simple tapered cylinder, just slice it so the center is where you want it. Either way, you'll use llTargetOmega to avoid the more complex (and much laggier) constant adjustment of rotation about an axis offset from the link's center. (That's certainly possible, but not something to do constantly if you can avoid it, as you can here.)

 

2 hours ago, Quistessa said:

I agree with Qie that llTargetOmega is much better if you can use it, but setting a links rotation and position based on a non-root center of rotation is occasionally useful for other things (not a constantly rotating lighthouse light) and not /that/ difficult:


// Global Variables:
vector Center_of_Rotation; // in local coords, or for global just modify llSLPPF a little.
vector Offset = <position of linked prim when at zero rotation>-Center_of_Rotation;
rotation g_rot; // set this to different rotatitons, or multiply it a marginal ammount on a timer.

//...
//on a timer or whatever:
llSLPPF(link,[PRIM_POS_LOCAL,Center_of_rotation+Offset*g_rot,PRIM_ROT_LOCAL,g_rot]);

 

Thank you so much! :D


There are several movements but stops quickly. What did I do wrong?

 

vector rotate = < 0, 0, 10 > ;
rotation rot;

default
{
    state_entry()
    {
        llSetTimerEvent(1);
    }

    timer()
    {
        // Global Variables:
        vector Center_of_Rotation = < 73.66853, 145.58430, 3017.25000 > ; // in local coords, or for global just modify llSLPPF a little.
        vector Offset = < -1.24544, -0.06297, 0.00000 > -Center_of_Rotation;
        rotation g_rot; // set this to different rotatitons, or multiply it a marginal ammount on a timer.
        rotate *= DEG_TO_RAD;
        g_rot = llEuler2Rot(rotate);

        //...
        //on a timer or whatever:
        llSetLinkPrimitiveParamsFast(2, [PRIM_POS_LOCAL, Center_of_Rotation + Offset * g_rot, PRIM_ROT_LOCAL, g_rot]);
    }
}

 

Link to comment
Share on other sites

7 hours ago, Tattooshop said:

There are several movements but stops quickly. What did I do wrong?

You put the global variables in the timer section so they are constantly being re-initialised once a second.

The timer section needs to update the rotation and then adjust the beam by calling setPrimitiveParams, but I don't see an option in the code to repeatedly increase the rotation amount

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, Quistessa said:

🙊

 

2 hours ago, Profaitchikenz Haiku said:

You put the global variables in the timer section so they are constantly being re-initialised once a second.

The timer section needs to update the rotation and then adjust the beam by calling setPrimitiveParams, but I don't see an option in the code to repeatedly increase the rotation amount

There was a feeling that I did something stupid, thanks! :D

 

Link to comment
Share on other sites

Easiest way with mesh beam is to place a vertex node exactly at a point from the beam end equidistant to the beam in this way the beam willeo have full size and you can rotate it wil usual methods very easily without lag

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, VirtualKitten said:

Easiest way with mesh beam is to place a vertex node exactly at a point from the beam end equidistant to the beam in this way the beam willeo have full size and you can rotate it wil usual methods very easily without lag

Yes, thanks, most likely I will have to do this, or use a cylinder sliced off in the middle, if it's not a mesh but prim. ;)

Link to comment
Share on other sites

I moved global variables to the beginning of the script.
In order to educate myself, I would still like to know what is wrong here. :D

vector rotate = < 0, 0, 10 > ;

        // Global Variables:
        vector Center_of_Rotation = < 73.66853, 145.58430, 3017.25000 > ; // in local coords, or for global just modify llSLPPF a little.
        vector Offset = < -1.24544, -0.06297, 0.00000 > -Center_of_Rotation;
        rotation g_rot; // set this to different rotatitons, or multiply it a marginal ammount on a timer.
        rotate *= DEG_TO_RAD;
        g_rot = llEuler2Rot(rotate);

default
{
    state_entry()
    {
        llSetTimerEvent(1);
    }

    timer()
    {
        //...
        //on a timer or whatever:
        llSetLinkPrimitiveParamsFast(2, [PRIM_POS_LOCAL, Center_of_Rotation + Offset * g_rot, PRIM_ROT_LOCAL, g_rot]);
    }
}

 

Link to comment
Share on other sites

Fiiiine. . .

// Global Variables:
vector Center_of_Rotation = < 0.0, 2.0, 5.0 > ; // in local coords, or for global just modify llSLPPF a little.
vector Offset = < 2.5, 0.0, 0.0 >;
rotation Current_Rotation; // the rotation accumulator for the rotating linked prim.
rotation Delta_Rotation; // = llAxisAngle2Rot(<0,0,1>,5*DEG_TO_RAD);
rotation Link_Zero_Rotation; // = llEuler2Rot(<0,90,0>*DEG_TO_RAD); // the rotation of the linked prim when in its default position and the root is at 0 rotation.
// you can't calculate in the preamble, so move that to state_entry.

default
{
    state_entry()
    {
        Delta_Rotation = llAxisAngle2Rot(<0,0,1>,5*DEG_TO_RAD);
        Link_Zero_Rotation = llRotBetween(<0,0,1>,<1,0,0>);
        llSetTimerEvent(0.2);
    }

    timer()
    {
        Current_Rotation*= Delta_Rotation;
        llSetLinkPrimitiveParamsFast(2, 
        [   PRIM_POS_LOCAL, Center_of_Rotation + Offset * Current_Rotation,
            PRIM_ROT_LOCAL, Link_Zero_Rotation*Current_Rotation
        ]);
    }
}

 

  • Thanks 1
Link to comment
Share on other sites

6 hours ago, Quistessa said:

Fiiiine. . .


// Global Variables:
vector Center_of_Rotation = < 0.0, 2.0, 5.0 > ; // in local coords, or for global just modify llSLPPF a little.
vector Offset = < 2.5, 0.0, 0.0 >;
rotation Current_Rotation; // the rotation accumulator for the rotating linked prim.
rotation Delta_Rotation; // = llAxisAngle2Rot(<0,0,1>,5*DEG_TO_RAD);
rotation Link_Zero_Rotation; // = llEuler2Rot(<0,90,0>*DEG_TO_RAD); // the rotation of the linked prim when in its default position and the root is at 0 rotation.
// you can't calculate in the preamble, so move that to state_entry.

default
{
    state_entry()
    {
        Delta_Rotation = llAxisAngle2Rot(<0,0,1>,5*DEG_TO_RAD);
        Link_Zero_Rotation = llRotBetween(<0,0,1>,<1,0,0>);
        llSetTimerEvent(0.2);
    }

    timer()
    {
        Current_Rotation*= Delta_Rotation;
        llSetLinkPrimitiveParamsFast(2, 
        [   PRIM_POS_LOCAL, Center_of_Rotation + Offset * Current_Rotation,
            PRIM_ROT_LOCAL, Link_Zero_Rotation*Current_Rotation
        ]);
    }
}

 

Thank you so much! :)

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...