Jump to content


Photo

Bullet Physics


  • Please log in to reply
245 replies to this topic

#1 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 06 June 2008 - 01:21 AM

The Bullet Physics library is a 3D physics engine which is not only completely open source, but is also used in several commercial applications, including on consols such as the PS3. The project is lead by Erwin Coumans, and the homepage can be found at http://www.bulletphysics.com/

This DLL allows GM users to take advantage of this powerfull library.

Current features supported by the DLL:
-Discrete (non-continuous) simulation
-Rigidbodies
-Constraints
-Concave/convex triangle meshes
-3DS and BSP file loading
-.obj, .x, and GM model file loading with GMModelEx.
-Raycasting
-D3D based Debug drawer
-Vehicle constraint
-Data structure based Get/Set functions, for rapid communication.

Last updated: April 12th 2009. Most recent version: 1.34

The DLL and extension package can be downloaded at: http://www.andrewpaul.com/GMBullet.zip
A Help file is included, please use it.
Source code included.

If you find any bugs, please post reports in this thread. Please include a description of the bug, how to re-create it (ie: what causes it?) And, if possible, an editable game file which demonstrates the bug.

New feature and function requests are also welcome ;)

---

Continuing from the Request topic:
A bug was found in the get_rotation functions, it has been fixed, the rotations should work correctly now.
The problem was 2-fold. First, Bullet uses a left-handed coordinate system instead of a right-handed one, thus all rotations were being performed in the wrong direction (that took a while to figure out,) and second, it seems Bullet's internal matrix-to-euler conversion is not working with GM correctly, and has been replaced with other code. The Zip file has been updated with the new version.

The new Euler rotations need to be applied in the order: y,z,x as opposed to x,y,z.
Also note that I added code to negate the input angle values from the various functions which define rotations (to convert counter-clockwise rotation to clockwise.) If this is in err, let me know.

-Andrew

Edited by andbna, 12 April 2009 - 05:01 AM.

  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#2 hanson

hanson

    GMC Member

  • GMC Member
  • 444 posts
  • Version:GM8

Posted 06 June 2008 - 02:05 AM

Great work so far! I would suggest though that you return the rotations from the dll in such a way that the transformations are applied in xyz order. This is as simple swapping the code in the dll functions. Pretty simple, but it would make it easier(for me) to use ;).

-hanson
  • 0

#3 Rixeno

Rixeno

    The One 'n' Only

  • New Member
  • 513 posts

Posted 06 June 2008 - 07:53 PM

Yes, the rotations are fixed, this is great! So now I can go back at the example (which I accidentally deleted with the old version)... oh well, I'll just start back, it shouldn't take long, I'll try to get something going on soon :o

EDIT: Thanks gosh that I uploaded it on BOX.net, nevermind, I didn't lose the example, I'll try to restart the example :D

Edited by Rixeno, 06 June 2008 - 09:55 PM.

  • 0
Do you need an example? You can PM me a request and I'll try my best.
Creations:
- Extra String Functions - Sprite Chroma Key - String at Position - Word Censor - Draw_Line_Width (Unreg GM6-) - Shadowed Text - Draw N-Gon - PIXEL PERFECT COLLISION ENGINE-

#4 Rixeno

Rixeno

    The One 'n' Only

  • New Member
  • 513 posts

Posted 08 June 2008 - 03:57 PM

I'm still getting problems with my old example with rotations, it's just the coding, so I'll restart a new one. I'm surprised there isn't many comments about this considering people have been asking for 3D physics DLLs for ever :P
  • 0
Do you need an example? You can PM me a request and I'll try my best.
Creations:
- Extra String Functions - Sprite Chroma Key - String at Position - Word Censor - Draw_Line_Width (Unreg GM6-) - Shadowed Text - Draw N-Gon - PIXEL PERFECT COLLISION ENGINE-

#5 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 09 June 2008 - 01:27 AM

Hanson; sorry changing the rotation order is a bit more mathematical than changing a few things around, but I'l look for some code designed for an x-y-z order (or derrive it myself if I have to... maby thats what French class will consist of tomorow :huh: )

Thanks Rixeno for continuing to work on that example, give me a shout if those rotation problems persist!

Anyway, I'm continuing to add features to the DLL, currently I'm working on ray and convex sweep tests, as well as collision masks and 'collision at position' functions.

-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#6 hanson

hanson

    GMC Member

  • GMC Member
  • 444 posts
  • Version:GM8

Posted 09 June 2008 - 03:35 AM

Oops - you're right. I thought you meant something different. It makes more sense now that I read it again :huh:

-hanson
  • 0

#7 Rixeno

Rixeno

    The One 'n' Only

  • New Member
  • 513 posts

Posted 09 June 2008 - 08:51 PM

Cool, more features. Exams are coming up this week and next week, so I'll be busy on others things for quite a while, I'll try to find time here and there anyways :whistle:

EDIT: I'm currently having an error, I don't know if I missed something, but the rotations didn't change for me... HERE'S the link of the file so far (it's still the old version that I last updated last month with small updates...)

Edited by Rixeno, 09 June 2008 - 11:11 PM.

  • 0
Do you need an example? You can PM me a request and I'll try my best.
Creations:
- Extra String Functions - Sprite Chroma Key - String at Position - Word Censor - Draw_Line_Width (Unreg GM6-) - Shadowed Text - Draw N-Gon - PIXEL PERFECT COLLISION ENGINE-

#8 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 11 June 2008 - 01:39 AM

Rixeno; the rotations are in the wrong order, you now have to apply them in:
Y
Z
X

Sorry about the confusion, I will get it back to X-Y-Z soon.
-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#9 Rixeno

Rixeno

    The One 'n' Only

  • New Member
  • 513 posts

Posted 11 June 2008 - 06:50 PM

lol, I finally found out what that meant, I had to call the rotations in that order... No problem :GM068:, I tried it again and it worked flawlessly, I might get an example done before the end of the month (because exams next week)

EDIT: This is what I have so far, you can add it to the download if you want Andbna, but I plan on using more of the functions later on after the exams next week maybe. I think this is the link : DOWNLOAD

Edited by Rixeno, 11 June 2008 - 08:16 PM.

  • 0
Do you need an example? You can PM me a request and I'll try my best.
Creations:
- Extra String Functions - Sprite Chroma Key - String at Position - Word Censor - Draw_Line_Width (Unreg GM6-) - Shadowed Text - Draw N-Gon - PIXEL PERFECT COLLISION ENGINE-

#10 luenardi

luenardi

    GMC Member

  • New Member
  • 323 posts

Posted 12 June 2008 - 08:32 PM

This Rules! :whistle:
  • 0

Posted Image

My system: CoreI5 661, 6GB Ram, 2X GF280GTX 2GB, Boot Drive 6GBPS SDD, 2x 500GB storage.
Boot time on Win7 Ultimate 5.02 seconds.

#11 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 14 June 2008 - 08:22 AM

I'm real happy someone took over this task. When someone suggested it, I took a look at the API and found it way over my head.

I bumped the room speed to 60. Unfortunatly, at 50 cubes, the FPS is 30. The slowdowns is due to the number of APIs call needed to map the GM objects to the world objects.

You can fix that by packing the x,y,x,rx,ry,rz into one value and unpack it in gm... Someone made an example on how to do that that in the comunity. That would reduce the number of dll calls by 6

Make the cube invisible and comment out the step event, you will get more instances.

Unfortunatly, the FPS really starts to drop around 60 cubes now. While the new cube is moving the fps drops to 25. Then it's back up to 60 when the new cube stops moving. That must be in the simulation itself. There has to be something there that was overlooked.


I'd be happy to go through the code if you want.


Take care!

Edited by icuurd12b42, 14 June 2008 - 08:24 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#12 Rixeno

Rixeno

    The One 'n' Only

  • New Member
  • 513 posts

Posted 14 June 2008 - 11:44 AM

It's also true that D3D isn't the fastest method for 3D, I'd like to create a U3D demo once I get the D3D demo finished and compare the speed results (which I think I can already tell...)

NOTE: I just finished two exams yesterday, I have 3 more to go until I restart working on the example :)
  • 0
Do you need an example? You can PM me a request and I'll try my best.
Creations:
- Extra String Functions - Sprite Chroma Key - String at Position - Word Censor - Draw_Line_Width (Unreg GM6-) - Shadowed Text - Draw N-Gon - PIXEL PERFECT COLLISION ENGINE-

#13 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 14 June 2008 - 03:18 PM

It's also true that D3D isn't the fastest method for 3D, I'd like to create a U3D demo once I get the D3D demo finished and compare the speed results (which I think I can already tell...)

NOTE: I just finished two exams yesterday, I have 3 more to go until I restart working on the example :)

Yeah, I know, that's why I disabled it to only test the DLL.


You need to be aware that you have a limit of 100-200 dll calls per step... Even less if you try to run at 60 FPS.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#14 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 14 June 2008 - 03:41 PM

Thank's for your feedback luenardi and icuurd :)

The slowdowns is due to the number of APIs call needed to map the GM objects to the world objects.
You can fix that by packing the x,y,x,rx,ry,rz into one value and unpack it in gm... Someone made an example on how to do that that in the comunity. That would reduce the number of dll calls by 6

I'd been wondering about whether that would be a problem. Thanks for stress-test.

Now, as for the slowdown with the cubes; it's actualy not going as slow as you think. I had a chance to better look through Rixeno's example, and the StepSimulationCall is a bit iffy.

gmbStepSimulationTime(10,room_speed/2,0.005);

The first argument is the amount of time (in seconds) that you want to simulate for during that single call (ie: time elapsed since the last call.) The third argument is the internal framerate of the DLL (ie, number of simulations you want it to do per second.) The middle is a frame-cap for a single call.
0.005 is a frame-rate of 200Hz, and 10 seconds at 200FPS, means 2000 simulations per call! Of course, the frame cap of room_speed over 2 limits this amount to 15 simulations from that 1 function call at a roomspeed of 30.
Now, multiply this by the 30FPS GM is running at, and you get 15*30=450FPS that the DLL is running at.

Jack up the room speed, and you increase the frame-rate cap to 60/2=30, but you also try and call the step simulation twice as much, so at a room speed of 60, your demanding Bullet to do 30FPS*60FPS=1800FPS. That's some pretty hardcore simulation.

However, the actual speed of the game is 25FPS you said, so multiply that by the 30 frames Bullet is running, and we get 25FPS*30FPS=750FPS that Bullet is able to simulate at. Not bad considering it's standard frequency is 60FPS.

To correct the step simulation call, try something allong these lines:

gmbStepSimulationTime(1/room_speed,1,1/room_speed);

Now I'v asked Bullet to keep it's internal frequency equal to GM's. I'v also asked it to perform 1/room_speed amount of simulation, so it should do 1 simulation for each StepSimulation call. Since as it is set up there it will always execute 1 simulation per call, I capped the max number of steps at 1; it really dosnt matter.

One might consider however using Yourself's High Resolution Timer, and actualy computing the time difference between the current and the last call, allowing for a variable framerate game, while keeping a fixed framerate physics simulation (Bullet will also interpolate for you if you ask it to simulate less time than it's frequency.)

Anyway, the only other thing is, you don't need to create the same cube/cyllinder/sphere shape each time you create a corresponding RigidBody. But that should not really affect simulation. It's looking great Rixeno, and good luck with your exams.

-Andrew

Edited by andbna, 14 June 2008 - 03:44 PM.

  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#15 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 14 June 2008 - 06:10 PM

It sure is a thing of beauty to watch... Though with the new setting, it's all slow motion.

So I set the room to 60 and kept adding cubes until the fps was 30. Giving me the maximums (for a 30 FPS game).

200 instance with draw
320 with no draw
1600 with not update calls
800 instance with single udate get data and unpacking the values

You could move the gm synch position to the draw event so that when we hide the instance it no longer updates

For unpacking, I assume the first 3 bytes would be 360 degrees packed in a 0 to 256 byte

the remainding bytes can be used to pack the x,y,z. Not sure how much you would loose in room size or granularity though


All you need is supplement your API by adding the extra "one call gets all" function for the hard core guys and suply a GM unpacking routince

packet = gmbGetPositionPacket(body);

rotx = packet & $FF/255*360
roty = packet >> <2bytes> & $FF/255*360
rotz = packet >> <4bytes> & $FF/255*360
and so on


I'm pretty sure I'm going to use this in a 2d top down space game. I was making a dll for the collision/rotation/momentum system but this does what I was coding. AND IT WORKS UNDER VISTA AND GM7. Yes!

You dont really need Yourself's dll, GM's date/time functions (not the current_time) go all the way down to 1 millisec wich is good enough for game timing..


Check this method to reduce API calls too
http://gmc.yoyogames...&...t&p=2734336

Edited by icuurd12b42, 14 June 2008 - 08:42 PM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#16 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 15 June 2008 - 01:38 AM

Though with the new setting, it's all slow motion.

Yah, it appears that way since there is no real perspective to base the speed and distance on other than the camera's distance from the floor, which one assumes to be about 1.5m (looking through a persons eye's). Relative to the gravity however (assuming we are on earth), it's more like 10meters. Those cubes are ~15m in length, and that floor your standing on is nearly half a kilometer squared, so they are falling from quite a distance above. Set the gravity to around 100 and it should look more 'normal.'

Thanks for those numbers too; those are pretty nice results :( Good to hear it works on Vista too.
I'l certainly add some One-call-update functions for the next update, thanks for that link.

And good to hear this is gonna be put to use already :) Good luck with the space game.
-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#17 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 15 June 2008 - 03:03 AM

Though with the new setting, it's all slow motion.

Yah, it appears that way since there is no real perspective to base the speed and distance on other than the camera's distance from the floor, which one assumes to be about 1.5m (looking through a persons eye's). Relative to the gravity however (assuming we are on earth), it's more like 10meters. Those cubes are ~15m in length, and that floor your standing on is nearly half a kilometer squared, so they are falling from quite a distance above. Set the gravity to around 100 and it should look more 'normal.'

Thanks for those numbers too; those are pretty nice results :( Good to hear it works on Vista too.
I'l certainly add some One-call-update functions for the next update, thanks for that link.

And good to hear this is gonna be put to use already :) Good luck with the space game.
-Andrew


Cool

Bug
global.GMBULLET_GMBULLET_ActivateBody = external_define('GMBullet.DLL','GMBULLET_ActivateBody',dll_cdecl,ty_real,2,ty_real,ty_real);


Are all the functions implemented? Or are some of them stubs... Because the only thing working (for me so far) is the world gravity. I can't seem to be able to add momentum manually to the objects using
Set/AddLinearVelocity...


I merged with my space game, thought the bullets are not "GMBulletized" yet, A added a collision with the cubes, and tries to add momentum to the cubes when the bullet hits... Maybe the values are too small. Though gravity s off and so is friction (I assume)

[edit]
Nevermind. I figured it out. I was activating the body on create... It got deactivated because it's not moving (I Guess). So my motion calls had no effect.

Tip: Move the function in the API... One less function to call.
Tip2: Give my angles in degrees (Add to the API, keep the original), one less GM interpretation line to do/ Lets squeeze as much juice out of it as we can...
[/edit]

So the values are meters... Good to know.


Perhaps you can add a setWorldScale. Similar to FMOD sound system.

[code=auto:0]
//export double FMODSetWorldScale(double scale)
//Sets the scale of the worls.
//Default scale is 1 meter per pixel
//it affects the doppler effect
//if your player moves 3 pixels in one second
//it will appear to the sound system as though he moved
//3 meters per second
//reduce the value to reduce the overall doppler effects in the game

return external_call(global.dll_FMODSetWorldScale,argumen
t0);
[/cdode]

In your case, it would affect speed and gravity

Edited by icuurd12b42, 15 June 2008 - 04:15 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#18 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 15 June 2008 - 03:52 AM

Bug
global.GMBULLET_GMBULLET_ActivateBody = external_define('GMBullet.DLL','GMBULLET_ActivateBody',dll_cdecl,ty_real,2,ty_real,ty_real);

Ah, the joys of copy and paste. Thank you, I'l fix the script.

Are all the functions implemented? Or are some of them stubs... Because the only thing working (for me so far) is the world gravity. I can't seem to be able to add momentum manually to the objects using
Set/AddLinearVelocity...

Yah, they are all implimented. Hmm, what type of object are you trying to add velocity too? Those particular functions only work with dynamic objects (type 1.) I think I tested those one's myself too, and found them to be working. Try Disabling deactivation when you create the bodies and try again, as a deactivated body won't respond to a manual momentum change (and Bullet handles deactivation for you.)

So the values are meters... Good to know.

The Bullet manual referances the units as meters, though I should think the actual unit does not really matter, other than sticking to something consistantly.

Perhaps you can add a setWorldScale. Similar to FMOD sound system.

Well, I would think that this is best implimented at the user-end, since scaling in those cases is a simple multiplication (I think the doppler effect uses a non-linear function,) and I don't think there would be any apreaciable speed difference between doing that in GM or in the DLL.

-Andrew

Edited by andbna, 15 June 2008 - 03:54 AM.

  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#19 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 15 June 2008 - 05:02 AM

[edit-from post above in case you missed it]
Nevermind. I figured it out. I was activating the body on create... It got deactivated because it's not moving (I Guess). So my motion calls had no effect.

Tip: Move the function (Activate) in the API... One less function to call. If I'm adding motion, I want it active now.
Tip2: Give me angles in degrees (Add to the API, keep the original), one less GM interpretation line to do/ Lets squeeze as much juice out of it as we can...
[/edit]

But if the object was inactive, why does gravity affect it. Perhaps Inactive and static are not the same thing

Yes, well, in your case, the factor would only affect gravity I think. Where a gravity of 1 would resolve in a variable distance/sec relative to the world scale. but you are right, I can resolve this. But since I’m calling a dll, It's best to differ the math there too. Again, to squeeze as much out of this thing as possible.

OK, you have GetWHATEVERxyz but dont have a SetWHATEVERyzy, forcing me to call GetWATEVERx,y,z when setting only one value...

Like
gmbSetLinearVelocity(body, gmbGetLinearVelocityX(body),gmbGetLinearVelocityY(
body),0)


Normally, it's not an issue, but in GM it is. If you provide
gmbSetLinearVelocityY(body,<value>);
that would limit the damage. Not complaining here.


OK. I found a bug. Not wanting to be picky, but during the simulation, a level of error introduces itself which, over time, such as in the space game I playing with right now causes problems.

All my objects are a z 0, colliding at z 0 (center). But, the objects start to rotate on the x or y axis after a period of time and the z value changes sot object no longer collide since they are no longer on the same level. Which IMHO, should not happen. It's with cubes.

The little 3d demo allows adding hundreds of spheres on top of each other. They don't fall and that is fine because they are on the exact same x,y axis. I was expecting the same result with collision on the exact same zaxis.

Don’t want to be thorn on your side here. But you see how this can be useful in a top down setting for a 2d or 3d game you don’t want the z or xr,yr to change.


Ah, And I found a useful function you should add for a lite weight object

ApplyCollision(body,fmass,fx,fy,fz,fxr,fyr,fzr,fxs
,fys,fzs,otherproperties,...)

Effectively faking 2 objects colliding, but using a fake object as opposed to a real one (f)arguments. Where I supply where the fake object is located, its rotation, and speed/direction.

That way I can have, for example, a lot of bullets not affected by the world and having no step event acting out on a real world object. I simply use GM's collision event as a pre-check for collision and apply the collision in the system... Which may or may not result in a real collision in the system, depending if the fake object, given the setting, would actually collide with the real one. Hope the paragraph is clear enough.


Man I am so impressed right now.


Looks like I can make compound objects!?? Can you tell me how? It's the reason I was writing my own DLL. My setup involved adding/grouping a bunch of circles/spheres inside a sprite/model for collision and rotation based on impact position/rotation/direction/speed


Oh, and what shapes are most efficient in the system?


Ok, enough for now. There's always tomorrow.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#20 Hepolite

Hepolite

    GMC Member

  • GMC Member
  • 130 posts
  • Version:Unknown

Posted 15 June 2008 - 11:30 AM

I have to say that this is amazing! It might be just what I need, if only I could understand how to use it. i need some help with some models, a .3ds model.

The code I have now is:

gmbStartTriMeshShape();
gmbLoad3DS(working_directory+"\test.3ds");
shape=gmbFinishTriMeshShape(0);

But it don't work...
What would be the correct way for doing this?

Also, I'd like to see a description of what the script does inside GM, not just in the help-file. That would make this much easier to use.
  • 0
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why.

#21 luenardi

luenardi

    GMC Member

  • New Member
  • 323 posts

Posted 15 June 2008 - 03:32 PM

I Have tested this in U3D it rules hardcore.
ThanX
  • 0

Posted Image

My system: CoreI5 661, 6GB Ram, 2X GF280GTX 2GB, Boot Drive 6GBPS SDD, 2x 500GB storage.
Boot time on Win7 Ultimate 5.02 seconds.

#22 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 15 June 2008 - 05:00 PM

That way I can have, for example, a lot of bullets not affected by the world and having no step event acting out on a real world object. I simply use GM's collision event as a pre-check for collision and apply the collision in the system... Which may or may not result in a real collision in the system, depending if the fake object, given the setting, would actually collide with the real one. Hope the paragraph is clear enough.

So bullet's actualy push the other player? Now thts cool :( Il certainly add such a function. And 'ok' to the worldScale and degree-based angles, and I'l make sure there are some addVeclocity functions (and wherever else such type of functions would be applicable, eg; an addGravity too.)

Don’t want to be thorn on your side here. But you see how this can be useful in a top down setting for a 2d or 3d game you don’t want the z or xr,yr to change.

Actualy, I encountered that as soon as I started toying with it in GM, so I added the option of specifying a Null-collision shape when creating a rigid body, with that you can use a constraint to limit motion to 2D:
nullBody=GMBULLET_AddRigidBody(0,0,-1,0,0,0,0,0,0,0,0,0,0); //Create a static non-colliding body at the origin
GMBULLET_Prepare2BodyConstraint(nullBody,0,0,0,0,0,0,0);
playerConstraint=GMBULLET_Create2Body6DOFConstrain
t(playerBody,0,0,0,0,0,0,0,1,1); //Create a 6DOF constraint between your 2D object and the null body
GMBULLET_Set6DOFLimit(playerConstraint,0,1,0); //Unlock the x 
GMBULLET_Set6DOFLimit(playerConstraint,1,1,0); // and y axis
GMBULLET_Set6DOFLimit(playerConstraint,2,0,0); //Lock the Z axis
GMBULLET_Set6DOFLimit(playerConstraint,3,0,0);//Lock rotation about x
GMBULLET_Set6DOFLimit(playerConstraint,4,0,0);// and y axis
GMBULLET_Set6DOFLimit(playerConstraint,5,0,0); //Optional: lock, limit, or free rotation about the z-axis.
Il add a "2D" constraint though, for simplicity, which will do that for you.

Now, I'm not sure which primitives have the most efficient collision algorithm, as each one has it's own, but I think the boxes and spheres are the best (most likely sphere's are the most efficient.) I can tell you that triangle meshes would be the slowest.

to make a coumpound shape,
use:
GMBULLET_StartCompoundShape, to begin
Add child shapes with GMBULLET_AddToCompoundShape, specifying thier location and orientation within the compound shape. Note that the child shapes need to stay alive as long as the compound shape is. Thus, if you add a box shape, then create a compound shape and add that box as a child, you can't delete the box untill you delete the compound shape (or rather, you CAN delete the box, but your going to get an access violation and crash the game next time you step the simulation.)

Finally, GMBULLET_FinishCompoundShape will return the Shape ID of your new compound shape.

Quick fun: You can nest calls of Start and Finish compound shape, just like you can with curly brackets in code. If you add a compound shape in this manner, it is always added to the most recently started, and still-unfinished, shape.
Anyway, thank you for all the feedback icuurd, it has been very helpfull.

Hepolit:
The start triangle mesh functions are there only if you want to manualy add the faces for a tri-mesh. The model loading functions take care of all that buisness for you however, so you need not wory about them.
Instead, to load a 3DS model, which will be stored as a Shape, first call Load3DS as you have done.
This function will return the number of meshes that it found in the 3DS shape (this function is set up so you can load multiples meshes from a single 3DS.)

If you know that this model only has 1 mesh, the next part is quite simple:
just call gmb3DSGetNextMeshShape(0,MeshType)
Where MeshType is either 0 for a convex mesh, 1 for a non-moving concave, or 2 for a moving concave.
0 is fastest, but your sacrificing accuracy for speed. 1 is the second fastest, but you can only use it on static objects (type 0,) 2 is for the rest.

It returns a ShapeID which you can use to make a rigid body with.

Also, I'd like to see a description of what the script does inside GM, not just in the help-file. That would make this much easier to use.

What do you mean by that? As in an example of what each function does?


Finally, thanks Luenardi, glad yo hear you like it! :)
-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#23 Rixeno

Rixeno

    The One 'n' Only

  • New Member
  • 513 posts

Posted 15 June 2008 - 05:07 PM

I have to say that this is amazing! It might be just what I need, if only I could understand how to use it. i need some help with some models, a .3ds model.

The code I have now is:

gmbStartTriMeshShape();
gmbLoad3DS(working_directory+"\test.3ds");
shape=gmbFinishTriMeshShape(0);

But it don't work...
What would be the correct way for doing this?

Also, I'd like to see a description of what the script does inside GM, not just in the help-file. That would make this much easier to use.

I think you have to do this instead
var i,shape;
model_meshes=//The amount of meshes in the model
gmbStartCompoundShape();
gmbLoad3DS(working_directory+"\test.3ds");
for (i=0;i<model_meshes;i+=1)
{
shape=gmb3DSGetNextMeshShape(0,0);
gmbAddToCompoundShape(shape,0,0,0,0,0,0,0);
}
object_shape=gmbFinishCompoundShape();
I'm not quite sure, some functions may have to be tweaked cause I just made this from reading the help file, and you might have to change the xyz and rx/ry/rz/rFlags for the AddToCompoundShape depending on stuff. No garanties of working :(

NOTE: You'll have to know how many meshes you have to do this way I think, or you can just check every step in the "for" statement and see if "shape==0" to know when it's done.

If the other worked, this might work too
var i,shape;
gmbStartCompoundShape();
gmbLoad3DS(working_directory+"\test.3ds");
do
{
shape=gmb3DSGetNextMeshShape(0,0);
gmbAddToCompoundShape(shape,0,0,0,0,0,0,0);
}
until (gmb3DSGetNextMeshShape(0,0)==0) 
object_shape=gmbFinishCompoundShape();

EDIT: BTW, I updated the example with what Andbna said about StepTimeSimulation, cause I had no idea what it meant really :)... DOWNLOAD

Edited by Rixeno, 15 June 2008 - 05:10 PM.

  • 0
Do you need an example? You can PM me a request and I'll try my best.
Creations:
- Extra String Functions - Sprite Chroma Key - String at Position - Word Censor - Draw_Line_Width (Unreg GM6-) - Shadowed Text - Draw N-Gon - PIXEL PERFECT COLLISION ENGINE-

#24 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 16 June 2008 - 03:28 AM

That way I can have, for example, a lot of bullets not affected by the world and having no step event acting out on a real world object. I simply use GM's collision event as a pre-check for collision and apply the collision in the system... Which may or may not result in a real collision in the system, depending if the fake object, given the setting, would actually collide with the real one. Hope the paragraph is clear enough.

So bullet's actualy push the other player? Now thts cool :whistle: Il certainly add such a function. And 'ok' to the worldScale and degree-based angles, and I'l make sure there are some addVeclocity functions (and wherever else such type of functions would be applicable, eg; an addGravity too.)

That fake object method would be great to induce proper v/r-exchange. Better than addVelocity.

And the SetVelocityZ(0) will help tweak stuff witout having to call too many DLL calls

Don’t want to be thorn on your side here. But you see how this can be useful in a top down setting for a 2d or 3d game you don’t want the z or xr,yr to change.

Actualy, I encountered that as soon as I started toying with it in GM, so I added the option of specifying a Null-collision shape when creating a rigid body, with that you can use a constraint to limit motion to 2D:
nullBody=GMBULLET_AddRigidBody(0,0,-1,0,0,0,0,0,0,0,0,0,0); //Create a static non-colliding body at the origin
GMBULLET_Prepare2BodyConstraint(nullBody,0,0,0,0,0,0,0);
playerConstraint=GMBULLET_Create2Body6DOFConstrain
t(playerBody,0,0,0,0,0,0,0,1,1); //Create a 6DOF constraint between your 2D object and the null body
GMBULLET_Set6DOFLimit(playerConstraint,0,1,0); //Unlock the x 
GMBULLET_Set6DOFLimit(playerConstraint,1,1,0); // and y axis
GMBULLET_Set6DOFLimit(playerConstraint,2,0,0); //Lock the Z axis
GMBULLET_Set6DOFLimit(playerConstraint,3,0,0);//Lock rotation about x
GMBULLET_Set6DOFLimit(playerConstraint,4,0,0);// and y axis
GMBULLET_Set6DOFLimit(playerConstraint,5,0,0); //Optional: lock, limit, or free rotation about the z-axis.
Il add a "2D" constraint though, for simplicity, which will do that for you.

Woa, that is complicated.

Here is a dumbed down suggestion
EnableVelocityXYZ(body,true,true,false);
EnableRotationXYZ(body,false,false,true);

EnableWorldVelocityXYZ(true,true,false);
EnableWorldRotationXYZ(false,false,true);


Now, I'm not sure which primitives have the most efficient collision algorithm, as each one has it's own, but I think the boxes and spheres are the best (most likely sphere's are the most efficient.) I can tell you that triangle meshes would be the slowest.

to make a coumpound shape,
use:
GMBULLET_StartCompoundShape, to begin
Add child shapes with GMBULLET_AddToCompoundShape, specifying thier location and orientation within the compound shape. Note that the child shapes need to stay alive as long as the compound shape is. Thus, if you add a box shape, then create a compound shape and add that box as a child, you can't delete the box untill you delete the compound shape (or rather, you CAN delete the box, but your going to get an access violation and crash the game next time you step the simulation.)

Finally, GMBULLET_FinishCompoundShape will return the Shape ID of your new compound shape.

Quick fun: You can nest calls of Start and Finish compound shape, just like you can with curly brackets in code. If you add a compound shape in this manner, it is always added to the most recently started, and still-unfinished, shape.

So I could get a sub body from the main body out of that so I could map a sub body to a real instance? Let's say, I have a space station with 3 arms extending from the center base, and each arms has another part at the tip. I could split those into 1 main body, 3 arms 3 tipsand actually have them work in concert and have a matching object set in GM?...


Yea, I know it's hard to get

Posted Image

Anyway, thank you for all the feedback icuurd, it has been very helpfull.


Cool. I'm sure I'll have more insights soon.


I'm thinking there is a method to limit the DLL calls to 1 call per step, yes only one. I'll tell you about it the next time around. I need to refer back to my original dll notes.

Edited by icuurd12b42, 16 June 2008 - 03:29 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#25 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 16 June 2008 - 04:12 AM

That fake object method would be great to induce proper v/r-exchange. Better than addVelocity.

Actualy; I think I managed to ommit a fairly usefull function that applys an impulse at a certain point and direction; thus having Bullet compute the torque and velocity change.

So I could get a sub body from the main body out of that so I could map a sub body to a real instance? Let's say, I have a space station with 3 arms extending from the center base, and each arms has another part at the tip. I could split those into 1 main body, 3 arms 3 tipsand actually have them work in concert and have a matching object set in GM?...

Well, first I think I made a typo: what I meant to say was when nesting compound shape start calls, any shapes added with GMBULLET_AddToCompoundShape are added to the most recently started compound shape. The nested compound shape itself is not automaticaly added to anything. However, it would be a trivial matter to add said shape to the higher scope one when it is finished; (so you can have compound shapes composed of compound shapes.)
So yes, your spacestation would be feasable.

Of course, individual arm locations would need to be computed based upon the central body's position and orientation, and if you wanted it to say, explode, you would have to make some new shapes and rigid bodies. Off course, if it's not exploding, and one big model, then no problems.

Woa, that is complicated.

Here is a dumbed down suggestion
EnableVelocityXYZ(body,true,true,false);
EnableRotationXYZ(body,false,false,true);

EnableWorldVelocityXYZ(true,true,false);
EnableWorldRotationXYZ(false,false,true);

Yah it is at first glance: il just make a function: GMBULLET_Create2DConstraint(BodyID,bool_zRotationL
ocked);

-Andrew

Edited by andbna, 16 June 2008 - 04:14 AM.

  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#26 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 16 June 2008 - 06:19 AM

That fake object method would be great to induce proper v/r-exchange. Better than addVelocity.

Actualy; I think I managed to ommit a fairly usefull function that applys an impulse at a certain point and direction; thus having Bullet compute the torque and velocity change.

So I could get a sub body from the main body out of that so I could map a sub body to a real instance? Let's say, I have a space station with 3 arms extending from the center base, and each arms has another part at the tip. I could split those into 1 main body, 3 arms 3 tipsand actually have them work in concert and have a matching object set in GM?...

Well, first I think I made a typo: what I meant to say was when nesting compound shape start calls, any shapes added with GMBULLET_AddToCompoundShape are added to the most recently started compound shape. The nested compound shape itself is not automaticaly added to anything. However, it would be a trivial matter to add said shape to the higher scope one when it is finished; (so you can have compound shapes composed of compound shapes.)
So yes, your spacestation would be feasable.

Of course, individual arm locations would need to be computed based upon the central body's position and orientation, and if you wanted it to say, explode, you would have to make some new shapes and rigid bodies. Off course, if it's not exploding, and one big model, then no problems.

Woa, that is complicated.

Here is a dumbed down suggestion
EnableVelocityXYZ(body,true,true,false);
EnableRotationXYZ(body,false,false,true);

EnableWorldVelocityXYZ(true,true,false);
EnableWorldRotationXYZ(false,false,true);

Yah it is at first glance: il just make a function: GMBULLET_Create2DConstraint(BodyID,bool_zRotationL
ocked);

-Andrew


Cool, we'll see how it goes... but I believe my EnableVelocityXYZ is a little more obvious though. A little tip is try to put yourself in the mindset you were in when you started this. The "I have no clue" mindset is very useful to dumb down your interface to a level that is useable right away by your users. Helping you providing a easy to use set of api as well as a hard core one.

We often find ourselves rewriting the same complicated interface when making a wrapper dll. At one point we are so much into it that everything becomes too obvious for us and we start to expect the same from our users.

Does the impulse function take mass,direction,speed,rotation and all that jazz as argument? Or does it need me to have to calculate things manually?


OK, I'm not sure I got the compound system 100%, I will play with it for a bit.

here is how it works in my setup

each instance has a owner id and a children array id

I can add children to the base (3 arm holders)

Then I add an arm to the 3 arm holder

Then I add a tip to each arm

PRE

base
holder1
arm1
tip1
holder2
arm2
tip2
holder3
arm3
tip3


At any time, I can unhook anything from anything. I can unhook arm2 from holder2 at this point the compound base mass is what it was minus the removed parts and the center of gravity shifts (Hoping my dll would do that). And arm2 and tip2 become a single compound object made of 2 components.


With your setup, I would like each instance to obey their bullet body position, like the demo does. Without having to code anything special in case it's part of a larger group.



OK. I found the notes on a single DLL call per step.

The premiss/reason: though GML is slow and calling a DLL function can help accelerate the game speed but calling too many dll functions will actually cause the game to be slower than interpreting the same amount of GML code. That is if you call 100 dll functions that do nothing but say x=x and do the same in gml (x=x), GML will be faster (much). So the DLL functions have to do a lot more for you for the implementation to be useful (Your stuff does that).

In short, if the DLL does the heavy duty stuff for you, it's useful as long as the system does not bottleneck to the point where GML would be faster.

The bottleneck is the getValues in your case. you can setup a system that you dont need to get the values for every intance from the dll every step. But only when the simulation detects a drastic change. You let gm do the moving as it does and update only when the bullet system detects a change it knows gm must resync with.

here an example to help you visualise what this implies


in the step event of the bulletcontroller
if(gmbWorldNeedsReSync())
{
	with(BulletObjects)
	{
		 if(gmbNeedsReSync(body))
		 {
			 vspeed = gmbGetVSpeed(body);
			 hspeed = gmbGetHSpeed(body);
			 friction= gmbGetFriction(body);
			 x= gmbGetX(body);
			 y= gmbGetY(body);
		 }
	}
}

That's it! No code (in this case) is required in the instances. GM does what it does bullet does what it does, they work together... That is, of course if the values are "compatible" and calculated the same way.


Of course, we are dealing with 3d here so we need to add code in the BulletObjects parent to deal with the values GM does not handle at it's core.

BulletObjects step event (simplified);
zspeed+=zgravity;
zspeed -=zfriction; //it's not that exactly but you get the point
z+=zspeed;

xrotspeed -= xrotfriction;
xangle += xrotspeed;

yrotspeed -= yrotfriction;
yangle += yrotspeed;

zrotspeed -= zrotfriction;
zangle += zrotspeed;
image_angle = zangle; //2d

//Now the controller step event again
if(gmbWorldNeedsReSync())
{
	with(BulletObjects)
	{
		 if(gmbNeedsReSync(body))
		 {
			 vspeed = gmbGetVSpeed(body);
			 hspeed = gmbGetHSpeed(body);
			 friction= gmbGetFriction(body);
			 x= gmbGetX(body);
			 y= gmbGetY(body);
			 xangle= gmbGetXangle(body);
			 yangle= gmbGetYangle(body);
			 zangle= gmbGetZangle(body);
			 ...
			 and so on for zfriction, rotation speeds, gravity, gravity_direction, zgravity
		 }
	}
}

That method would push the instance limit close to gm's native limit. Hope you give it some thought.


Cheers!

Next up is the collision triggering system. That will blow your mind (too) I think.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#27 qwertyuiop23

qwertyuiop23

    GMC Member

  • New Member
  • 940 posts

Posted 16 June 2008 - 07:37 AM

Rixeno. Just a suggestion change the size of the texture to a power of 2; 2 4 8 16 32 64 128 256 etc it makes the texture not be screwy on some computers.
  • 0

#28 Hepolite

Hepolite

    GMC Member

  • GMC Member
  • 130 posts
  • Version:Unknown

Posted 16 June 2008 - 12:45 PM

<snip>


Well, I tried it, but it didn't work. I tried to add some more code, and ended up with this:

var i,shape;
object_shape=gmbStartCompoundShape();
i=gmbLoad3DS(working_directory+"\test.3ds");
repeat(i)
{
shape=gmb3DSGetNextMeshShape(0,1);
gmbAddToCompoundShape(shape,0,0,0,0,0,0,0);
}
object_shape=gmbFinishCompoundShape();

But this returns an unexpected error, and I need to know how to make this work.

EDIT:
It has to be some errors with the gmbStartCompoundShape(). I ran a quick test, if(gmb...){}, and it returned not succeded. This causes an unexpected error when it comes to gmbFinishCompondShape().

Edited by Hepolite, 16 June 2008 - 01:03 PM.

  • 0
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why.

#29 gandalf20000

gandalf20000

    GMC Member

  • New Member
  • 478 posts

Posted 16 June 2008 - 09:44 PM

I think it's probably a coding error. gmbLoad3DS loads the model. gmb3DSGetNextMeshShape loads the meshes.

I'm having problems with this myself, though... I'm trying to load some terrain for my game (which is using U3D), but when I try to load the terrain, which is static, the physics object, which is dynamic, goes straight through the terrain.
  • 0
Programming rig:
Pentium E2160 dual core processor at 1.8 GHz, Intel 945G chipset, BFG NVidia 8500 GT with 512 MB of GDDR2 RAM, 3 GB of dual-channel DDR2 RAM at 667 MHz, 400 GB 7200 RPM hard drive, Labelflash capable DVD RW drive. 20" 1600x900 monitor.

Gaming rig:
Intel Core i7 920 @ 2.66 GHz, Intel X58 Express chipset, NVidia GTS 250 with 1 GB of GDDR3 RAM, 9 GB of triple-channel DDR3 RAM at 1066 MHz, 1 TB 7200 RPM hard drive, Lightscribe capable DVD RW drive, Blu-Ray drive. 23" 1920x1080 monitor.

#30 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 16 June 2008 - 10:07 PM

Is it all done? Like all functions?
  • 0

#31 ZZ man

ZZ man

    GMC Member

  • New Member
  • 1745 posts

Posted 17 June 2008 - 05:25 PM

Nice
  • 0
If you will be laughing on December 23 2012, put this in your sig.

#32 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 17 June 2008 - 09:39 PM

Thank's ZZ man, glad you like it.

Is it all done? Like all functions?

All the functions listed in the help file/scripts/GEX are implimented (and appear to be working), but I am by no means finished, as you can see from the dialogue between Icuurd and myself, there's plenty comming.

Hepolite:
First; the compound shapes and the 3DS loader are completely independant; though you may wish to add models into a compound shape as they are loaded, it is irrelevant.
Next, if you are getting errors, can you (and Gandalf too, or anyone else with poblems,) post the return values of the functions? They are pretty specific.

That said, taking Icuurd's suggestions into account; I may redo those functions and replace them with a single-call loader; in which a ds_map is returnedm with the ShapeID as the key, and the model name as the value (or something allong those lines.)

In the meantime here is a code snippet which will load all the meshes into 1 compound shape, based on your script Hepolite;
var i,shape,mesh_array;
gmbStartCompoundShape();
i=gmbLoad3DS(working_directory+"\test.3ds");
for(j=0,j<i;j+=1)
{
shape=gmb3DSGetNextMeshShape(0,1);
gmbAddToCompoundShape(shape,0,0,0,0,0,0,0);
mesh_array[j]=shape //Keep track of those shape ID's so you can delete them latter, otherwise you will create memory leaks
}
object_shape=gmbFinishCompoundShape();
Anyway, this isn't different eanough to rule out the error, so again, could you post the return values?

Does the impulse function take mass,direction,speed,rotation and all that jazz as argument? Or does it need me to have to calculate things manually?

It operates on 1 body, and I believe it takes 2 vectors and a scalar for input: the point relative to the body, and the direction of the impulse, with of course the magnitude as the scalar. I'l check the API latter, right now im swapping thing's onto a new computer ^_^
Anyway, I read the rest of your post Icuurd, and I'm going figure out the best way to impliment your sudgestions.
Though, one thing I should like to know is: what's the speed of he ds_*_getstring functions? Perhaps a grid could be used to get the transformations for every object at once (via one collossal string.)

-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#33 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 17 June 2008 - 10:38 PM

So the DLL is incomplete? Missing a few functions?
  • 0

#34 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 18 June 2008 - 12:07 AM

Does the impulse function take mass,direction,speed,rotation and all that jazz as argument? Or does it need me to have to calculate things manually?

It operates on 1 body, and I believe it takes 2 vectors and a scalar for input: the point relative to the body, and the direction of the impulse, with of course the magnitude as the scalar. I'l check the API latter


The point I wanted to stress is that I dont want to have to determine the vector values (other than rotation and direction and speed), cause I'm lazy, from having to get the mass from the object I'm adding impulse to and the mass of my bullet and have to calculate what the final vectors would be... If you get what I mean. Usually the low level functions force you to have to calculate things prior... Nothing wrong with that, it's useful to have, but I believe higher level functions are also a good thing to have...

eg
AddImpulseWithMass(body, x,y,z,vx,vy,vz,vrx,vry,vrx,mass)

Anyway, I read the rest of your post Icuurd, and I'm going figure out the best way to impliment your sudgestions.
Though, one thing I should like to know is: what's the speed of he ds_*_getstring functions? Perhaps a grid could be used to get the transformations for every object at once (via one collossal string.)

-Andrew

I'm not sure how fast it would be. But it's worth giving it a shot. And yes having a grid with all objects could make things faster but there is always a chance to hit some sort of limit due to the string size.

Have you looked at my one call per step suggestion? That method could also be sufficient enough so you would not need to use a ds_grid at all because, on average, only a few objects would need updating once in a while.

I have another more streamlined sln. Which does not have to loop through each object using a with statement. I was saving it for this post. Still not using a grid system, but you can modify it to use a grid later on.

OK, I mentioned triggering collision events in my prior post... Because now that bullet handles collision event, We still need to catch the collision event in gm for special handling such as to inflict damage.


How to do this? Well you need to associate the body with an instance... You do that in GM but the association can also be useful in the dll itself for later on.

body=gmbAddRigidBody( random(100)+100,1, shape_box, x, y, z, rotx, roty, rotz, 0);
gmbAssociate( body, id);
or
body=gmbAddRigidBody( random(100)+100, 1, shape_box, x, y, z, rotx, roty, rotz, 0, id);

All you need is to add the extra UINT to your structure that will hold GM's instance id.

How is this useful?
Now, in your simulation, you can keep track of what collided/needs updating and make a list/collection in the dll for me to look through later on. You could even keep track of what colided with what... Make a list consisting of 2 entries of each body (gm instances) that collides

Now the code example I provide before
if(gmbWorldNeedsReSync())
{
	with(BulletObjects)
	{
		 if(gmbNeedsReSync(body))
		 {
			 vspeed = gmbGetVSpeed(body);
			 hspeed = gmbGetHSpeed(body);
			 friction= gmbGetFriction(body);
			 x= gmbGetX(body);
			 y= gmbGetY(body);
		 }
	}
}

can be replaced with
var inst;
if(gmbWorldNeedsReSync())
{
	inst = gmdWorldGetFirstSync();
	loop
	{
		with(inst)
		{
			//if(gmbNeedsReSync(body)) //no longer needed
			{
				 vspeed = gmbGetVSpeed(body);
				 hspeed = gmbGetHSpeed(body);
				 friction= gmbGetFriction(body);
				 x= gmbGetX(body);
				 y= gmbGetY(body);
			 }
		 }
		 inst = gmdWorldGetNextSync()
	} until (!inst)
}

So now, every once in a while, gm would have to resync with bullet... Usually, only 2 objects would be involved when that happens; because it usually needs resync when 2 objects collided. So, once in a while, you would have to make, in the case above, 13 calls to the dll.

One call every step, and 13 calls now and then... Now that is a lot better than 6 calls per instance per step.


And now you have a means to trigger collision events too. If you keep a collision pair list is the dll, you can trigger gm's collision event in the controller loop


if your collision pair list list looks like this
100001
100002

100001
100003

No duplicates

//the collision trigger code would look like this
var inst,inst2;
if(gmbWorldNeedsReSync())
{
	inst = gmdWorldGetFirstSync();
	if(inst)
	loop
	{
		with(inst)
		{
			//if(gmbNeedsReSync(body)) //no longer needed
			{
				 vspeed = gmbGetVSpeed(body);
				 hspeed = gmbGetHSpeed(body);
				 friction= gmbGetFriction(body);
				 x= gmbGetX(body);
				 y= gmbGetY(body);
			 }
		 }
		 inst = gmdWorldGetNextSync()
	} until (!inst)

	inst = gmdWorldGetFirstCollision();
	if(inst)
	loop
	{
		inst2 = gmdWorldGetNextCollision();
		with(inst2)
		{
			 with(inst)
			 {
				  event_perform(ev_collision,other.object_index)
				  with(inst2)  event_perform(ev_collision,other.object_index)
			 }
		}
		inst = gmdWorldGetNextCollision()
	} until (!inst)
}


if your collision pair list list looks like this (now actually collision quads)
100001
100002

100002
100001


100001
100003

100003
100001

note the duplicates

//the collision trigger code would look like this
var inst,inst2;
if(gmbWorldNeedsReSync())
{
	inst = gmdWorldGetFirstSync();
	if(inst)
	loop
	{
		with(inst)
		{
			//if(gmbNeedsReSync(body)) //no longer needed
			{
				 vspeed = gmbGetVSpeed(body);
				 hspeed = gmbGetHSpeed(body);
				 friction= gmbGetFriction(body);
				 x= gmbGetX(body);
				 y= gmbGetY(body);
			 }
		 }
		 inst = gmdWorldGetNextSync()
	} until (!inst)

	inst = gmdWorldGetFirstCollision();
	if(inst)
	loop
	{
		inst2 = gmdWorldGetNextCollision();
		with(inst2)
		{
			 with(inst)
			 {
				  event_perform(ev_collision,other.object_index)
			 }
		}
		inst = gmdWorldGetNextCollision()
	} until (!inst)
}


I pretty sure the concept is sound. It's the method I was planning for my dll. Now I pass the ball on to you.

Hope you find this information useful...

Have fun!
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#35 gandalf20000

gandalf20000

    GMC Member

  • New Member
  • 478 posts

Posted 18 June 2008 - 03:23 PM

Hepolite:
First; the compound shapes and the 3DS loader are completely independant; though you may wish to add models into a compound shape as they are loaded, it is irrelevant.
Next, if you are getting errors, can you (and Gandalf too, or anyone else with poblems,) post the return values of the functions? They are pretty specific.

The return value I'm getting is 2. The physics object falls straight through and lands on an invisible platform that is a static rigid body, which keeps it from falling even more. It rolls around and pokes through the terrain, and when I remove the platform, it falls straight through again.
  • 0
Programming rig:
Pentium E2160 dual core processor at 1.8 GHz, Intel 945G chipset, BFG NVidia 8500 GT with 512 MB of GDDR2 RAM, 3 GB of dual-channel DDR2 RAM at 667 MHz, 400 GB 7200 RPM hard drive, Labelflash capable DVD RW drive. 20" 1600x900 monitor.

Gaming rig:
Intel Core i7 920 @ 2.66 GHz, Intel X58 Express chipset, NVidia GTS 250 with 1 GB of GDDR3 RAM, 9 GB of triple-channel DDR3 RAM at 1066 MHz, 1 TB 7200 RPM hard drive, Lightscribe capable DVD RW drive, Blu-Ray drive. 23" 1920x1080 monitor.

#36 Hepolite

Hepolite

    GMC Member

  • GMC Member
  • 130 posts
  • Version:Unknown

Posted 18 June 2008 - 04:46 PM

Well, the code did make things work,
I just couldn't have more than one of the object.
  • 0
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why.

#37 luenardi

luenardi

    GMC Member

  • New Member
  • 323 posts

Posted 19 June 2008 - 04:32 AM

Dude the Rotations are still funky...
@ Rixeno
just noticed i used the same keys you did how odd is that..
  • 0

Posted Image

My system: CoreI5 661, 6GB Ram, 2X GF280GTX 2GB, Boot Drive 6GBPS SDD, 2x 500GB storage.
Boot time on Win7 Ultimate 5.02 seconds.

#38 Rixeno

Rixeno

    The One 'n' Only

  • New Member
  • 513 posts

Posted 19 June 2008 - 02:17 PM

Doesn't U3D and D3D have different rotations though? So you would have to use a different rotation flag right? Or just switch the rotations from y/z/x to something else.
  • 0
Do you need an example? You can PM me a request and I'll try my best.
Creations:
- Extra String Functions - Sprite Chroma Key - String at Position - Word Censor - Draw_Line_Width (Unreg GM6-) - Shadowed Text - Draw N-Gon - PIXEL PERFECT COLLISION ENGINE-

#39 mrsmes

mrsmes

    GMC Member

  • GMC Member
  • 1506 posts
  • Version:GM:Studio

Posted 21 June 2008 - 10:40 AM

the example, file still contains errors such as executing a external function.
  • 0

Assuming I helped you out in a questions and answers topic won't you return the favour by helping me with one my coding problems, or recommend some one who can chat to me over pms about helping and how to overcome my obstacles, after all lets just say I did help you or them or many people with similar problems, in that topic.

Here i have a topic for those of you struggling with type writer text and mugshots in your games especially if it is a rpg see the link below for more info

http://gmc.yoyogames...howtopic=619103

almost no code needed, only uses two events.

click here for the l8est version of feed the alien pizza, it has some major polished up features.


#40 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 21 June 2008 - 05:59 PM

The return value I'm getting is 2. The physics object falls straight through and lands on an invisible platform that is a static rigid body, which keeps it from falling even more. It rolls around and pokes through the terrain, and when I remove the platform, it falls straight through again.

Positive values indicate a success. Which function is returning 2? Are you calling other functions? (You must be if your creating a rigid body,) What are thier return values? Maby post the code snippet?

Well, the code did make things work,
I just couldn't have more than one of the object.

Could you be a bit more specific?

Dude the Rotations are still funky...

Are you applying them in the order: y, z, x?

the example, file still contains errors such as executing a external function.

Did you extract the ZIP file and run the EXE in the same location as the DLL? Try compiling an actual EXE to do this.


The point I wanted to stress is that I dont want to have to determine the vector values (other than rotation and direction and speed), cause I'm lazy, from having to get the mass from the object I'm adding impulse to and the mass of my bullet and have to calculate what the final vectors would be... If you get what I mean. Usually the low level functions force you to have to calculate things prior... Nothing wrong with that, it's useful to have, but I believe higher level functions are also a good thing to have...

eg
AddImpulseWithMass(body, x,y,z,vx,vy,vz,vrx,vry,vrx,mass)

Alright, Il add a similar function. It does not take rotation as an argument (it calculates torque based upon the position the impulse is applied at) and it will calculate the momentum gain based on mass and a velocity vector.

After reading the rest of your post; here is what I think I will impliment:
-Functions to retrieve a list of currently active collision bodies; Bodies deactivate automaticaly when thier velocities fall below a certain threshhold; I will provide functions to set those threshholds. This is essentialy a list of bodies who 'need an update' for thier positions each step.
This would be the single call per step, plus updates for any returned bodies.
-Functions to retrieve a list of the collision pairs dispatched during the previouse StepSimulation call. Duplicates will not be generated; however, if multiple simulations steps are done in a single StepSimulation call, a pair could collide twice, creating a duplicate in that respect. Will add options to remove such duplicates. Alternativly, a list of bodies who collided could be querried; a body who collided with 2 objects in one step (like a ball hitting the corner of a floor and wall) would only appear once on this list.
-Functions to retrive multiple properties at once (eg: transformation information put into a ds_* string.)

Tell me what you think of that.

So the DLL is incomplete? Missing a few functions?

More functions can (and are) certainly being added. It is by not a complete reperesentation of the Bullet Library (and as Bullet is being constantly updated; eg: the release of some SoftBody support in April, it will never be truly complete.)

-Andrew

Edited by andbna, 21 June 2008 - 06:42 PM.

  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#41 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 22 June 2008 - 02:18 AM

the example, file still contains errors such as executing a external function.


Before you start, save the project... If the dll is in the folder of the project, that should fix this (GM bug) problem. I have hit this snag before with GMPhysics and GMNPF and GMFMODSimple...

If that does not fix it, the problem could be that andbna is using msvc and not devc++... in that case, some pcs are missing 2 or 3 dll files used by the msvc binaries... I can't remember what they are... that is why I use msvc for testing then recompile with devc++

After reading the rest of your post; here is what I think I will impliment:
-Functions to retrieve a list of currently active collision bodies; Bodies deactivate automaticaly when thier velocities fall below a certain threshhold; I will provide functions to set those threshholds. This is essentialy a list of bodies who 'need an update' for thier positions each step.
This would be the single call per step, plus updates for any returned bodies.
-Functions to retrieve a list of the collision pairs dispatched during the previouse StepSimulation call. Duplicates will not be generated; however, if multiple simulations steps are done in a single StepSimulation call, a pair could collide twice, creating a duplicate in that respect. Will add options to remove such duplicates. Alternativly, a list of bodies who collided could be querried; a body who collided with 2 objects in one step (like a ball hitting the corner of a floor and wall) would only appear once on this list.
-Functions to retrive multiple properties at once (eg: transformation information put into a ds_* string.)

Tell me what you think of that.


That sound good.

If there is a way to implement the loops I suggested, that would be best... But that requires emulation in GM as well. I was implying that moving object (non colliding) would not cause the system to require a resynch since GM would move it's objects the same way the bullet system does based on velocities/position of the last synch. Resynchs would only be needed when they would hit something that would change their speed and direction and rotation speeds...

Making a list of active objects does the same things but it will be a little more intencive on GM as active objects are moving, so they require to get their bullet properties ever step. Still, it is an acceptable progressinve step.

Simply doing a check in every object before getting the x,y,z will improve performance too...

if(!BULLET_isActive(body)) exit;
x = getx
y = gety
z = getz

Adding a list of colliding objects... that will be grand... Do remove the duplicates. Come to think of it, I can make my synch loop just based on that actually. I assume you will add the gmbAssociate(body,id) so the list you generate will have GM ids which is much more useful to us.


I got the bullet documentation and sources to learn the capabilities... I found that I can make my space station using joints instead of a compound body.


I also found PhysX from NVIDIA... It's sounds like the 2 system have the exact same features. Except, form payling with them both on my system, physX seems to be faster. It also has deactivation and will use your physics chip if you have one... You should seriously take a look at it. Could it be that bullet is PhysX under disguise?

Sounds like we covered everything regarding motion and collision here. Keep me informed when you add the lists in.



OK I see the ray tracing samples.

That is CollisionLine3d

So, my next suggestion, is to add the CollisionXXXfunctions that gm has but for 3d.

id = CollisionLine3d(x,y,z,x2,y2,z2,object or id,presision, notme)

same for CollisionBox, CollisionSphere

InstancePlace3d would be nice... Take a look a GM's collision functions... The ones that return a gm id are the most important.


This implies adding another association to the body

gmbAssociate(body,id,id.object_index)



The APIs now can be gm id centric... And some can be GM id or object index centric. You could possibly phase out the need to hold the body in the gm instance since you now have a gm id in your dll...


OK, that's enough for now.

Edited by icuurd12b42, 22 June 2008 - 02:22 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#42 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 22 June 2008 - 08:48 AM

BTW, dont try that string and ds_list just yet. I'm doing some tests right now and it does not look promissing.


[edit]

I made a boo boo in my test bench...

raw ds_list get access
1482837 calls in 10 seconds
raw API calls
414825 calls in 10 seconds

So, if making a ds_list buffer in the dll and loading it up using ds_read() is not much of an overhead, things could get fast real quick.

I contacted Yourself and asked if he could share his method to make a ds_list buffer in a dll

[/edit]

Edited by icuurd12b42, 22 June 2008 - 09:51 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#43 Nout1

Nout1

    GMC Member

  • New Member
  • 1 posts

Posted 22 June 2008 - 05:27 PM

Few questions:

* For which version of bullets is the wrapper set up?
* Is the wrapper source code public?
  • 0

#44 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 23 June 2008 - 02:22 AM

Adding a list of colliding objects... that will be grand... Do remove the duplicates. Come to think of it, I can make my synch loop just based on that actually. I assume you will add the gmbAssociate(body,id) so the list you generate will have GM ids which is much more useful to us.

Excelent; querrying collisions would be much easier to impliment than an explicit 'needs-update' function; naturaly I'l include the GM ID's.

I also found PhysX from NVIDIA... It's sounds like the 2 system have the exact same features. Except, form payling with them both on my system, physX seems to be faster. It also has deactivation and will use your physics chip if you have one... You should seriously take a look at it. Could it be that bullet is PhysX under disguise?

Hehehe, I don't think they are actualy related in that sense.

As for Raytracing; that was actualy what I was implimenting next, before you informed me of just how much impact the external_call overhead had on speed. So it will be included.

I made a boo boo in my test bench...

raw ds_list get access
1482837 calls in 10 seconds
raw API calls
414825 calls in 10 seconds

So, if making a ds_list buffer in the dll and loading it up using ds_read() is not much of an overhead, things could get fast real quick.

I contacted Yourself and asked if he could share his method to make a ds_list buffer in a dll

Sound's good then :huh: And let me know if Yourself will share his method (and allow it to be used here.) If not I'l figure it out.

Few questions:

* For which version of bullets is the wrapper set up?
* Is the wrapper source code public?

The DLL was last compiled using Bullet version 2.68, but since 2.69 is out, the next compilation will use it.
And yes, it is open source, though currently I have not uploaded it. I make no guarentees that it is legible however, as I use niether any accepted rules of variable naming, nor do I use many comments ;)
If you want the source, send me a PM.

-Andrew

Edited by andbna, 23 June 2008 - 02:26 AM.

  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#45 ashrat3000

ashrat3000

    GMC Member

  • New Member
  • 305 posts

Posted 24 June 2008 - 09:46 PM

The rotations in u3d are still buggy. It may be because u3d rotation order doesn't matter. You can change the rotx then roty and get the same result as changing roty then rotx.

(by the way, roty rotates around the z axis, and rotz rotates around y)

Roty (z axis) is independent, it does not rotate. However, the x axis will change if roty is changed. The x axis is rotating around the z axis. The y axis will rotate around the x and z axes. This means you can change the rotation in whatever order you want and get the same result, and I think this is messing up the rotations for bullet.
  • 0

#46 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 24 June 2008 - 10:40 PM

OK, I'm done with the ds_list investigation. Using a ds_list method to bypass the slowness of calling a api is a dead end. This would have worked only if the ds_list_read(buffer) was efficient enough... It is not and it nullifies the speed gain we would have gotten from doing a series of ds_list_find_vaue().


This does not affect the internal DLL list of collision/active objects mechanism mentioned beforehand.

You/we will still benefit from a list type setup such as

theid = getFirstActive()
while (theid)
{
with (theid)
{
x = getX(body)
y = gety(body)
...
}
theid = getNextActive();
}

rather than blindly getting the values in every instances.


to recap, this is slowest when you have a lot of objects (say 1000)

in instance step
x = getx()
y = gety()
z = getz()
xr = getxr()
yr = getyr()
zr = getzy()

results in 6000 API calls per step, every step.

This is a little better
in instance step
if!(isActive()) exit
x = getx()
y = gety()
z = getz()
xr = getxr()
yr = getyr()
zr = getzy()

7000 calls, worst case, then progressively down to 1000 calls + numactive*6 calls per step

then this one in your controller
theid = getFirstActive()
while (theid)
{
with (theid)
{
x = getx()
y = gety()
z = getz()
xr = getxr()
yr = getyr()
zr = getzy()
}
theid = getNextActive();
}

7001 calls, worst case, then progressively down to numactive*6 + numactive + 1 calls per step.


Of course, the solution used would depend on the game. Offering the 3 possibilities will benefit us all.

Edited by icuurd12b42, 24 June 2008 - 10:50 PM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#47 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 26 June 2008 - 08:06 PM

The rotations in u3d are still buggy. It may be because u3d rotation order doesn't matter. You can change the rotx then roty and get the same result as changing roty then rotx.

Aye, looking through the documentation, U3D's transformations only take Euler angles, and are applied in the order x-y-z. I even looked at the matrix functions, and they are quite useless: with no multiplication function you can't even create your own matrix in a different order! All I cna say: hold tight untill I get the rotations back into the x-y-z order.

OK, I'm done with the ds_list investigation. Using a ds_list method to bypass the slowness of calling a api is a dead end. This would have worked only if the ds_list_read(buffer) was efficient enough... It is not and it nullifies the speed gain we would have gotten from doing a series of ds_list_find_vaue().

Ah, darn. Well, thank you very much for the information, it is a great help. I'l impliment the lists as you asked for, and include one's for getting a list of objects which collided.
The three methods you describe above will each be useable.

Thanks again.

edit: You did mention packing variables into a single double. Bullet uses 32bit floats, rather than the 64bit reals GM uses, so I could halve the number of 'Get' function calls, with no impact on precision (in theory.) The question would be: how do you extract the variables? Since, I don't think a simple bit-shift operation can be used with floating point numbers; I doubt the fraction, exponent, and sign would line up correctly. But, we could probably figure out a way to do it. I'l think it over later, gotta go right now. Let me know what you think.

-Andrew

Edited by andbna, 26 June 2008 - 09:15 PM.

  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#48 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 26 June 2008 - 11:49 PM

OK, I'm done with the ds_list investigation. Using a ds_list method to bypass the slowness of calling a api is a dead end. This would have worked only if the ds_list_read(buffer) was efficient enough... It is not and it nullifies the speed gain we would have gotten from doing a series of ds_list_find_vaue().

Ah, darn. Well, thank you very much for the information, it is a great help. I'l impliment the lists as you asked for, and include one's for getting a list of objects which collided.
The three methods you describe above will each be useable.
Thanks again.

Cool I can't wait to try it out.

edit: You did mention packing variables into a single double. Bullet uses 32bit floats, rather than the 64bit reals GM uses, so I could halve the number of 'Get' function calls, with no impact on precision (in theory.) The question would be: how do you extract the variables? Since, I don't think a simple bit-shift operation can be used with floating point numbers; I doubt the fraction, exponent, and sign would line up correctly. But, we could probably figure out a way to do it. I'l think it over later, gotta go right now. Let me know what you think.

-Andrew

That would only double the speed of the extractor... Which is not really a great inprovement since the method is (currently) 6 times slower than straight API calls.

http://gmc.yoyogames...&...t&p=2749899

rereads...
But, yeah I have not tried the single double packing 2 floats, I only used a string buffer. Just keep on implementing the list system... I'll test the packing theory with my current test dll.

That packing system is different than the original method I mentionned, where 3 bytes woud hold 3 angles from 0 to 255... and the rest would pack the 3 xyz coords (impossible withouth MAJOR loss). Still if we can half the calls...

Edited by icuurd12b42, 27 June 2008 - 12:26 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#49 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 27 June 2008 - 09:07 AM

OK, I figured it's impossible to pack 2 floats into a double and unpacking it on the GM side because I would need to have access to the double bits on the gm side... which I don't have.


The only thing you could pack safely without going into "floating point troubles" and getting eroneous values are the 3 angles.


Benchmark numbers:

Number of object placement in 10 second using straigth API calls
153752 -> 256 instance limit
Number of object placement in 10 second using 4 straigth (getx,y,x + angles) API calls + decompress angles
183013 -> 305 instance limit

So, 50 more instances.

If I had been able to pack 2 floats then 1 float+3 angles
197714 set in 10 seconds
330 instances

if we could have managed to pack everything in a single double (impossible)
376759 sets in 10 seconds
630 intances...

Nothing sobers you up more like numbers LOL.

My initial test may have been a little flawed though my laptop seems to have "broke" somehow over the last week. Something is telling me my laptop in on the edge of death... A lot of tearing and all my games are slow and unplayable now.

Edited by icuurd12b42, 27 June 2008 - 09:36 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#50 gandalf20000

gandalf20000

    GMC Member

  • New Member
  • 478 posts

Posted 28 June 2008 - 05:26 PM

Positive values indicate a success. Which function is returning 2? Are you calling other functions? (You must be if your creating a rigid body,) What are thier return values? Maby post the code snippet?

Here is the code for my dynamic object:
//Create Event:
box_shape=gmbCreateBoxShape(16,16,16)
z=65
gmbSetCreationInertia(0,0,0)
body=gmbAddRigidBody(2,1,box_shape,x,y,z,0,0,0,0)

//Step Event:
x=gmbGetPositionX(body)
y=gmbGetPositionY(body)
z=gmbGetPositionZ(body)
rotx=radtodeg(gmbGetRotationEulerX(body))
roty=radtodeg(gmbGetRotationEulerY(body))
rotz=radtodeg(gmbGetRotationEulerZ(body))

Here is the code for my terrain object:
//Create Event:
i=gmbLoad3DS("models\terrain2.3ds");
shape=gmb3DSGetNextMeshShape(0,1);
gmbSetShapeScaling(shape,4,4,1)
body=gmbAddRigidBody(0,0,shape,x,y,z,0,0,0,0)
As I said, the box falls straight through the terrain.
  • 0
Programming rig:
Pentium E2160 dual core processor at 1.8 GHz, Intel 945G chipset, BFG NVidia 8500 GT with 512 MB of GDDR2 RAM, 3 GB of dual-channel DDR2 RAM at 667 MHz, 400 GB 7200 RPM hard drive, Labelflash capable DVD RW drive. 20" 1600x900 monitor.

Gaming rig:
Intel Core i7 920 @ 2.66 GHz, Intel X58 Express chipset, NVidia GTS 250 with 1 GB of GDDR3 RAM, 9 GB of triple-channel DDR3 RAM at 1066 MHz, 1 TB 7200 RPM hard drive, Lightscribe capable DVD RW drive, Blu-Ray drive. 23" 1920x1080 monitor.