Slider to control Lightwave animation in shockwave

zardoz

Active member
Hi everyone,

I need help in this...is there a way to have a slider to control an animation exported by LW to Director?

I'm not a programer...I've been doing some things in Director with the help of a friend but he doesn't have the time to help me always so I've been 'fishing' bits of code all over the web...so what I have is a play/pause button on my animation and I made it loop...:hey:

What I would like to have was the same play/pause button and a slider bar to move thru the time of my animation...like the one we have in Layout...

tx
 

MentalFish

LScript minion
All animated objects that are exported by LW has an animation "property" applied to them, and that can either be keyFramesPlayer or bonesPlayer (as you propably have seen when scripting the play/pause function). If you want to set the timeline of an animation by a slider you will have to use this bit of code:

Code:
member("w3d").model("box").keyFramePlayer.currentTime = sprite(2).loch

But that does not take into account the actual end time of the animation and that would take this bit of code:
Code:
totalFrames = 60
framesPrSecond = 30
sliderLength = 618
animLength = (totalFrames/framesPrSecond)*1000.0
member("w3d").model("box").keyFramePlayer.currentTime = (sprite(2).loch / sliderLength) * animLength

I have attached an example file you can look at. And remember if you want to control the playback of a model with bones you have to use the bonesPlayer instead of keyFramePlayer.
 

zardoz

Active member
tx for answering petter

but...I have dozens of objects...it's an assembly of lots of stuff, and I have the full animation in lightwave. When I export it to .w3d and import it in director it just plays in a loop. so that's why I have the play/stop button. I was looking for some slidebar to control all the animation...imagine the animation has 100 frames in LW....in director I would have a slidebar to go from frame 1 to 100.

Do I have to apply that code to every object of my animation in director?

and thank you SO much for the attached example...I can learn a lot from this file.
 

MentalFish

LScript minion
Yes you have to! but not really, because I have done it for you in a new one :)

This one applies control to all objects, regardless of them having any animation applied or not.

The only thing you have to modify yourself is the variable that is named totalFrames (framesPrSecond too if you have a different FPS).

Also, the script refers to the first cast member in the cast library, so make sure your W3D file is the first one in the library.
 
Last edited:

zardoz

Active member
Once again thank you so much for helping me with this...I'm trying to implement it now...if I find any problems I'll come back here and ask for your help again.

Thanks

:thumbsup:
 

zardoz

Active member
Hi petter (and everyone else)

I tried everything and it works really fine and simple. I only found 2 problems...

1st: I have some code to orbit the objects and adding your code messed up the code I'm using...and I can't find where is the problem. The pan & zoom code (coded by my friend) are ok...he also did some code for the orbit/rotation but the pitch was 'locked'...it was like local axis...if you rotate the heading of the object the pitch is kind of 'locked' to that heading...and what I want is to have the pitch always paralel to the world z axis...I don't know if my english is ok...So I had to find some other code for the rotation on the web and I did, and it worked but when I added your code it doesn't work anymore...

2nd: I want the slider to start somewhere else on the x pos in director, so I changed your code to make this, but when it starts playing it always jumps to x=0...if I grab it there then it will work where I want...

so these are the 2 issues I have for this to be perfect...if you (or someoneles...) can help me, that would be great.

I have here your second example with the changes I made.

Thanks in advance.
 

zardoz

Active member
Hi petter,

I wish to thank you for the help you gave me on this. Now everything is working just fine...I had to spend some time learning some lingo but I'm still a noob in this. I had to change some of your code and scratched my head a lot to make the bones work...when you are not into code and when you just don't have the time to learn it, can be really hard. When I was 10 years old I learned basic on the spectrum, but now...lol, it's useless.

So, once again, thanks for your kind help.
 
Top Bottom