Box2D Forums

It is currently Sat May 25, 2013 12:14 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jan 23, 2012 5:36 am 
Offline

Joined: Sat Feb 06, 2010 10:55 am
Posts: 37
I really stuck at implementing wrapping world.

My idea is to use object wich contains NSMutableArray of its bodies (which can be up to 4 elements). When i create the object i add initial body to the array simultaneously with adding it to the world.

Then when some conditions occur i add one more body with modified position. But this body exists only as element of the array.

I can't understand how to properly create copy of body from an element of the array in the world if i must use safe adding as safe removing (outside of world->Step())?

Any clues?


Top
 Profile  
 
PostPosted: Tue Jan 24, 2012 3:30 am 
Offline

Joined: Sat Feb 06, 2010 10:55 am
Posts: 37
After few tries i replaced NSMutableArray with usual NSArray with 9 elements for superposition matrix. It covers all situations and has a more clear logic for me.

But the main problem is creating body without adding to the world. For example:

In collision logic (pseudocode)
Code:
[self.bodies addObjectAtIndex:index] = [self masterBody];


where
Code:
masterBody
returns a template (master copy) for object body. But i can't write this method because there is only one
Code:
world->CreateBody(&bodyDef);
method.

I can create separately only definition of the body, but full creation (with fixtures) can't be made without adding it to the world.

Any ideas? Use separate world for storing template bodies of every game object?


Top
 Profile  
 
PostPosted: Thu Feb 09, 2012 12:36 am 
Offline

Joined: Sat Feb 06, 2010 10:55 am
Posts: 37
Okay, i'm one step from creating wrapping world.

I need the last function: to transfer impulse between all bodies in the system.

How to apply impulse to all other bodies of the object (stored in the array) if one of them get hit?

Don't understand how to calculate the impulse.


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

All times are UTC - 8 hours [ DST ]


Who is online

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