Physics simulator: Global variable storage?

You’re doing bad, bad, stuff! andnbsp;:) andnbsp;Having a script running while selecting faces in the main window… andnbsp;???

Richard

I don’t know how useful this might be, but here goes…

I wrote a level exporter for DarkBasic once that required both active local and global variables in the 3DC environment as well as a way to make them persistent.

This is what I did:

Each object in 3DC is in a group of some form, right? So I used the group names to give the objects a andquot;friendly nameandquot;, and used the actual object name as a delimited variable string.

For instance, you have a sphere in the scene. You name its group andquot;Ballandquot;, and you rename the object within the group to something like andquot;varname0;varname1;varname2;varname3andquot;.

Then to any script that needs those specific variables, you would pass the object’s (not group) name as a parameter string.

Use the Split() function with andquot;;andquot; as the delimiter and spool those values out into placeholder variables in the script…so you’re basically splitting the parameter string, assigning these values to a scriptside variable array, and then using those indices for the variable data you require.

For global data, I use a single object at the scene root level. I name its group Globals and for the object name, I assign an appropriate parameter string. Because you know that the Globals object always exists and its name never changes, you can parse its variable string in any other script.

Anyway, that was the basic approach. I also wrote a frontend to make the parameter strings easier to assign, so all I had to do was select an object and run the SetProperties plugin I wrote, then tick off checkboxes or optionbuttons before clicking OK/Cancel to update the object’s parameter string.

I hope this helps. I have to rewrite the whole thing because the level exporter code (and a lot of other things) were lost when my old 200mhz died.

-Mel

[BLOCKQUOTE class=’ip-ubbcode-quote’][font size=’-1′]quote:[/font][HR]You’re doing bad, bad, stuff! andnbsp; andnbsp;Having a script running while selecting faces in the main window… andnbsp;[HR][/BLOCKQUOTE]

Heh… andnbsp;Is there a better way? I am wide open for ideas! Essentially I would like to do the following:

[UL TYPE=SQUARE]
[LI]MsgBox andquot;Select object/face #1 for surface collision detection. Press OK when done or Cancel when finished.andquot;
[LI]-] Select an object
[LI]-] Click OK
[LI]MsgBox andquot;Select object/face #2 for surface collision detection. Press OK when done or Cancel when finished.andquot;
[LI]-] Select an object
[LI]-] Click OK
[LI]MsgBox andquot;Select object/face #3 for surface collision detection. Press OK when done or Cancel when finished.andquot;
[LI]-] Click Cancel
[LI]MsgBox andquot;Select object #1 for initial trajectory. Press OK when done or Cancel when finished.andquot;
[LI]-] Select an object
[LI]-] Click OK
[LI] InputBox andquot;Enter object #1 velocity vector (vX, vY, vZ)andquot; …
[LI] etc.
[LI]MsgBox andquot;Select object #2 for initial trajectory. Press OK when done or Cancel when finished.andquot;
[LI]-] Select an object
[LI]-] Click Cancel
[LI] etc.
[/UL]

So, an interactive selection process is pretty important. Currently, I have to generate a textual parameter file by hand.

[BLOCKQUOTE class=’ip-ubbcode-quote’][font size=’-1′]quote:[/font][HR]
Each object in 3DC is in a group of some form, right? So I used the group names to give the objects a andquot;friendly nameandquot;, and used the actual object name as a delimited variable string.[HR][/BLOCKQUOTE]

Hmmm… A very interesting idea! Apart from the likely string length limitation and temporary clutter with oddly-named objects, I think this sounds like a reasonable approach. The global object will help solve a few problems.

Thanks to everyone for your help on this,
Cal.

You must be logged in to reply in this thread.