tokamak physics thread 4

Blitz3D Forums/Blitz3D Programming/tokamak physics thread 4

skidracer(Posted 2004) [#1]

to·ka·mak ( P ) Pronunciation Key (tôk-mk, tk-)
n.
A doughnut-shaped chamber used in fusion research in which a plasma is heated and confined by magnetic fields.


Download Blitz Tokamak: www.freewebs.com/sweenie

Tokamak Homepage: http://www.tokamakphysics.com

Tokamak Physics Threads:

www.blitzbasic.co.nz/Community/posts.php?topic=29381
www.blitzbasic.com/Community/posts.php?topic=29680
www.blitzbasic.com/Community/posts.php?topic=30024

Blitz Tokamak Tutorials

www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=bot__builder102082004102230.html
www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=bot__builder103252004031037.html


D_Town_Tony(Posted 2004) [#2]
This is my first time downloading any of the tokamak stuff and when I try to run the samples is says it's missing
the toksim_createsimulator function can't be found, where do I get it from?


BlitzSupport(Posted 2004) [#3]
Did you put the 'tokamak.decls' and 'tokamakwrapper.dll' files into your Blitz3D -> userlibs folder? Got the tokamakdll.dll file in the same folder as your source code? If not, do so and restart Blitz...


Bot Builder(Posted 2004) [#4]
Also, If you start using tokamak alot, you might as well put tokamakdll.dll in windows\system32. This makes it accessible from anywhere.


Rob(Posted 2004) [#5]
However if distributing game demos, it makes sense to keep both the wrapper dll and the tokamak dll with your game executable.

This is because we can't forsee what other people will have in their systems - ie a different version of tokamak.


JoshK(Posted 2004) [#6]
Everything just slides through the floor. It stops for a while, then sinks into it.

Are there any issues with scale?


Sweenie(Posted 2004) [#7]
Four important things to remember when using Tokamak.

* Don't use enormous masses(like 1000 for a 1x1x1 box)
* Don't take too big timesteps(the bigger the timestep, the bigger chance of missed collisions)
* Always make sure the inertiatensor is set (correctly)
* Keep the scale low to avoid floating point errors.


JoshK(Posted 2004) [#8]
How would keeping the scale low avoid floating point errors? It's just going to be accurate to some number of places, regardless of offset from the decimal point.


Sweenie(Posted 2004) [#9]
sorry, forget that one... :)
I meant not to use to high float values...ahh

Read this thread instead, it explains it better than I do ;)
http://www.tokamakphysics.com/phpbb/viewtopic.php?t=284


JoshK(Posted 2004) [#10]
I am following the instructions from the terrain tutorial, but it looks to me like Tokamak DOES NOT support accurate collisions on a "map" type mesh, which is probably why I haven't seen any demos. The FPS game shown on the site must be constructed completely out of animated bodies (boxes).


taxlerendiosk(Posted 2004) [#11]
You obviously haven't seen the one that looks like this then halo?




JoshK(Posted 2004) [#12]
Well is that all one mesh, or did you create a bunch of physics shapes to appoximate the (map) objects?


Vorderman(Posted 2004) [#13]
As I said in the other thread, using the code from the car demo program I am using a large racetrack mesh of perhaps 10k polys or so with no problems at all.

The makeTokcollider function works pefectly.


JoshK(Posted 2004) [#14]
That's good to know. Thanks.


Bot Builder(Posted 2004) [#15]
Or, my function library which allows multiple objects, and physics properties based on textures:

http://playerfactory.proboards25.com/index.cgi?board=tokamak2&action=display&num=1077666832

You might also want to grab the tokamak command refrence:

http://www.freewebs.com/botbuilder/TokamakHelp.7z OR
http://www.freewebs.com/botbuilder/TokamakHelp.exe

(7z is a bit smaller)


JoshK(Posted 2004) [#16]
Oh SWEET!

Thank you! That fixed the boxes, and fixed some collision errors I was getting.

I actually ended up using a value of about ten, to get it really accurate at high speeds, and not have those floaty, slow-mo physics.


JoshK(Posted 2004) [#17]
Hmmm, it appears that there is no way to make an upright cylinder for the player. Using a sphere causes objects to go through your head, while constantly righting a cylinder causes collision errors. Tokamak is presently useless for FPS games.

I called Havok, and their license fee is at least $100,000!


JoshK(Posted 2004) [#18]
Okay, I figured out a solution. Set the cylinder intertia tensor to a huge value, so the mass is spread over an enourmous volume. Forces applied to the center of the object won't create enough torque to rotate it.


Vorderman(Posted 2004) [#19]
Have you tried 2 spheres, jointed and positioned vertically?


JoshK(Posted 2004) [#20]
How would that be any good? It's just going to separate them any time you run into a situation where the top and bottom hit different things.


Vorderman(Posted 2004) [#21]
Really? Try it and see. The joint will hold the two together. When my 9-object car hits a wall, the body doesn't carry on without the wheels. That's the point of a jointed rigid body system....

You can also set joint limits to prevent the top sphere moving relative to the bottom, set torques to hold it upright etc...

Personally I don't see the point of using tokamak for the normal movement part of a FPS. Using it for ragdoll style death anims etc... is fair enough, but not for the generally unrealistic movement required in the average shooter.

You can try to bully it into working, but a combination approach using normal movement or tokamak where well suited will probably yield the best results.


Rob(Posted 2004) [#22]
Vorderman - how are you handling breaking for the car, and keeping it from sliding sideways on a slope?

My car never seems to have enough friction in the world for it.


Vorderman(Posted 2004) [#23]
It's difficult to get a nice balance between sliding or not, but I've added a few extra bits -

At very very low speed the car body has its linear damping increased to stop it slowly sliding around.

When in midair it has an upwards impulse applied every frame to negate gravity to a certain degree - this allows me to have high normal gravity to keep it on the ground, but still allows the car to make vast jumps in gentle arcs.

The angular damping of the body is increased dep. upon speed, to allow it to hold in a straight line. This also takes into account the steeringangle, allowing you to fling the car sideways if you want.

I'm using these friction settings...

TOKSIM_SetMaterial 1,6,0.15 	;objects 6,12		3,0.15
TOKSIM_SetMaterial 2,2,0.15		;ground	2,10		3,0.15
TOKSIM_SetMaterial 3,6,0.15		;ground	2,10		3,0.15


...for ground objects, and front and rear wheels seperately, allowing me to vary the balance of the car, or create a handbrake effect by decreasing friction on the rear wheels.

For braking, I'm using a negative torque on the driving wheels, which in this case are primarily the front wheels. The rear wheels can be driven to the certain variable degree to promote oversteer, but primarily front wheel drive gives a nicely balanced car.

I'm also allowing the player to balance the car in the air by pitching the nose up and down with the throttle and brake, to allow a bit more control. I might introduce a slight steering effect in the air also.

Note that this lot is for my Stunt Car Racer clone, not for a serious driving sim.


Mark Judd(Posted 2004) [#24]
Vorderman : I can't wait to see that clone, one of the greatest games ever imho.

Tokamak seems really good to me.
I've got ten landyachts sailing around a course without any trouble. The yachts, sails, ground and environment are all handled by tokamak.

The landscape is formed from two meshes, an invisible one for passing to the physics, only covers the driveable areas,
and a second mesh, visible this time, higher detail and covering a larger area.

re friction :- They have a degree of sideways slippage on the wheels, i control the amount by factoring the sideways velocity of wheels (after tforming the x,y,z velocities to global, then factoring x and then re-tforming and applying back to the wheel).

FunkyFrank


bradford6(Posted 2004) [#25]
the demo I made awhile back uses a single mesh for the 'world'

I am almost back...
(been working on a huge security project --14 hour days)

I am kinda waiting for Sweenies next release so I hit the ground with a fresh build.

I am also working on some Python>blitz3d bindings
(could be cool)


Tracer(Posted 2004) [#26]
has anyone done a nice car sim yet with Toka?

Tracer


poopla(Posted 2004) [#27]
Not that I'm aware of... most people still seem to be fiddling with the basics(myself included).


JoshK(Posted 2004) [#28]
After a couple of weeks of testing, I don't think this is very useful for FPS games. You just can't get all aspects of it working at once. You either are going through boxes, or the player cylinder is falling over, or the physics are too slow, or something.


Vorderman(Posted 2004) [#29]
You need to take a different approach and use a combination of normal techniques and tokamak when it suits. Use the normal Blitz system for player movement, bullets etc..., then bring in Tokamak only when a physics based reaction or movement is required, such as a bullet knocking over a barrel. Once the movement is complete the physics is no longed required.

This is how games that use Havok or similar systems, such as Max Payne 2, Half Life 2 etc.. combine their physics with normal gameplay. There's no way the Max character is simulated with the physics engine, just the objects he hits / moves, and only when required.


JoshK(Posted 2004) [#30]
Yes but then the player can't be affected by objects, like a moving door or whatever.


Rob(Posted 2004) [#31]
Halo,

How would you integrate tokamak with for example, BlitzPlay internet lib?

I take it that multiplayer is still something you've notyet done? I'm interested too.


JoshK(Posted 2004) [#32]
I'd just let the sever control all crucial events, and let the client machines control all physics that are just for looks.


Rob(Posted 2004) [#33]
So each client is responsible for it's own physics and just uploads the result?

The problem here is a bit different from standard FPS stuff - it's all about response. If a response doesn't occur at exactly the right time, they get wildly out of sync.


JoshK(Posted 2004) [#34]
No, physics that actually effect things, and aren't just for show, should be controlled by the server, and the results sent to clients.


AntonyWells(Posted 2004) [#35]
I wouldn't do that, as there would be a noticable lag between action and reaction on the client side.
What I'd do is say player A shot a box, that goes flying across the room. Player A calculates the physics for it, and sends a constant force to the server, that ensures the same response happens, this force/impulse is then sent to all other clients.
You can optionally send updates to keep it in sync, in case there was a bad bit of lag when it was first 'hit'.

If you let the server handle all the physics, when player A hits the box, the box won't move until the server has sent a response back the player. This won't be bad in good games, but lag would make the game look very juddery, where as if you do the physics client side it may snap now and then, but it'll be smoothr.

And imagine the player..you want him to move and push boxes etc out of the way instantly, or you break the natural feel of the gameplay.


Rob(Posted 2004) [#36]
Nice theory but it doesn't work in practise.

The amount of updates you propose will require it to be a lan-only game.


AntonyWells(Posted 2004) [#37]
You time your updates and use cubic splines to interpolate the incoming values.

You never send constant data, you create a timer. And once it ticks, you update the server. And the server decides what clients need to be updated.
Good method of this is to scale the update frequence from server to client based on distance. Sort of like Network based Level of detail. And when I say distance, I'm talking in terms of visual distance on screen. If player b can barely see player A, there's really no need for player A's psoition to be that accurate in player B's eyes.
Also, you can skip updates for off-screen entities all together(With a set safetly margin, to avoid popping)

So yes, it would work. Don't argue with me, or there will be trouble. Right!? ;)


AntonyWells(Posted 2004) [#38]
Anyway, check out this tutorial Rob, it's great.
http://www.bookofhook.com/Article/GameDevelopment/MultiplayerProgramming.html


Rob(Posted 2004) [#39]
Cheers Otacon, petty neat tips :) I had the idea of lod myself. I guess the rule of thumb is to only send and recieve whats vital.

I wonder what the buffer sizes are for modems and stuff?


bradford6(Posted 2004) [#40]
what is the plan for TOKAMAK+Blitz

Does Mark Sibly plan on incorporating it into BMAX?

Does Sweenie plan on creating a newer wrapper?

Does Tokamak plan on releasing TOKAMAK 2 anytime soon?

If anyone has this info, please share.


Bot Builder(Posted 2004) [#41]
Does Mark Sibly plan on incorporating it into BMAX?

I doubt it.

Does Sweenie plan on creating a newer wrapper?

Yes.

Does Tokamak plan on releasing TOKAMAK 2 anytime soon?


Hard to say. There hasn't been much visible tokamak activity, but who knows.


aCiD2(Posted 2004) [#42]
ok, to jump the topic :)
ive just uploaded my rag doll demo and im now incorporating it into the game (very easy :D) however, i was wandering how i should go about with water... should i move the rigid bodies as normal but when i move the bones move them between the rigid body and their current position, and then moving the rigid body back to the bone. or just lowering the mass of the rigid body. oooor even-- the water provides a constant upwards force, not quite as strong as gravity?


Bot Builder(Posted 2004) [#43]
Hmm. A constant upward force would be most physicaly accurate. If you have the patience to set realistic density values you could make it look even better - basically the force is the density of water divided by the density of the object multiplied by gravity. Even better would be to multiply this by a number between 0 and 1 representing the amount of the rigid body submerged. As you can see, this force can be greater than gravity (if the object density is less than water), this is how things float. You're also going to want to make linear and rotational damping alot higher for the rigid body - preferably based on the amount submerged, but doesn't really matter. Water friction, as you probably know is very dramatic.


aCiD2(Posted 2004) [#44]
hey good post bot :) i'll start off just using a constant upwards force and then try and do those calculations...ek :P


Bot Builder(Posted 2004) [#45]
Hehehe. Yeah. I did alot of research on bouyancy while doing my physics engine. For games, Your method of constant force should be fine.


OverDozing(Posted 2004) [#46]
@ Bot Builder !
thank you for the 2 tutorials talking about tokamak wrapper, there is only 2 tutorials and it's from you! damn !

Then, I am requesting a tutorial for a car physics ???? it would be so interresting, don't you think?

Thank you anyway for all your work guys ! awesome ! :)


bradford6(Posted 2004) [#47]
what does this do?

* Iteration of existing geometries (TOKRB_BeginIterateGeometry,TOKRB_GetNextGeometry,
TOKAB_BeginIterateGeometry,TOKAB_GetNextGeometry)


Bot Builder(Posted 2004) [#48]
Hehe. Thanks. I guess a car tut would be possible. I'd base it of the demo already done, and add some special stuff. Also, check out the command refrence I made for it - http://playerfactory.proboards25.com/index.cgi?board=tokamak2&action=display&num=1078737396

Bradford6-

I bet their similar to the Read dir/nextfile commands in Blitz. This way you can get all the handles for geometries under the rb by first Begining the Iteration and then Getting the Next Geometry over and over until 0. Note - I have not actually tried them.


aCiD2(Posted 2004) [#49]
yea im also for car physics tutorial - currently im workign on making cloth and rope simulations :) Got the water working aswell btw


bradford6(Posted 2004) [#50]
BOT,
Thanks for the help files. they are great!
Sweenie,
Thanks again for this awesome set of tools. (I am now able to spend more time with this...been out of the loop for awhile)


Sweenie(Posted 2004) [#51]
Just wanted you to know that the Tokamakteam just released version 1.2 of their physicslibrary.
I'll start wrapping immediately. :)
Major news...
* Convex hull collider
* Sliderjoint


Mark Judd(Posted 2004) [#52]
Nice one !
It's good news, not least because the lack of communication from the TOKAMAK team led me to suspect they had stopped work.
However can't see anything in the release info text file about wheel dynamics stuff (i.e. helping to fix the common friction issues).
Hope there is something in there, anyway the slider joint and convex collider hull will be useful as soon as i've figured out just what they do......

Thanks again for your efforts sweenie.

Funky Frank


Sweenie(Posted 2004) [#53]
A convex hull can be used instead of the basic primitives.
They included a tool that inputs a list of vertices that you provide and generates a closed convex mesh covering the vertices as tightly as possible.

Lets say you want a boulder falling down from a hill.
You probably would choose the sphereprimitive for this as this is the shape that best fits the boulder.
But in real life a boulder wouldn't roll as smoothly as a perfect sphere(unless the boulder is VERY smooth).
Instead take your bouldermesh, run it through the convexhull generator and use the resulting hull in Tokamak as the collisionvolume for the boulder.


Ricky Smith(Posted 2004) [#54]
Sounds great - I'm dying to get to grips with this once I've finished my current project.


bradford6(Posted 2004) [#55]
this sounds great. What about the slider joint? is this something that can be used for a spring/damper?


Ice9(Posted 2004) [#56]
I wonder if the convex hull can be dynamicaly changed.
Say a boned convex hull attached to your player model.
Or another Idea... Preselect vertices in your mesh and
save the indexes. Use this smaller selection as your convex
hull then update the convex hull vertice information with
each frame.

slow? or not possible?


Ricky Smith(Posted 2004) [#57]
I imagine it would only be calculated once per simulation like the CreateTerrainMesh for the main collision entity.


Picklesworth(Posted 2004) [#58]
so a convex hull can automatically make a precise physics sim object for a game model?
Does this mean that there's no need to set up an objects out of boxes except in very special circumstances?
Um, how do I run the adjacency tool?


bradford6(Posted 2004) [#59]
I think you'll have to wait for Sweeney to get a new wrapper out with these changes.

the Adjaceny tool takes a list of vertices and creates teh convex hull

example:
4
X Y Z
X Y Z
X Y Z
X Y Z

THE "4" TELLS THE ADJACENCY TOOL HOW MANY VERTS
then the 4 lines of coordinates are the actual verts.


Sweenie(Posted 2004) [#60]
Check this java-applet.
It demonstrates how convex hulls are constructed.
http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html


Sweenie(Posted 2004) [#61]
@arbitrage:

I don't think you could modify the hull during simulation, but you should be able to remove the currently used hull and replace it with another hull.

@dillpickle79:

Yes, this means that your spaceship could get a better fitting collisionvolume.
However, since your spaceship is convex you probably would have to create three hulls.
One for the ship's body and two for both wings.


Rob(Posted 2004) [#62]
whats faster - 1 cube with two cylinders, or one really low poly convex hull?


Paul "Taiphoz"(Posted 2004) [#63]
Just a question to those of you using this so far.

Is there anyone working on a tutorial for this ? .. I know there are some samples and demos but a tutorial to actuall explain some things would be nice.

Im thinking about using this system for a small game project, it would have to handle collisions between humanoid chars. Im wondering how hard it is to set all this up.


N(Posted 2004) [#64]
I'm looking into 'extending' my particle system by adding a little toggle so the particles in it can (optionally) use Tokamak. Now, because I'm completely ignorant on this subject, I was wondering if someone could help me through the basic steps I'd have to take in order to get it working (properly or not, I'd just like to get it working first)?

I'm reading Bot Builder's tutorial, but while I'm doing that I'm hoping someone could help me understand what would be required for this and if it's even plausible.


Bouncer(Posted 2004) [#65]
The convex hull collider sounds great!... go sweenie go! :)


Bot Builder(Posted 2004) [#66]
Well, the whole particle thing is a bit of a kludge from my perspective. the only difference between them iand rigid bodies is that they don't collide with themselves - a rigid particle won't collide with another rigid particle. probably worthless unless you want the particle engine to follow contours etc.


N(Posted 2004) [#67]
a rigid particle won't collide with another rigid particle


That's a good thing, actually. Basically, I want them to react 'realistically' with the environment, but they shouldn't interact with themselves.


Bot Builder(Posted 2004) [#68]
Well, yes, but I first thought they might be dumbed down even more (no rotation for instance), making them faster, maybe with some features like emiters and exemption from gravity.


Sweenie(Posted 2004) [#69]
I actually thought Tokamak-particles would be faster too, but judging from some quick speed tests they aren't much faster than a regular rigidbody.
So throwing 2000 particles into the simulation brings the simulation to it's knees and I think a particlesystem should be able to handle alot more particles than that.


bradford6(Posted 2004) [#70]
the slowdown has to do with the way blitz handles entities, not the tokamak particles.

perhaps a single-surface particle system with the tokamak physics particles would work better.

I have always thought that blitz should have a simple emitter system built-in that does not rely on each particle being a part of the entity system. maybe an emitter entity with attributes that affect the particles it generates.


N(Posted 2004) [#71]
Well, I've added basic Tokamak 'support' to my particle system if anyone wants to mess around with it or has any suggestions on how I can improve the way Tokamak is being used by it.

Bradford: Even with a single surface system this occurs. I've done the tests- anything over thousand Tokamak particles can and will make everything hideously slow.

[complete ignorance]
As an example, I made this to test how well Tokamak handles particles, as far as I'm concerned it's doing a pretty good job for a thousand or so, but the rigid particles would have to be carefully limited in order to make it work well. [/complete ignorance]


Sunteam Software(Posted 2004) [#72]
Noel, had a look at your PS but the test code couldn't find function:

SetEmitterUsesTokamak


N(Posted 2004) [#73]
Sunteam: The Tokamak version of the code is 'disabled' by default- you have to change an include in 'h_lotus.bb' to make it work.


bradford6(Posted 2004) [#74]
Tokamak is dead. Long live Tokamak...


N(Posted 2004) [#75]
Riiiiiiiiiiiiiiiiiiiiiii... TWO HOURS LATER ...iiiiiiiiiight.


Bot Builder(Posted 2004) [#76]
hehe. you're just in the wrong forum....

http://playerfactory.proboards25.com/

900 posts and rising


Sweenie(Posted 2004) [#77]
Version 0.6 of the wrapper is almost done.
I'm just having some trouble with the convex-mesh collision.
I get an error as soon as the mesh collides with another body.
But I know it's a bug somewhere in the wrapper because the Tokamaksample 3 uses it without problems.


Picklesworth(Posted 2004) [#78]
oh, hooray!
I can't wait for convex hulls :D


Sweenie(Posted 2004) [#79]
Hmm, It wasn't exactly a bug.
I thought that I were supposed to pass the binaryfile data straight to Tokamak with the SetConvexMesh function and I did.
However after getting a crash everytime the convex collided I checked the Tokamaksample.
Turned out that I needed to extract the verts, faces & edges from the binfile and put them in a certain order.
Luckily for me, the Tokamak samplebase already had a premade function for doing that.
Works like a charm now.
Then I noticed that the convex mesh didn't collide with spheres, and after reading the changelog I realized that it won't.
Convex-Convex, Convex-Box and Convex-Terrain collision are implemented but not Convex-Sphere.

So, only breakage left now, but I will release wrapper 0.6 before implementing breakage.


Mac M(Posted 2004) [#80]
Sounds cool!!
I can't wait to see convex hulls in action...
And breakage too!

Thanks Sweenie

BTW: Any example or idea using tokamak with water?


Sweenie(Posted 2004) [#81]
BTW: Any example or idea using tokamak with water?


Here is a demo with faked buoyancy
[Edit]
I improved it a bit.
Fixed inertiatensor and added rotationaldamping in water
/Edit]




Picklesworth(Posted 2004) [#82]
That's neat. I geuss here is another addon to my program for the todo list. I was going to ask about buoyancy at some point but I guess I don't now. Thanks :P


Sweenie(Posted 2004) [#83]
If you know how to spell 'buoyancy' you are halfway there. lol! ;p
Couldn't Archimedes have called it 'Floatiness' instead? hehe 8P


Mac M(Posted 2004) [#84]
Wow! That's nearly what I was looking for. I will try to make it with dynamic ocean instead of a plane.
Thanks.

"Buoyancy" hehe. Here we call it "Flotabilidad", hehe.


Sweenie(Posted 2004) [#85]
It will be interesting to see the result.
Good luck on your submarine game.(It looks great)


Vorderman(Posted 2004) [#86]
Any news on the next update with the sensor functions added Sweenie?


Sweenie(Posted 2004) [#87]
I should be able to release it within the next 24 hours.


Vorderman(Posted 2004) [#88]
Excellent - I'm looking forward to trying my rally game with the sensors for suspension - hopefully it will improve the reaction to the road surface and allow a more realistic feel - currently the suspension is a bodge and doesn't give you that pitch and roll feel that is required.

Thanks
James


Sweenie(Posted 2004) [#89]
The sliderjoint works in the new release aswell.


Picklesworth(Posted 2004) [#90]
stop teasing us and release it!! :P


bradford6(Posted 2004) [#91]
way to setup the tension Sweenie! you should change your naming scheme to 'Episodes'

Sweenie Tokamak Wrapper Episode 0.6: A New Hope

seriously,
the slider joint sounds great.
Your Bouyancy demo looks great.


Sweenie(Posted 2004) [#92]
Buoyancy, Bill! Buoyancy!
Bouyancy, isn't that the girl who sang in Destiny's Child? ;p


Rob(Posted 2004) [#93]
lol...

you're great for doing this sweenie, I really appreciate it.


Sweenie(Posted 2004) [#94]
Ah, Friday... I love fridays...
Good shows on the tv, no more work for a couple of days, pizza, beer and new wrapper releases... ;)
Get it here --> http://www.freewebs.com/sweenie/


CopperCircle(Posted 2004) [#95]
Excellent work Sweenie, I have been waiting for this release like it was Christmas :)


Picklesworth(Posted 2004) [#96]
Thank you lord sweenie!!!!

Those motors and sensors sound pretty useful if they are what they say they are. And more work for me :D


bradford6(Posted 2004) [#97]
nice work Sweenie!


Bot Builder(Posted 2004) [#98]
mmm. sounds like I won't be able to add the documentation along with it. Oh well.

Great work!


Sweenie(Posted 2004) [#99]
Oh.. Sorry Botbuilder, I forgot. :(
Tell you what, update the documentation and send it to me and I will update the wrapperpackage to include the documentation.

ps!
Thanks for helping me out and I hope you aren't angry at me for forgetting the docs. :)


Rob(Posted 2004) [#100]
Thanks man!

sweenie - will you be interested in a mac tokamak?


Bot Builder(Posted 2004) [#101]
That's okay. :D

I'm just happy the new version's out.

Now I'm gonna monkey with it and write the docs.


Rob(Posted 2004) [#102]
and post your support for a mac version on the tokamak official forums or you'll all cry when blitzmax comes out and you've nowhere to go mac-wise.


Bot Builder(Posted 2004) [#103]
Okay sweenie, emailed you :D

That was quite a large update. Cant wait to start experimenting with the sensors and convex hulls!


Sweenie(Posted 2004) [#104]
A mac-version of Tokamak would be cool, but considering the somewhat slow developement of Tokamak for PC I wouldn't bet any money on Tokamak for Mac showing up anytime soon.
But hey, you never know.


Picklesworth(Posted 2004) [#105]
found it. Thanks again!


Bot Builder(Posted 2004) [#106]
Isn't C/C++ cross platform? Maybe I'm being ignorant in this case, but I coulda sworn it was. Since Tokamak is essentially bunch of math, I wouldn't think there would be to much stopping them from making a mac version. Although, I don't know if there is a file equivalent to a dll on macs.

For those that didn't notice - there are docs by me available off the tokamak website. Put the zip in your blitz directory. It will overwrite one Blitz help file - the main page, to provide a link to the documentation. F1 help works.


Sweenie(Posted 2004) [#107]
I don't know how ordinary windows DLL works with mac, but could the .lib version of Tokamak work?


ZombieWoof(Posted 2004) [#108]
Doesnt OSX have linux/posix compatible compilers ??


Rob(Posted 2004) [#109]
The problem here is the tokamak people. We must encourage them.


Picklesworth(Posted 2004) [#110]
I plan to do this myself shortly, but does anyone already have a function that parents two tokamak geometries together? Presently, this is done using a solid joint (I think), and I think it would be more readable if there were a function like TokGeom_Parent()
Or even better, is there a parenting function within tokamak?


Rob(Posted 2004) [#111]
You can add geometry to the same rigid body without problems or extra functions.


CyBeRGoth(Posted 2004) [#112]
Not used tokamak much, but i love the stuff i have seen done with it so far.

I have a question tho, i have managed to load a .3ds map in as a level, convert it to a rigid body, but how easy would it be to add other rigid (or are the animated?) bodies to this map, such as moving elevators, rotating floors etc?

I tried to tilt my level just to see if i could get the player to slide off but he just stands there as if the mesh and the tokamak collisions are seperate.

Anyone have some code that will show me how to do this? IE rotate or tilt a level and have the player affected by it?

Cheers


podperson(Posted 2004) [#113]
Zombie:

OSX's standard set of dev tools includes gcc3, so yes.


Carrot(Posted 2004) [#114]
I'd personally use animate bodies for entities like doors and elevators (lifts!), but the tilting map idea could be easier modeled by twisting the camera and then just applying a force to all rigidbodies, including the player entity.

Alternatively, you could modify the gravity vector.


Carrot(Posted 2004) [#115]
You can add geometry to the same rigid body without problems or extra functions.


Anyone manage to do this successfully yet? I can't get it to work.


Bot Builder(Posted 2004) [#116]
Sure:

http://playerfactory.proboards25.com/index.cgi?board=tokamak2&action=display&num=1076363448

It only works with an older version though (different syntax) you should get the idea though.


Eric(Posted 2004) [#117]
I am playing around with a lunar lander game, How would I create Tok objects for my lander, making sure that when it lands that it sits at the right angle.

Would this be hard to do? I have my basic code running, without tokamak, but I would like to incorporate it.

What would be involved?

Regards,
Eric

ps My Lander has 4 landing pads.


Bot Builder(Posted 2004) [#118]
Well, I would first create a rigid body for the lander, and add four boxes to it, using TOKGEOM_SetPositionAndRotation to position them at the pads of the lander. Then perhaps making the body of the lander out of one of the other geometries (depends on the shape). I presume you would have a static mesh for he terrain. In your main loop you would update tokamak, and position the lander model to the tokamak rigid bodies position and orientation. For thrusts just do a TFormVector to transform 0,force#,0 from object local space to global space, then apply the impulse. If this is to confusing I can do a bit of sample code.


Eric(Posted 2004) [#119]
Bot,

Ok So I can Create a Tok_Sphere, and connect 4 boxes for the pads. Can you show me how to do that part.

Regards,
Eric


Bot Builder(Posted 2004) [#120]
Well, you might be able to use a convex body as I mentioned on the player factory forums. I also mentioned how to combine multiple geometries into the rigid body. I presume you will use a static mesh for the terrain? http://playerfactory.proboards25.com/index.cgi?board=tokamak2&action=display&num=1077666832 Will allow you to do it without to mych trouble. Then its just a matter of initializing tokamak, advancing in your main loop and finally positioning the objects.


Eric(Posted 2004) [#121]
Bot,

You will have to forgive me, but sometimes I have a hard time getting my head around new things (sswift can attest to this, he helped me learn basic physics stuff without tokamak). Can you give me an Idea how to make a pyramid with 5 cubes. With the top point being my Lander and the bottom four cubes as my landing skids.

Then my next question is, can I turn the RB (Lander) manually, or do I have to apply impulse. What I want to end up with is a way to pivot the lander on both the x and z axis.

I played around lastnight with my lander within a single RB cube and a AB ground cube. I used ApplyImpulse2 and set the point of impact 10 units above my lander to use that to tilt it left, right , fore and backwards, but the effect I got was that I pushed the Lander too far, off course trying to turn it... Has this made any sense?

Best Regards,
Eric


Picklesworth(Posted 2004) [#122]
oh, I think I know what oyur problem could be. This happened in a thing I was doing... Just apply a reverse impulse on the opposite side at the same time.


Eric(Posted 2004) [#123]
You mean in addition to ApplyImpulse2, use an ApplyImpulse in the opposite direction?


Picklesworth(Posted 2004) [#124]
no, the same kind of impulse as the first side, just with a negative value.


Eric(Posted 2004) [#125]
Will Try when I get home.... Is there a way that I can rotate my lander without impulse? A manual way...Like rotating the RB.

REgards,
Eric


Picklesworth(Posted 2004) [#126]
I think you can use tokrb_setTorque, tokrb_setAngularMomentum, or tokrb_applyTwist (there are probably more...). They all basically rotate an object. Apparently tokrb_setAngularMomentum is a bit buggy, but I haven't tried out any of them myself.


Bot Builder(Posted 2004) [#127]
TOKRB_SetRotation can set the rotation but be warned it messes up collisions, so best it's probably best to use turning impulses (and more realistic) as I (in the playerfactory forums) and dillpickle have suggested.

Also, if you never need your lander to collide with spheres or capsules, I would suggest using it as a convex body at first. If this proves problematic you could always switch to geometry based, even though I don't know of any problems.


Eric(Posted 2004) [#128]
Bot,

I have used both methods of rotation. I do like the impulse method, it seems more realistic, your right. In my original game, The joystick controlled the X and Z Axis rotation. I transformed Joystick X and Z from Camera to world space, so no matter what direction the camera was facing, left was left and right was right.

For some reason, I can't get this to work within the Tokamak world. For Rotation on the X-Axis for instance I am using the following abbreviated statments


TokRB_ApplyImpulse2 RB,.1,0,0,Getx(),Gety()+12,GetZ()
TokRB_ApplyImpulse2 RB,-.1,0,0,Getx(),Gety()-12,GetZ()

I used two Impulse statments like Mr Picklesworth suggested above.

How can I apply my joystick inputs so the orientation stays correct in the camera view..

Regards,
Eric


Bot Builder(Posted 2004) [#129]
mmm. Does this work?
TFormVector 0,-1.1,0,camera,0
TokRB_ApplyImpulse2 RB,.1,0,0,Getx()+TFormedX(),Gety()+TFormedY(),GetZ()+TFormedZ()
TokRB_ApplyImpulse2 RB,-.1,0,0,Getx()-TFormedX(),Gety()-TFormedY(),GetZ()-TFormedZ()


BTW, this will actually be rotation about the Z axis.


Eric(Posted 2004) [#130]
Bot,

Nope it doesn't work, Sheesh I am getting frustrated with this. I thought It was going to be a fairly simple project and the stupid camera, is holding me back.

Regard,
Eric


Bot Builder(Posted 2004) [#131]
How doesn't it work? just doesn't move at all? try debugging various variables - see what the problem is. Make sure you've set the RB variable, and the Getx/y/z things are typed properly. Debug the values of the tformedx/y/z. See if they are responding to your input.

[edit]Okay so there was a little error :P I made a demo to test:
Const Rigid_Bodies=100,Animated_Bodies=5
TOKSIM_SetRigidBodiesCount Rigid_Bodies
TOKSIM_SetAnimatedBodiesCount Animated_Bodies
TOKSIM_SetRigidParticleCount 0
TOKSIM_SetControllersCount 0
TOKSIM_SetGeometriesCount Rigid_bodies+Animated_Bodies ;Assuming each one only has one geometry.  Not true with more complex rigid bodies and animated bodies.
TOKSIM_CreateSimulator(0,0,0)

Graphics3D 640,480
;Setup The scene
lander=CreateCube()
landerb=TOKRB_Create()
TOKRB_AddBox landerb,2,2,2
campiv=CreatePivot()
cam=CreateCamera(campiv)
PositionEntity cam,0,0,-5

l=CreateLight()

While Not KeyHit(1)
	TurnEntity campiv,0,.25,0
	TOKSIM_Advance .1,1
	;Position graphical representation
	PositionEntity lander,TOKRB_GetX(landerb),TOKRB_GetY(landerb),TOKRB_GetZ(landerb)
	RotateEntity lander,TOKRB_GetPitch(landerb),TOKRB_GetYaw(landerb),TOKRB_GetRoll(landerb)
	TFormVector .1,0,0,cam,0
	x#=TFormedX()
	y#=TFormedY()
	z#=TFormedZ()
	TFormVector 0,(KeyDown(205)-KeyDown(203))/100.0,0,cam,0
	TOKRB_ApplyImpulse2 landerb,x#,y#,z#,TOKRB_GetX(landerb)+TFormedX(),TOKRB_GetY(landerb)+TFormedY(),TOKRB_GetZ(landerb)+TFormedZ()
	TOKRB_ApplyImpulse2 landerb,-x#,-y#,-z#,TOKRB_GetX(landerb)-TFormedX(),TOKRB_GetY(landerb)-TFormedY(),TOKRB_GetZ(landerb)-TFormedZ()
	RenderWorld
	Flip
Wend
TOKSIM_DestroySimulator
I don't think its a very suitable way to control a lunar lander sim but oh well.


Eric(Posted 2004) [#132]
BOT,

Thanks for your reply, I actually use a joystick, and appreciate your code above, I will play with it tonight when i get home.. Your comment "I don't think its a very suitable way to control a lunar lander sim but oh well."

Please give me some insight as to what you would do. I am just learning, and would appreciate and advice you may offer.

Regards,
Eric


Bot Builder(Posted 2004) [#133]
Well, I'd say it depends. The problem I see with this method is that at any time you don't have control over one of the axis of rotation. For instance, as in my sample, the camera is rotating around the lander.you can apply a thrust but then half a second later (after turning 90 degrees) you can't stop that rotation. Perhaps if the y axis of the joystick did pitch thrusts(relative to camera) and the x axis did roll thrusts (relative to camera) it could work pretty well with tweaking as to how much the joystick affects it. Maybe trigger to do a thrust (or perhaps z axis of joystick, maybe user-settable) and button 2 for super thrust maybe (very bad for fuel).


Eric(Posted 2004) [#134]
Bot,

Thanks for the insight, I figured out my camera problem. And it seems to work pretty well. I Place a camera target at 0,5,-10 relative to the lander, and made the Parent another Pivot.
Center=CreatePivot(Lander)
Target=CreatePivot(Center)

I check the angle of the Camera to The Lander and rotate the Center pivot to match, This way as I'm flying past the camera, The Camera swings around the lander. It's like it is trapped in a 10 unit circle around the lander. It's pretty smooth coming from an amature like me.. :)

Regards,
Eric


Eric(Posted 2004) [#135]
Ok The tokamak Sensor, I looked at the sample code and it looked pretty simple until I tried to put a sensor on the bottom of my lander. TokRB_AddSensor (RB,0,0,0,0,-10,0)

Is this Wrong? I want to detect if I am getting close to the ground. Using The GetDectectDepth# Command, but it is always reading Zero... Is there a trick to this command?

Regards,
Eric


Bot Builder(Posted 2004) [#136]
Yeah, sounds like a pretty cool camera system :D

Yes, the sensors all a little wierd. GetDetect Depth will actually return the amount the sensor has penatrated. Also, The sensors are local to the rigid body so if say you want it to measure altitude, you'll have to continuosly change it's location. However, the sensors are probably faster than blitz linepicks so you might as well use it:

TFormPoint EntityX(lander),0,EntityY(Lander),0,Lander
TOKSENSOR_SetLineSensor Sensor,0,0,0,TFormedX(),TFormedY(),TFormedZ()
TOKSIM_Advance .01,1
altitude#=TOKRB_GetY(lunarb)-TOKSENSOR_GetDetectDepth(Sensor)


[edit]To tell you the truth, i can't get it to work either :/ Haven't actually tried using a sensor till now, although I'll probably have a use for them. I'm not sure what the demo is doing that I'm not.


Eric(Posted 2004) [#137]
I can't get the darn thing to work, So I am gonna work on other things for the time being. Currently I am using Terragen to make my landscapes then importing them into Truespace to convert to .X.. I then Create a Static Mesh.. Right now I'm pushing 40,000 Tris. Way too much. Right now I am still concentrating on the Physical Properties of the Lander... SO... how can I create proper geometry on my lander? I just want four small boxes on the Lander pads and a sphere to encomass the upper portion. I can't visualize, how to orient the boxes to line up with the lander. Can you help with that?

Also, Do the Sensors, work on static Meshes? If anyone out there knows how to use sensors let me know.

Regards,
Eric


Bot Builder(Posted 2004) [#138]
Hmm. Well I just did a test on the sensors and they appear to *not* work on static meshs :'(. You can try using blitz's linepick.

Does terragen work off hightmaps? If so that may be one way to make your own super fast linepick method. Figure out the point on the bitmap your lander is above and take the red value of it (readpixel and then take the result And $FF), then multiply this by the amount your map is scaled in the y direction. Take the y of the lander subtacted by the terrain y.

Even easier would be to use a blitz terrain, load up the heightmap and use landery-TerrainY(). However you would still need a triangle version because you can't pass a terrain to tokamak.



These might help as far as positioning the pads/sphere right. Just twiddle with it until its close to right.


Eric(Posted 2004) [#139]
Hey Thanks for the functions, Much appreciated.

Bot...Here is what I have.. I have a Lunar.X Model, And a staticMesh Terrain.. Using your Function by the way.

My collisions happen, In other words when the lander hit or touches the Terrain, it reacts.. My problem is, I can't figure out how to trap those events...None of the commands seems to work... Do you have experience with collisions?

Also Materials... I've tried using your functions, and they don't make sense to me, Textures and Materials.. Will they work on a static Mesh? How do I get them to work also... I can't figure out why I can't get a lot of these function to work... Sensors..Materials...Collisions


Regards,
Eric


Adam Bossy(Posted 2004) [#140]
Where can I find the demo that Denzil Quixode posted a screenshot of (near the top of the thread)?


GeordieB(Posted 2004) [#141]
http://www.the-radfords.net/tokatest5.zip


GeordieB(Posted 2004) [#142]
Can someone explain how the "height" value off TOKAB_addCylinder() works off, cause its not the same as sphere/cube

im using absolute values to set the sizes, not a scale %, but this doesnt work for Cylinders

speaking of which, is there any way at all to be able to change the X and Z size of Spheres and Cylinders or are you stuck with diameter and thats it?


Bot Builder(Posted 2004) [#143]
you are stuck with the diameter. As for the height, the "actual height" is diameter+height. The reason being that the "cylinder" is really a capsule.


Picklesworth(Posted 2004) [#144]
I'm sure this doesn't happen in real life, or we would all be floating.

In both versions of tokamak, I have found that if you put a significantly lighter object below a heavier one (or light above a heavy one), the above object will bounce in the air for no reason, and in a very fast manner. I have finally decided to face this glitch upon trying to fix a problem in the rope demo (the crate bounces when it lands on the rope).
So, has anyone else found this problem, and do you have a solution?
A good way to see the effect is by making the tires in the car demo (in the tokamak lib samples folder) very light, and the chassis very heavy.


Picklesworth(Posted 2004) [#145]
Oh no,don't tell me I just killed another thread!!! this always happens with my post being last!!
NOOOOO!


Eric(Posted 2004) [#146]
Well, You didn't I was just waiting for an answer to my question above... BTW I figured it out... For anyone that doesn't know... The collisons ID of a static Mesh Terrain is -1... :) Now I just have to figure out Materials.

Regards,
Eric
PS My Lunar Lander Game is Coming along Pretty good now. Baby Steps!!


bradford6(Posted 2004) [#147]
there is a serious lack of Tokamak demos in this thread.

come on. share the love...


Bot Builder(Posted 2004) [#148]
Ok. Here's two:



And here's one by me: http://blitzstuff.250free.com/zips/Tokamak_intro.zip (234 KB)

Its a wrecking ball demo where the ball nocks over the letters "TOKAMAK". No user interaction, so its suitable for a game intro or somthing. Also uses lotus particle system (included, with intact liscence.txt), so at the end "Using lotus" and "tokamak" logos fade in.


Eric(Posted 2004) [#149]
Bot,

Can you explain the use of Materials in Tokamak, How do I implement them with your Terrain Mesh Functions. I read your description but still don't understand.

Thanks,
Eric


Picklesworth(Posted 2004) [#150]
ooh, hehe, I thought it was my restitution on the rope causing that problem. `my bad :)
Come to think of it, I think that's the same reason for my trouble with the car demo... So I've learned a lesson: never trust restitution unless it's really needed.

Tokamak materials are quite simple: You put toksim_setmaterial at the top of your code for each material you want to create. Remember the index you use (in fact, using a constant for the indexes is a good idea). Then you can apply it to geometries at any point with tokgeom_setmaterial()


Eric(Posted 2004) [#151]
So it really has nothing to do with how you texture it.

Can you give me a brief code snip.

I have a box and a Static Mesh terrain.

My LinearDampining is very low, so when the box rests on the terrain is slides on even the slightest incline. I want the Box to have more friction based on the material it collides with.

Regards,
Eric


Picklesworth(Posted 2004) [#152]
Sorry, I'm not great at code snips but here's a slightly codified example to show you sort of how materials are done.
Sorry about any wrong/missing functions, but I'm too lazy to look them up.


I hope this helps to some extent :)


GeordieB(Posted 2004) [#153]
Eric,

you say the collisons ID of a static Mesh Terrain is -1, how do you actually trap if your ball hits it and do something?

I cant see a command to check if X hit Y if you know what i mean.

Also is there a way to make gravity more realistic? If you make a ball, with a mass of 300, why does it still fall slower than a feather in a storm, it should fall like a brick......


Eric(Posted 2004) [#154]
Sorry, But I don't remember the exact command names

but you set the Collisions ID of let's say a cube to 1

and the Static Mesh terrain is defaulted to -1

Now TOKSIM_SetCollisionResponse(1,-1,3) To get feedback.

Then TOKSIM_GetCollisionCount()

Then there are a whole bunch of Bank Related commands to determine Things about the collions. Y Velocity and stuff

Hope this Helps,
Eric


Picklesworth(Posted 2004) [#155]
Oh yes, good old gravity. What do you have the gravity variables set at?


GeordieB(Posted 2004) [#156]
Thanks Eric, i did see them but wasnt too sure how to use them, got it sussed and working now, ta :-)

Ive got my Y gravity to -20 at the mo? havent played with that too much, my object is set to a mass of 300, but falls slooowwwwww, and if i set gravity any higher, my objects start squashing into each other and/or the floor.....


Eric(Posted 2004) [#157]
Pickle,

Currently I am using 0,-5,0 for my gravity... But in the future I am going to have to use the set Gravity command, because my terrain is going to be a sphere instead of flat.. But that's in the future.

Bonks,

Make sure you set your inertia tensor properly.

If using a Cube RB at 1,1,1 with a mass of 20

TOKRB_SetBoxInertiaTensor(RB,1,1,1,20)

And Also Properly set the LinearDampening to a value that gives a good feel. Too high a value will make your RB seem like it's in glue.

Regards,
Eric


Bot Builder(Posted 2004) [#158]
As far as how materials work in my terrain mesh stuff, I decided it was easiest to assign by texture, so areas that looked like dirt would have some different properties than grass areas. Of course, its not foolproof. You can also set the material of a particular mesh or a default material for a particular mesh in the case that there is no material for a texture.

Const GroundMat = 0
Const WallMat = 1
toksim_SetMaterial GroundMat,0.8,0.01 
toksim_SetMaterial WallMat,0.2,0.8

TOK_SetTextureMaterial("Ground.jpg",GroundMat)
TOK_SetTextureMaterial("Wall1.png",WallMat)
TOK_SetTextureMaterial("Wall2.png",WallMat)

TOK_AddMesh LoadMesh("Level.3ds")
TOK_SetMesh



Eric(Posted 2004) [#159]
Ok I will play more with this when I get home, Thanks.

Eric


Picklesworth(Posted 2004) [#160]
Botbuilder, where can I get those functions?


Eric(Posted 2004) [#161]
Bot I hope you don't mind...



Mr. Picklesworth
These Functions are in the Documents for tokamak




bradford6(Posted 2004) [#162]
BOT,
I like the Tokamak intro thingy. very nice job with that.


skidracer(Posted 2004) [#163]
continued here:

www.blitzbasic.com/Community/posts.php?topic=36626