View Full Version : Legacy Docs
carllooper
10-31-2004, 10:58 PM
I've lost my copy of the original (legacy) docs for LScript - which included really useful Appendices on extending LScript with C, and writing native Object Agents.
Can these docs be made available somewhere? The Appendices in these docs are still relevant.
Carl Looper
faulknermano
11-05-2004, 10:32 PM
i've upload a "subset" of the docs that i have.
http://www.geocities.com/lightwavespreaddepot/LSCRIPT_DOCS.zip
carllooper
11-06-2004, 03:46 AM
Invaluable.
my immense thanks,
Carl
An object agent re Appendix B of the legacy docs:
http://www.clandestine.com.au/Viewport.html
faulknermano
11-06-2004, 09:56 PM
Invaluable.
my immense thanks,
Carl
An object agent re Appendix B of the legacy docs:
http://www.clandestine.com.au/Viewport.html
****.
and my IMMENSE thanks to you.
if i could bother you with a question regarding this OA. veyr poor at this, but xfrm() "returns three vectors representing a 3x3 transformation from world coordinates to viewport coordinates for the specified viwport." is this related to rotation?
particularly, i have this script called PViewGN/MC and uses the lw scene file, along with the viewport info there (my crude way of bypassing lscript's inability to access what you have just now provided). because the lw scene is straightforward i was able to relate the needed info to get the right position and rotation of the viewport.
now i was just thinking of adjusting the code to make use of your OA. but i'm not sure how to use the 3x3 transformation data. if you could oblige with a explanation, i'd appreciate it. :) thanks.
carllooper
11-07-2004, 03:59 PM
xfrm() "returns three vectors representing a 3x3 transformation from world coordinates to viewport coordinates for the specified viwport." is this related to rotation?
Yes. You'll need some familiarity with transformation matrices. And I'll need to review my notes on the "handedness" of the viewport transforms - and get back to you.
But basically the 3x3 matrix represents the upper left submatrix of a full 4x4 transform matrix - ie. it represents the the rotational components (sines and cosines) of the full transform.
Until I get back to you - have a read of Ernies discussion, in the SDK, under "articles\w2s.html"
It talks about how one transforms points in world coordinates to points in camera (or "eye") coordinates. The viewport transform is basically the same thing except from world to viewport. Of course, if the camera is the current viewport there should be a one to one mapping between Ernie's discussion and the discussion I should be having.
Anyway, I'll get back to you with something a bit more comprehensible.
Carl
carllooper
11-08-2004, 04:01 AM
OK. The best way to describe this is to imagine the following.
We've created a Viewport object
viewport = Viewport();
And we've obtained the viewport's position (in world coords)
t = viewport.pos(1); // get pos of first viewport
And we've obtained the viewport's rotation matrix (world to viewport transform)
(r1,r2,r3) = viewport.xfrm(1); // get rotation matrix
Alright, we create two nulls A and B.
We position the first null, A at the postion of the viewport's origin (centre of projection) with:
SelectItem("A");
Position( t.x, t.y, t.z );
Next we are going to position the second null at z=1 (in viewport coords)
d = <0,0,1>;
e = d;
e.x = (d.x * r1.x) + ( d.y * r1.y) + (d.z * r1.z) + (1 * -t.x) ;
e.y = (d.x * r2.x) + ( d.y * r2.y) + (d.z * r2.z) + (1 * -t.y) ;
e.z = (d.x * r3.x) + ( d.y * r3.y) + (d.z * r3.z) + (1 * -t.z) ;
SelectItem("B");
Position(e.x, e.y, e.z);
If you imagine a line between null A and null B it will be a line going from the viewport's origin (centre of projection) through it's target point (whatever it is looking at) to Null B.
It's a good idea to try this experiment with actual nulls. Set up two viewports so that you can see what's going on in the first viewport through the second viewport.
Carl
carllooper
11-08-2004, 03:27 PM
I should add that if you are after something like "heading" and "pitch" you can use the rotation matrix to compute these terms as well. But keep in mind that these terms (hpb) usually represent the user's point of view rather than a script's point of view. A script takes the user terms (hpb) and computez the transform matrix. But pos() and xfrm() have already done this for you. That said, you may want to convert the transform matrix back into user understandable terms, or where other script components use hpb as parameters.
In the previous discussion we effectively created a vector from the viewport origin to the viewport target. You could use this vector to determine heading and pitch. The viewport's bank is always zero.
Here it is:
heading = -90 + deg( acos( (e.x - vt.x)/sqrt( ((e.x-vt.x)*(e.x-vt.x)) + ((e.z-vt.z)*(e.z-vt.z)) ) ) ) ;
pitch = -90 + deg( acos( (e.y - vt.y)/sqrt( ((e.y-vt.y)*(e.y-vt.y)) + ((e.z-vt.z)*(e.z-vt.z)) ) ) ) ;
Carl
carllooper
11-08-2004, 06:38 PM
The viewport's bank is always zero.
Except when the viewport represents a camera. whoops.
So:
bank = -90 + deg( acos( (e.x - vt.x)/sqrt( ((e.x-vt.x)*(e.y-vt.y)) + ((e.x-vt.x)*(e.z-vt.z)) ) ) ) ;
Also, in each one you'll need to ensure that if the sqrt() returns zero (as it can) that you just set the appropriate channel h,p or b to zero, rather than evaluating the entire expression, otherwise you'll get a division by zero error which will crash the system.
If you have any problems, let me know. I may have overlooked something else. But nothing that can't be fixed.
thanks again for the Lscript docs
Carl
carllooper@hotmail.com
faulknermano
11-08-2004, 10:28 PM
carl, you're welcome, and thanks for the explanations.. but on the first read i still have to digest it. :)
i'm saving it for reference and most likely will recode the scripts using this OA at the next available time i have. extracting info from the scene file is clunky on larger scenes and causes instability after many runs.
(wouldn't it be great to have viewport control too? :D )
GregMalick
11-09-2004, 12:10 PM
faulknermano,
I can't believe all the gems in the docs you provided.
You are indeed an LScript champion! :D
faulknermano
11-10-2004, 01:07 AM
actually i cant believe that these release notes arent accessible from the newtek site. much of the understanding i got in lscript comes from these release notes. the rewritten pdfs still dont come quite near to the info you get from bob's original notes.
GregMalick
11-10-2004, 02:15 AM
Yes,
That Q&A doc was phenomenal!
Everyone reading this thread should look at those docs you attached.
Thanks again for sharing with the community.
GregMalick
04-17-2005, 10:46 PM
Carl! :eek:
I was just re-reading this thread and have to ask -- could you write some dll's that would provide "similar" Viewport functionality to LScript in Modeler?
carllooper
04-18-2005, 02:05 AM
I'm not sure - there isn't any info in the current SDK docs - I'll have to look back in some older docs.
Carl
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.