LE / Scripting - Related Info

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 / Scripting - Related Info // Feature suggestions

1  |  

Post by Electric Jim // May 29, 2008, 2:34am

Electric Jim
Total Posts: 98
I've been looking into the possibility of using the Link Editor (or, as a secondary option, scripting) to construct a series of constraints, i.e., configurable relationships that force one or more "target" objects to maintain some defined relationship relative to one or more "control" objects. For example, force one object's rotation around the X-axis to be equal to twice another object's rotation around the Z-axis. Or force one object's Z-axis location to always be equal to another object's Y-axis location plus three times its rotation (in radians) around the X-axis. (Or whatever...)


To do this, I would need a basic understanding of the terms and relationships tS uses for its implementation of 3D, and I can't seem to find it. (I have a decent understanding of linear algebra & vector math and sufficient programming experience, but I need to know the basics of tS's specific implementation.) The Developer's Guide, to which I found a link in the forums, is more -- I guess one would say "philosophical" -- at the beginning, then more detailed about specific function calls and so forth at the end. But it never seems to present a basic description of the terms and methods tS uses when implementing 3D. I just need basic descriptive or explanatory information along the lines of...


- How are the rows or columns of the ObjMatrix defined? (My impression is that it holds the location, rotation, & scale data for an object. But assuming that's right, how is that data arranged/formatted in the matrix, so I know which data to strip out, manipulate and put back in -- all via matrix & vector algebra, of course -- to achieve the result I want?)

- Ditto for the WldMatrix. (What is the WldMatrix, anyway? How is it different from the ObjMatrix?)

- A description of the basic or fundamental matrix/vector/scalar manipulation LE objects that would let me know how to access, modify, & replace the appropriate matrix contents. (I've tried "hit & miss" playing with the Normal Transform & Euler Transform objects, but can't seem to get consistent, understandable, & predictable results. So what is the basic definition of these objects, so I can know which one to use when, and how?)

- A complete list of the data types involved, and instructions on how to convert between them so that connectors which I thought should be connectable to each other actually can be connected ? (Looking at the data types of various objects' input & output connectors in the LE, I see a plethora of data types, some of which seem like they should be compatible, but which I can't hook up to each other. I figure there must be some sort of conversion or type-casting blocks that I can't find, which could be placed between such connections to make them compatible. ...Or else things are even stranger than I thought.)


Does a document with this sort of information, which would give me enough to get started producing simple but functionally useful results on my own, exist? (I'm thinking it wouldn't need to be very long, probably much less than ten pages' worth of data.)

Post by trueBlue // May 29, 2008, 2:43am

trueBlue
Total Posts: 1761
pic
It may be helpful to read the script within the Mesh Cube Example located in the Objects - Script Objects. Glen did a great job commented the code.
Also this may be heplful too:
http://forums1.caligari.com/truespace/showthread.php?t=5014

Post by frootee // May 29, 2008, 5:13am

frootee
Total Posts: 2667
pic
Hi Jim.


This may also be of help. It's a 'Getting Started with Scripting and the LE' powerpoint presentation.


http://forums1.caligari.com/truespace/showthread.php?t=3856

Post by Norm // May 29, 2008, 6:22am

Norm
Total Posts: 862
pic
Jim, we are currently working on the trueSpace7.6 SDK. The SDK will answer lots of your questions once it is released. Until then, as mentioned, the existing script objects are great source of insight into some areas you are interested in. A matrix is a matrix. If you search the internet for matrix or matrix math, you get the "graph" description of translation, rotation, scale and shear values. If you "expand" the matrix in the LE, check out the expanded tab, which shows "shear" values as well. You can access these values through scripting. This is what many of the examples in the libraries do.

Post by Electric Jim // May 29, 2008, 6:27am

Electric Jim
Total Posts: 98
Thanks for the info, guys. I'll look at the suggested resources. (And look forward to the tS7.6 SDK...!) :)

Post by Délé // May 29, 2008, 7:09am

Délé
Total Posts: 1374
pic
You are right, the matrix inputs and outputs hold the objects translation (tx, ty, tz), rotation (yaw, pitch, roll), and scale (sx, sy, sz). If you right click on any of the matrix inputs or outputs on a node and select "expand", it will expand that matrix and you can link data together with other objects/scripts.

Here is a simple tutorial that shows how to create simple behaviors between objects:
http://forums1.caligari.com/truespace/showthread.php?t=2928

Here's a simple breakdown of matrices:
Matrix - This is the main input matrix for the object to control the objects translation, rotation and scale.
OwnerMatrix - This is kind of like a sub input for the control of the object. When you encapsulate (group) objects together, the main transform for the group gets linked into each encapsulated objects ObjMatrix allowing for a heirachy where all of the sub objects move with the main group object. This is used mainly for encapsulating objects together, but it basically allows one object to control another.
WldMatrix - This is the main output matrix for the object. You can use this to link together with other objects/scripts.
ObjMatrix - I haven't really used this, but I believe that this is the output equivalant of the OwnerMatrix input. When the object is encapsulated, this outputs the objects translation, rotation, and scale in relation to the encapsulations axis. I'm not 100% sure on this, but I think that's what it does.

To collect or change matrix values from script using Jscript it would work something like this:

// the object we'll be using is named "cube"

// collect matrix from cube
CubeMatrix = Node.Value(Space.CurrentScene() + "/Cube", "Matrix");

// set the matrix for the cube
Node.Value(Space.CurrentScene() + "/Cube", "Matrix") = CubeMatrix;

// collect specific information from the matrix we already collected
CubeTransX = CubeMatrix.GetTransX();
CubeTransY = CubeMatrix.GetTransY();
CubeTransZ = CubeMatrix.GetTransZ();
CubeYaw = CubeMatrix.GetYaw();
CubePitch = CubeMatrix.GetPitch();
CubeRoll = CubeMatrix.GetRoll();
CubeScaleX = CubeMatrix.GetScaleX();
CubeScaleY = CubeMatrix.GetScaleY();
CubeScaleZ = CubeMatrix.GetScaleZ();

// set specific matrix values
CubeMatrix.SetTransX(5);
CubeMatrix.SetTransY(5);
CubeMatrix.SetTransZ(5);
CubeMatrix.SetYaw(45);
CubeMatrix.SetPitch(45);
CubeMatrix.SetRoll(45);
CubeMatrix.SetScaleX(2);
CubeMatrix.SetScaleY(2);
CubeMatrix.SetScaleZ(2);

hth

Post by Electric Jim // May 29, 2008, 3:49pm

Electric Jim
Total Posts: 98
Thanks, Délé! ...And, again, to all you guys (and to Clintonman, whose work clearly surpasses what I'd make on my own, but from whose efforts I may be able to learn). Yet more indications of what users of so many other 3D programs are coming to learn: That perhaps the greatest strengths of trueSpace are its helpful community and Caligari's support team. :)
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