PDA

View Full Version : Access to Dynamics Engine?



MiniFireDragon
11-14-2007, 04:05 PM
I was wondering if there is access to the dynamics engine in the SDK. I looked through it and didn't find anything. I am more interested in collision detection.

As an example, place two nulls and what ever objects the line between the nulls passes through, I want to access.

If we don't have access to it in the SDK, can someone point me to a collision detection how too.

Another good example of collision detection is in the plugin "groundthoseobjects" found in flay.

MiniFireDragon
11-16-2007, 04:12 PM
I take the silence as no, or the right people haven't looked at this thread yet.

adamredwoods
11-16-2007, 04:53 PM
Thre is no dynamics handler, so I don't believe there is access to dynamics that I know of.

but what is your end result? ie. distorting geometry of an object, stopping motion, etc.

You would create your plugin to match the handler class to what you want the result to be. Usually for particles I think the plugin goes into the displacement handler.

You can then place a function in _evaluate to check it against two nulls (that you select in xpanels) and compare the xyz position against intersecting a line (btw- line should maybe be a plane when dealing with 3d).

Hope that helps a little. Someone else may have more insight to dynamics.
//Adam

MiniFireDragon
11-16-2007, 05:29 PM
I am learning my way through lightwave plugin building. One of the plugins I am writing is an object altering plugin. And I only really want to effect the polygon(s) of the object(s) that the line of 2 nulls passes through.

adamredwoods
11-18-2007, 08:14 PM
Then you would want to create a Displacement Handler plugin. This plugin is then attached to the object you want to be effected.

The displacement handler, in its evaluate function pointer, will run through each point in the mesh object.


typedef struct st_LWDisplacementAccess {
LWDVector oPos;
LWDVector source;
LWPntID point;
LWMeshInfo *info;
} LWDisplacementAccess;

You can see how with LWDisplacementAccess, you can obtain a point's position, point's ID, get mesh info, and figure out any additional information you need for processing.

The inertia.c example in the SDK is a good example to start your plugin.

MiniFireDragon
11-18-2007, 09:45 PM
Hmmm, Interesting. I will read into it more. I thought the displacement was merely for moving the points of an object. I just am not sure how to go about finding objects in the line.

Or would I have to just check every polygon to see if a point on it's plane intersects the line?

adamredwoods
11-19-2007, 01:39 PM
To get info from other objects, you need the iteminfo global function, and the ID of the object(s) you want to check. This usually has to be set by a user interface, or a settag function if you want to be more streamlined. I suggest starting off with an xpanel interface to set the two items you want to compare.

ItemInfo can be accessed anywhere in any plugin (thus called a global function).

iteminfo->param( ..... );

I believe is the function to get LWIP_POSITION, LWIP_ROTATION, LWIP_W_POSITION, etc..

Summary of plugin you want:
You would create a displacement plugin that took two objectIDs, grabbed the world position (through iteminfo), and created a plane with the two points (google geometry websites for the math). If the displacement object's points passed through the plane (check for + or - offsets in case the user wants to have a boundary falloff) then modify that point to whatever it needs to do.

Good luck! :)

MiniFireDragon
11-20-2007, 03:13 PM
Yes, I have written a plugin that goes through every object in the scene looking for a specific name. I will probably (to make it quicker) require the user to select the objects they want effected by the plugin. That way they don't need to use a drop down box since the selection array will be filled.

Is there a way to get the bounding box information instead of the polygonal mesh? That way it's only 4 faces I need to look at vs how ever many per model.

As for the math part, there is a rather excellent book called:

3D Math Primer for Graphics and Game Developement by Dunn & Parberry.

I highly recommend this book as not only do they cover Matrice Math but also supply basic functions in C++ to do the math.

They also cover how to test for collisions and other things.

adamredwoods
11-20-2007, 05:50 PM
Bounding Box: Hmmm... i couldn't find one. I know there is one in LScript.

Anyone else?

evenflcw
11-20-2007, 08:07 PM
No, there is no bounding box to be fetched from anywhere. If you want it, you'll have to fetch it yourself (ie iterate through all points).

If you want to alter a mesh (ie not just displace points) I think you need to use the meshdataedit class which works in Layout since LW8.x something.

Dodgy
11-21-2007, 03:19 AM
You can get the bounding box in modeler like this:

http://www.dodgy.ghostoutpost.com/Lscript/Source/Modeler_Commands.htm#boundingbox

In layout by this:

http://www.dodgy.ghostoutpost.com/Lscript/Source/Meshes.htm#position

evenflcw
11-21-2007, 04:21 AM
Ah yes, I remember now how I in lscript had to determine what layer I had selected (item id->layer index) by either parsing the layers name or by searching for a match with the layername() function depending on whether the layer had a user assigned name or not, just to get the correct pointcount. Very quirky stuff.

I wonder if the lscript functions are calculating the bbox or just grabbing the value from somewhere.

MiniFireDragon
11-21-2007, 10:04 PM
Thanks Dodgy, but I am doing a .p plugin. I will simply iterate through all points and build a box and then save the data for alterations. Unless you don't think iterating through a million poly's will slow the PC down.

adamredwoods
11-24-2007, 05:04 PM
If you have the plugin do the crunching in the _create function, and store the bounding box in the instance data, I don't think it should cause too much interruption in someone's day.

Also do a search on the Yahoo message group to see if they have any solutions.