Box2D Forums

It is currently Wed May 22, 2013 9:47 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Jul 03, 2012 8:19 am 
Offline

Joined: Tue Jul 03, 2012 8:15 am
Posts: 2
Hello there,

I just got started with box2D.
I want to know if it's possible to create a sphere container, in which I can put other objects that will reacts to the bounds of this container (like the walls in the examples).

I don't really know where to look at, any example would be awesome!

Thank you :)


Top
 Profile  
 
PostPosted: Tue Jul 03, 2012 11:36 pm 
Offline

Joined: Sun Oct 25, 2009 3:28 am
Posts: 242
You can make a circular container out of a bunch of polygons (rectangles or triangles). You can use a for loop to do the correct position and angles so you don't have to make each thing by hand.


Top
 Profile  
 
PostPosted: Wed Jul 04, 2012 1:08 am 
Offline

Joined: Tue Jul 03, 2012 8:15 am
Posts: 2
All right that's what I thought ... do you know if somehow it's possible to do it only with one shape ?


Top
 Profile  
 
PostPosted: Wed Jul 04, 2012 1:43 am 
Offline

Joined: Sun Oct 25, 2009 3:28 am
Posts: 242
Dermiste wrote:
All right that's what I thought ... do you know if somehow it's possible to do it only with one shape ?

In the current release state of Box2D AS3 2.1a, unfortunately not, and the hidden-and-non-working way does not technically create one shape either. Here's a post about it with one of the developers of the AS3 port: viewtopic.php?f=8&t=4651

There are b2EdgeShapes (which are infinitely thin lines that stuff can collide with), but they can only be static. You only have to specify the ends as vertices, so you don't have to worry about angles and sizes of polygons. I'm not sure if b2EdgeShapes work in 2.1a because I've never used them.

In the old Box2D version (2.0.x), you can use b2EdgeChainDef to make a bunch of b2EdgeShapes, but it can only be static (cannot move). The b2EdgeChainDef does not work with 2.1a simply because it's old code that's carried over from 2.0.x and Box2D 2.1 does not use shape definitions.


Top
 Profile  
 
PostPosted: Wed Jul 04, 2012 2:16 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
(I don't know about the Flash port, but in C++....)
Although edge shapes don't collide with each other, there is no reason that edge shapes can't be put on a dynamic body. With only edge shapes the body will have no density and therefore will not rotate naturally, but that can be fixed by adding a non-edge shape (circle or polygon) dummy fixture to get the mass data calculated correctly. You could make the dummy fixture a sensor so it doesn't interfere with anything, or if you really don't want any dummy fixtures you could set the mass data explicitly yourself. Probably the easiest way to do that is first add fixture(s) to get the mass and inertia how you want it, copy the mass data, then remove the fixtures and set the mass data that you copied. Adding or removing fixtures after this will mess up your custom mass data, so if you want to change it later on you'll have to reset the mass data again.


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

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 2 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