Wheel texture animation problem.
|
Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
|
07-19-2005 16:33
I am using this script to animate the textures on my wheels. default { state_entry() { llSetTimerEvent(0.20); } timer() { vector vel = llGetVel(); float speed = llVecMag(vel); llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, 0, 0, 0, 0, 1, speed*0.5); } } However, there is a problem. When my vehicle goes in reverse, the texture animation on the tires plays like they're moving forward. Can someone please correct the above script so that the texture will play backward when the vehicle itself moves backward? I don't know how to do it.
|
Jim Bunderfeld
The Coder
Join date: 1 Mar 2004
Posts: 161
|
07-19-2005 16:41
I'd suggest just rotating the texture in photoshop. Also try using texture rotation, found under Texture --> Rotate Texture (at the bottom of the box)
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
07-19-2005 16:49
Just add "| REVERSE" to "ANIM_ON | SMOOTH | LOOP". (So it's "ANIM_ON | SMOOTH | LOOP | REVERSE".)
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
07-19-2005 16:50
Like so: default { state_entry() { llSetTimerEvent(0.20); } timer() { vector vel = llGetVel(); // Got your velocity vector. Good. vel /= llGetRot(); // Divide out llGetRot to make it local
// Depending on the axis you want to use for the forward movement, // you may want to change this a bit. For now we use the X-axis. if(vel.x > 0) llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, 0, 0, 0, 0, 1, vel.x*0.5); else llSetTextureAnim(ANIM_ON | SMOOTH | LOOP | REVERSE, 0, 0, 0, 0, 1, -1 * vel.x*0.5); } } Simple, yes? Edit: You might want to use llGetRootRotation instead of llGetRot. I realized this about 10 minutes after posting, but had some errands to run.
_____________________
---
|
Aerolithe Mechanique
Registered User
Join date: 14 Jun 2005
Posts: 21
|
a question
08-09-2005 12:51
I tried out this script last night and was impressed that it's based on the velocity. I hadn't even gotten that far in my scripting skills to even consider that possibility.
I'm having a problem however when I apply this script to a torus which has a tire tread texture, it seems to slide at a 45 degree angle. I've looked through the wiki regarding llSetTextureAnim, and tried tweaking the script with no luck. Could someone tell me what I am missing or not understanding?
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
08-10-2005 01:49
The way the texture will rotate depends on the shape of the prim :/ on tori the center of rotation of the texture is "inside" so it looks weird.
Also, I'd like to suggest changing the script a bit so that it only calls llTextureAnim() when velocity has changed since last timer call.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
Aerolithe Mechanique
Registered User
Join date: 14 Jun 2005
Posts: 21
|
I sort of figured it out
08-10-2005 05:15
I managed to fake it by rotating my texture in photoshop by 90 degrees and then did the same in SL.
I'm still curious if there is another way to change the direction the texture slides via scripting.
|
Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
|
12-04-2006 05:12
From: Jesrad Seraph The way the texture will rotate depends on the shape of the prim :/ on tori the center of rotation of the texture is "inside" so it looks weird. Also, I'd like to suggest changing the script a bit so that it only calls llTextureAnim() when velocity has changed since last timer call. How exactly would you do that? Can you provide a code example?
|
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
|
12-04-2006 06:50
Just add a float OLD to the top and after the animation call, make OLD = vel.x, and after the velocity call, compare. float OLD; default { state_entry() { llSetTimerEvent(0.20); } timer() { vector vel = llGetVel(); // Got your velocity vector. Good. vel /= llGetRot(); // Divide out llGetRot to make it local // Depending on the axis you want to use for the forward movement, // you may want to change this a bit. For now we use the X-axis. if (vel.x != OLD) { if(vel.x > 0) llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, 0, 0, 0, 0, 1, vel.x*0.5); else llSetTextureAnim(ANIM_ON | SMOOTH | LOOP | REVERSE, 0, 0, 0, 0, 1, -1 * vel.x*0.5); OLD = vel.x; } } }
Tho I think the benefit of this would be limited as the value for llGetVel is probably going to be different on a ground-based vehicle every call, even at a steady throttle.
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
12-04-2006 10:22
You could use an order of magnitude comparison or any other fudge factor, only change if chanegd by more than 10% or something.
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
12-04-2006 16:31
if (llFabs (vel.x - OLD) > 0.1)
|
Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
|
12-04-2006 19:58
From: ed44 Gupte if (llFabs (vel.x - OLD) > 0.1) You might want to input this segment into the entire code so we can see what you're talking about. =)
|