Newbie question: entities tracking

Official forum for the Chipmunk2D Physics Library.
Post Reply
pattern23
Posts: 1
Joined: Sat Jul 16, 2011 1:27 pm
Contact:

Newbie question: entities tracking

Post by pattern23 »

Hello, i've just started to learn the library for my current project, using marmalade sdk (aka airplay sdk) and c++.
I chose chipmunk because i found its entities' (bodies, shapes, etc) structure very simple, intuitive but powerful, but i got stuck, altough i read the entire documentation once, with a banal problem.

Consider the PyramidStack example. Here you have only one global objcet, the space. In the init function you initialize only one object for a body and a shape, but you use them many times to add a lot of entities in the space, in order to build the pyramid. These object are destroyed and the func returns the space full of that stuff.
Now, what if i want to access the structure of one of these blocks (through the space that contains them), for example get the position of a specific body or the friction of a shape? there is some unique ID held by each entity in order to access it? is it the spatial hash? or do i have to keep an object global and never destroy it?
i'm sorry for the stupid question, maybe i didn't get something during my readings
thank you in advance
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Newbie question: entities tracking

Post by slembcke »

Normally in a game you would have some sort of game object that owns the physics objects and keep references to them from there. Then when you want to know where the body is positioned, you just get it's position/rotation. Otherwise no, there is no ID or anything like that that you can use to get the objects back later other than just the pointers to them.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests