Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Facial expressions - how to ad?

Shuangli Zhangsun
Registered User
Join date: 14 Oct 2008
Posts: 8
01-08-2009 06:21
hello world!

i want to add facial expressions to some posaballs. I learned i must use the build in animations from sl, and that they can be triggered by a script in sl. Im searchung such a script.

Can someone give me these lines of code? maybe with a little explanation on what i have to do with them or together with a poseballscript?

thanks for your help!

Shuangli
Carbon Philter
Registered User
Join date: 4 Apr 2008
Posts: 165
01-08-2009 07:45
Check out the following thread: /52/60/256472/1.html

There's a script set-up in it to view all the inbuilt gestures. You should be able to adapt it to suit expressions, maybe?
Shuangli Zhangsun
Registered User
Join date: 14 Oct 2008
Posts: 8
01-08-2009 16:30
hello,

and thank you for your answer!

sadly im not a scripter and i cant adjust the script of the link.

i would need something like that in a more final form:

(

start: onsit
start expression: express_tongue_out
loop expression sec: 5.0
stop: unsit

)

like that, just as a real script :) i need it for a poseball, so the code should work with a poseballscript or maybe someone can give me a poseball script with the option the change the facial expression?

thanks :)

Shuangli
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-08-2009 16:50
Did you try asking in the Products Wanted forum or looking in SLExchange (or whatever it is now)? You might find just what you are looking for there, or at least something to study and use as a model. This forum is really for people who want to learn how to script.
Shuangli Zhangsun
Registered User
Join date: 14 Oct 2008
Posts: 8
01-08-2009 16:57
hi,

yes i searched slxchange, the other forum you mentioned i dont know. i found something in the web that tells me an syntax error when running it and it doesnt work..

i think i have an interesting question that fits good in this forum, and i wonder that there is no answer around for something that basic like facial expressions.

thanks for all help!

Shuangli
Shuangli Zhangsun
Registered User
Join date: 14 Oct 2008
Posts: 8
01-12-2009 08:58
oh my... so noone really knows this simple piece of code : ( or noone will tell? i cant believe it, but its sad and for sure it doesnt improve the sl expirience. imagine this code known openly, so everyone can use it, how much better most of the animations would become. sl looses track way to fast from the evolution of videogames. maybe its true waht other says, that a virtual world will exist in future, but that probably it wont be sl - i dont wonder seeing i cant get a simple 5 line script for a basic, not on the net, not in sl, not for free, not even to buy :(

p.s.: yes, i posted my request also on the product wanted forum..
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
01-12-2009 10:10
From: Shuangli Zhangsun
i cant get a simple 5 line script for a basic, not on the net, not in sl, not for free, not even to buy :(

p.s.: yes, i posted my request also on the product wanted forum..
Well, you can find the basic code for playing facial expressions at /52/fa/55835/1.html#post590854 or by picking up a free emote hud from Yadni's Junkyard, taking it to bits and finding out how it works. That's how I learned how to do this.

Getting it to work with a poseball takes a bit more than "a simple 5 line script" but if you want to have a go, I'll happily help you here.

Alternatively, you get a full rights pose ball that does what you want for L$10 (free in world) from http://www.xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=337499
Shuangli Zhangsun
Registered User
Join date: 14 Oct 2008
Posts: 8
01-13-2009 18:48
oh, hello - and thank you so much for your help! and sorry for my angered posting before :)

i got the hud but i sadly i was not able to adept it for a poseball..

now i got the poseball you adviced and im confident i got what i need and i can manage it (hopefully). also the link with the basic script is great!

again, thank you! im sure this post will be usefull for a lot of people as well as i had really problems to find informations about how to trigger facial expressions (in poseballs).

with best regards and best wishes

Shuangli
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-13-2009 19:52
Here's the deal. Facial expressions are a property of an animation. When you upload an animation, you can either leave the facial expression unspecified (just like the animation may not move a certain bodypart), or you can choose one of a set of predefined ones. As far as I am aware the built-in animations that change facial expression are just like other animations but don't move any joints (or might move a small set of joints a little bit for emphasis or something).

If an animation has a facial expression specified, the expression is maintained while the animation is playing. Now remember that (stupidly; they should've done it like sound instead where you can loop or not when you play) animations are either looped or not. You choose when you upload the animation, and it is forever fixed after that.

So if you want a looped facial expression, you have to play a looped animation that includes that facial expression. I think the built-in animations that change facial expression are all unlooped.

As for playing an animation when you sit, then unsitting after a chosen period, it can be as simple as:

CODE

string ANIMATION = "whatever";

float SIT_PERIOD = 5.0;


key sitter = NULL_KEY;


animate()
{
if (sitter == NULL_KEY)
{
return;
}

if (llGetPermissionsKey() != sitter ||
!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
{
llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
} else
{
llStopAnimation("sit");
llStartAnimation(ANIMATION);
}
}

unanimate()
{
if (sitter != NULL_KEY &&
(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
{
llStopAnimation(ANIMATION);
llStartAnimation("stand");
}
}

handleSitter()
{
key newSitter = llAvatarOnSitTarget();
if (newSitter == sitter)
{
return;
}

llSetTimerEvent(0.0);

unanimate();
sitter = newSitter;
animate();

if (sitter != NULL_KEY)
{
llSetTimerEvent(SIT_PERIOD);
}
}


default
{
state_entry()
{
handleSitter();
}

changed(integer changes)
{
if (changes & CHANGED_LINK)
{
handleSitter();
}
}

timer()
{
if (sitter != NULL_KEY)
{
llUnSit(sitter);
}
}

run_time_permissions(integer perms)
{
animate();
}
}
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
01-14-2009 03:04
The problem with the non-looping built-in expressions is that they don't last very long, and if you want to play them more than once, you need to make them loop. While there's no built-in way of looping facial expressions, you can roll your own, using a timer, to make them play while you're playing another anim. And you need, of course, to stop the timer -- and thus the loop -- when you stop the other animation, or you wander around pulling silly faces after you've got up from the poseball.

This is my generic code for doing it, anyway:
CODE


list gAnimations = ["express_toothsmile","express_tongue_out" ];

restartAnimations()
{
integer i ;
integer max = llGetListLength(gAnimations) ;
string ani ;
for (i=0;i<max;i++)
{
ani = llList2String(gAnimations, i) ;
llStopAnimation(ani) ;
llStartAnimation(ani) ;
}
}
string sitAnimation="";

// if sitAnimation is left blank
// the script will grab the first animation in the container.
// if a value is set, it will use that instead.



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

state_entry() {
llSetText("Sit to Pose", <0.0,1.0,0.0>, 1);
llSitTarget( <0,0,0.75>, ZERO_ROTATION );

// if blank, we look in inventory
if (sitAnimation == "") {
sitAnimation = llGetInventoryName(INVENTORY_ANIMATION, 0);

// oops, use default
if (sitAnimation == "") {
sitAnimation = "sit";
}
}
}


// Using state to control sitting
// If you're in this state, no one is sitting
changed(integer change) {
if (change & CHANGED_LINK) {
key avatar = llAvatarOnSitTarget();
if ( avatar != NULL_KEY ) {
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
llSetTimerEvent(0.5) ; // keeps the tongue out permanently .. to keep on sticking your tongue in and out, change to something like 5.0
}
}
}


run_time_permissions(integer parm) {
if(parm == PERMISSION_TRIGGER_ANIMATION) {
llStopAnimation("sit");
llStartAnimation(sitAnimation);
state sitting;
}
}
}


state sitting {
state_entry() {
}



// Assume sitting, thus any CHANGED_LINK means standing.
changed(integer change) {
if (change & CHANGED_LINK) {
llStopAnimation(sitAnimation);
llSetTimerEvent(0);
llResetScript();
}
}
timer()
{
restartAnimations() ;

}
}