Box2D Forums

It is currently Wed May 22, 2013 6:42 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Apr 17, 2008 8:25 am 
Offline

Joined: Mon Sep 17, 2007 4:30 am
Posts: 40
Location: appleton, wi
I'm curious what other would think of adding some sort of abastract "Controller" concept to Box2D.

This would probably only contain an "Update(dt)" method that would need to be implemented.

A Controller would then be used to create any object that needs to apply external forces, torques, or impulses.

Box2D could have facilities for Adding and Removing Controllers and would simply loop thru them and call "Update()" for each at the most opportune time in the physics loop.

Currently you need to Apply forces, torques and impulses yourself outside Box2D. The Controller concept would allow for a more structured means of applying external influences.

This would also allow Box2D to decide when best to apply these forces, torques, and impulses.

It'd be nice for things like steering forces, springs, etc...

Box2D could also contain some pre-defined common controllers (again, thinking of things like springs)

I'm on the fence whether this is worth adding to Box2D as you could do this all outside of Box2D. Just wanted to throw the idea out and see what other think.

-Jeff Weber


Top
 Profile  
 
PostPosted: Thu Apr 17, 2008 9:19 am 
Offline

Joined: Mon Jan 07, 2008 10:51 am
Posts: 1911
No one has implemented something like that (on this board), because individually, it is very much easier to do without special classes etc. But on a community wide level, I think this sort of thing is pretty much mandatory, to help small projects and people getting started. I've been meaning to do something similar. At the moment the ethos of Box2D is orientated at bigger projects, where you will want to implement details like this yourself to tie in best with the rest of our system. But lots of people who build their projects around Box2D rather than visa versa, at least for the Box2DAS3 which attracts less, uh, involved developers.

A simple controller scheme should be pretty easy to put together. I was concerned that having GetShapeList, GetJointList, GetControllerList etc would get too confusing, so was pondering some unified system expanding on Joints. After all, your described "spring" controller would actually require two bodies, and have a lot of joint like information, while not actually requring the velocity or position solvers to step in.


Top
 Profile  
 
PostPosted: Thu Apr 17, 2008 9:40 am 
Offline

Joined: Mon Sep 17, 2007 4:30 am
Posts: 40
Location: appleton, wi
While the spring example is much like a joint, I was also thinking of things like FluidControllers, SteeringBehaviorControllers(Flocking, Avoidence, Puruit..), SoftbodyControllers, etc. etc... Some controllers, like flocking, might work on an entire array of bodies.

The more common/universal controllers like springs could be added to Box2D for easy access, the less common could be shared amongst the community by other means.

Having Box2D define the "interface" for the controller would make it easier to share components.

-Jeff Weber


Top
 Profile  
 
PostPosted: Thu Apr 17, 2008 10:00 am 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
There are some physics engines that have this functionality. From a technical point of view, it should have no impact on how the solver operates.

I wouldn't want this to extend off joints, because they have a solver interface that is not needed by applied forces. Rather, you might want to extend controllers into unilateral, bilateral, trilateral, etc.

This is a feature that can easily be implemented by the community. I would be happy to integrate this via a patch file.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


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