Should've put my Advanced Orbit Script here

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.

Should've put my Advanced Orbit Script here // Scriptorium

1  |  

Post by robert // Sep 23, 2008, 4:19pm

robert
Total Posts: 609
pic
It's over here http://forums1.caligari.com/truespace/showthread.php?t=6701.


Reattached it below.

Post by robert // Sep 27, 2008, 5:36am

robert
Total Posts: 609
pic
Here's the actual script for those who want to see the code without downloading the object.

// Modified version of orbit script to have more control, props to Norm Fortier for the original

// Author: Robert D. Plante


// OnComputeOutputs

// Called to compute values of all output connectors

function OnComputeOutputs(params)

{

// Input parameters

// Get the time from PhysEngine

var inTime = params.ConValue('inTime');

// Get the desired number of days

var inDays = params.ConValue('inDays');

// Get the desired number of years

var inYears = params.ConValue('inYears');

// Get the desired distance from object

var inDist = params.ConValue('inDist');

// Get the desired size of object

var inSize = params.ConValue('inSize');

// Get the desired tilt of object

var inTilt = params.ConValue('inTilt');

// Get the desired starting angle

var inAngle = params.ConValue('inAngle');

// Get the desired starting rotation

var inRot = params.ConValue('inRot');


// Create matrix data

var matrix = System.CreateDO('Math Package/Matrix Float Data');


// Perform calculations

// Scale time and convert to be useful, the long number is 2pi to 30 decimal places

var modTime = ((inTime * inYears) / 60) * 6.283185307179586476925286766559;

// Modify inAngle to be in radians, long number is pi to 30 decimal places

var modAngle = (inAngle * 3.1415926535897932384626433832795) / 180;

// Set X values for orbit

matrix.SetTransX(Math.cos(modTime + modAngle) * inDist);

// Set Y values for orbit

matrix.SetTransY(Math.sin(modTime + modAngle) * inDist);

// Set Tilt

matrix.SetPitch(inTilt);

// Set Yaw, the long number is 180/pi to 30 decimal places

matrix.SetYaw((modTime * (inDays - 1) * 57.295779513082320876798154814105) + inRot);

// Scale planet accordingly

matrix.SetScaleX(inSize);

matrix.SetScaleY(inSize);

matrix.SetScaleZ(inSize);


// Define and output the matrix data

params.ConValue('oMatrix') = matrix;

}

Post by robert // Oct 11, 2008, 3:23pm

robert
Total Posts: 609
pic
Made a slightly different version with less settings that takes the objects position along the selected axis and from there calculates the orbit. In the video (http://8uglma.bay.livefilestore.com/y1p9zwiVEkamKA7b_HCwzkTbpvShqqkCj8__ROQSaESiABo9zc-NhRB4elQxxUXBZuvNerZhNNOJU4BsLosiM0oPQ/recording.avi?download) all the objects use the same settings and are at different locations only because they have different distances from the center of the scene.


There are two main aspects, Default and Choose/Link.


The Default aspect allows for the changing of all settings.:)


The Choose/Link aspect had two buttons: the first button will be for selecting the object, and the second one will automatically hook this thing up with the Timer object whose name you specify.:cool:


The Timer you use should have both a Time output and a Control Out output.;)


What's funny is the Control In and Control Out things have a space in front of their names while every other input/output doesn't. e.g " Control In" is what it is as opposed to "Control In" see how there's the space? Wonder why it's like that.:confused:
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2020. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn