Box2D Forums

It is currently Sun Nov 23, 2014 8:42 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Controllers
PostPosted: Sun Oct 05, 2008 5:03 pm 
Offline

Joined: Mon Jan 07, 2008 10:51 am
Posts: 1911
Ok, this isn't nearly as cool as some of the other things I've done, but I think this is necessary. I've implemented a bit of a Controllers suite, where by controller I mean helper class for applying forces, like the buoyancy controller I posted earlier.
Demo
Download
Details

See details for more info. Of particular interest is probably b2TensorDampingController, which despite its obscure name, is essentially a controller which allows you to do (one kind of) top down wheel behaviour, which a few people were asking about earlier.

Please please please comment on the design choice I made (e.g. perhaps you'd prefer this in the Box2D package, rather than my own). I'm gonna start porting to C++ now, so it's important to get it right.


Top
 Profile  
 
 Post subject: Re: Controllers
PostPosted: Sun Oct 05, 2008 7:19 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 915
The separate package doesn't matter me. In fact, I think I prefer it. The only complaint I have about your contributed code is that I have to patch the core Box2d classes all over the place. Upgrading when a new version comes out is going to be painful.

I've been working on some crazy gravity implementations, stuff like gravity that changes direction based on sin(x), gravity that's part linear / part radial (rounded rectangle), and I'm thinking of using your controllers for the final implementation. The base controller classes are general enough that I think a lot of useful stuff could be built on them...


Top
 Profile  
 
 Post subject: Re: Controllers
PostPosted: Mon Oct 06, 2008 2:29 am 
Offline

Joined: Wed Sep 10, 2008 8:03 am
Posts: 138
Small side question, any idea why your side fails in firefox? The flash file works fine:
http://boristhebrave.com/sites/default/ ... abPack.swf
But it won't show up on the demo page...


Top
 Profile  
 
 Post subject: Re: Controllers
PostPosted: Mon Oct 06, 2008 4:19 am 
Offline

Joined: Tue Apr 29, 2008 1:55 am
Posts: 102
works fine here with FF 3.0.3 on Vista x64. Any addons blocking it perhaps?


Top
 Profile  
 
 Post subject: Re: Controllers
PostPosted: Mon Oct 06, 2008 4:51 am 
Offline

Joined: Wed Sep 10, 2008 8:03 am
Posts: 138
zappBrannigan wrote:
works fine here with FF 3.0.3 on Vista x64. Any addons blocking it perhaps?
Only have adblock installed, but that's not blocking it. Also got firebug installed. I don't see any errors in the error console, and I can see with firebug that it does load the flash file.


Top
 Profile  
 
 Post subject: Re: Controllers
PostPosted: Mon Oct 06, 2008 5:53 am 
Offline

Joined: Mon Jan 07, 2008 10:51 am
Posts: 1911
I get jerkiness myself (FF3, vista, 32). I don't know what the problem is or how to fix it, though I'd love to hear. Firefox has never been good with Flash for some reason. I'm using SWFObject, which I thought would have dealt with any problems.

mayobutter wrote:
The separate package doesn't matter me. In fact, I think I prefer it. The only complaint I have about your contributed code is that I have to patch the core Box2d classes all over the place. Upgrading when a new version comes out is going to be painful.

Hmm. This is really what source control etc is designed for. You don't need manually do all that patching, but instead make a patch from my contributed code, and apply it to the new version, or visa versa. I used to provide patches as well as .zip downloads, but it was apparent no one was using them. Also, the odds aren't too bad that the next version will come with some of this code.

mayobutter wrote:
The base controller classes are general enough that I think a lot of useful stuff could be built on them...

Exactly the point. Now hopefully we will be able to share snippets of code easier without having do adapt it to different frameworks every time.


Top
 Profile  
 
 Post subject: Re: Controllers
PostPosted: Mon Oct 06, 2008 6:02 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1966
Location: Tokyo
Wow, this is the first time I've seen the buoyancy one. Extra cool! Many thanks Boris.


Top
 Profile  
 
 Post subject: Re: Controllers
PostPosted: Mon Oct 06, 2008 8:56 am 
Offline

Joined: Mon Feb 18, 2008 12:30 am
Posts: 88
This is awesome. Looking forward to the C++ port!


Top
 Profile  
 
 Post subject: Re: Controllers
PostPosted: Tue Oct 07, 2008 3:00 am 
Offline

Joined: Fri May 16, 2008 2:52 pm
Posts: 280
Hey,

I took a look at your code, but haven't got a chance to test it out yet. I think it's pretty clear, and nicely separated from the rest of the engine, at the moment.

I can imagine that if this is a useful enough feature, inclusion in the Box2D package would seem logical. (maybe in Box2D.dynamics.controllers ? ) (So that it works "out of the box" so to say).

API-wise, at this moment it seems straightforward enough, but again, if this becomes a standard feature, something along the lines of
Code:
world.CreateController(....)

might be worth considering? Or am I overlooking something?


Top
 Profile  
 
 Post subject: Re: Controllers
PostPosted: Tue Oct 07, 2008 4:17 am 
Offline

Joined: Mon Jan 07, 2008 10:51 am
Posts: 1911
I did code exactly that up, but deleted it. Here are some reasons why I'm apprehensive, despite the obvious nicety of having a similar interface. Though none are especially compelling, there are quite a few...
  • Thus far, I haven't gone down the factory route of making matched Defs to go with each class, so it would be misleading to give a similar behaviour.
  • Controllers are order dependent, at least some of the non-force generating ones are (currently only TensorDamping, I think).
  • Box2D doesn't "know" which bodies a controller controls, and enabling this would be messy. This means sleep doesn't work properly, nor implicit destruction, or islands. The user must code around these problems.

Basically, once I "attach" controllers to the world, it is necessary to implement the full many-to-many relationship of controllers to bodies for consistency reasons, and re-implement a lot of the joint based features. And in box2d style the relationship would be represented by some sort of convoluted linked list. I'd really rather wait until Erin creates a pattern for dealing with dynamically sized arrays as he mentioned he might, before proceeding.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group