Eye blink script?
|
Maya Remblai
The one with pink hair.
Join date: 25 Mar 2006
Posts: 434
|
04-17-2006 03:45
The eternal question: How to script blinking eye textures!? I've got a 512x512 texture, split into four equal frames, each containing the eye texture at a different stage of blink. I can get the default "open" frame lined up on my head sphere easily enough, but when I put in the open source blink script I found, the texture resizes itself to the default 500 and 250 settings everytime it blinks! I assume that I have to set the size for each frame individually, but how do I do that? Any help would be appreciated. 
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-17-2006 05:16
I've never actually done an eyeblink but... http://secondlife.com/badgeo/wakka.php?wakka=llSetTextureAnimis the place to help. I think, from your description, you want it set to look something like: llSetTextureAnim(ANIM_ON | PING_PONG | SMOOTH, 2,2,0.0,0.0,1.0); but you'll have to play with this to get it just right for you - just subsitute the line I've given you for the line in the script on the wiki.
|
Maya Remblai
The one with pink hair.
Join date: 25 Mar 2006
Posts: 434
|
04-17-2006 06:39
That just makes it jump to a mostly blank spot on the image and stay there. Looking over the Wiki information it seems that the problem is that you can't use llSetTextureAnim and llScaleTexture in the same script. That doesn't explain why it works for the avatar I pulled it from, though. Here's the script I have, with my image's coordinates supplied: // This blink script uses a single texture with the frames set up as follows within the image. // // +-----+-----+ // | 1 | 2 | // +-----+-----+ // | 3 | 4 | // +-----+-----+
// The minimum time between blinks float minBlinkTime = 0.5; // in seconds
// The Maximum time between blinks float maxBlinkTime = 12.0; // in seconds
// The animation frame speed float animationSpeed = 7; // in fps
// number of frames in the animation integer numberFrames = 4;
// temporary variable float waitTime;
// Returns a reandom number between min and max float randBetween(float min, float max) { return llFrand(max - min) + min; }
default { // Main part of the program state_entry() { // Sets the size and position of the default frame llOffsetTexture(-.350,.680,ALL_SIDES); llScaleTexture(1.800,1.000,ALL_SIDES); // Intialize time even llSetTimerEvent(randBetween(minBlinkTime,maxBlinkTime)); waitTime = (numberFrames * 2) / animationSpeed; } // Timer event timer() { // Temporarily turn off the timer event llSetTimerEvent(0.0); // Animate the eyes onces. llSetTextureAnim(ANIM_ON|PING_PONG,ALL_SIDES,2,2,1,4,animationSpeed); // Wait for the eyes to finish animating llSleep(waitTime); // Turn off animation llSetTextureAnim(FALSE,ALL_SIDES,2,2,1,4,animationSpeed); // Reset Timer for next event llSetTimerEvent(randBetween(minBlinkTime,maxBlinkTime)); } }
|
Geepa Lazarno
Registered User
Join date: 7 Apr 2006
Posts: 61
|
04-17-2006 10:46
A lot of the freebie furs include access to a basic 4-state blink script. I've tried simply taking the texture out and putting the new eye setup into it.
Some issues with trying to figure out alpha channels and color replacement, but no issue with eye placement.
I am interested in how it would work.
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-17-2006 11:53
OK, you're mixing and matching things. I think: default { state_entry() { llSetTextureAnim(ANIM_ON | PING_PONG | SMOOTH, 2,2,0.0,0.0,1.0); } }
Should give you the effect you want (although not necessarily at the right speed - the final 1.0 is the thing to use to control that. You're quite right that llScaleTexture and llOffsetTexture don't work with the texture anim controls. That should also be accessible, but it looks like you've got some odd numbers in the script you've got, like it's set up for a much bigger map (18 parts to the blink or something odd?).
|
Maya Remblai
The one with pink hair.
Join date: 25 Mar 2006
Posts: 434
|
04-17-2006 16:31
That script results in a script error: Function call mismatches type or number of arguments.
And is it just me, or is there something seriously wrong with the grid right now? Things aren't loading correctly. :/
EDIT: Geepa: Next time I see you, you'll have to show me the script you're using...The one I posted above comes from the blue Renamon av, and works just fine for that avatar, but not for anything else I've tried it in. :/
|
Geepa Lazarno
Registered User
Join date: 7 Apr 2006
Posts: 61
|
04-17-2006 17:33
How odd, because I have lifted it from say a Wolf avatar, and placed it a head for a personal avatar I want to do. It seems to work fine. I'll be sure to give you a copy of both the script and a sample of the eyes on a sphere.
|
jrrdraco Oe
Insanity Fair
Join date: 28 Oct 2005
Posts: 372
|
04-17-2006 17:34
I have one of that and it works just fine. The logic behind that is that you will have to texture the object at the scale of 1/4 texture size because it will be the second animation frame (of four). Everytime it animates it will just change the texture offset -250H,250V which will be the third frame, then more 250H for the fourth frame then 0,0 the first frame (in this case, closed eyes). If you need any help feel free to contact me inworld, maybe Ill be able to help.
This code seems a bit odd to me, I dont remember very well, but I think the coords are wrong
// Main part of the program state_entry() { // Sets the size and position of the default frame llOffsetTexture(-.350,.680,ALL_SIDES); llScaleTexture(1.800,1.000,ALL_SIDES);
I think texture scale should be (.5,.5,ALL_SIDES) and Offset should be (0,0) (0,.250) (.250,0) (.250,.250)
Ill check that right when I get online
|
Maya Remblai
The one with pink hair.
Join date: 25 Mar 2006
Posts: 434
|
04-17-2006 19:14
The offset and scale I posted are correct for my texture. The scale you posted is he default, which works fine for the tiny Renamon eyes but not for the large eyes I made. I could try scaling my texture's frames down, but it would be better to learn how the script works because I plan on selling my builds later.
|
Fox Stirling
Certified Lunatic
Join date: 16 Aug 2004
Posts: 120
|
04-17-2006 19:58
IM me in world and I'll be happy to go over all of the ins and outs with you.. from aligning the texture to writing the code.. btw, when using a 2x2 texture animation the sizing will always be .5 x .5 and the offset will always be 0.25 and -0.25.
Fox Stirling Devious Creations
_____________________
...
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-18-2006 00:42
default { state_entry() { llSetTextureAnim(ANIM_ON | PING_PONG | SMOOTH, ALL_SIDES, 2,2,0.0,0.0,1.0); } }
Try that one - forgot the sides parameter.
|
Maya Remblai
The one with pink hair.
Join date: 25 Mar 2006
Posts: 434
|
04-18-2006 01:47
I think the problem may be my texture after all, as using the provided scripts results in the eyes being way too large, giving a freaky cyclops kind of effect. I was under the impression that this type of script uses the entire frame, but apparantly it doesn't since it's stretching my texture out so much. I'm used to the world of Poser, where bigger is better as far as textures are concerned, and you always use every pixel to its fullest. 
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-18-2006 06:13
I think you've met the joy of SL. It's pretty much impossible to be a scripter without also being a fairly competent builder and often a fairly competent texturer too - although there are exceptions to this rule depending on the scripts you make and the partnerships you form.
Robin Sojourner has, in world, a temple of textures, that include grid maps for the various prims. They sometimes also appear in the Design and Textures forum, but a quick search didn't show them otherwise I'd have posted a link. Depending on the prim you're using, you might have to play with the texture a bit to make it look right.
Oh, and yes, llSetTextureAnim is the nicest way to do the eyeblinking IMO, but it's *really* critical you get the textures right. You could use a timer loop to adjust the offsets (and scaling if necessary, although llSetPrimitiveParams() is the way to adjust them both together with minimal delay), but I strongly suspect a four part eye blink won't look that good that way. I'm not quite sure how well llSetTextureAnim "tweens" if at all, but from memory it looks better than just jumping the offsets around.
|
Maya Remblai
The one with pink hair.
Join date: 25 Mar 2006
Posts: 434
|
04-18-2006 07:03
I managed to get the freebie script working, after I scaled the frames of my texture down to about 1/4 of what they were. I also had to redo the head part of my model to get the prim in the right position. The eyes are on a seperate sphere, which is scaled up and offset slightly from the head sphere so the eyes don't disapear into the head. The eye texture has an alpha channel so the size difference doesn't show (and it allows me to use full bright for a nice glowy look  ) I still don't understand all the particulars of why it works, but at least it is working now. Thanks for the help 
|