script command for playing an animation

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 command for playing an animation // Scriptorium

1  2  |  

Post by frootee // Sep 3, 2007, 5:46am

frootee
Total Posts: 2667
pic
Hi folks. I am trying to find the jscript command to play an animation.


What I want to achieve is this: use a distance trigger to start the animation when the avatar gets close enough.


Any thoughts?


Thanks!


Froo

Post by 3dvisuals dude // Sep 3, 2007, 5:56am

3dvisuals dude
Total Posts: 1703
pic
Have you tried moving the objects manually while the Jscript Macro Recorder is running and see what code it produces which you could include in your trigger script?

I haven't done this yet but was planning to myself.

Mark

Post by frootee // Sep 3, 2007, 6:01am

frootee
Total Posts: 2667
pic
yeah; that seem s to work fine but I need to load a pre-recorded animation. Specifically an IK character.


froo

Post by Emma // Sep 3, 2007, 6:01am

Emma
Total Posts: 344
pic
I remember there was a scripting thing where a website was opened when getting near to a face of something like an octahedron.


http://forums1.caligari.com/truespace/showthread.php?t=823&highlight=script+link+open


instead of that link you could perhaps open the player

Post by frootee // Sep 3, 2007, 6:20am

frootee
Total Posts: 2667
pic
thanks Emma. That may be helpful, but what I really looking for is, a command

that will play an animation Clip that is in a scene.


Basically, I have an architectural type scene, with a character in it.


When you get close to the character, the character's clip is played/activated.


So I am trying to find the command that allows me to play the clip. Maybe I can use the Activity.Activate type script.


Thanks!


Froo

Post by 3dvisuals dude // Sep 3, 2007, 6:25am

3dvisuals dude
Total Posts: 1703
pic
Fro,

what about all the objects whirling around in Norm's "Dance Hall 3" scene that shipped with trueSpace 7.5?

He has animated light spheres with adjustable paths and animated airplanes in there... they are all activated by the user in truePlay or trueSpace so why not use the same methods to just hook up the actions to a sensor?

- Mark / 3dvisuals dude

Post by 3dvisuals dude // Sep 3, 2007, 6:33am

3dvisuals dude
Total Posts: 1703
pic
If the IK animation can be saved as a scripted RsObj file it can be loaded by trigger using the jscript command for loading rsobj files.

Or, if it can be placed in a scene as a prerecorded keyframed animation it can also be hidden there from the start and have it's visibility activated upon approach.

- Mark / 3dvisuals dude

Post by 3dvisuals dude // Sep 3, 2007, 6:35am

3dvisuals dude
Total Posts: 1703
pic
Better yet... (I'm still waking up and downing coffee, sorry)

Send me the file or post it and I'll see if I can get this working for you myself.

I owe you a few already!:D

- Mark / 3dvisuals dude

Post by trueBlue // Sep 3, 2007, 9:28am

trueBlue
Total Posts: 1761
pic
Hi folks. I am trying to find the jscript command to play an animation.
What I want to achieve is this: use a distance trigger to start the animation when the avatar gets close enough.
Any thoughts?
Thanks!
Froo

Sure me thinks the trueSpace7 Animation Play/Stop command would do the trick.
:)

Post by Asem // Sep 3, 2007, 9:53am

Asem
Total Posts: 255
RsTime.Play(""); // those quotes are needed or it won't work

Apparently you might be able to choose which object gets animated but I'm not sure. If the str type doesn't do that then there is a way to script to disable clips tha would be possible going through animation scripting.

Post by frootee // Sep 3, 2007, 10:36am

frootee
Total Posts: 2667
pic
thanks folks. I think what trueblue has suggested will do the trick. I will try to select which objects get animated.


Question though: I cannot find information in the documentation for this, so how do I go about finding out about its existence, and other functions like it? That's the part that drives me nuts...


Froo

Post by trueBlue // Sep 4, 2007, 10:41am

trueBlue
Total Posts: 1761
pic
This command plays the whole animation. You could also put a path string inside the quotes to play a certain object, but it still plays all animation globally. I do not believe you can play a certain clip, still checking on that scenario. I do believe you could load a clip though. You can also use the Filters to Play only selected object hence where using the string would come in handy. Another idea would be to script the Connection and Disconnection of the Links. Record a Macro doing this would give you the code. I do not have tS7 here to check but I think there is a way.
HTH

Frootee: I find these commands from Buttons in Library, Toolbars in Windows Manager Space, and also in the Script Editor. When you set your Attribute look for the data set for Animation part.

Post by frootee // Sep 4, 2007, 10:47am

frootee
Total Posts: 2667
pic
hm... how about configuring the trigger to only play certain clips, by looping through all the clips in the scene, and disabling all clips except for those we want to play?


Is there a command for disabling clips?


Also, is Filters to Play a command? I'll check that out.


I will also try connect and disconnect of the links while recording a macro. I noticed that errors were commented in the recorded macro if I tried recording keyframes, while recording the macro.


BTW when you get a chance could you please post an example of some of these solutions?


Thanks trueblue,


Froo


BTW just read your edit. Will do thanks man! So that's where they are! Man, I was wondering where does this stuff come from? :-D

Post by Asem // Sep 4, 2007, 11:28am

Asem
Total Posts: 255
I did look through that and there did seem to be a way to disable clips as they are their own nodes and have that option. There were actually two types of animation calls RsTime.whatever and RsAnim.Whatever and seem to work in hand somehow.

With RsAnim, I did a lot of testing but was only able to do something like move to next frame and that oddly required RsAnim.AnimStart = "AnimStart Mark5" (well I was copying what I was getting from the results of the output console pretty helpful).

You should actually be able to link a on/off button to that specific clip and maybe tie all of it together with a proxy sensor node and script and let RsTime.Play("") just play globally only having effect on active/deactive clips by proxy sensor node if that makes sense to you guys/gals.

Post by frootee // Sep 4, 2007, 11:33am

frootee
Total Posts: 2667
pic
Hm. I'll have to try this when I get home then.

If the clips have a check box then they have an attribute For that checkbox. As such I can toggle the state of the attribute. Cool.


Froo

Post by Asem // Sep 6, 2007, 12:13pm

Asem
Total Posts: 255
I got a scenario that should work but doesn't seem to work because the Animation Editor doesn't seem to refresh it self or recognize that the clip is either active/deactivate though you can see it happening when moving in and out of the sensors though there's probably a simple command or so that will do this at this point I'm not sure.

This is supposed to work by moving into a proximity zone and activating a clip so that when playing globally (all animation will try to be animated) the other objects won't animate while the one that you set of will.

I'm also suggestion that there be a ignore matrix input on the proximity sensor node that will allow an animated object to be enclosed and not set of the sensor.

Another thing would be to disable collision support of objects within the object attributes for the FPS tool to allow people to walk into the enclosed sensor zones without colliding into them.

what's here (All Scripts in JScript):

-I created an animation play/stop script instead of having to worry about switching back and forth to the 4d aspect. there is some scripting in the node and within the buttons that I added mostly to the stop button that will make it return to the start frame. [Play Anim]

-There is also a script that reverses to output of the proximity sensor from 1 to 0 and 0 to 1 because of how the disable clip checkbox works. [Reverse Integer Script]

- Sense the global view won't set of the sensor's are ended creating a camera and a second window (to set its view to the newly created camera) to set off the proximity sensors which are the white boxes.

I have a few ideas to get through this but if anyone knows the answer post it at the mean time I'll at the some point try to condense this are into a simple script for all this instead are creating multiple node all over the place .

Monitor Space was something I assumed needed the owner space of where all objects were but it can probably be ignored.

I'm also attaching the scene and project file.

[sidenote] I had this a little more informative but the browser went wacky on me so if your confused on anything go ahead and ask though the scripts themselves are easily readable

Here's a picture:

Post by frootee // Sep 6, 2007, 12:20pm

frootee
Total Posts: 2667
pic
Thanks Asem. I will take a look at this tonight.


Lookin forward to it!


Froo

Post by trueBlue // Sep 6, 2007, 9:47pm

trueBlue
Total Posts: 1761
pic
Okay here is an example using two Triggers to Play an Animation and enable a Disabled Clip.
8292
First white Trigger is set up with Action Radius of 30.
Activate = RsTime.Play('');
Deactivate = RsTime.Stop();RsTime.SetTime(0);
Second red Trigger is set up with Action Radius of 5.
Activate = Node.Value(Space.CurrentScene() + "/Cube/AnimClip, 1", "ClipDisabled") = 0;
Deactivate = Node.Value(Space.CurrentScene() + "/Cube/AnimClip, 1", "ClipDisabled") = -1;
This is a simple animation of a cube with two AnimClips, one for rotation and the other for moving. I Disabled the AnimClip, 1 for moving. I recorded a jScript Macro to uncheck the ClipDisabled in AnimClip, 1, note the screen grab and the script above in the second trigger.

Post by frootee // Sep 7, 2007, 2:37am

frootee
Total Posts: 2667
pic
Thanks trueblue. That is very straightforward. I will have to get into the habit of using the macro record. I'll see if this works with character animation.


:)


Froo

Post by frootee // Sep 7, 2007, 2:58am

frootee
Total Posts: 2667
pic
here is the result. THank you so much trueblue. THis is a very simple, elegant solution. I gotta use the dang jscript record toolbar! New mantra for me.


so it looks like, for checkboxes:


Node.Value(Space.CurrentScene() + "/Cube/AnimClip, 1", "ClipDisabled") = 0


Node.Value(Space.CurrentScene() + "/Cube/AnimClip, 1", "ClipDisabled") = -1


a value of 0 means, Unchecked (Deactivated/Disabled), and

a value of 1 means, Checked (Activated/Enabled)


is that correct? I think it is but just to make sure...


Froo

Post by Asem // Sep 7, 2007, 7:06am

Asem
Total Posts: 255
Neat trueBlue, I didn't even know that trigger node was there. I kinda find it a little weird that my example was a dud but yours is less involved and better.

Post by trueBlue // Sep 7, 2007, 7:16am

trueBlue
Total Posts: 1761
pic
Asem: I think that your example could be used as well. But you would have to have the Avatar holding an object to be used in the Prox. sensor or access the Eye Camera, if that is possible. The Trigger already does this. One thing I noticed as well is why not use a plane inside of a cube in your example to elimanate the impassible barrier? Any way I am sure we could find a way to use your example in other ways too. So many possibilties for sure.
Frootee: 0 = False and -1 = True.
Did you notice the circles that I used as an Object for the Triggers?
The idea was to give you an idea of the ActtionRadius.

Post by frootee // Sep 7, 2007, 7:23am

frootee
Total Posts: 2667
pic
Asem: I think that your example could be used as well. But you would have to have the Avatar holding an object to be used in the Prox. sensor or access the Eye Camera, if that is possible. The Trigger already does this. One thing I noticed as well is why not use a plane inside of a cube in your example to elimanate the impassible barrier? Any way I am sure we could find a way to use your example in other ways too. So many possibilties for sure.

Frootee: 0 = False and -1 = True.

Did you notice the circles that I used as an Object for the Triggers?

The idea was to give you an idea of the ActtionRadius.


Hi trueblue. Why would the avatar have to be holding an object in order to use the proximity sensor? Is the proximity sensor useful only for objects which are not avatars?


Yeah, I did notice the circles. THat is another question: How do we change the object type that represents the trigger? I see inside the trigger example that a sphere is used, but can we just drop a cube in there instead, then delete the sphere?


Interesting choice for true and false values. Looks like 0 (False) is: 0000 0000 (hex), and -1 is FFFF FFFF (hex), 32 bit, all 1's


Also accessing the eye camera is possible:


Cam = Node.SubObject("/D3DView", 0);


gets the first (and usually Only I believe) item in the D3DView. Check this forum discussion, where Dele figured this out for teleporters, etc:


http://forums1.caligari.com/truespace/showthread.php?t=3900&page=9

Post by trueBlue // Sep 7, 2007, 7:27am

trueBlue
Total Posts: 1761
pic
Look at the Lamp Post example. I beleive it uses a selected object's Matrix. Right?

Post by frootee // Sep 7, 2007, 7:50am

frootee
Total Posts: 2667
pic
yeah, it does. I was wondering what the difference was between a Proximity Sensor and a Distance Trigger. I am not sure if it is actually explained in the documentation or not, but they sound kinda similar to me. I was wondering if we could use a Distance Trigger could be used for selected objects too. The terms are similar, but apparently they are for different purposes, yet accomplish the same thing:


Distance Trigger: activated by avatars Only, not objects

Proximity Sensor: activated by objects only, not avatars


is that right? Does it make sense?


Thanks again man; I'm catching up, slowly but surely. (I know... stop calling you Shirley.... :D )


Froo

Post by Asem // Sep 7, 2007, 9:52am

Asem
Total Posts: 255
Actually, I did have a place holder (it was a camera object then just switched to it's view which when using movement widget would activate/deactivate the clip when I was in zone) but doesn't seem to work well with connectors oh well. Kinda like the problems I had in the past where I was making a custom background widget that would change how you moved around the 3d space. the middle scroll wouldn't work sometimes but either way it was what the trigger did so all is well (at least what it was supposed to).

I guess it may be better to use proximity when objects need to interact with each other rather than the user.

Post by trueBlue // Sep 7, 2007, 11:40am

trueBlue
Total Posts: 1761
pic
Frootee: Yes I would beleive so.
Asem: Yes Widgets do not like the Middle Mouse Button/Wheel. Interferes with the Background Widget I suppose.

Post by frootee // Sep 7, 2007, 11:41am

frootee
Total Posts: 2667
pic
OK. Thanks Trueblue. I'll add that to my list of notes then.


Froo

Post by 3dvisuals dude // Sep 7, 2007, 3:47pm

3dvisuals dude
Total Posts: 1703
pic
Excellent! Looks like you guys are homing in together on a solution - well done!:D

Post by Asem // Sep 7, 2007, 8:13pm

Asem
Total Posts: 255
If anyone comes up with a way to change animation tracks by script throw a post.

There seems to be an invisible package for animation that was picked up by the macro recorder ( System.createDo("package?") ) but it's methods won't pop up there is also RsAnim.SetAttrKeyFrame(str, str, var) I was guessing that one of these would let me set the track but it doesn't seem like it though I know that regular RsAnim.SetKeyframe(object[str], frame # to key[var]).

Thanks.
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn