Procedurals (Make'm Move)

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.

Procedurals (Make'm Move) // Interactive Artwork

1  2  |  

Post by Délé // Jan 28, 2006, 8:56pm

Délé
Total Posts: 1374
pic
Hey guys,

I'm just moving the stuff I've assembled to these new forums. There are two scene files in the zipped folder. One has some flow controllers and the other has the Rock 'N Roller, Pulsator, and ZigZagger. :D

I only have the one Rock 'N Roller now because when I added the "Start Position", two versions were no longer needed.

Post by Délé // Jan 28, 2006, 8:57pm

Délé
Total Posts: 1374
pic
Here's what's in the scene files above:

Post by Délé // Jan 28, 2006, 8:59pm

Délé
Total Posts: 1374
pic
The image below shows how I'm hoping to be able to hook things up eventually. The three things in the red boxes I have yet to make. Those three are going to take some scripting I think. So if anyone more experienced in scripting would like to have a go at making them, that would be cool. :)


A brief explanation of the scripting things I would like to make or see made:


Timer: I would like to have a timer where you could input the frame rate and the "frames" output would output the frame number for the defined frame rate.


KeyFrame REC: I think it would be cool to be able to plug the "frames" output from the timer mentioned above into the KeyFrame Recorder (perhaps filtered through a trigger to make it start and stop at desired frames). When the button is set to "REC ON" it would record the entire scene into the KFE for the inputted frames. So when you start the animation with the start button, it gets recorded into the KFE. Then it could be rendered out with Lightworks, Virtualight, or Vray.


Loop Trigger: I've actually been trying to get this to work with no success yet. I would like to be able to plug a timer into the "Loop Trigger". When the input time reaches the defined "Trigger Loop @", then the loop will begin counting from the "Start Count @" number up to the "loop Amount". This will continue to loop while the input time is going.


I've been able to get some "if, else" statements to work, but I freeze TS when I try to make loops. :eek: I still have to get a little more proficient with VBScript to get these working. I'll continue to try to make them, but if someone else feels compelled, go for it. :)

Post by mrbones // Jan 28, 2006, 9:12pm

mrbones
Total Posts: 1280
pic
Very Impressive Dele, Keep up these great developments. I will be watching, learning and trying too.:eek: Cheers

Post by Norm // Jan 29, 2006, 4:32am

Norm
Total Posts: 862
pic
I've been able to get some "if, else" statements to work, but I freeze TS when I try to make loops. :eek: I still have to get a little more proficient with VBScript to get these working. I'll continue to try to make them, but if someone else feels compelled, go for it. :)


Inside the Objects/Script Objects/Smartie Mod, you will find a script object called Texture Modulation. It is actually a loop system, done in VBScript. It might give you idea of something to try Dele.

Hope is helpful.

Post by noko // Jan 29, 2006, 5:55am

noko
Total Posts: 684
Awesome and cool Délé! Another idea is using random number generator for random motions like trees swaying or varying the rate of motion over time randomly.

Post by Délé // Jan 29, 2006, 12:30pm

Délé
Total Posts: 1374
pic
Thanks guys. :)

Norm: Thanks, I didn't think to look there. I had looked at your rotation engine for the lights though. :) I think that I kind of understand what's going on in your texture modulation, but there are a couple of things I'm not sure of.

1.) "reminder = inFrame Mod wholeLoopSteps" (I'm guessing that "Mod" is a calculation of some sorts?)

2.) "outX = inStep * CDbl(reminder)" (I didn't see "CDbl" declared anywhere so I'm guessing it's a predefined number, or calculation?)

Here's a script that I had unsuccessfully tried, lol:

' OnComputeOutputs
' Called to compute values of all output connectors
Sub OnComputeOutputs(params)
TimerIN = params.conValue("TimerIN")
LoopAmount = params.conValue("LoopAmount")

If TimerIN = 0 Then
X = 0
End If

Y = TimerIN - X

If Y >= 0 and Y < LoopAmount Then
params.convalue("result") = Y

Else
X + LoopAmount
End If

End Sub

I was hoping that this would basically subtract the (loop amount * the number of loops already performed) from the timer being input essentially looping the inputted timer by the amount desired and outputting it starting from zero. This also assumes that the timer being inputted starts at zero.

This stuff can be hard to explain, lol.

Noko: That's a great idea! I can already think of a couple of things to try. I'm also thinking that it would be cool to make some sort of "easer", which could be used to ease select animations in or out. So many ideas and possibilities, lol. :)

Post by Délé // Jan 29, 2006, 6:05pm

Délé
Total Posts: 1374
pic
hmm....I think I'm understanding now.


Mod = modulo (kind of like the remainder)

CDbl = Convert to double


Does that mean the modulo oblongata = the remainder of the brain not used? :D

Post by ProfessorKhaos // Jan 29, 2006, 6:37pm

ProfessorKhaos
Total Posts: 622
pic
I can tell I need to read up more on this stuff. :)

Post by peterma // Feb 1, 2006, 2:01am

peterma
Total Posts: 48
hmm....I think I'm understanding now.


Mod = modulo (kind of like the remainder)

CDbl = Convert to double




Yes. Both are native VBScript functions / operators. There is no embedded VBScript\jScript reference help in tS7, but you can easily download offline documentation directly from MS pages:


http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

Post by peterma // Feb 1, 2006, 2:34am

peterma
Total Posts: 48
Here's a script that I had unsuccessfully tried, lol:


' OnComputeOutputs

' Called to compute values of all output connectors

Sub OnComputeOutputs(params)

TimerIN = params.conValue("TimerIN")

LoopAmount = params.conValue("LoopAmount")


If TimerIN = 0 Then

X = 0

End If


Y = TimerIN - X


If Y >= 0 and Y < LoopAmount Then

params.convalue("result") = Y


Else

X + LoopAmount

End If


End Sub




Dele you can find some usefull 'getting-started' info in DG docs, not sure if they are available yet.



Some notes to your script sample:


- you should have the TimerIn input connector defined (using attributes tab in the Script editor) in your script object when you want to call:


TimerIN = params.conValue("TimerIN")


I assume you did this, just to make sure :)




- in your script you are setting computed output value only under certain conditions (and again, you should have the 'result' output connector defined) :


If Y >= 0 and Y < LoopAmount Then

params.convalue("result") = Y



standard approach is to set ALL output values ALWAYS when OnComputeOutputs is executed (to avoid unpredictable behaviour).

See e.g. the Norm's Texture Modulation script.





Feel free to ask if something is not clear still.

Post by Cayenne // Feb 1, 2006, 12:51pm

Cayenne
Total Posts: 144
pic
I'm also thinking that it would be cool to make some sort of "easer", which could be used to ease select animations in or out. So many ideas and possibilities, lol. :)


the engine object in the activities base library may supply the ease in part that you are looking for.


Look at the script in the Tom Interpolator.

Post by Délé // Feb 2, 2006, 9:00pm

Délé
Total Posts: 1374
pic
Thanks guys. :)

I'm diving in here and looking at some of the scripts that I can find. I'm already starting to recognize some of the structures. I'm anxious to get the developers guide too. That will probably help as well.

Thanks for the suggestions, I'll keep pluging away. :)

Post by Norm // Feb 2, 2006, 9:15pm

Norm
Total Posts: 862
pic
I used google.com lots when I was beginning with scripting. I would look up Mod and CDbl etc. I found some sites that were easy enough to understand and that I related to. So in your searching, if you come across a site that explains things in a way you can understand, bookmark it and return the next time you have another question to answer.


Along with the examples available, we should be able to get some neat scripts here on forums.

Post by Délé // Feb 17, 2006, 2:04pm

Délé
Total Posts: 1374
pic
Ok, I've got another little toy here. :) My first script object. :D

I'm planning on making a better one that works closer to how I'd like, but this may still be useful at times. It's kind of stiff right now so I'm going to try to make a version that's more fluent. You hook two objects to it. When you move the "lead" object, it will pull the "follow" object. You can use more than one of these to hook many objects up in tandem.

Below is an image of how to hook it up. Also, there's an image of a bacteria animation I'm working on. I'm using this "object follow" script object to link the spheres together, and then animating the "lead" sphere with the zigagger to make it move around the scene while dragging the segments behind it. I've also hooked up the pulsator to each sphere to make each segment pulsate slightly. I'll upload a 3d recording when I finish it. :)

Post by ProfessorKhaos // Feb 17, 2006, 3:26pm

ProfessorKhaos
Total Posts: 622
pic
Forgive me for asking such a simple question but where do I save these RsObj files and how do I load them? I haven't gotten that far in the manual yet. :)

Post by Délé // Feb 17, 2006, 4:19pm

Délé
Total Posts: 1374
pic
I probably would have missed that myself if Paul hadn't told me about it a while back. :)

To load an .RsObj file, right click in an empty area of the objects library and select import object. Then you can just drag and drop it into the LE. You can load an .RsScn file by doing the same thing in the scenes library. :)

edit: I should have mentioned also that if you right click in an empty space in the object library and select insert object, it will insert the selected object into the library. If you right click on an object in the library and select export, you can save it to a file.

Post by noko // Feb 18, 2006, 8:19am

noko
Total Posts: 684
That is pretty cool Délé :jumpy:. Now on your example below if you havn't tried this before that is :) ; hook up the following object (sphere) using the OwnerMatrix node vice the Matrix node. You will then be able to use object widget on the following object to place anywhere on the screen while object will still follow the lead object. This will allow direct manipulation, even when animating the lead object.

Post by Délé // Feb 18, 2006, 8:52am

Délé
Total Posts: 1374
pic
oh cool. Thanks for the tip noko. :) I'm still a little uncertain of the difference between the Matrix, OwnerMatrix inputs as well as the ObjMatrix, WldMatrix outputs.


I did notice that there definitely is a difference when I was making the script though. The script was only working correctly with the X axis at first. This didn't make sense because I'd just copied and pasted the same script and altered it for the Y and Z axes. After many frustrating hours I realized that I was using the ObjMatrix outputs and instead needed to use the WldMatrix outputs for it to work properly. 'doh :rolleyes:

Post by SiRender // Feb 18, 2006, 9:02am

SiRender
Total Posts: 38
Thanks for sharing that. I'm still getting the hang of scripting too.


One thing I'd suggest is use a vector and distance to get the effect you like. See the "Mouse Chasing Object" script (From "Libraries -> Activities -> Base") for how to use some vector data objects.


Another advantage of using the vector is you can just hook up the translation vector as opposed to each X,Y,Z component. If you don't want to do everything in script, I think you can also use the objects "ComponentsFromVector" and "VectorFromComponents" from "Libraries -> Math -> Matrices/Vectors".


There are a ton of Data Object types in the list you get when adding an attribute. I hope the upcoming developers guide will talk about these.

Post by Délé // Feb 19, 2006, 12:26am

Délé
Total Posts: 1374
pic
Thanks SirRender. :) Yeah, I was thinking there is a better way mathematically to do this. I actually had looked at the mouse chasing object before I started but couldn't really get a handle on what was going on. I'll have to dig in and learn a bit more for the next one. :)

Post by peterma // Feb 19, 2006, 4:27am

peterma
Total Posts: 48
Good progress, Dele, a nice toy :)

Actually the Mouse Chasing Car is quite similar to you scheme. The script there is a little more complicated as it also computes a speed for the car.

The second main difference is a way how it interacts with objects.

Look e.g. at this code, how script command can obtain position of arbitrary object 'inName', without need to wire the x,y,z links in LE:


// obtain current object's pos and rot first

curPos = System.CreateDO("Math Package/Point Data");

matrix = Node.Value(inName, 'ObjMatrix');

curPos.x = matrix.GetTransX();

curPos.y = matrix.GetTransY();

curPos.z = matrix.GetTransZ();

...

Post by ProfessorKhaos // Feb 19, 2006, 4:44am

ProfessorKhaos
Total Posts: 622
pic
Cool stuff!


Thanks for the info earlier too Dele! :)


Hmmm.... all this scripting stuff gives me some ideas. I always wanted a version of "look at" that allowed you to rotate around an axis other than +z world coordinates... if you catch my meaning (a bit difficult to describe)


Also, this would be appropriate as "look at" doesn't work on the player side unless you record keyframes. With a script object I assume what holds true in modeller will also work in player.

Post by Délé // Feb 19, 2006, 5:53am

Délé
Total Posts: 1374
pic
Peter: Thanks. :) I think I understand. I'll try adapting my script to do that. Shouldn't be too hard if I understand correctly. :)


ProfessorKhaos: Thanks. :) I think I know what you're describing. Being able to choose which axis you would like to have look at the object? That sounds like a good idea. I wouldn't think that it would be too terribly difficult to make actually. Though I've said that before, lol. :rolleyes:


Have you tried the player "look at"? I think the player "look at" transfers to the model view.

Post by ProfessorKhaos // Feb 19, 2006, 6:17am

ProfessorKhaos
Total Posts: 622
pic
Hmmm... didn't know about that one yet. LOL. Still climbing that learning curve. Guess I know what I want to do just not how to do it yet :)


What I'd like to be able to do is have a part that rotates in elevation only with a "parent" part that rotates in azimuth only (i.e. like guns on a battleship)... only that the gun is mounted at an angle so that the azimuth axis isn't necessarily vertical. Pretty sure I've got an idea how to do it with python in TS6.6 but it should be even easier in TS7... and better yet it will be automatic that way.

Post by Délé // Feb 19, 2006, 7:00am

Délé
Total Posts: 1374
pic
ah, I see. Just restricting it to a specific axis. That sounds like a good idea. Perhaps a script where one could have complete control over every aspect of the "look at". A "Super Look At", lol. :)

Post by SiRender // Feb 19, 2006, 9:51am

SiRender
Total Posts: 38
[...]

The second main difference is a way how it interacts with objects.

Look e.g. at this code, how script command can obtain position of arbitrary object 'inName', without need to wire the x,y,z links in LE

[...]



Peter,


Is there a way for an object to discover whether an input value came from a wire or entered in the attribute property field manually?

Post by Norm // Feb 19, 2006, 8:55pm

Norm
Total Posts: 862
pic
This is quickly becoming a cool thread guys.

Post by Délé // Feb 20, 2006, 3:49am

Délé
Total Posts: 1374
pic
I just discovered something. Make sure the bridge is either set to "auto" or "off" when using my object follow script. Also it only seems to work properly in the player view.

Post by peterma // Feb 20, 2006, 11:04pm

peterma
Total Posts: 48
Peter,


Is there a way for an object to discover whether an input value came from a wire or entered in the attribute property field manually?


Most likely it is not possible to detect this for script objects for now. We can add the methods for this, but still, I'm curious what scenario do you have in mind because this is quite a special request.
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