LE mini-tut

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.

LE mini-tut // Roundtable

1  |  

Post by Délé // May 15, 2007, 3:17pm

Délé
Total Posts: 1374
pic
I thought I'd post a little mini-tut here for those people wanting to explore the Link Editor but don't know where to start. We'll make a simple interaction between two objects. One object will mirror the others location.


First download the script object posted below. It's just a simple script that takes 3 numbers and multiplies them by -1 to make positive numbers negative and negative numbers positive. Once you have it downloaded locate a library in the stack that you would like to put it in. Right click in your desired library and select import. Locate the script object you downloaded in the browser window that pops up and load it.


6039


6043


Now the object should be in your library. Click and drag it into the LE (Link Editor) window. It should show up as a 2d node in the Link Editor. Now click on the cube primitive icon in the toolbar at the bottom and create two cube primitives in the workspace.


6041


Find the nodes for the cubes in the LE and click the "Exp" tab at the top of their nodes. Then drag the title bars on the top of the nodes to position the script node in-between the cube nodes as shown in the image below.


6040


Now right click where it says "WldMatrix" on the first cube node and select "expand". This is the matrix output for that object. You can tell that it's an output because it has a blue triangle at the edge. Blue triangles are outputs, red triangles are inputs.


A matrix is a grouping of object information. It contains the X, Y, and Z location, rotation, and scale of an object. When you expand it, you expose each of these individual properties. On the expanded matrix, tx, ty, and tz are the X, Y, and Z location coordinates for that object. The yaw, pitch, and roll are of course the rotation for the object. And the sx, sy, and sz are the X, Y, and Z scale parameters of the object.


Once you've expanded the "WldMatrix" output for the first cube, do the same to expand the "Matrix" input for the second cube (red triangle next to it).


6042

Post by Délé // May 15, 2007, 3:19pm

Délé
Total Posts: 1374
pic
Now click and drag the "tx" from the expanded "WldMatrix" of the first cube as shown below. Drag it into the "A input" on the script and let go. A link will be made. Continue on by linking the "ty" output into the "B input" and the "tz" output into the "C input".


Now the script is taking those location coordinates and multiplying each of them by -1 so as to reverse them.


6045


Now drag the "A output" from the script into the "tx" input on the second cube. Continue on by dragging the "B output" into the "ty" and the "C output" into the "tz".


6044


Now you should have everything linked up. It should look like below. Each of the first objects location coordinates are being linked into the script which is multiplying each of them by -1. Then those negative outputs are getting linked back into the second cube's Matrix "input".


So now if you move the first cube, the second cube will mirror the first cubes location coordinates. Try it out. Move the first cube around. You might notice that you can't move the second cube with the widget in the workspace. This is because when you expand a matrix input, that overrides the workspace widget. The script now has control over the second cube.


6046

Post by weaveribm // May 15, 2007, 11:46pm

weaveribm
Total Posts: 592
Thanks Dele!

Does this 'one object depends on another object for its location' mean in theory that a flock of bird objects (starlings like earthlings) could alter their individual positions based on the leader's position and also the position of the birds close by in flight-formation - to adjust each bird's position in the flock not to bump into other birds or trees? The leader bird has one more flocking rule yes :)

Peter

Post by splinters // May 16, 2007, 12:16am

splinters
Total Posts: 4148
pic
Dele, three years I have been a Beta tester and I never really knew how to do this...always thought of the LE as a dark place to avoid...:D


Many thanks for this-I will try it when I get home. You are a great help, even to an 'old timer' like me...;)

Post by Steinie // May 16, 2007, 12:47am

Steinie
Total Posts: 3667
pic
Dele, You made this look interesting and until now I was not interested. So thats a start! Thanks I will try it out.

Post by Tiles // May 16, 2007, 1:04am

Tiles
Total Posts: 1037
pic
Yup, surely comes in handy once i need to touch the LE :)

Post by Délé // May 16, 2007, 3:25am

Délé
Total Posts: 1374
pic
Thanks guys. I hope it helps get more people started. The LE is still a largely untapped resource and can do a lot of cool stuff. :)


Another thing to try:


In the mini-tut we shared object coordinates between two objects to create an interaction between them. We can also share rotation and scale parameters. Try linking the location of the first object directly into the scale of the second. Now the location of the first object will affect the scale of the second. So you can see, there are many ways to create relationships between objects. You can have one objects location affect another objects scale...one objects rotation affect another's location, etc. There are many possibilities.


You can even do math calculations to create your interactions without any scripting knowledge. Open the Library Browser. In the Library Browser window locate and double click the "Math - Operations" library. The library will open in the stack.


6060


Now in this Math - Operations library, there are two bricks in particular that I like. Drag the "BinaryOp" and "UnaryOp" into the LE (shown below). With these two nodes you can perform math calculations without any scripting knowledge. The BinaryOp will perform a mathematical operation on 2 numbers. So you can type in two numbers in the A and B inputs. Or, even better, you can LINK two numbers into the A and B inputs. So you can for instance link the X and Y location coordinates of an object into the BinaryOp and add them together, then link the output into another objects location, rotation, or scale. The UnaryOp performs a calculation on a single number.


The BinaryOP can perform: +, -, *, /, Min, Max

The UnaryOp can perform: cos, sin, sqrt


Just change the Operand field to the operation that you want to perform. With these math bricks you can create all kinds of interaction without knowing a single bit of script. :)


6059


To see the Math bricks in action, check out the free video HERE (http://www.caligari.com/products/trueSpace/ts5/Courses/newprocanim.asp?Cate=Training&SubCate=Master) in the procedural animation course. That will give you an example of how these can be used. :)

Post by Délé // May 16, 2007, 3:30am

Délé
Total Posts: 1374
pic
Does this 'one object depends on another object for its location' mean in theory that a flock of bird objects (starlings like earthlings) could alter their individual positions based on the leader's position and also the position of the birds close by in flight-formation - to adjust each bird's position in the flock not to bump into other birds or trees? The leader bird has one more flocking rule yes


That's exactly the kind of thing you can do in the LE. :) It would take a bit of math to get it to work the way you want, but possible, yes. You can also mix and match Location, Rotation, and Scale. So one objects scale can affect the rotation of another. Many possibilities. :D

Post by weaveribm // May 16, 2007, 5:00am

weaveribm
Total Posts: 592
So one objects scale can affect the rotation of another

For a character running away from big bully blokes. You must turn before running and the bigger the enemy the faster the turn :)

Peter

Post by zwilson // May 16, 2007, 8:27am

zwilson
Total Posts: 35
Great tutorial very easy to follow even for a link editor newbie like me.

Post by Burisman // May 16, 2007, 1:00pm

Burisman
Total Posts: 128
pic
Dele, you make this look fun and easy, thanks for guiding my first steps through the LE :p Crisp and clear!


One small question though, the script you started with did not fall from the sky; I assume that you wrote it in an external editor. How do you get TS to recognize it as a building block in the LE?

Post by Délé // May 16, 2007, 1:37pm

Délé
Total Posts: 1374
pic
Thanks guys. Glad to hear it is easy enough to follow. :)

Burisman: Actually it was all done in tS. If you open the library browser and open the "System - Scripts" library, there are blank script nodes. You can just drag a "Jscript object", "Jscript command", "VBscript object", or "VBscript command" into the LE. I often use the Jscript object myself.

Then you can click on the orange triangle on the script node to enter it. There you can define the "Attributes" (inputs and outputs). And if you click the "Methods" tab in the script editor you can write the actual script. Then just select the big orange triangle on the window to move back out.

If you right click on the title bar of a node in LE it will open a toolbar that will let you customize the node with buttons, text fields, sliders, and such. Then you can right click on the title bar again when you're done customizing the node to save it, or cancel the changes.

If you're looking at getting into scripting you might want to check out the Jscript and VBscript macro recorders (bottom toolbar, third from the far right). These will let you record your actions. Then you can go into the macro node it creates to see how the script is written. This is a great way to learn how to write Jscript or VBscript in tS.

So, there are really a lot of tools to help with and do scripting right inside of tS. :)

If you enter the node for the reverse script I posted it will take you inside the script and you'll see the script editor window. (like below)

6092

Post by W!ZARD // May 17, 2007, 3:29am

W!ZARD
Total Posts: 2603
pic
Very cool Délé - thank you for this. I figured that this was the type of thing the LE was capable of but your simple and clear explaination helps a great deal. Thanks again! :D

Post by frootee // Aug 13, 2007, 12:46pm

frootee
Total Posts: 2667
pic
I have a question Dele.

What's the difference between the Matrix, ObjMatrix, and WldMatrix connectors? When would you use one type of matrix over another?


Thanks,

Froo


Now click and drag the "tx" from the expanded "WldMatrix" of the first cube as shown below. Drag it into the "A input" on the script and let go. A link will be made. Continue on by linking the "ty" output into the "B input" and the "tz" output into the "C input".


Now the script is taking those location coordinates and multiplying each of them by -1 so as to reverse them.


6045


Now drag the "A output" from the script into the "tx" input on the second cube. Continue on by dragging the "B output" into the "ty" and the "C output" into the "tz".


6044


Now you should have everything linked up. It should look like below. Each of the first objects location coordinates are being linked into the script which is multiplying each of them by -1. Then those negative outputs are getting linked back into the second cube's Matrix "input".


So now if you move the first cube, the second cube will mirror the first cubes location coordinates. Try it out. Move the first cube around. You might notice that you can't move the second cube with the widget in the workspace. This is because when you expand a matrix input, that overrides the workspace widget. The script now has control over the second cube.


6046

Post by Délé // Aug 13, 2007, 2:52pm

Délé
Total Posts: 1374
pic
If you use the "encapsulate in 3d" tool to encapsulate a couple of objects and go inside, you will see that the "wld matrix" of the transform node is linked into the "owner matrix" of the objects. This makes it so when you have the entire group selected (outer node) the sub-objects will all move, rotate, and scale together. You can still use their "matrix" inputs to adjust where each object is within the encapsulation or "group".

Hope that makes sense. So the "matrix" is kind of like the objects regular individual input. The "owner matrix" is used to make that object a sub-object of a group (or to have another object "own" it). The "wld matrix" is the final output for that object. I'm not sure what use the "obj matrix" has to be honest. Never used it.

Post by frootee // Aug 13, 2007, 4:33pm

frootee
Total Posts: 2667
pic
Ah I see. Thanks!


So, if we have 3 cubes encapsulated in 3d, we have:


World matrix: output of transform node.

Connects to: Input Owner Matrix of each 3D Encapsulated object


so when 3d group moves, transform data gets fed to transform node.


Transform node pumps data from its World matrix output to Owner matrix inputs of each encapsed object, so they rotate/move/scale as a group, identically. The Owner of each of these encapsed objects is the Transform. The transform represents the objects' World.


And the Matrix input is used for transform of each subobject.


Thanks@

Froo


If you use the "encapsulate in 3d" tool to encapsulate a couple of objects and go inside, you will see that the "wld matrix" of the transform node is linked into the "owner matrix" of the objects. This makes it so when you have the entire group selected (outer node) the sub-objects will all move, rotate, and scale together. You can still use their "matrix" inputs to adjust where each object is within the encapsulation or "group".


Hope that makes sense. So the "matrix" is kind of like the objects regular individual input. The "owner matrix" is used to make that object a sub-object of a group (or to have another object "own" it). The "wld matrix" is the final output for that object. I'm not sure what use the "obj matrix" has to be honest. Never used it.

Post by 3dvisuals dude // Aug 13, 2007, 9:54pm

3dvisuals dude
Total Posts: 1703
pic
http://forums1.caligari.com/truespace/showthread.php?t=387 (http://forums1.caligari.com/truespace/showthread.php?t=387)

The Owner Matrix has you Neo.

Post by 3dvisuals dude // Aug 13, 2007, 10:21pm

3dvisuals dude
Total Posts: 1703
pic
When you expand a matrix input as you did in your first example in this thread the control of the second "owned" object overrides the workspace widget as you indicated.

Ok... what happens then in a case of the owner object and the owned object moving parallel in a given direction freely under constant velocity, but the owned object running parallel to it encounters an obstacle in that path which the owner object does not? Ie: does it override collision or gravity as well?

Also as a side note, this script you wrote above is almost identical to the method I whipped up in my head a while ago (not that I know yet how to do it in the LE though) to control avatars in elevators by utilizing the elevator as the owner object in an animation and the avatar as the owned object, thus bypassing gravity altogether by maintaining the vertical relationship of the avatar in relation only to the elevator cab's vertical position.

In addition to that, that same collision bypass concept / method is the basis, once combined with ProfessorKhaos's External Data File Reader Script (not sure of exact name of that script), for feeding externally defined paths to objects via stream input, enabling goodies like "flying carpets" in shared space which could actually work.:D

I love this stuff...

I once had an Architectural Design teacher who said to me in relation to research, "The more you dig, the more you realize why you need to dig."

This definitely applies to the LE, because the more I dig the more sheer power becomes visible to me for manipulation and control in unprecedented ways, especially in the realm of interactive first person activities.

Makes one feel like we're living in the days of Tesla and Edison again.http://www.smileyskit.com/general-misc-smileys_files/idea1.gif

- 3dvisuals dude

Post by Délé // Jul 29, 2008, 10:28am

Délé
Total Posts: 1374
pic
Just bumping this for new users interested in trying something simple in the LE. ;)

Post by sj41 // Jul 29, 2008, 6:10pm

sj41
Total Posts: 31
Thanks -- tS is becoming more and more interesting...
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2021. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn