Jump to content

Multipose Stand


Rolig Loon
 Share

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

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

Recommended Posts

Sometimes you need a pose stand with more than one pose. Perhaps you need a versatile modeling stand, or a dance pad.  This script lets you cycle through as many animations or poses as you load into the one-prim stand, using either touch or chat commands.  See internal comments for the available commands.

 

//Multipose Stand --  Rolig Loon -- 7/09/09 -- Updated March 2011

// Place this script and your animations in a prim pose stand.
// Touch pose stand to select the next animation in inventory or
// type chat commands in channel 47.
// Type /47 HELP to see a list of chat commands.

integer ThisAnim = 0;
integer NumAnims = 0;
string CurrAnim = "turn_180";
string HoldName;
key agent;

default
{
	on_rez(integer start_param)
	{
		llResetScript();
	}

	state_entry()
	{
		HoldName = llGetObjectName();
		llSetAlpha(1.0,ALL_SIDES);
		llSetObjectDesc("Chat commands on channel 47");
		NumAnims = llGetInventoryNumber(INVENTORY_ANIMATION);
		llListen(47,"","","");
		llSetSitText( "Stand" );
		llSitTarget( <0.00, 0.00, 0.80>, ZERO_ROTATION );
	}

	listen(integer channel, string thing, key id, string message)
	{
		if(id == agent)
		{
			if (llToUpper(message) == "ON")  // Make the stand visible
			{
				llSetAlpha(1.0,ALL_SIDES);
			}
			else if (llToUpper(message) == "OFF")  //  Make ths stand invisible
			{
				llSetAlpha(0.0,ALL_SIDES);
			}
			else if (llToUpper(message) == "LIST")  // LIST all available animations by number
			{
				integer j;
				for (j=0;j<= NumAnims-1;j=j+5)
				{
					llInstantMessage(id,"/me " + (string)(j+1) + " = " + llGetInventoryName(INVENTORY_ANIMATION,j) +" \n"
						+  (string)(j+2) + " = " + llGetInventoryName(INVENTORY_ANIMATION,j+1) +" \n"
						+  (string)(j+3) + " = " + llGetInventoryName(INVENTORY_ANIMATION,j+2) +" \n"
						+  (string)(j+4) + " = " + llGetInventoryName(INVENTORY_ANIMATION,j+3) +" \n"
						+  (string)(j+5) + " = " + llGetInventoryName(INVENTORY_ANIMATION,j+4));

				}
			}
			else if (llToUpper(message) == "SHOW") //SHOW the currently active animation in chat
			{
				llInstantMessage(id,"/me Current Animation " + (string)ThisAnim + " = " + CurrAnim);
			}
			else if (llToUpper(message) == "NOTE")
			{
				llGiveInventory(id,"MultiPose Instructions"); // Give instruction notecard
			}
			else if (llToUpper(message) == "HELP")
			{
				llInstantMessage(id,"/me Left click the pose stand to advance poses or use chat commands on channel 47:");
				llInstantMessage(id,"/me     LIST produces a list of available poses with key numbers.\n"
					+ "        Typing a key number advances immediately to that pose in the LIST.\n"
					+ "        SHOW displays the key number and name of the current animation.\n"
					+ "        ON makes the pose stand visible.\n"
					+ "        OFF makes the pose stand invisible.\n"
					+ "        NOTE offers instructions on a notecard. \n"
					+ "        HELP produces this message.");
			}
			else
			{
				ThisAnim = (integer)message -1; //Listen for an optional direct command to apply animation #message
				if ((integer)message > NumAnims | (integer)message <= 0)
				{
					llInstantMessage(id,"/me Please type a number between 1 and " + (string)(NumAnims));
					ThisAnim = 0;
				}
				else
				{
					llStopAnimation(CurrAnim);
					CurrAnim = llGetInventoryName(INVENTORY_ANIMATION, ThisAnim%NumAnims);
					llStartAnimation(CurrAnim);
					llInstantMessage(id,"/me " +(string)(ThisAnim+1) + " = " + CurrAnim);
					++ThisAnim;
					ThisAnim = ThisAnim%NumAnims;
				}
			}
		}
	}

	touch_start(integer num_detected)
	{
		if (llDetectedKey(0) == agent)
		{
			llStopAnimation(CurrAnim);
			if(NumAnims != 0)
			{
				CurrAnim = llGetInventoryName(INVENTORY_ANIMATION, ThisAnim%NumAnims);
				llStartAnimation(CurrAnim);
				llInstantMessage(llDetectedKey(0),"/me " + (string)(ThisAnim+1) + " = " + CurrAnim);
				++ThisAnim;
				ThisAnim = ThisAnim%NumAnims;
			}
			else
			{
				llStartAnimation("turn_180");  // The default if there are no stored animations is the SL Appearance stance
			}
		}
	}

	changed(integer change)
	{
		if (change & CHANGED_LINK)
		{
			agent = llAvatarOnSitTarget();
			if (agent)
			{
				llInstantMessage(agent,"Click the pad to start and advance animations. Type \"/47 help\" for chat commands.");
				llRequestPermissions(agent,PERMISSION_TRIGGER_ANIMATION);
			}
			else 
			{
				if ( llGetPermissions() == PERMISSION_TRIGGER_ANIMATION)
				{
					llStopAnimation(CurrAnim);
					llSetObjectName(HoldName);
				}
				llResetScript();
			}
		}
		else if (change & CHANGED_INVENTORY)
		{
			llResetScript();
		}
	}

	run_time_permissions(integer parm)
	{
		if(parm == PERMISSION_TRIGGER_ANIMATION)
		{
			llStopAnimation("sit");
			llSetAlpha(0.0,ALL_SIDES); //Make the pose stand invisible
			llSetObjectName("");
			llStartAnimation(CurrAnim);
		}
	}
}

 

 

  • Like 6
Link to comment
Share on other sites

  • 3 weeks later...
  • 3 months later...

This is cool... Stumbled into this script looking for something else. That is, i need to place anims on a prim, u sit on it or wear it, and then it plays the animation list automatically. With timer, for example: anim1: 5,3s, anim2: 12,13s... etc. etc. I'm not a scripter, so forgive my dumb questions... How difficult it'd be to modify this script to do that? Thanks, if you bother to answer :)

Link to comment
Share on other sites


Maar Auer wrote:

This is cool... Stumbled into this script looking for something else. That is, i need to place anims on a prim, u sit on it or wear it, and then it plays the animation list automatically. With timer, for example: anim1: 5,3s, anim2: 12,13s... etc. etc. I'm not a scripter, so forgive my dumb questions... How difficult it'd be to modify this script to do that? Thanks, if you bother to answer
:)

Sorry, I didn't spot your note until just now.  You shouldn't have any trouble doing that.  It's basically a matter of adding a timer event to take the place of the touch_start event.  It would trigger the next animation every X seconds just as if you had clicked the stand.  You'd probably want to keep just enough of the touch_start event to use as a switch to toggle the timer on and off.  If all you want is a stand that cycles through the animations in its inventory, though, you can probably write a stripped down script that's simpler even than this one to do the job.

Link to comment
Share on other sites

  • 3 months later...

Thanks for posting this and thanks to you I was able to build my first model pose stand - yay! 

I've loaded the poses I wanted into the prim and they advance as they should. However, when its in use, my subjects sink into the prim. Also, I'm not able to advance it if someone is on it which I will need to do as the photographer. 

Am I missing a step? How can I get the subject to "stand" and not sink and how do I advance it while someone is on it? 

Elle  

 

 

 

Link to comment
Share on other sites

You're free to modify it any way you like.  If you remove the if statement at the start of the touch_start event, then it won't just work when llDetectedKey(0) == agent.  The reason I wrote it that way was so that other people couldn't mess with my poses while I was on the stand, that's all.  As far as "sinking" is concerned, ...... the pose stand turns transparent when you stand on it, if that's what you mean.  That's another one of those things you can change if you want.  Just change any llSetAlpha statements to 1.0 to be sure that the stand stays visible.  If you really do sink in the stand, though, check to see that you didn't make it phantom.

Link to comment
Share on other sites

Instead of incrementing ThisAnim each time you click on it ( ++ThisAnim ), decrement it ( --ThisAnim ).  If you want a way to pick whether you go forward or backward, the cleanest way is to use two buttons and then detect which one was touched, as in, for example ...

 

if (llDetectedLinkName(0) == "Forward"){    ++ThisAnim;}else if (llDetectedLinkName(0) == "Back"){    --ThisAnim;}

 

 

  • Like 1
Link to comment
Share on other sites

  • 2 months later...


ellerc wrote:

Thanks for posting this and thanks to you I was able to build my first model pose stand - yay! 

I've loaded the poses I wanted into the prim and they advance as they should. However, when its in use, my subjects sink into the prim. Also, I'm not able to advance it if someone is on it which I will need to do as the photographer. 

Am I missing a step? How can I get the subject to "stand" and not sink and how do I advance it while someone is on it? 

Elle  

 

 

 

Hey, I figured out how to make the avatar not sink into the prim.

On line 28, where it says

llSitTarget( <0.00, 0.00, 0.80>, ZERO_ROTATION );

Change 0.80 to 1.00, so that you end up with

llSitTarget( <0.00, 0.00, 1.00>, ZERO_ROTATION );

That is on an object that has been flattened down to 0.0100 (the Z size)

My assumption is that messing with that number will help you if you don't have a flattened prim, I am not certain what the reference point is for that number, I guess the center of the prim? 

Link to comment
Share on other sites

You also use the llSitTarget for that. Rotations are expressed in a way that is a little confusing for most people (including me), but there are ways to make them more readable - 1. You use Euler rotations instead of quaternions and then convert euler to quaternions (llEuler2Rot), 2. You enter degrees instead of radiants in the llEuler2Rot function and conver them by multiplying the degrees by the built in variable DEG_TO_RAD. In the line below, you just enter the degrees you want to rotate the ava in the x, y and z axes respectively:

llSitTarget( <0.00, 0.00, 1.00>, llEuler2Rot(<x, y, z> * DEG_TO_RAD) );

 


  • Like 1
Link to comment
Share on other sites

That's the way that standard LL animation works.  It's even called "turn_180".  I suppose that I could add a camera control code to flip the camera around too, though.....    Never thought of that.

ETA:  Oh, wait.. I see what you're doing.  (Thanks for the kick, Darkie.... :smileytongue:  )  See right at the top of the script where the sit target is defined?  It says

llSitTarget( <0.00, 0.00, 0.80>, ZERO_ROTATION );

So just change it to say

llSitTarget( <0.00, 0.00, 0.80>, llEuler2Rot(<0.0,0.0,PI> );
Link to comment
Share on other sites


Rolig Loon wrote:

That's the way that standard LL animation works.  It's even called "turn_180".  I suppose that I could add a camera control code to flip the camera around too, though.....    Never thought of that.

I got rid of the turn 180 pose (at least I think I did). I don't want the camera flipped, that would not be beneficial if say I had a cool background I was trying to capture, you know? Or using some sort of backdrop. The pose stand I have been using forever which I love with all of my heart but only has a t pose does not turn me about, so I was trying to figure out how to do that.

Link to comment
Share on other sites

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