Jump to content

How to spin a texture clockwise?


XxAmanexX
 Share

Recommended Posts

Hello everyone!

I'll be short and sweet here, I'm completely new to scripting and am attempting to figure out how to get a texture to spin clockwise on the face of an object. Kind of like in a spiral or hypnosis pattern in the direction the arrows are going in the image attached. I've tried using scripts from the marketplace to see if I can find something I can break down and understand myself, but the scripts I've found don't move the texture properly. - On this particular object the Face I am attempting to spin the texture on is Face 2. I have tried specifying the number 2 in place of ALL_SIDES in the script provided below, but that doesn't change how the texture moves on the object. I've been channeling my best Google-fu for the last couple of hours and I've come across a few posts on here suggesting that I can rotate the mesh object/prim instead of the texture itself. I figured it'd be best to reach out here before trying that for some advice, as I don't want to rotate the entire object itself, I think I can create some extra faces as child objects to spin over the main object if that's the case?

Any pointers would be greatly appreciated!

Here's an a GIF showing what one of the scripts I've found is causing the texture to do:

https://gyazo.com/98abb559729c517bbb79d4a814fe95f9

And the exact script written out here:

//Rotate a texture.

//Drop this script into the prim you want to rotate a texture on.

//Adjust settings as needed and hit "Save".

//For a simple texture rotation, delete this script after running.

//For more advanced scripts, you may wish to turn the rotation on and off or change speeds.

//To do more than one side, unless it is ALL_SIDES, you can put the face number directly in the function below, and use one function per face.


//You can select one face number or use the constant "ALL_SIDES".
integer side = 2;

//A positive number rotates counter clockwise. A negative number rotates clockwise.
float speed = 2.0;

default
{
    state_entry()
    {
        //Start rotation by using 1, TRUE, or ANIM_ON.
        llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | ROTATE | LOOP, ALL_SIDES,1,1,0, TWO_PI, 2*TWO_PI);
        
        //Stop rotation by using FALSE;
        //llSetTextureAnim(FALSE | SMOOTH | ROTATE | LOOP, side, 1, 1, 0, TWO_PI, speed);
        
    }//End state_entry event handler.
}//End default state.

 

Example.png

Link to comment
Share on other sites

 

4 hours ago, XxAmanexX said:

llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | ROTATE | LOOP, ALL_SIDES,1,1,0, TWO_PI, 2*TWO_PI);

You're almost there. You don't need to set the two scale figures for rotate. ALL_SUDES should be replaced by the specific face, and to change the direction it spins, either specify a REVERSE mode flag or set rate as a -ve number.

Try this (not tested inworld) 

llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | ROTATE | REVERSE | LOOP, side, 0, TWO_PI, 2*TWO_PI);

It might be worth while checking the value you have set for side is actually the face you are looking at. If for some reason side = 2 is pointing at a blank face you will see nothing hapenning :)

 

// get the specified face number of a prim
// drop this in the actal child to be worked on

touch_start(integer num)
{
  integer face = llDetectedTouchFace(num - 1);
  llOwnerSay("Face is " + (string) face);

}

 

Link to comment
Share on other sites

4 hours ago, Profaitchikenz Haiku said:

 

You're almost there. You don't need to set the two scale figures for rotate. ALL_SUDES should be replaced by the specific face, and to change the direction it spins, either specify a REVERSE mode flag or set rate as a -ve number.

Try this (not tested inworld) 

llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | ROTATE | REVERSE | LOOP, side, 0, TWO_PI, 2*TWO_PI);

It might be worth while checking the value you have set for side is actually the face you are looking at. If for some reason side = 2 is pointing at a blank face you will see nothing hapenning :)

 

// get the specified face number of a prim
// drop this in the actal child to be worked on

touch_start(integer num)
{
  integer face = llDetectedTouchFace(num - 1);
  llOwnerSay("Face is " + (string) face);

}

 

I'm not sure I understand where the two scale figures are being set in the script? I tried putting in the line you gave me earlier and specifying the Face as 2 however the compiler threw me a "Function call mismatches type or number of arguments" error below. So I went ahead and added 0,0,0, and that caused the texture to move similar to how it was moving in my initial post. - I'd like the texture to remain centered on its face and rotate clockwise in place. The script seems like it's making it move around an axis that's not shown on the face itself. Thanks for the second script! I was able to get it working and can definitely confirm the face I am attempting to rotate is defined as 2. I just don't understand why the texture is moving like the way its shown in the gif instead of spinning to the right in place. Is there another parameter or value I'm not specifying correctly in the script?

 

Function Call Error:

https://gyazo.com/dc68d08b9c9459ba30d6c5b1a7a50d40

Adding 0,0,0,

https://gyazo.com/2d5b612683cda35bc3d7837c94be5748

Second Script Face:

https://gyazo.com/1cd3d32ffe47a10fe1f3467c0ff77e97

Link to comment
Share on other sites

Texture rotate animation doesn't have a pivot you can choose, it rotates around the midpoint of the texture (and I guess a corner for PBR materials, haven't checked). If what you're trying to animate isn't centered on the pivot on the UVs, it won't work. Best you could do is rotate the entire object with llTargetOmega, which may or may not be doable considering you said you didn't want to do that -- if you were concerned about performance, non-physics TargetOmega is a viewer-side effect and doesn't have much cost resource-wise.

Link to comment
Share on other sites

23 minutes ago, Frionil Fang said:

Texture rotate animation doesn't have a pivot you can choose, it rotates around the midpoint of the texture (and I guess a corner for PBR materials, haven't checked). If what you're trying to animate isn't centered on the pivot on the UVs, it won't work. Best you could do is rotate the entire object with llTargetOmega, which may or may not be doable considering you said you didn't want to do that -- if you were concerned about performance, non-physics TargetOmega is a viewer-side effect and doesn't have much cost resource-wise.

Ah, that's unfortunate! If I can't choose the pivot point of the texture to rotate on then it is what it is. If I separated the face depicted in the Gifs from the mesh and created a child object linked to the main mesh would I be able to rotate the child object specifically by using llTargetOmega? That would give me the effect I'm looking for without the need to rotate the entire object itself, as the outer ring of the object needs to remain stationary!

Link to comment
Share on other sites

6 minutes ago, XxAmanexX said:

If I separated the face depicted in the Gifs from the mesh and created a child object linked to the main mesh would I be able to rotate the child object specifically by using llTargetOmega?

Yup, child prims can have their own omega independent of the root (you can even have both, with the entire linkset rotating via the root and the children rotating individually on their own axes). Either set it via a script inside that specific prim, or via a llSetLinkPrimitiveParamsFast call from a script in another prim.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...