Jump to content

Animating faces separately on a single mesh object - can this be done now?


Pixels Sideways
 Share

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

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

Recommended Posts

I have a mesh object with 8 faces.

 

I applied the same texture to the whole object - all 8 faces.

 

To achieve the visual effect I am aiming for, I'd like to animate each face separately so they all animate at different speeds.

 

I modified my "touch faces to do stuff" script and added the animation code to each face section. I removed the touch start and integer and got an error message. 

 

Then I added this but it doesn't work as only one face is animated which is face #0.

 

default
{
   state_entry()
    {
       integer face = (0-7);
       
 
        if (face == 0) {
            string oldName = llGetObjectName();
            llSetObjectName(":");
        llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, 0,0,2,0.0, 1,0.14);
    llSleep(4);
    llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, 0,0,2,0.0, -1.0,-0.14);
    llSleep(4);
            llSetObjectName(oldName);
            llSleep(1);
        }
                
        else if (face == 1) {
            string oldName = llGetObjectName();
            llSetObjectName(":");
        llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, 1,0,2,0.0, 1,0.1);
    llSleep(4);
    llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, 1,0,2,0.0, -1.0,-0.1);
    llSleep(4);
            llSetObjectName(oldName);
            llSleep(1);
        }

 

Is my integer incorrect - and if so, how do I write it so face = all 8 faces 0-7?

I also read some old forum posts that said you cannot separately texture animate different sides of a prim.  Is this still the case and does it apply to mesh objects as well??

Thanks. 

pixels xo

Link to comment
Share on other sites

To set all faces at once you need to use the constant ALL_SIDES.

 

However, to do what you wish to do you will need to provide a loop that increments the variable from 0 to llGetNumberOfSides(); and take action accordingly

// thi is a snippet, not a complete script

setFaces()
{
	integer face;
	integer maxFace = llGetNumberOfSides();

	// set any initial texture states here such as texture, stopping anims, etc
	llSetTextureAnim(0, ALL_SIDES, ...

	for(face = 0; face < maxFace; face++)
    {
         if( face == 1) // set a texture anim for this particular face
         {
               llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, face, ... remaining parameters                  
         }
         else if(face == 4) // do something different
         {
                 llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, face, ... different parameters                  
         }
         // otherwise do nothing
    }

}

The snippet shows you how to go through the faces one by one and do things for specific faces.

 

If you want to start and stop these animations alternately you are better using a timer which calls this function every few seconds, and have a global variable onOff which controls whether the functtion starts or stop the animations, changing the value of onOff at the end of the function so the next time the call curs it does the alternate action.

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

4 hours ago, Pixels Sideways said:

I also read some old forum posts that said you cannot separately texture animate different sides of a prim.  Is this still the case and does it apply to mesh objects as well??

That is correct: you cannot use multiple concurrent instances of llSetTextureAnim or llSetLinkTextureAnim on the same single prim/mesh. Doesn't matter of you try to target different faces, the most recent invocation of the function will override whatever is currently playing across the entire single prim/mesh. If you want to give the appearance of an animation playing at different rates on an object, you need to get creative.

One possible approach is to split the mesh up into separate objects: one mesh (with one material slot) for each section that will play the texture animation at the desired rate. That way, you can still link them together into a linkset and use llSetLinkTextureAnim for each link.

  • Thanks 1
Link to comment
Share on other sites

Unfortunately as Fendix said, different texture animations on different sides is not possible, but there are some clever things you cna do with using the same animation, but different textures. using ALL_SIDES as your face will (as expected) apply the animation to all sides of the object. The direction in which textures slide (for sliding animations) is relative to the rotation of the texture on the face.

  • Like 1
Link to comment
Share on other sites

Does it have to be the same object? Can it be a (clever) linkset?

 

key owner = NULL_KEY;
integer debug = TRUE;

default
{
    state_entry()
    {
        owner = llGetOwner();
    }
    
    touch_start(integer num)
    {
        if (llDetectedKey(0) == owner) {
            integer linkNr = llDetectedLinkNumber(0);
            string objectClicked = llGetLinkName(linkNr);
            integer faceClicked = llDetectedTouchFace(0);

            if (objectClicked == "Object_1") // Here you can set the name of an object in the linkset that has to be detected as touched.
            {
                if (debug) { llOwnerSay("Key "+ objectClicked +" was pressed on face" + (string) faceClicked + ""); }
                llSetLinkTextureAnim(objectClicked, ANIM_ON | SMOOTH | LOOP , faceClicked,0,2,0.0, 1,0.14);
            }
            else if (objectClicked == "Object_2") // Here you can set the name of an object in the linkset that has to be detected as touched.
            {
                if (debug) { llOwnerSay("Key "+ objectClicked +" was pressed on face" + (string) faceClicked + ""); }
                llSetLinkTextureAnim(objectClicked, ANIM_ON | SMOOTH | LOOP , faceClicked,0,2,0.0, 1,0.14);
            }
        }
    }
}

I wrote this in like 5 minutes, may need adjusting. This is a concept out of my head.

Link to comment
Share on other sites

7 hours ago, CaithLynnSayes said:
            if (objectClicked == "Object_1") // Here you can set the name of an object in the linkset that has to be detected as touched.
            {
                if (debug) { llOwnerSay("Key "+ objectClicked +" was pressed on face" + (string) faceClicked + ""); }
                llSetLinkTextureAnim(objectClicked, ANIM_ON | SMOOTH | LOOP , faceClicked,0,2,0.0, 1,0.14);
            }
            else if (objectClicked == "Object_2") // Here you can set the name of an object in the linkset that has to be detected as touched.
            {
                if (debug) { llOwnerSay("Key "+ objectClicked +" was pressed on face" + (string) faceClicked + ""); }
                llSetLinkTextureAnim(objectClicked, ANIM_ON | SMOOTH | LOOP , faceClicked,0,2,0.0, 1,0.14);
            }

I wasn't going to press the issue with the code you posted in the other thread, but for situations where the thing you're doing (setting a texture animation) is the same or very similar over a range of input(clicking on different objects) your code will be a bit more efficient and look much nicer if you search for your expected input, and associated output from a list:

list name2params = 
[
  "Object_1",0,2,0.0,1,0.14,
  "Object_2",0,2,0.0,1,0.14
  /*...*/
];
integer objectIndex = llListFindList(name2params, (list)objectClicked);
if(objectIndex!=-1)
{
  //I'm to lazy to look up the wanted types for llSetTexture anim...
  integer p1 = llList2float(name2params,objectIndex+1);
  integer p2 = llList2float(name2params,objectIndex+2);
  float   p3 = llList2float(name2params,objectIndex+3);
  integer p4 = llList2float(name2params,objectIndex+4);
  float   p5 = llList2float(name2params,objectIndex+5);
  if (debug) { llOwnerSay("Key "+ objectClicked +" was pressed on face" + (string) faceClicked + ""); }
  llSetLinkTextureAnim(objectClicked, ANIM_ON | SMOOTH | LOOP , faceClicked,p1,p2,p3,p4,p5);
}
  

The technique is much more elegant with llSetLinkPrimitiveParamsFast, or things which take a list though.

Link to comment
Share on other sites

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