Tokamak Physics

Blitz3D Forums/Blitz3D Programming/Tokamak Physics

bradford6(Posted 2004) [#1]
Who wants to create a DLL or link from Blitz-3d to TOKAMAK

www.tokamakphysics.com


UPDATE:
1/19/2004
Sweenie took the challenge and produced a DLL in 6 days.
scroll down to download his creation...


Gabriel(Posted 2004) [#2]
I thought someone already started work on adapting this for Blitz?


bradford6(Posted 2004) [#3]
cool.

I think that if either Mark or the creator of Tokamak creates a top-quality DLL for Blitz, Sales would go through the roof.

Half-Life II's ace in the hole is Havok

Blitz-3D's could be a professional and stable implementaion of Tokamak Physics.

Darkbasic does not have anything like this, but I understand someone is working on it.


Gabriel(Posted 2004) [#4]
I hope I'm not getting anyone's hopes up unnecessarily, but I seriously think this should be a BlitzMax module. The whole point of BlitzMax is to have a plug-in module-based architecture, and this would fit the bill perfectly.

As for Blitz3d, the present, I found the worklog with the Tokamak wrapper :

http://www.blitzbasic.com/logs/userlog.php?user=285


poopla(Posted 2004) [#5]
Looks cool, all I can say till theres a functional demo.


Sweenie(Posted 2004) [#6]
I really want to release a preview of Tokamak and Blitz in action but the license issue is very unclear right now.

One of the Tokamakstaff says in the forum that a wrapper can be made to get Tokamak working with Blitz.(That is what i'm doing right now)
Another one of the Tokamakstaff says that if I make the wrapper it may only be available as a download on their site so that they don't have to "compete" with their own physicsengine.
But the thing is, my wrapper is useless without their physicsDLL so I don't see how it could compete with it.


Beaker(Posted 2004) [#7]
That sounds like baloney. Your wrapper is written by you so you should be able to do what you like with it. If a user then downloads your wrapper and the physicsDLL (from different places) and runs the two together, that isn't your issue.

Of course, you may want the free publicity generated by putting your wrapper on their site. :)


Ricky Smith(Posted 2004) [#8]

I seriously think this should be a BlitzMax module



BlitzMax does not exist !
We need a physics library for Blitz3d which does exist !


RayTracer(Posted 2004) [#9]
totally agree with smiff

i think that the licence thing is bull, it's in their best intrest to make this wrapper , they would get their work distributed,the library is free anyway


darklordz(Posted 2004) [#10]
[silly me]


bradford6(Posted 2004) [#11]
tokamak v1 license.

"We are pleased to announce the release of a new license agreement for the Tokamak Game Physics SDK. You can now use Tokamak for Commercial and Non-commercial purposes FREE!

more detail...

1) The LICENSEE may not redistribute the SOFTWARE, except as part of a compiled software program that is not itself a physics library.

2) The LICENSEE may not use the SOFTWARE to reverse engineer the computer algorithm used by the SOFTWARE.

3) The LICENSEE agrees to credit the use of the Tokamak physics library in any program information, including splash screens, "About" dialogs, program notes or instructions and shrink-wrapped packaging.

4) The LICENSEE agrees to notify Tokamak Physics (the Company) of any products, commercial, shareware or free that incorporate the Tokamak library.

5) The LICENSEE agrees that the Company can refer to any such product as described in item (4) in its promotional material or press releases unless a specific agreement is made with the Company prior to its usage.


Koriolis(Posted 2004) [#12]
Another one of the Tokamakstaff says that if I make the wrapper it may only be available as a download on their site so that they don't have to "compete" with their own physicsengine.
Point (1) above clearly shows that you can distribute yourself the wrapper as long as you don't include the tokamak DLL (or any part of the tokamak SDK) itself in your distribution. The wrapper should come in the form of an additional DLL that sits between blitz and the tokamak DLL.


bradford6(Posted 2004) [#13]
I think Tokamak would benefit greatly by this (and so would blitz)

Blitz-3d collisions are good. Mark has done a good job with them. some may argue that it is the responsibility of the programmer to come up with the physics.

If Blitz had a high-quality wrapper to Tokamak, the sheer quality of the demos would increase and improve the sales of Blitz

Darkbasic don't do physics.


Gabriel(Posted 2004) [#14]
BlitzMax does not exist !
We need a physics library for Blitz3d which does exist !


Nice of you to selectively quote me, missing out the part where I said we needed this in Blitz3d for the present too. Thanks.

Of course we need it now. I just think it should be integrated in the future so that we don't have to rely on the efforts of users to add something which is fast becoming core functionality of any game language. Particularly when something of this quality is available for free and with considerably less work than writing your own system from scratch.


BlitzSupport(Posted 2004) [#15]
I *imagine* (I don't actually speak for Mark in saying this) that for Blitz 3D in the near future this will be a case of relying on a wrapper like Sweeney's (which sounds as if it should be perfectly good anyway), as Mark is working very hard on Blitz Max (which, in passing, should make it much easier to integrate stuff like this!).


One of the Tokamakstaff says in the forum that a wrapper can be made to get Tokamak working with Blitz.(That is what i'm doing right now)
Another one of the Tokamakstaff says that if I make the wrapper it may only be available as a download on their site so that they don't have to "compete" with their own physicsengine.


Have you tried emailing them directly [ info@... ] explaining exactly what you want to put out, under what terms (ie. freeware/shareware/whatever), and so on? Might be worthwhile giving it a go if not.


bradford6(Posted 2004) [#16]
3) The LICENSEE agrees to credit the use of the Tokamak physics library in any program information, including splash screens, "About" dialogs, program notes or instructions and shrink-wrapped packaging.


I don't mind putting a "Tokamak Inside" logo on any thing i use Tokamak with. I'll even tattoo it on my arse if need be.


LostCargo(Posted 2004) [#17]
no doubt. i agree. id get the tattoo if i could get my hands on the dll with blitz


Tom(Posted 2004) [#18]
Sweenie, any chance of an AVI demo in the meantime? :)

Tom


StOrM3(Posted 2004) [#19]
yes, I am ready to see this wrapper for blitz.. This is going to be great. I also wouldn't mind putting a Tokamak logo in anything I write.

We are definitely making a giant step forward here.


Bot Builder(Posted 2004) [#20]
Yeah. Would it be legal for mark to include tokomak along with future releases of blitz?

this would be awesome.


bradford6(Posted 2004) [#21]
Just as it is legal to include QuakeIII bsp funcionality, I think including Tokamak 'hooks' inside blitz would be perfectly legal.

Anyone releasing a game/demo with tokamak functionality would be required to mention tokamak in a splash screen, readme, whatever.

a seperate DLL or plugin that brings the Tokamak functionality to blitz would GREATLY benefit both parties

Blitz-3d would benefit by improving the quality of user-released games, demos and applications

Tokamak would benefit because everyone who uses blitz + Tokamak would be required to mention Tokamak and visit their site for the documentation (where you can see the status of Tokamak 2)

If a small percentage of us wanted to step up to Tokamak 2 when it is released (and maybe license it for a commercial release) We'll be familiar with the architecture.

win/win!


BlitzSupport(Posted 2004) [#22]
It would be cool, but it's not part of their license that it's OK for people to release demos that say "made with Tokamak"... whether it would be legal or not isn't that relevant, especially these days -- unfortunately, what's relevent is whether you want to pay to defend yourself from a lawsuit or not (whether it's Mark or Sweeney); the outcome isn't really the point since you have to pay a sh!tload to defend youself in the first place!

Really, let Sweeney see what they have to say (I agree that it's in everyone's interests for the Tokamak guys to OK it, even if they say you have to acknowledge publicly that your program uses Tokamak)...


Sweenie(Posted 2004) [#23]
Ok, It's a go. :)
Creating a WrapperDLL in between Blitz3D and the Tokamak.DLL won't break the license as long as you download the actual Tokamak.DLL from their site.

Somehow they must have misunderstood me and thought that I wanted to create a DLL directly using the Tokamak.lib and that would have break the license.

Question is: I can't distribute the Tokamak.DLL to YOU, instead you'll have to download it.
Can YOU distribute it to the end-users of the application using tokamak or do they have to download it as well?

If it turns out that you can't, perhaps the tokamak team will agree to make some kind of runtime libraries setup package, to make it easier for end-users to install it.
I doubt many end-user can extract a dll from a SDK.


Difference(Posted 2004) [#24]
Question is, does that mean that if You want to release for example a simple shareware app using Tokamak, you can't include the tokamak.dll but instead you'll have to tell the end-user to download it?


According to the licence quoted above you can. You just need to tell them that you did.


Sweenie(Posted 2004) [#25]
So it's only me, the developer of the wrapper that may not distribute the tokamak.dll?

[Edit]
Ah, of course it is. Silly me!
I think i've got it now.
You download the tokamak.dll from their website which you can freely distribute to the end-users as long as you give credit to the Tokamakteam.
My role in this is simply providing a wrapper so that you can link it in with Blitz.


Gabriel(Posted 2004) [#26]
The key part is :

The LICENSEE may not redistribute the SOFTWARE, except as part of a compiled software program that is not itself a physics library.


You have to point us to their site for their dll to go with your userlib because your compiled software program is a physics library.

We can distribute freely because our compiled software program is NOT a physics library.

It looks all good.


Ricky Smith(Posted 2004) [#27]

Nice of you to selectively quote me, missing out the part where I said we needed this in Blitz3d for the present too. Thanks.


My most humble apologies.


bradford6(Posted 2004) [#28]
some useful stuff.

with blitz, it would be nice to create a function that shows a quick TOKAMAK INSIDE splash screen with the official TOKAMAK logo. this would clear 99% of us and satisfy the license.


LostCargo(Posted 2004) [#29]
so sweenie hows the wrapper going? is it getting close?


bradford6(Posted 2004) [#30]
I am looking forward to testing this.

Sweenie,
If you want someone to test it for you and give you feedback, let me know.


RayTracer(Posted 2004) [#31]
This is going to be awesome ,keep us posted Sweenie


jhocking(Posted 2004) [#32]
Hoo hoo, I'ld love to test this for you too. Vorderman's ODE dll was awesome until I realized it was unstable in new versions of Blitz. A new physics plugin will be very useful indeed.


LostCargo(Posted 2004) [#33]
jhocking. i noticed the same thing with ode. it was cool to use and play with though.


Sweenie(Posted 2004) [#34]
Because of the total lack of interest i've decided to dump the project.......



NOT! ;p

Just give me a little more time(a couple of days) to add some more functions and clean it up a little.


jhocking(Posted 2004) [#35]
"i've decided to dump the project......."

You trying to give me a heart attack?


BlitzSupport(Posted 2004) [#36]
Looking forward to seeing this too!


Paul "Taiphoz"(Posted 2004) [#37]
Helll yeah am I looking forward to this. I have a game im gona make that the Box physics will be sweet for. so roll it out m8y..


Sweenie(Posted 2004) [#38]
Last night I've wanted to know if Tokamak was stable and doesn't leak memory and such, so I left the simulator running over night with 500 rigidbodies(50% Cubes, 50% Spheres) and applied an impulse(tossed them up in the air) every 5 seconds to keep the bodies in constant motion.
When I checked this morning the simulator had run for 8 hours and was still running.
The available systemmemory had shrunk with approx. 1500 bytes and those bytes was probably caused by the OS.
I also checked the blitzprocess and the memoryusage hadn't budged an inch(or byte).

This probably isn't a good way to test stability but it shows that it copes well with blitz, at least on my computer ;)


bradford6(Posted 2004) [#39]
very cool. I like stability, it is more important than features. that is why we like blitz better than DB-Pro.

Once you get it stable, I will write a tutorial.


LostCargo(Posted 2004) [#40]
i feel like a kid waiting on christmas eve with all this talk of a release and a tutorial.

I'm actually salivating at the thought of yet another new physics package for blitz to try out and play around with.


bradford6(Posted 2004) [#41]
ahh, don't get squishy on us kid...


RayTracer(Posted 2004) [#42]
same here :)


DarkEagle(Posted 2004) [#43]
i really cant wait for this, those samples that you can download rock, inparticular the bodies falling down stairs! all this will be available in blitz right?


Paul "Taiphoz"(Posted 2004) [#44]
/me also cant wait for this.


Sweenie(Posted 2004) [#45]
I'm starting to feel like a nervous newbie actor who is about to enter a stage for the first time knowing that there is a big crowd outside expecting a good performance. :)

If the wrapper becomes a big failure I will change my nick to something like John Smith and deny any knowledge about tokamak..... uh, tokaWhat?


bradford6(Posted 2004) [#46]
don't feel pressure. this is all just fun for us.


Bouncer(Posted 2004) [#47]
I'm also very keen on seeing this happen... hurry up Sweenie :) don't take any pressure :)


bradford6(Posted 2004) [#48]
What will be the most interesting is to see some of the unique and creative uses of physics that will come out of this.

please, not another FPS...

Games which require the use of physics to solve problems are the most fun.

using this tool to create Yet Another Ragdoll Enemy (YARE) in Yet Another First Person Shooter (YAPFS) would S.U.C.K


Tangent(Posted 2004) [#49]
Heh. Ragdolls are fun.
HAd a game idea a while ago that was based around a ragdoll.
The character was a mob bosses nefew, and was given a job disposing of bodies.
Each level is basically the player attempting to get the body from point a to point b without being seen by the general populance. The corpse was going to be the narrator for the game, just for comedies sake.
I'm planningon using it for objects you can pick up and drop, or knock around, in the game I'm working on now. Fairly simple stuff.

Physics puzzles are a little hard to do, due to the chances of something going seriously wrong.


Gabriel(Posted 2004) [#50]
In generak terms though, it's a good point that Bill makes. Physics for the sake of physics is crap. Trespasser had physics for the sake of physics and is one of the most boring games I've ever played. Deus Ex 2 has physics for the sake of physics and they actually detract from what would otherwise be a not particularly good, ok-ish kinda game.


Tom(Posted 2004) [#51]
YAPWAFPSGs suck worse! :)

(Yet Another Person Whining About FPS Games)

in good spirit!
Tom


jhocking(Posted 2004) [#52]
"Stay on target."


bradford6(Posted 2004) [#53]
I love FPS games. I can't wait for HL2 and DOOM3.

With a general purpose tool like Blitz in the hands of the creative people on this forum, another FPS just seems like a waste of resources. There are excellent tools out there for creating FPS games. Mods , SDK's and FPS Game engines are everywhere. Blitz's strength is in it's flexibility. what it gives up as a result of that flexibility is genre specificity.

Blitz does not do FPS terribly well compared to the hundreds of engines and GDK's out there that do.

people are going to do an FPS anyway with blitz and that is great.
My comment was to urge people to think a little more and come up with something unique.

anyway to " stay on target"


================================================

Sweenie,
How's that wrapper coming...no pressure ;)


Bot Builder(Posted 2004) [#54]
well, Sweenie, If you get stuck you could always just release what you've got and have the community work on it.

[edit] Infact, why not let the community have at it right now? Basically, Post current problems/ etc. up along with code and then other people could solve the problems and combine various solutions to eventually get it working nicely.


Sweenie(Posted 2004) [#55]
Infact, why not let the community have at it right now?


Yep, I've decided to release what i've got so far.
Still working on the joints though.

But I've got a problem... I don't have anywhere to host my wrapper. Eventually I was gonna get me a website at b-one.net but i'm a little low on cash right now.

I could also need some help with deciding a good namestandard for the functions.

I found out last night that there exist a sliderjoint(useful for springs and dampers), a ballsocket2 joint(no idea what it does) and the motorjoint(can be seen in one of the demos).
It's hard to tell if they are fully implemented but there are several other functions that works that aren't mentioned in the documentation.

Tokamak seems to have more features than I first thought.


Bot Builder(Posted 2004) [#56]
I found out last night that there exist a sliderjoint(useful for springs and dampers), a ballsocket2 joint(no idea what it does) and the motorjoint(can be seen in one of the demos).
It's hard to tell if they are fully implemented but there are several other functions that works that aren't mentioned in the documentation.

Sounds very cool!

I would gladly host it for you. email it to me at:

bot_builder56 at fastmail.fm

replacing the at with an @ and taking out the spaces :)

[edit] O and BTW you can get host space for free off www.250free.com (250 MB) although their speed sux and they have banners. OR/AND you can do www.freewebs.com who are nice/fast no banners just tiny strip at the bottom. I use 250 free for images and freewebs for my actual website.


Tracer(Posted 2004) [#57]
same here, just mail it to me at:

tracer(at)darkeffect.com

the (at) = @

Tracer


Beaker(Posted 2004) [#58]
I can host it, and if you want a forum (temp or otherwise) for it, I can put one here:
http://playerfactory.proboards25.com/

How about TOK_ for the naming?


DarkEagle(Posted 2004) [#59]
oh oh oh! i want i want! :D cant wait to get my hands on this! hope theres some samples etc... really looking forward to the ragdoll stuff too, been waiting for an easy way to do ragdoll physics for ages! this is just the ticket :)


Sweenie(Posted 2004) [#60]
Thanks for your offers, but I think I will go for the freewebs alternative that botbuilder suggested for now.
That way I can quickly update the wrapper and so on.

@MasterBeaker:
A forum would be great. Does the offer remain even if I choose to host the wrapper elsewhere?


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

I will release the wrapper tonight, but I can't promise that the joints will be implemented.
If I get enough time, maybe the balljoint will be.

I'm currently renovating my livingroom so I only get a couple of hours before bedtime to work on the wrapper.
I overslept today and came to work 40 minutes to late.
I couldn't tell my boss that it was because I stayed up all night coding a wrapper so I blamed it on the snow that came last night, perfect timing ;) hehe.


LostCargo(Posted 2004) [#62]
lol.


oh btw everyone if you havent seen the site:
Coming in 2004 - Tokamak version 2!


Sweenie, do you think there will be much difference in how the physics engine works? and will you / the community need to rebuild the wrapper?


Beaker(Posted 2004) [#63]
A forum would be great. Does the offer remain even if I choose to host the wrapper elsewhere?

Of course. Consider it done (because it is already ;P):
http://playerfactory.proboards25.com
..in programming section.

Sweenie, you need to register so I can give you mod rights.


Bot Builder(Posted 2004) [#64]
lol. and then someone registers as 'sweenie'... just kidding


DarkEagle(Posted 2004) [#65]
code faster already :D

hehe j/k ;)


RayTracer(Posted 2004) [#66]
we're all waiting :))


Sweenie(Posted 2004) [#67]
Ok, here it is...
http://www.freewebs.com/sweenie/
*drops the package and starts running like a maniac*

@DarkEagle:
Something went wrong when I registered(got a timeout or something) and now I can't register because it says that the username Sweenie is already taken.


LostCargo(Posted 2004) [#68]
Baudspeed pauses for a moment. Asks himself why the 'intrepid hero of the physics loving masses', known as sweenie is running. Then wanders over to inspect the package.

lol


RayTracer(Posted 2004) [#69]
Superb work sweenie


RetroBooster(Posted 2004) [#70]
Excellent sweenie, looking forward to seeing more of this, I will most likely be adding support for it in my engine!


bradford6(Posted 2004) [#71]
SWEENIE!!!!

You are the MAC DADDY!

I just fired up your 2 demos and I am thoroughly impressed.
when I get home tonight, I will play with them and work on a tutorial.

Great Work!!!


fredborg(Posted 2004) [#72]
This rocks! It's going to be fun playing with this!

Great work Sweenie!


Caff(Posted 2004) [#73]
Nice one sweenie, all works so far... don't run off yet! You need to explain it to us!


Gabriel(Posted 2004) [#74]
Holy crap, am I reading the times right? That's fffffffffast!!


Bot Builder(Posted 2004) [#75]
Holy crap, am I reading the times right? That's fffffffffast!!
Yep. It's awesome. as fast as andreas_blixt's 2d engine (which is extremly fast aswell) but this is 3d :)

Oh yeah, and your using pretty much the same template as me :) great minds think alike www.freewebs.com/botbuilder/


Beaker(Posted 2004) [#76]
Sweenie - you are now a mod on your forum. Might be worth putting a link to the forum from your site.


JoshK(Posted 2004) [#77]
If you get the boxes to collide with polygon maps, this will be very useful.


BlitzSupport(Posted 2004) [#78]
Thanks, Sweenie!


DarkEagle(Posted 2004) [#79]
can i have your babies now :D


bradford6(Posted 2004) [#80]
this simply adds:
1. camera navigation (WASD keys and Mouselook)
2. textures for the objects

i have had only a few minutes to mess with this but I am very impressed.

Great Work Sweenie!

since TOKAMAK is doing all the heavy lifting, this demo is FAST. try upping the # of ENTS!!!

;# TOKAMAK DEMO v1 (bradford6)
; Credits:
; SWEENIE for creating the TOKAMAK WRAPPER
; www.tokamakphysics.com to get SDK
; note:
; you must put TOKAMAK.DLL (from SDK) in system32
; must put sweenies tokamak files in blitz3d/userlibs directory




Const FPS=50
Const w=17, s=31, a=30, d=32, space=57

Global latspeed#,speed#,MX#,MY#

Graphics3D 800,600,0,2
SetBuffer BackBuffer()

WireFrame False

Const ENTS=75

Global campiv = CreatePivot()
Global camera = CreateCamera(campiv)
CameraClsColor(camera,20,20,205)


CreateSimulator(ENTS,5,0,-10,0)



ground = CreateCube()
EntityColor ground,55,55,55 
ScaleEntity ground,50,5,50 
PositionEntity ground,0,-5,0
abground = CreateAB()
ABAddBox(abground,100.0,10.0,100.0)
ABSetPosition(abground,0.0,-5.0,0.0)

wall1 = CreateCube()
EntityColor wall1,25,25,55 
ScaleEntity wall1,2,10,50 
PositionEntity wall1,50,0,0
abwall1 = CreateAB()
ABAddBox(abwall1,4.0,20.0,100.0)
ABSetPosition(abwall1,50.0,0,0.0)

wall2 = CreateCube()
EntityColor wall2,25,25,55 
ScaleEntity wall2,2,10,50 
PositionEntity wall2,-50,0,0
abwall2 = CreateAB()
ABAddBox(abwall2,4.0,20.0,100.0)
ABSetPosition(abwall2,-50.0,0,0.0)

wall3 = CreateCube()
EntityColor wall3,25,25,55 
ScaleEntity wall3,50,10,2 
PositionEntity wall3,0,0,-50
abwall3 = CreateAB()
ABAddBox(abwall3,100.0,20.0,4.0)
ABSetPosition(abwall3,0.0,0,-50.0)

wall4 = CreateCube()
EntityColor wall4,25,25,55 
ScaleEntity wall4,50,10,2 
PositionEntity wall4,0,0,50
abwall4 = CreateAB()
ABAddBox(abwall4,100.0,20.0,4.0)
ABSetPosition(abwall4,0.0,0,50.0)


Dim obj(ENTS)
Dim rb(ENTS)

SeedRnd MilliSecs()  

; go and create a generic checkerboard texture to apply to the objects
cubetex = create_cube_texture()
spheretex = create_sphere_texture()
cyltex = create_cyl_texture()
For i=1 To ENTS
rot#=rot#+8.2
x#=Cos(rot)*20
z#=Sin(rot)*20

height_var# = .7
 ; change the line below to 1,3 to include "cylinders".
 ; I render them as cylinders but the rigidbody is really a capsule, so
 ; the bodies will behave like capsules and not like cylinders.
 nr=Rnd(1,3)		
 If nr=1 Then
  obj(i) = CreateCube()
	EntityTexture obj(i),cubetex
  rb(i) = CreateRB()
  RBAddBox rb(i),2.0,2.0,2.0
  RBSetPosition(rb(i),x#,i*height_var#,z#)
  RBSetLinearDamping rb(i),0.001
  RBSetMass rb(i),2.0
  RBSetBoxInertiaTensor rb(i),2.0,2.0,2.0,2.0  
 ElseIf nr=2 ; CREATE Sphere objects
  obj(i) = CreateSphere()
		EntityTexture obj(i),spheretex

  rb(i) = CreateRB()
  RBAddSphere rb(i),1.8
  RBSetPosition(rb(i),x#,i*height_var#,z#)
  RBSetAngularDamping rb(i),0.02 
  RBSetLinearDamping rb(i),0.001 
  RBSetMass rb(i),2.0
  RBSetSphereInertiaTensor rb(i),2.0,1.8  
 ElseIf nr=3 ; CREATE CYLINDERS actually Capsules or elongated spheres
  obj(i) = CreateCylinder()
								EntityTexture obj(i),cyltex
  rb(i) = CreateRB()
  RBAddCylinder rb(i),2.0,1.0
  RBSetPosition(rb(i),x#,i*height_var#,z#)
  RBSetAngularDamping rb(i),0.02 
  RBSetLinearDamping rb(i),0.001 
  RBSetMass rb(i),2.0
  RBSetCylinderInertiaTensor rb(i),2.0,1.0,2.0  
 EndIf

 EntityColor obj(i),Rnd(100,230),Rnd(100,230),Rnd(100,230) 

Next

Centerpivot = CreatePivot()

light=CreateLight()
PositionEntity light,7,15,-5
PointEntity light,Centerpivot

rot#=0

period=1000/FPS
time=MilliSecs()-period

imptime=MilliSecs()

camx#=Cos(rot#)*50
camz#=Sin(rot#)*50

;rot#=rot#+0.05

If rot#>360 Then rot#=0

PositionEntity campiv,camx#,40,camz#
PointEntity campiv,centerpivot  


; +++ MAIN LOOP START ++++++ MAIN LOOP START ++++++ MAIN LOOP START ++++++ MAIN LOOP START +++
While Not KeyHit(1)

	Repeat
		elapsed=MilliSecs()-time
	Until elapsed

	ticks=elapsed/period
	tween#=Float(elapsed Mod period)/Float(period)

	For k=1 To ticks
		time=time+period
		If k=ticks Then CaptureWorld

		Advance(1.5/FPS)

move_camera()

	UpdateWorld

	Next

; Not sure wether to put this here or inside the for/next above...
For i=1 To ENTS
 If RBIsIdle(rb(i)) Then
  EntityAlpha obj(i),0.5
 Else
  EntityAlpha obj(i),1.0
 EndIf

 PositionEntity obj(i),RBGetX#(rb(i)),RBGetY#(rb(i)),RBGetZ#(rb(i)) 
 RotateEntity obj(i),RBGetPitch#(rb(i)),RBGetYaw#(rb(i)),RBGetRoll#(rb(i)),False
Next



If KeyHit(57) Then
 i=Rnd(1,ENTS) 
 RBApplyImpulse rb(i),Rnd(-3.0,3.0),Rnd(15,30),Rnd(-3.0,3.0) 
EndIf

RenderWorld tween

Text 0,0,"Physics Time:"+GetPhysicsTime()*1000.0+ " milliseconds"
Text 0,10,"Render Time:"+Str(elapsed)+ " milliseconds"
	Flip False

Wend

; == MAIN LOOP END ==== MAIN LOOP End ==== MAIN LOOP End ==== MAIN LOOP End ==== MAIN LOOP End ==


DestroySimulator()

End

;==================================================================================
Function curvevalue#(newvalue#,oldvalue#,increments# )
	If increments>1 Then oldvalue#=oldvalue#-(oldvalue#-newvalue#)/increments
	If increments<=1 Then oldvalue=newvalue
	Return oldvalue#
End Function
;==================================================================================
Function move_camera()
	; Movement controls
	If KeyDown(w)=1 Then speed# = speed#+.03
	If KeyDown(a)=1 Then latspeed# = latspeed# - .02
	If KeyDown(s)=1 Then speed# = speed# -.03
	If KeyDown(d)=1 Then latspeed# = latspeed# + .02

latspeed#=latspeed#*.98
speed#=speed#*.98

MY#=curvevalue#(MouseYSpeed(),MY#,3 )
MX#=curvevalue#(MouseXSpeed(),MX#,3 )
TurnEntity campiv,MY#,-MX#,0 ; turn camera up and down
;TurnEntity campiv,0,-MX#,0 ;  turn nnn left --right
RotateEntity campiv,EntityPitch(campiv),EntityYaw(campiv),0

MoveMouse 100,100

MoveEntity campiv,latspeed#,0,speed#
	


End Function
;==================================================================================
Function create_cube_texture()
	tex = CreateTexture(128,128)
	SetBuffer TextureBuffer(tex)
		Color 255,255,0
		Rect 0,0,128,128
		Color 0,0,255
		Rect 0,0,64,64
		Rect 64,64,128,128
	SetBuffer BackBuffer()
	Return tex
	
End Function
;==================================================================================
Function create_sphere_texture()
	tex = CreateTexture(128,128)
	SetBuffer TextureBuffer(tex)
		Color 0,200,0
		Rect 0,0,128,128
		Color 255,255,0
		Rect 0,0,64,64
		Rect 64,64,128,128
	SetBuffer BackBuffer()
	Return tex

	
End Function

;==================================================================================
Function create_cyl_texture()
	tex = CreateTexture(128,128)
	SetBuffer TextureBuffer(tex)
		Color 0,0,0
		Rect 0,0,128,128
		Color 255,0,0
		Rect 0,0,64,64
		Rect 64,64,128,128
	SetBuffer BackBuffer()
	Color 255,255,0 ; YELLOW
	Return tex

	
End Function

;==================================================================================

;==================================================================================





jfk EO-11110(Posted 2004) [#81]
here is it again, the blitz spirit :) thank you

.very
goto very

much!!!


LostCargo(Posted 2004) [#82]
three letters W 0 W

this is gonna be shaweeet


bradford6(Posted 2004) [#83]
here is another one

WASD to move
mouselook

mousedown to 'shoot' cubes in your crosshair

;# TOKAMAK DEMO v2 (bradford6)
; Credits:
; SWEENIE for creating the TOKAMAK WRAPPER
; www.tokamakphysics.com to get SDK
; note:
; you must put TOKAMAK.DLL (from SDK) in system32
; must put sweenies tokamak files in blitz3d/userlibs directory




Const FPS=50
Const w=17, s=31, a=30, d=32, space=57

Global latspeed#,speed#,MX#,MY#

Graphics3D 800,600,0,2
Global midw = GraphicsWidth()/2
Global midh =GraphicsHeight()/2
SetBuffer BackBuffer()
HidePointer 
WireFrame False

Const ENTS=60

Global campiv = CreatePivot()
Global camera = CreateCamera(campiv)
Global pictentity 
CameraClsColor(camera,20,20,205)


CreateSimulator(ENTS,5,0,-10,0)



ground = CreateCube()
EntityColor ground,55,55,55 
ScaleEntity ground,50,5,50 
PositionEntity ground,0,-5,0
abground = CreateAB()
ABAddBox(abground,100.0,10.0,100.0)
ABSetPosition(abground,0.0,-5.0,0.0)

wall1 = CreateCube()
EntityColor wall1,25,25,55 
ScaleEntity wall1,2,10,50 
PositionEntity wall1,50,0,0
abwall1 = CreateAB()
ABAddBox(abwall1,4.0,20.0,100.0)
ABSetPosition(abwall1,50.0,0,0.0)

wall2 = CreateCube()
EntityColor wall2,25,25,55 
ScaleEntity wall2,2,10,50 
PositionEntity wall2,-50,0,0
abwall2 = CreateAB()
ABAddBox(abwall2,4.0,20.0,100.0)
ABSetPosition(abwall2,-50.0,0,0.0)

wall3 = CreateCube()
EntityColor wall3,25,25,55 
ScaleEntity wall3,50,10,2 
PositionEntity wall3,0,0,-50
abwall3 = CreateAB()
ABAddBox(abwall3,100.0,20.0,4.0)
ABSetPosition(abwall3,0.0,0,-50.0)

wall4 = CreateCube()
EntityColor wall4,25,25,55 
ScaleEntity wall4,50,10,2 
PositionEntity wall4,0,0,50
abwall4 = CreateAB()
ABAddBox(abwall4,100.0,20.0,4.0)
ABSetPosition(abwall4,0.0,0,50.0)


Dim obj(ENTS)
Dim rb(ENTS)

SeedRnd MilliSecs()  

; go and create a generic checkerboard texture to apply to the objects
cubetex = create_cube_texture()
spheretex = create_sphere_texture()
cyltex = create_cyl_texture()

; add--------------------------------------------------------------------------
entcount = 0
height_var#=1.5
For i=1 To ENTS
	count = count + 1
			
	zpos# = count*2
	If count>10
		height_var# = height_var# + 2
		count = 0
	EndIf
	 
	obj(i) = CreateCube()
	EntityPickMode obj(i),2
	EntityTexture obj(i),cubetex
	rb(i) = CreateRB()
	RBAddBox rb(i),2.0,2.0,2.0
	RBSetPosition(rb(i),x#,height_var#,zpos#)
	RBSetLinearDamping rb(i),0.001
	RBSetMass rb(i),2.0
	RBSetBoxInertiaTensor rb(i),2.0,2.0,2.0,2.0  
	
	
	 
Next

; add--------------------------------------------------------------------------

Centerpivot = CreatePivot()

light=CreateLight()
PositionEntity light,7,15,-5
PointEntity light,Centerpivot

rot#=0

period=1000/FPS
time=MilliSecs()-period

imptime=MilliSecs()

camx#=Cos(rot#)*50
camz#=Sin(rot#)*50

;rot#=rot#+0.05

If rot#>360 Then rot#=0

PositionEntity campiv,camx#,40,camz#
PointEntity campiv,centerpivot  


; +++ MAIN LOOP START ++++++ MAIN LOOP START ++++++ MAIN LOOP START ++++++ MAIN LOOP START +++
While Not KeyHit(1)

	Repeat
		elapsed=MilliSecs()-time
	Until elapsed

	ticks=elapsed/period
	tween#=Float(elapsed Mod period)/Float(period)

	For k=1 To ticks
		time=time+period
		If k=ticks Then CaptureWorld

		Advance(1.5/FPS)

move_camera()

	UpdateWorld

	Next

; Not sure wether to put this here or inside the for/next above...
For i=1 To ENTS
 If RBIsIdle(rb(i)) Then
  ;aEntityAlpha obj(i),0.2
 Else
  EntityAlpha obj(i),1.0
 EndIf

 PositionEntity obj(i),RBGetX#(rb(i)),RBGetY#(rb(i)),RBGetZ#(rb(i)) 
 RotateEntity obj(i),RBGetPitch#(rb(i)),RBGetYaw#(rb(i)),RBGetRoll#(rb(i)),False
Next



If MouseDown(1) Then shoot_cannon()

RenderWorld tween

Text 0,0,"Physics Time:"+GetPhysicsTime()*1000.0+ " milliseconds"
Text 0,10,"Render Time:"+Str(elapsed)+ " milliseconds"
Color 255,0,0
Rect midw-4,midh-4,8,8,0
	Flip False

Wend

; == MAIN LOOP END ==== MAIN LOOP End ==== MAIN LOOP End ==== MAIN LOOP End ==== MAIN LOOP End ==


DestroySimulator()

End

;==================================================================================
Function curvevalue#(newvalue#,oldvalue#,increments# )
	If increments>1 Then oldvalue#=oldvalue#-(oldvalue#-newvalue#)/increments
	If increments<=1 Then oldvalue=newvalue
	Return oldvalue#
End Function
;==================================================================================
Function move_camera()
	; Movement controls
	If KeyDown(w)=1 Then speed# = speed#+.03
	If KeyDown(a)=1 Then latspeed# = latspeed# - .02
	If KeyDown(s)=1 Then speed# = speed# -.03
	If KeyDown(d)=1 Then latspeed# = latspeed# + .02

latspeed#=latspeed#*.98
speed#=speed#*.98

MY#=curvevalue#(MouseYSpeed(),MY#,3 )
MX#=curvevalue#(MouseXSpeed(),MX#,3 )
TurnEntity campiv,MY#,-MX#,0 ; turn camera up and down
;TurnEntity campiv,0,-MX#,0 ;  turn nnn left --right
RotateEntity campiv,EntityPitch(campiv),EntityYaw(campiv),0

MoveMouse 100,100

MoveEntity campiv,latspeed#,0,speed#
	


End Function
;==================================================================================
Function create_cube_texture()
	tex = CreateTexture(128,128)
	SetBuffer TextureBuffer(tex)
		Color 255,255,0
		Rect 0,0,128,128
		Color 0,0,255
		Rect 0,0,64,64
		Rect 64,64,128,128
	SetBuffer BackBuffer()
	Return tex
	
End Function
;==================================================================================
Function create_sphere_texture()
	tex = CreateTexture(128,128)
	SetBuffer TextureBuffer(tex)
		Color 0,200,0
		Rect 0,0,128,128
		Color 255,255,0
		Rect 0,0,64,64
		Rect 64,64,128,128
	SetBuffer BackBuffer()
	Return tex

	
End Function

;==================================================================================
Function create_cyl_texture()
	tex = CreateTexture(128,128)
	SetBuffer TextureBuffer(tex)
		Color 0,0,0
		Rect 0,0,128,128
		Color 255,0,0
		Rect 0,0,64,64
		Rect 64,64,128,128
	SetBuffer BackBuffer()
	Color 255,255,0 ; YELLOW
	Return tex

	
End Function

;==================================================================================
Function campick()
	CameraPick(camera,midw,midh)
	If PickedEntity()<>0
	pictentity = PickedEntity() 
	EntityAlpha pictentity,.7	
		
	
	EndIf
	

End Function
;==================================================================================

Function shoot_cannon()
		
		campick()
	 	For n = 1 To ENTS
			If pictentity = obj(n)
				i = n
			EndIf
		Next
		
 		RBApplyImpulse rb(i),Rnd(0.1,-6.0),Rnd(2,8),Rnd(-1.1,-5.1) 
	

End Function




Bot Builder(Posted 2004) [#84]
jeez. I turned off rendering, and put ents at 1200! only 14 milliseconds! most of the time is spent rendering. if I put it at 500, then its about 7 milliseconds physics, 50 rendering. And thats if I lower the spheres and cylinders down to bare minimum segments(8).


bradford6(Posted 2004) [#85]
heres another before I go to bed:

WASD to move around
mouselook

click on an entity to push it.
it uses pick normals so it will move away from the camera.

;# TOKAMAK DEMO v4 (bradford6)
; Credits:
; SWEENIE for creating the TOKAMAK WRAPPER
; www.tokamakphysics.com to get SDK
; note:
; you must put TOKAMAK.DLL (from SDK) in system32
; must put sweenies tokamak files in blitz3d/userlibs directory




Const FPS=50
Const w=17, s=31, a=30, d=32, space=57

Global latspeed#,speed#,MX#,MY#

Graphics3D 800,600,0,2
Global midw = GraphicsWidth()/2
Global midh =GraphicsHeight()/2
SetBuffer BackBuffer()
HidePointer 
WireFrame False

Const ENTS=60

Global campiv = CreatePivot()
Global camera = CreateCamera(campiv)
Global pictentity,pnx#,pny#,pnz#
CameraClsColor(camera,20,20,205)


CreateSimulator(ENTS,5,0,-10,0)



ground = CreateCube()
EntityColor ground,55,55,55 
ScaleEntity ground,50,5,50 
PositionEntity ground,0,-5,0
abground = CreateAB()
ABAddBox(abground,100.0,10.0,100.0)
ABSetPosition(abground,0.0,-5.0,0.0)

wall1 = CreateCube()
EntityColor wall1,25,25,55 
ScaleEntity wall1,2,10,50 
PositionEntity wall1,50,0,0
abwall1 = CreateAB()
ABAddBox(abwall1,4.0,20.0,100.0)
ABSetPosition(abwall1,50.0,0,0.0)

wall2 = CreateCube()
EntityColor wall2,25,25,55 
ScaleEntity wall2,2,10,50 
PositionEntity wall2,-50,0,0
abwall2 = CreateAB()
ABAddBox(abwall2,4.0,20.0,100.0)
ABSetPosition(abwall2,-50.0,0,0.0)

wall3 = CreateCube()
EntityColor wall3,25,25,55 
ScaleEntity wall3,50,10,2 
PositionEntity wall3,0,0,-50
abwall3 = CreateAB()
ABAddBox(abwall3,100.0,20.0,4.0)
ABSetPosition(abwall3,0.0,0,-50.0)

wall4 = CreateCube()
EntityColor wall4,25,25,55 
ScaleEntity wall4,50,10,2 
PositionEntity wall4,0,0,50
abwall4 = CreateAB()
ABAddBox(abwall4,100.0,20.0,4.0)
ABSetPosition(abwall4,0.0,0,50.0)


Dim obj(ENTS)
Dim rb(ENTS)

SeedRnd MilliSecs()  

; go and create a generic checkerboard texture to apply to the objects
cubetex = create_cube_texture()
spheretex = create_sphere_texture()
cyltex = create_cyl_texture()

; add--------------------------------------------------------------------------
entcount = 0
height_var#=1.5
For i=1 To ENTS
	count = count + 1
			
	zpos# = count*2
	If count>10
		height_var# = height_var# + 2
		count = 0
	EndIf
	nr=Rnd(1,3)		
 	If nr=1 Then
	 		obj(i) = CreateCube()
			EntityPickMode obj(i),2
			EntityTexture obj(i),cubetex
			rb(i) = CreateRB()
			RBAddBox rb(i),2.0,2.0,2.0
			RBSetPosition(rb(i),x#,height_var#,zpos#)
			RBSetLinearDamping rb(i),0.001
			RBSetMass rb(i),2.0
			RBSetBoxInertiaTensor rb(i),2.0,2.0,2.0,2.0 
	ElseIf nr=2 ; CREATE Sphere objects
  			  obj(i) = CreateSphere()
			  EntityPickMode obj(i),2

			  EntityTexture obj(i),spheretex
			  rb(i) = CreateRB()
			  RBAddSphere rb(i),1.8
			  RBSetPosition(rb(i),x#,height_var#,zpos#)
			  RBSetAngularDamping rb(i),0.02 
			  RBSetLinearDamping rb(i),0.001 
			  RBSetMass rb(i),2.0
			  RBSetSphereInertiaTensor rb(i),2.0,1.8  
	 ElseIf nr=3 ; CREATE CYLINDERS actually Capsules or elongated spheres
			  obj(i) = CreateCylinder()
   			 EntityPickMode obj(i),2
  			 EntityTexture obj(i),cyltex
			  rb(i) = CreateRB()
			  RBAddCylinder rb(i),2.0,1.0
			  RBSetPosition(rb(i),x#,height_var#,zpos#)
			  RBSetAngularDamping rb(i),0.02 
			  RBSetLinearDamping rb(i),0.001 
			  RBSetMass rb(i),2.0
			  RBSetCylinderInertiaTensor rb(i),2.0,1.0,2.0  
	EndIf
	 
	
	
	 
Next

; add--------------------------------------------------------------------------

Centerpivot = CreatePivot()

light=CreateLight()
PositionEntity light,7,15,-5
PointEntity light,Centerpivot

rot#=0

period=1000/FPS
time=MilliSecs()-period

imptime=MilliSecs()

camx#=Cos(rot#)*50
camz#=Sin(rot#)*50

;rot#=rot#+0.05

If rot#>360 Then rot#=0

PositionEntity campiv,camx#,40,camz#
PointEntity campiv,centerpivot  


; +++ MAIN LOOP START ++++++ MAIN LOOP START ++++++ MAIN LOOP START ++++++ MAIN LOOP START +++
While Not KeyHit(1)

	Repeat
		elapsed=MilliSecs()-time
	Until elapsed

	ticks=elapsed/period
	tween#=Float(elapsed Mod period)/Float(period)

	For k=1 To ticks
		time=time+period
		If k=ticks Then CaptureWorld

		Advance(1.5/FPS)

move_camera()

	UpdateWorld

	Next

; Not sure wether to put this here or inside the for/next above...
For i=1 To ENTS
 If RBIsIdle(rb(i)) Then
  ;aEntityAlpha obj(i),0.2
 Else
  EntityAlpha obj(i),1.0
 EndIf

 PositionEntity obj(i),RBGetX#(rb(i)),RBGetY#(rb(i)),RBGetZ#(rb(i)) 
 RotateEntity obj(i),RBGetPitch#(rb(i)),RBGetYaw#(rb(i)),RBGetRoll#(rb(i)),False
Next



If MouseDown(1) Then shoot_cannon()

RenderWorld tween
Color 255,255,255
Text 0,0,"Physics Time:"+GetPhysicsTime()*1000.0+ " milliseconds"
Text 0,10,"Render Time:"+Str(elapsed)+ " milliseconds"
Text 0,20,"pnx"+pnx#+"  pny "+pny#+"  pnz  "+pnz# 
;Text 0,30,"Render Time:"+Str(elapsed)+ " milliseconds"
;Text 0,40,"Render Time:"+Str(elapsed)+ " milliseconds"
;Text 0,50,"Render Time:"+Str(elapsed)+ " milliseconds"

Color 255,0,0
Rect midw-4,midh-4,8,8,0
	Flip False

Wend

; == MAIN LOOP END ==== MAIN LOOP End ==== MAIN LOOP End ==== MAIN LOOP End ==== MAIN LOOP End ==


DestroySimulator()

End

;==================================================================================
Function curvevalue#(newvalue#,oldvalue#,increments# )
	If increments>1 Then oldvalue#=oldvalue#-(oldvalue#-newvalue#)/increments
	If increments<=1 Then oldvalue=newvalue
	Return oldvalue#
End Function
;==================================================================================
Function move_camera()
	; Movement controls
	If KeyDown(w)=1 Then speed# = speed#+.03
	If KeyDown(a)=1 Then latspeed# = latspeed# - .02
	If KeyDown(s)=1 Then speed# = speed# -.03
	If KeyDown(d)=1 Then latspeed# = latspeed# + .02

latspeed#=latspeed#*.98
speed#=speed#*.98

MY#=curvevalue#(MouseYSpeed(),MY#,3 )
MX#=curvevalue#(MouseXSpeed(),MX#,3 )
TurnEntity campiv,MY#,-MX#,0 ; turn camera up and down
;TurnEntity campiv,0,-MX#,0 ;  turn nnn left --right
RotateEntity campiv,EntityPitch(campiv),EntityYaw(campiv),0

MoveMouse 100,100

MoveEntity campiv,latspeed#,0,speed#
	


End Function
;==================================================================================
Function create_cube_texture()
	tex = CreateTexture(128,128)
	SetBuffer TextureBuffer(tex)
		Color 255,255,0
		Rect 0,0,128,128
		Color 0,0,255
		Rect 0,0,64,64
		Rect 64,64,128,128
	SetBuffer BackBuffer()
	Return tex
	
End Function
;==================================================================================
Function create_sphere_texture()
	tex = CreateTexture(128,128)
	SetBuffer TextureBuffer(tex)
		Color 0,200,0
		Rect 0,0,128,128
		Color 255,255,0
		Rect 0,0,64,64
		Rect 64,64,128,128
	SetBuffer BackBuffer()
	Return tex

	
End Function

;==================================================================================
Function create_cyl_texture()
	tex = CreateTexture(128,128)
	SetBuffer TextureBuffer(tex)
		Color 0,0,0
		Rect 0,0,128,128
		Color 255,0,0
		Rect 0,0,64,64
		Rect 64,64,128,128
	SetBuffer BackBuffer()
	Color 255,255,0 ; YELLOW
	Return tex

	
End Function

;==================================================================================
Function campick()
	pictentity = 0
	CameraPick(camera,midw,midh)
	pictentity = PickedEntity() 
	If Pictentity<>0
		
		EntityAlpha pictentity,.7	
		pnx# = PickedNX#()
		pny# = PickedNY#()
		pnz# = PickedNZ#()	
	
	EndIf
	

End Function
;==================================================================================

Function shoot_cannon()
		
		campick()
	 	For n = 1 To ENTS
			If pictentity = obj(n)
				i = n
				RBApplyImpulse rb(i),-pnx#,pny#,-pnz#
			EndIf
		Next
		
 		
	
		
End Function




elias_t(Posted 2004) [#86]
Hey very kewl!!!
Thanks Sweenie. It is very fast. Fasterthen ode I think.

Do you have in mind releasing the source for the wrapper so
others can jump in the development of the wrapper?

Bye.


Bot Builder(Posted 2004) [#87]
here's a small mod:
If MouseDown(1) Then shoot_cannon(4) ElseIf MouseDown(2) Then shoot_cannon(-4)

Function shoot_cannon(vel#)	
		campick()
	 	For n = 1 To ENTS
			If pictentity = obj(n)
				i = n
				RBApplyImpulse rb(i),-pnx#*vel#,pny#*vel#,-pnz#*vel#
			EndIf
		Next		
End Function
These are just the lines that I changed though.

Makes it so you can apply a negative force with the right mouse button.

Fasterthen ode I think.
Yep. I believe your right. And it's more stable as far as I know.

And I agree, how bout the wrapper source? This is already great! let's make it better :) I'm definitly looking forward to the 'motor' as long as its supported well enough. How hard would it be to inherit velocities from animations, I wonder. Each limb could easily be a box/sphere/capsule. What I'm wondering about is how to easily enough remember the previous positions, and have the person's limbs inherit their velocities. I guess it would be 'possible' in the wrapper, but this would best be done in blitz. So basically their would be two layers between you and the tokomakdll.dll. The blitz layer simply to make for easy integration, and a wrapper dll for access.

No pressure ohcorse. Heck, I don't know c/c++ verywell as it is. However, I would really like to have a nice physics engine for blitz.

This is lookin nicer and nicer. The thing to concentrate on is static polymesh addition. Once that's there, people could imeadiatly start using this in their games. Then we can worry about stuff like motors and joints and ragdolls.


Sweenie(Posted 2004) [#88]
Well, it seems the wrapper got a positive response.
I'll get started with the static mesh collision tonight.

The sourcecode for the wrapper will be included in the next release.

I thought of some further optimisations.
For example the function for retrieving positions and rotations could be changed so that it's made in one call.
That would reduce DLL-calling overhead.

In Tokamak the CreateJoint command takes either
one RB, two RB's or one RB and one AB.
Maybe the wrapped function could look like this instead.

CreateJoint(JointType,RB1,RB2,AB)

where JointType could be 1,2 or 3.
1=RigidBody to World connection(uses RB1)
2=RigidBody to RigidBody connection(uses RB1 & RB2)
3=RigidBody to AnimatedBody connection(uses RB1 & AB)

Oh, you might also have discovered the "Fall asleep to fast" bug in Tokamak.
Some cubes may actually come to rest on it's edge. This is because the "sleepthreshold" is to high. I've included the SetSleepingParameter function but i'm not sure wether this just works for jointconstrained bodies or not.


JoshK(Posted 2004) [#89]
Are you the guy I mailed the quaternion code to? Good job.


Vorderman(Posted 2004) [#90]
Damn right it's faster than ODE - I just tried 500 objects....virtually no physics time at all, just this crap PC trying to render too much.

Superb work Sweenie!


Koriolis(Posted 2004) [#91]
That's really nice. It instantly opens a whole bunch of new possibilities. Thanks Sweenie, and above all, let's not forget to thank the Tokamak's guys. Cool to have these kind of sweetness for us to play with.
Just one request: I highly recommend (as suggested by MasterBeaker) to prefix everything by "TOK_").


xmlspy(Posted 2004) [#92]
The demos are the best physics I have seen on the PC, I will never use ODE again.


Tom(Posted 2004) [#93]
Sweenie, excellent work :)

Koriolis: Yup, TOK_ prefix sounds good, you can change that in the .decls file if you wished, but maybe best wait until Sweenie decides else there'll be demos appearing that will need some editing to work.


Sweenie(Posted 2004) [#94]
let's not forget to thank the Tokamak's guys


Koriolis is absolutely right.
It's the Tokamak team that are the REAL heroes in this "Tokamak experience".
I'm sure they would love to hear from you, so if you guys show them as much appreciation as you did in this thread I'm sure it would inspire them to make tokamak even better.
You can reach them at info@...


Skitchy(Posted 2004) [#95]
Great work BTW :) I mean, *really* great work. I'd imagine there's going to be a whole lot of 'powered by Tokamak' splash screens popping up soon enough.

Would car physics be possible with this in its current state? If not, what needs adding?


Klaas(Posted 2004) [#96]
first of all ... wow, great work !!!

I've encountered some problems with the tokamak physic.
The calculation works fine with more "cubic" (same edge length) ... but more and more objects falling through the ground if they where more "stick"-like (longer in one direction)
Is this a problem with the intital caculation values or is it a weakness of the tokamak physic ?

Edit:
Oh on, forget about that ... i've played around some more and found out that this is has its result in not setting InertiaTensor correctly.

sorry for my awfull english ;)


Bouncer(Posted 2004) [#97]
Fantastic job Sweenie!!! Tokamak is the fastes f***** I've seen yet. And also fantastic job tokamak guys!! ;)

Really... now nobody can't complain about lacking physics in b3d nomore.


Tom(Posted 2004) [#98]
Dangly 'thing' :)

[code]
; TOKAMAK Dangle demo using Ball&Socket Joints
;
; Credits:
; Tokamak Physics for their cool physics library
; SWEENIE for creating the BB Tokamak Wrapper
; www.tokamakphysics.com to get the SDK
; www.freewebs.com/sweenie for the BB Tokamak Wrapper
;
; you must put TOKAMAK.DLL (from SDK) in system32
; must put sweenies tokamak files in blitz3d/userlibs directory

Graphics3D 800,600,0,2
SetBuffer BackBuffer()

Const ENTS=20
Const FPS=50

camera = CreateCamera()
PositionEntity camera,10,10,-10

Centerpivot = CreatePivot()

light=CreateLight()
PositionEntity light,7,15,-5
PointEntity light,Centerpivot

CreateSimulator(ENTS,1,0,-10,0)

;BB Visible ground
ground = CreateCube()
EntityColor ground,100,100,100
ScaleEntity ground,50,1,50
PositionEntity ground,0,-2,0

;Tokamak ground
abground = CreateAB()
ABAddBox(abground,100.0,1.0,100.0)
ABSetPosition(abground,0.0,-1.0,0.0)

Dim BoxBB(ENTS)
Dim BoxTOK(ENTS)
Dim Joint(ENTS-1)

;Create a chain of Boxes
For i=1 To ENTS
BoxBB(i) = CreateCube()
ScaleEntity BoxBB(i),.4,.4,.4
PositionEntity BoxBB(i),0,2,i
BoxTOK(i) = CreateRB()
RBAddBox BoxTOK(i),.4,.4,.4
RBCollideConnected BoxTOK(i),True
RBSetPosition(BoxTOK(i),0,2,i)
RBSetLinearDamping BoxTOK(i),0.003
RBSetAngularDamping BoxTOK(i),.03
RBSetMass BoxTOK(i),2.0
RBSetBoxInertiaTensor BoxTOK(i),.4,.4,.4,2.0
EntityColor BoxBB(i),Rnd(100,230),Rnd(100,230),Rnd(100,230)
Next

;Create a Ball/Socket Joint between each Box
For i=1 To ENTS-1
Joint(i) = CreateJointRB2RB(BoxTOK(i),BoxTOK(i+1))
JOINTSetPositionGlobal(Joint(i),0,2,i + .5)
JOINTSetTypeBallSocket(Joint(i))
Next

period=1000/FPS
time=MilliSecs()-period


; MainLoop
While Not KeyHit(1)

Repeat
elapsed=MilliSecs()-time
Until elapsed

ticks=elapsed/period
tween#=Float(elapsed Mod period)/Float(period)

For k=1 To ticks
time=time+period
If k=ticks Then CaptureWorld
Advance(2.0/FPS)
UpdateWorld
Next

For i=1 To ENTS
PositionEntity BoxBB(i),RBGetX#(BoxTOK(i)),RBGetY#(BoxTOK(i)),RBGetZ#(BoxTOK(i))
RotateEntity BoxBB(i),RBGetPitch#(BoxTOK(i)),RBGetYaw#(BoxTOK(i)),RBGetRoll#(BoxTOK(i)),False
Next

If KeyDown(57) RBApplyImpulse BoxTOK(1),0,.6,0
If KeyDown(203) RBApplyImpulse BoxTOK(1),-.5,0,0
If KeyDown(205) RBApplyImpulse BoxTOK(1),.5,0,0
If KeyDown(200) RBApplyImpulse BoxTOK(1),0,0,.5
If KeyDown(208) RBApplyImpulse BoxTOK(1),0,0,-.5

RenderWorld tween

Color 215,0,0
Rect 586,0,180,12
Color 255,255,255
Text 0,0,"Physics Time (Ms):"+GetPhysicsTime()*1000.0
Text 0,10,"Render Time (Ms):"+Str(elapsed)
Text 0,20,"Use Cursors to move, Space to lift"
Text 500,0,"Powered by WWW.TOKAMAKPHYSICS.COM"


Flip False
Wend
DestroySimulator()
End
[/CODE]

Tom


Mathieu A(Posted 2004) [#99]
Fantastic work sweenie!! Really a great piece of work


(tu) sinu(Posted 2004) [#100]
awesome, just d/l the demos of tokomak and those 20raddudes falling down the roof using ragdall is frigging awesome, just imagine a beatemup using those.

Thanks sweenie and tokomak devs!!


TartanTangerine (was Indiepath)(Posted 2004) [#101]
Wow, you've just made my life 100 times easier. I can't wait to see the source for the wrapper :)

Keep up the good work! And Thanks.. Flynn


(tu) sinu(Posted 2004) [#102]
all the demos off tokomak are wicked, i also think the car demo is tops, be nice to see car games in bliz use them.


Sweenie(Posted 2004) [#103]
I love playing puzzlegames like Incredible Machine.
Wouldn't it be cool to have a competition(when the wrapper is somewhat finished) there the goal is to make a puzzlegame like the Incredible Machine using Tokamak?


(tu) sinu(Posted 2004) [#104]
hey sweenie, is ragdoll fully working in this release/ setup of ragdoll possible?
it's the only thing im interested in for now cos im helping someone who needs them and thought i could use this .dll now.

Also maybe we should get a physics forum on here now, seems we've finally got everything we wished for regarding physics.
Also how bout posting on the front page of bb, it is major news :)


Sweenie(Posted 2004) [#105]
You could make a somewhat working ragdoll.
But I think the Hingejoint and jointlimits should be implemented first to be able to make a good ragdoll.

I also made a mistake in the wrapper that causes bodies connected to each other not to collide.
It's very noticeable in the second demo app I made, they should collide but don't.


bradford6(Posted 2004) [#106]
Sweenie,
You're work on the wrapper is fantastic.

How do you feel about this overwhelming response to your work?

I think a TOKAMAK-Blitz-3d repository needs to be set up for the code and projects that are going to stem out of these things:
1. a place to put tokamak+blitz demos, screenshots and projects
2. a place to host the wrapper's various incarnations
3. a place to host tutorials
4. a place to host documentation

what do you all think.


MattG(Posted 2004) [#107]
wheres the car demo ?

Matt


simonh(Posted 2004) [#108]
Excellent work Sweenie! Finally Tokamak and Blitz are brought together, and I'm sure it will be the start of a beautiful relationship :)


(tu) sinu(Posted 2004) [#109]
the car demo is one of the tokamoak demos, you need to download it off their site, its part of the full demo d/l.


(tu) sinu(Posted 2004) [#110]
It'd be way cool if/when we get ragdoll physics working like those in the tokamak demos, im guessing it won't be long before we do though.
Maybe we can get a generic one setup for everyone to use.


(tu) sinu(Posted 2004) [#111]

You could make a somewhat working ragdoll.
But I think the Hingejoint and jointlimits should be implemented first to be able to make a good ragdoll.

I also made a mistake in the wrapper that causes bodies connected to each other not to collide.
It's very noticeable in the second demo app I made, they should collide but don't.


i thought as much, hope they get put in soon and the collision problem gets fixed too, i got a cool demo to try them on then.


AL(Posted 2004) [#112]
Nice work Sweenie, this is much appreciated!

One question; can tokamak handle more complex objects, for example say a ball/box rolling down a uneven hill?


Bouncer(Posted 2004) [#113]
Yes...I don't know if it's in sweenies wrapper , but tokamak supports terrain meshes as animated objects.


aCiD2(Posted 2004) [#114]
brad: i agree, a repository would be very cool :)


DarkEagle(Posted 2004) [#115]
hmm just back to congratulate and thank you again for this kick ass piece of work :)

Vote Sweenie - Blitzer of the year 2004 :)


RepeatUntil(Posted 2004) [#116]
Wahou !! A new era opens for Blitz !! And the demo are very impressive !


Sweenie(Posted 2004) [#117]
Aaahh!
I've been spending a looooong time trying to find out why two connected bodies won't collide with each other though I set the CollideConnected flag to true.
I just found out that the Tokamak guys made it that way.
The collideconnected allows the rigidbody to collide with other connected bodies except the body(bodies) it's directly connected to.
Jointlimits should be used instead.

I've changed the function names to reflect the class it belongs to in the Tokamak API.

So every function that has to do with the simulator for example begins with TOKSIM_
Like this:
Simulator --> TOKSIM_
RigidBody --> TOKRB_
AnimatedBody --> TOKAB_
Joint --> TOKJOINT_
Geometry --> TOKGEOM_

That works for me and I hope it does for you as well.
If it doesn't, we'll change it.
After all, it isn't carved in stone yet.


IPete2(Posted 2004) [#118]
Sweenie,

Wow - I think everyone here owes you and the boyz at Tokamak a real big Thanks! so.

THANKS!

Fantastic work.

I can't wait to play with this (probably next week now!)

IPete2.


koekjesbaby(Posted 2004) [#119]
i can't help pbut wonder why this isn't frontpage news...

man, this is so good.


jfk EO-11110(Posted 2004) [#120]
I just wanted to say that too :)


BlitzSupport(Posted 2004) [#121]

i can't help pbut wonder why this isn't frontpage news...


If someone (Sweenie?) submits a news item we'll publish it on the front page...


IPete2(Posted 2004) [#122]
I think we need a second thread this is taking a long time to load!

IPete2.


Bot Builder(Posted 2004) [#123]
yeah. blitzcoder entry to.


bradford6(Posted 2004) [#124]
Sweenie,
could you also do a version for the updates.
i.e v0.1,v0.2 etc...
this will keep us all on the same page when we talk about the DLL version that needs to be in userlibs.


AbbaRue(Posted 2004) [#125]
Awsome, how fast it is.
There is a tutorial on the Tok. web site that uses a terrain mesh.
Are those functions working in the Blitz interface yet?


Sweenie(Posted 2004) [#126]
If someone (Sweenie?) submits a news item we'll publish it on the front page...


Ok, I will submit a news item

could you also do a version for the updates.

Yep, I thought of that to.
Let's make the current version v0.1

There is a tutorial on the Tok. web site that uses a terrain mesh.
Are those functions working in the Blitz interface yet?


I'm working on that right now.


AbbaRue(Posted 2004) [#127]
Question. I entered Tom's example and all worked fine.
Then I changed the graphics mode to
1024,768,32,1
and the snake doesn't move fully anymore.
I take it that the physics, has to be changed so there is enough energy applied for the larger screen size.
Am I right, and what value should I change?


Sweenie(Posted 2004) [#128]
It's because the screen is updated fewer times then before you changed the resolution.
Likewise if you lower your resolution the snake will move faster.

Move the KeyDown() part into the same place where the Advance() function is and it should stay in sync with the simulation regardless of the renderspeed.

It's my bad, I shouldn't have done it like that in my demo.


MattG(Posted 2004) [#129]
could this be used for aircraft physics , sorry if thats a dumb question

thanks

Matt


RepeatUntil(Posted 2004) [#130]
Very good job, Sweenie!
You will have soon to write a documentation, I presume! I hope that you will use Cod2Doc to create it ;-) Cod2Doc has a lot of nice features to document library like yours!! Check my sig for more details...
(I am so impatient to see some libraries documented with Cod2Doc!)


Sweenie(Posted 2004) [#131]
Tokamak handles gravital forces,forces generated by collisions and forces applied by you(applyimpulse,applytwist,setforce & settorque) but it doesn't calculate dragforces generated when air travels over and under the wings of the plane and so on.
But I guess that if you calculate these forces yourself and supply it to Tokamak it could work.


PsychicParrot(Posted 2004) [#132]
holy crap. It's amazing! Here I am just getting used to using ODE and you go and build a Tokamak wrapper! doh... really cool work, mister :)


DarkEagle(Posted 2004) [#133]
whats the deal with shareware/commercial products made with tokamak? its certainly a great piece of kit, but how is it for creating games to be published?


darklordz(Posted 2004) [#134]
teh first sentences on the site of tokamaphysics...

We are pleased to announce the release of a new license agreement for the Tokamak Game Physics SDK. You can now use Tokamak for Commercial and Non-commercial purposes FREE! We have also set up a forum to support the Tokamak users' community. Join the growing band of Tokamak users today and let Tokamak power your game physics.


Mark Judd(Posted 2004) [#135]
Thanks very much Sweenie.
Because of you, i've just purchased Blitz.

Fantastic work, can't wait to give my DB project a huge overhaul.

Cheers!


Tom(Posted 2004) [#136]
AbbaRue: That's odd, it works fine in 1024,768,32bit full screen mode for me.

Did you change anything else?


Ricky Smith(Posted 2004) [#137]
Excellent work Sweenie and of course the Tomakak guys !


DarkEagle(Posted 2004) [#138]

Const FPS=50


Graphics3D 800,600,0,2
SetBuffer BackBuffer()

WireFrame False

Const ENTS=5

camera = CreateCamera()
PositionEntity camera,0,40,-70

CreateSimulator(ENTS,7,0,-10,0)

ground = CreateCube()
EntityColor ground,5,5,55 
ScaleEntity ground,50,5,50 
PositionEntity ground,0,-5,0
abground = CreateAB()
ABAddBox(abground,100.0,10.0,100.0)
ABSetPosition(abground,0.0,-5.0,0.0)

wall1 = CreateCube()
EntityColor wall1,25,25,55 
ScaleEntity wall1,2,10,50 
PositionEntity wall1,50,0,0
abwall1 = CreateAB()
ABAddBox(abwall1,4.0,20.0,100.0)
ABSetPosition(abwall1,50.0,0,0.0)

wall2 = CreateCube()
EntityColor wall2,25,25,55 
ScaleEntity wall2,2,10,50 
PositionEntity wall2,-50,0,0
abwall2 = CreateAB()
ABAddBox(abwall2,4.0,20.0,100.0)
ABSetPosition(abwall2,-50.0,0,0.0)

wall3 = CreateCube()
EntityColor wall3,25,25,55 
ScaleEntity wall3,50,10,2 
PositionEntity wall3,0,0,-50
abwall3 = CreateAB()
ABAddBox(abwall3,100.0,20.0,4.0)
ABSetPosition(abwall3,0.0,0,-50.0)

wall4 = CreateCube()
EntityColor wall4,25,25,55 
ScaleEntity wall4,50,10,2 
PositionEntity wall4,0,0,50
abwall4 = CreateAB()
ABAddBox(abwall4,100.0,20.0,4.0)
ABSetPosition(abwall4,0.0,0,50.0)

point1 = CreateCube()
EntityColor point1,200,200,200
ScaleEntity point1,0.1,0.1,2
PositionEntity point1,-5,5,0
abpoint1 = CreateAB()
ABAddBox(abpoint1, 0.2, 0.2, 4.0)
ABSetPosition(abpoint1, -5, 5, 0)

point2 = CreateCube()
EntityColor point2,200,200,200
ScaleEntity point2,0.1,0.1,2
PositionEntity point2,5,5,0
abpoint2 = CreateAB()
ABAddBox(abpoint2, 0.2, 0.2, 4.0)
ABSetPosition(abpoint2, 5, 5, 0)


Dim obj(ENTS)
Dim rb(ENTS)

SeedRnd MilliSecs()  

obj(1) = CreateCube()
rb(1) = CreateRB()
CreateRBCube(obj(1),rb(1),0,6,0,6,0.2,2,4)

For i = 2 To 4
	obj(i) = CreateSphere()
	rb(i) = CreateRB()
	CreateRBSphere(obj(i),rb(i),i*4-12,8,0,2,1)
Next

obj(5) = CreateCube()
rb(5) = CreateRB()
CreateRBCube(obj(5),rb(5),0,15,0,6,0.2,2,4)


Function CreateRBCube(entity,rb,x#,y#,z#,xs#=1.0,ys#=1.0,zs#=1.0,mass#=1.0)

ScaleEntity entity,xs,ys,zs
PositionEntity entity,x,y,z

RBAddBox rb,xs*2,ys*2,zs*2
RBSetPosition rb,x,y,z
RBSetLinearDamping rb,0.001
RBSetMass rb,mass
RBSetBoxInertiaTensor rb,xs,ys,zs,mass

End Function

Function CreateRBSphere(entity,rb,x#,y#,z#,rad#=1.0,mass#=1.0)

ScaleEntity entity,rad,rad,rad
PositionEntity entity,x,y,z

RBAddSphere rb,rad#*2
RBSetPosition rb,x,y,z
RBSetLinearDamping rb,0.001
RBSetMass rb,mass
RBSetBoxInertiaTensor rb,rad,rad,rad,mass

End Function


Centerpivot = CreatePivot()


light=CreateLight()
PositionEntity light,7,15,-5
PointEntity light,Centerpivot


period=1000/FPS
time=MilliSecs()-period

imptime=MilliSecs()
; MainLoop
While Not KeyHit(1)

	Repeat
		elapsed=MilliSecs()-time
	Until elapsed

	ticks=elapsed/period
	tween#=Float(elapsed Mod period)/Float(period)

	For k=1 To ticks
		time=time+period
		If k=ticks Then CaptureWorld

		Advance(1.5/FPS)
				
		PointEntity camera,centerpivot  
		
		UpdateWorld
	Next

; Not sure wether to put this here or inside the for/next above...
For i=1 To ENTS
	If RBIsIdle(rb(i)) Then
		EntityAlpha obj(i),0.5
	Else
		EntityAlpha obj(i),1.0
	EndIf
	PositionEntity obj(i),RBGetX#(rb(i)),RBGetY#(rb(i)),RBGetZ#(rb(i)) 
	RotateEntity obj(i),RBGetPitch#(rb(i)),RBGetYaw#(rb(i)),RBGetRoll#(rb(i)),False
Next

If KeyHit(57) Then
	i=1 
	RBApplyImpulse rb(i),-10,20,0;Rnd(-8.0,8.0),Rnd(15,30),Rnd(-8.0,8.0) 
EndIf

RenderWorld tween

Text 0,0,"Physics Time:"+GetPhysicsTime()*1000.0+ " milliseconds"
Text 0,10,"Render Time:"+Str(elapsed)+ " milliseconds"

Flip False
Wend

DestroySimulator()

End


hit space to move the bottom shelf... this is so fun... and so easy! next step is to attatch the pieces the shelf rests on to a wall. im guessing this needs joints? i want to make a demo where theres a room full of shelves, and all the supports for the shelves can be shot. is the easiest way to do this by turning an AB into an RB so the support can drop, or will i just have to free the AB?


dangerdave(Posted 2004) [#139]
Just wondering ...

Why does a wrapper dll have to be made?
Why can't we just make .decl for the tokamak.dll?


CyBeRGoth(Posted 2004) [#140]
Cool sweenie, the physics are great and run very fast :)

I also agree that we should have a Tokamek forum or something where we can post code for neat physics demos using this wrapper


Beaker(Posted 2004) [#141]
Do you mean like this one?:
http://playerfactory.proboards25.com/index.cgi?board=tokamak
:)


RayTracer(Posted 2004) [#142]
Tokamak Wrapper 0.2 is out! Check sweenies page!


Sweenie(Posted 2004) [#143]
Why does a wrapper dll have to be made?
Why can't we just make .decl for the tokamak.dll?


The TokamakDLL makes use of classes with methods and so on.
Blitz doesn't support the creation of such classes.
Tokamak also use callbacks for collisioninfo and those can't be used directly in Blitz either.

Oh, by the way... I have released a new version. :)
Check my homepage. --> www.freewebs.com/sweenie


dangerdave(Posted 2004) [#144]
Thanks Sweenie for the info. I got to thinking about that while at work.
============================

Completely shameless rip from Sweenie's site.
2004-01-21
New update!
Version 0.2 is now available and can be downloaded
here --> twrapperv02.zip

This time I have implemented alot of new functions.
For example TOKSIM_SetTerrainMesh, which allows collision with terrain or any kind
of triangulated mesh.
The third demo will show you how to use it.


(tu) sinu(Posted 2004) [#145]
does the new version have updates/fixes for ragdoll ?


Sweenie(Posted 2004) [#146]
Well, you can create ragdolls but the limits is yet to be implemented.
As a matter of fact, i'm working on them right now. :)

This thread is getting big. Takes ages for my old modem to load...


LostCargo(Posted 2004) [#147]
lol. modem (shudder) dont u have highspeed?


LostCargo(Posted 2004) [#148]
lol. modem (shudder) dont u have highspeed?


aCiD2(Posted 2004) [#149]
sweenie in your enxt release pleeeassseeee include freerigidbody at least :D its needed baddly ;)

aCiD2


Tom(Posted 2004) [#150]
Sweet Sweenie :)


biostrike(Posted 2004) [#151]
Work Great !




Jeremy Alessi(Posted 2004) [#152]
Um, I want to use it but it tells me the user lib can't be found upon running and both the needed files are in my userlibs folder and I'm using 1.85. What the heck!


Koriolis(Posted 2004) [#153]
Put the tokamak DLL in the program folder or in yous c:\windows\system32 folder. It seems Blitz catch in some way any error at loading a DLL in the prog address space and shows the "userlib not found" message (even if it's not a userlib but was linked indirectly by another DLL).


Jeremy Alessi(Posted 2004) [#154]
Hmmm... doesn't seem to help. Do you mean the Tokamakwrapper.dll? I put all the Tokamak files in the samples folder and that didn't help. All the keywords are highlighted in Blitz too.


DarkEagle(Posted 2004) [#155]
w00t, cant wait to try this now! any answers to my questions about converting an AB (which doesnt get affected by gravity) to a RB (which does get affected by gravity)??? i either need to do that, or to delete a specified AB... as these are my supports for my shelves...


skidracer(Posted 2004) [#156]
ban, have you got both takomakdll.dll and tokamakwrapper.dll in your current dir?