09/03/2015 Still Working
Sorry about no updates lately. I've been quite busy. I have, however, included a bunch of the joint functions in the dll. If I have some free time this weekend, I'll get the updated dll posted with a few demos.
I'm actually coding right now and took a break to mention something in case anyone is messing with the source code for Tokamak. There are lots of helper functions in Tokamak. I haven't discovered any decent documentation so finding them and understanding how to use them and in what situations, is a daunting task to me.
I came upon a matrix function RotateXYZ() that allows you to supply angles and get back a matrix object. I originally was mad because I spent so many hours building my own matrix and quaternion functions that would work between DBC and Tokamak, and here's a rotation function that takes angles directly. The function does work, but only for rotations specifically in the X,Y and Z order. So I was happy that my original efforts weren't in vain, and still a little angry because there is no documentation. I think Tokamak would've been much more successful if there had been some detailed use instructions and indepth function descriptions. End of rant.
No new release yet, but some news. I'm including some of the tokamak material functions. It seemed logical to add this to the dbc functions that add geometry to bodies since it is the geometry object that is set to a material. And since you can have multiple geometries assigned to a single body, it makes sense that all of these collision areas may be different materials.
I'm also including stand alone material functions that will assign all of the geometry of a body to a particular material.
FYI, a material is what something is made up of (wood, rubber, steel, etc.). When you create a material and then apply it to a body, you influence how the body will respond to friction and its bounciness.
I'm looking at joints and terrain collision. I'm not exactly sure when I'll add those but I'm trying to understand them.
Removed Download. There are a couple of problems with the DLL- it works sometimes, other times it doesn't... It seems there is something wrong with the way I compiled it. I think I have it fixed, but I have to run more tests.
It has been hit and miss with DBC being able to load in the DLL. I think the same problem was occurring with the Coldet DLL I compiled a couple years back. Again, I think I have the problem fixed. When I've run some more tests, I'll repost it.
I just noticed a typo in one of the functions:
The DLL call in the function should use abody and not rbody:
Change call dll tokdll,"tokSetAnimatedSphereGeom",rbody,diam#
To call dll tokdll,"tokSetAnimatedSphereGeom",abody,diam#
Make sure you get rid of any previous downloads and replace them with this one. The last one was buggy and also had incorrect rotation calculations.
I've made a DBC library file (.dba) for use as an #INCLUDE. There's a new download attached to this post (Dbc tokamak library ver .04) There are currently about 25 functions. Mostly, they are setup functions.
I've included 3 demos that show the base object geometry used in Tokamak:
* Falling Boxes
* Falling Spheres
* Falling Capules
You'll need to change your setup.ini file. The line that reads windowmode=0 should be windowmode=1 . This will allow a function to automatically size the demos based on your desktop. If you don't want to do this, then comment out the function get_desktop_size(1,1) at the beginning of the demos and type in whatever set display mode you want.
Have a look at the demos, pull them apart, and maybe make some of your own. Usage may be slightly advanced because there is some reliance on memblocks. If you don't understand something, ask and maybe I can explain it. I'll keep plugging away and try to make available more of tokamaks functions. There's things like breakable objects, constraints, joints, collision, terrain collision, motors... a lot of it I don't quite understand yet, but I'll keep playing.
I've been working on rotating an object (what tokamak calls an animated body) in DBC, sending that to Tokamak, and reading back what Tokamak thinks the rotations are. This has been a big headache as I thought everything was good after having gotten the rigid bodies to rotate correctly. DBC uses Euler angles which depending on how they are derived, can have many different values for the same orientation. I think I have it now for animated bodies. When a Y rotation is 90 degrees, the return from Tokamak is weird. So now any 90 degree rotation becomes 90.1 and that seems to do the trick. A little inaccurate, but only at 90 degree angles (that includes 270). I haven't update the download yet, so the old demo with the bad rotation is still in there. I want to put together something with both rigid bodies reacting to controlled animated bodies, but I've only now think I have the rotations working (that's been said before!).
I'll post something as soon as it's ready.
I'm attaching the first demo to this. It's a bunch of falling cubes based on one of the original Tokamak demos. I think it's so cool that it works in DBC, I've run it about a thousand times!
Make sure you extract both the .DBA file and the .DLL to the same directory. Run the .DBA file. Press the SPACE key to restart the sim with slightly different positional offsets of the cubes from one another. If you have questions, please ask.
The code isn't real neat and I haven't made a nice, clean, DBC function library yet for easier use, but you can get the idea if you go through the code. As time permits, I'll create a DBC function #include file, hopefully a couple more demos, and an expansion to include the joints, ragdoll stuff, and collision available in the engine.
The rotations gave me some trouble, but I think they are ok. I'm not 100% sure as I haven't created anything more complicated than the falling cubes.
Completed translation of Quaternions to Euler angles. Still not sure of rotation order. Need to come up with a method o test rotations. Probably have to force a rotation in Tokamak and see if it matches DB.
To do before demo:
* also translate Tokamak Matrix rotations to Euler
* test rotation order
Should have a little time tonight to work on this. Project by no means stopped.
Back on track. I recompiled the static library and it seems to be working now and links properly to the DLL. I've got about 13 or 14 functions in the DLL and it should be enough to put together a demo. Things to work out before the demo:
* Timing to advance the simulation properly
* Management of all of the physics bodies (DBC arrays?)
* Passing the vectors back and forth - the data in Tokamak is stored in transformation matrices and/or quaternions. DBC uses euler angles. I also don't know the rotation order of Tokamak Matrices, so converting the transforms to something DBC can use is going to be tricky and trial and error.
* Setting up a DBC function library instead of direct calls to the DLL. Maybe not necessary, I'm not sure if calling the DLL functions from within DBC functions is less efficient (though easier to use)
Linker errors I can't quite resolve. I might have to compile the Tokamak library from scratch and start from there. As for right now, I can't get anything to work. The simulator object itself for some weird reason is undefined.
Things are progressing. I've made calls to the engine and no errors. I haven't pulled anything back to DBC yet. I'm aiming to have a basic framework and possibly an example sometime within the next 5 days.
Jan. 30 2015
I was going through a bunch of old DLL projects I had started or thought about at one time or another, and came upon some notes I had for Tokamak physics. Would anyone be interested in this if I were to try and knock something together for DBC? No guarantees, but it seems like a project that might be fun to mess around with a bit. My notes are a bit cryptic and dated from like 2007 or so, but I think I could revisit it and see what can be done.
Enjoy your day.