|
|
Script Question - Spinning object from Frame 0 through <whenever>
About Truespace Archives
These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.
They are retained here for archive purposes only.
Script Question - Spinning object from Frame 0 through <whenever> // Archive: Tech Forum
Post by tscorpio // May 22, 2007, 10:11am
|
tscorpio
Total Posts: 84
|
Scripting Question:
I know this is going to be a really dumb & easy question, but What is the setup for scripting an object that you just want to rotate through your entire animation. (Like helicopter blades, fans, or a police light)
I mean, I know it's gotta be some rotate function inside an infinite loop. I've been looking at the tutorials but don't know enough about the commands to figure out what I need to do.
Thanks! |
Post by Burisman // May 22, 2007, 10:20am
|
Burisman
Total Posts: 128
|
The functionality is partly described on p. 20 of your Artist Guide: "Creating Behaviours Using Link Editor". Only ... the rotation of the propellor there is not continuous, but a function of the distance the plane travels. The script will need some adaptation, just to let it rotate. But it's a good place to start. I suppose other, more experienced, forum members will come to the rescue soon ;)
Of course, there's the excellent Délé .. http://forums1.caligari.com/truespace/showthread.php?t=355&page=2 |
Post by tscorpio // May 22, 2007, 10:51am
|
tscorpio
Total Posts: 84
|
Yea I worked through that and managed to get it setup on a engine control and a compose. That got a spinning propeller in the player view that I could start/stop with the engine button.
But those controls are meant for Activities arn't they? As in for making objects for online worlds?
I'm really looking for code that is appliciable to rendering out animation frames... |
Post by Burisman // May 22, 2007, 10:58am
|
Burisman
Total Posts: 128
|
Well, there is a discussion on the mixing of frame-based and procedural animation here : http://forums1.caligari.com/truespace/showthread.php?t=2871&highlight=animation+activity
TomG gives an explanation.
It could be helpful |
Post by Délé // May 22, 2007, 11:02am
|
Délé
Total Posts: 1374
|
Well, in my triggered loop script (attached at bottom), I used modulus arithmetic to create a looping number. A number from a timer links into the script (see HERE (http://forums1.caligari.com/truespace/showthread.php?t=355) for linking). Modulus is performed on the input timer number and the user defined loop number. This creates a looping number from 0 to whatever the user defined as the loop amount. So to create a 360 degree loop, you would just perform modulus with the timer input number and 360. The modulus symbol in Jscript is %.
So you would script it like so:
params.convalue("output") = TimerInput % 360;
This will take the "TimerInput" and perform modulus on 360. So when you start the timer, as the number increases, the output will continuously loop from 0 to 360. Then you can link this output into one of your objects rotation inputs. When you start the timer it will make the object rotate.
You could also add a user defined speed input to change the speed of the timer thus speeding up or slowing down the loop.
You could script that like so:
params.convalue("output") = (Speed * TimerInput) % 360;
So if the user inputs anything lower then 1 for the speed, it will run slower then the original timer. If the user inputs anything above 1 for the speed it will run faster then the original timer.
If you need more clarification on anything just ask and I'll try to explain things better. :)
Now I have more stuff included in my script. So if you look at that you'll see some extra stuff. I added trigger times for starting and stopping as well as a user defined number to start with and also reverse.
hth |
Post by trueBlue // May 22, 2007, 11:05am
|
trueBlue
Total Posts: 1761
|
I do not think you are going to get the speed you need to rotate by script.
I would just Keyframe the rotation in the Animation Editor. Must likely it is the rz or Yaw in your Object's Matrix.
Edit: Oops sorry Dele. |
Post by Délé // May 22, 2007, 11:10am
|
Délé
Total Posts: 1374
|
But those controls are meant for Activities arn't they? As in for making objects for online worlds?You can use those for live activities or rendered animations. You can keyframe script inputs in the AE. Just select the script. Then right click on the "Record" button in the AE. This will bring up the keyframe editor. Then select the script input you want to keyframe from the list to activate it. Then when you change the numbers in the script inputs and record keyframes, it will animate that script input.
So for instance, if you use the script I posted, you could keyframe the "Timer IN". That would make the script output a looping number that you link into your object. Thus the script would be keyframed, and the script would in turn drive the rotation of the object it's linked into. |
Post by Délé // May 22, 2007, 11:14am
|
Délé
Total Posts: 1374
|
Keyframing the rotation as trueBlue suggested is probably the easiest thing to do. However, if you want to keep your animation parametric (meaning you can always adjust the speed, rotation amount, etc) then using a script could prove useful. Once you have the script keyframed, you can still change settings on the script to refine the animation. Plus, you can easily attach the script to other objects to mimic the same rotation or even swap out the object with another without having to re-keyframe.
So there are benefits to using scripts, but keyframing is usually faster and easier in most cases. :) |
Post by tscorpio // May 22, 2007, 11:21am
|
tscorpio
Total Posts: 84
|
Wow! So much information in such a short period of time!! Thank you all very much!
I write code during the day so the concepts aren't new, but their implementation in TrueSpace is!!! So you can't just select an object, switch to it's 1D view and type code that fires on a "Framechange" event or something? (Forgive me and my event programming anology there..)
The Procedurual Animation/Keyframe hotrod tutorial seems to use the techinique I'm looking for with it's wheels. |
Post by Délé // May 22, 2007, 11:31am
|
Délé
Total Posts: 1374
|
So you can't just select an object, switch to it's 1D view and type code that fires on a "Framechange" event or something?No, you'd have to write a script that will either link into objects or take control of objects from within the script.
If you can post exactly what you're trying to do, we may be able to help a little more. |
Post by trueBlue // May 22, 2007, 11:46am
|
trueBlue
Total Posts: 1761
|
The Procedurual Animation/Keyframe hotrod tutorial seems to use the techinique I'm looking for with it's wheels.
The script that makes the wheels move with motion is the same as with the Plane Propeller tutorial, the Rotation Script. I hacked only one value in that script and I think it was changing the X to Y. It's been awhile but you could compare to be sure. |
|