# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Stopping time for an objectPosted: Thu Jan 19, 2012 4:03 pm

Joined: Thu Jan 19, 2012 3:44 pm
Posts: 2
Hi!

I'm developing a game which will be based in physic interaction with objects. Our main character will have the power to stop time, but just for one object at a time.

For example, if the character throws a box and uses his power while the box is still "flying" it should stop moving and remain static in the air. Other objects should be able to collide with the box when it is "freezed". After "unfreezing" the box it should continue "flying" as if time had never been stopped.

I've been playing with bullet and seemed to achieve this result by switching the mass of the object to 0 ("switching" it to static) as well as changing its Linear and Angular velocity to 0,0,0. To "unfreeze" the object I just put back the orginal values.

The problem is that sometimes it does strange things (objects not colliding correctly with the freezed object or flying away of it).

I'm pretty sure this is not the best way to achieve this result. Could you give me a better solution to my problem?

David

Top

 Post subject: Re: Stopping time for an objectPosted: Mon Jan 23, 2012 4:48 pm

Joined: Sun Jan 01, 2012 7:37 pm
Posts: 55
Eh.. Why don't you just keep a buffer somewhere in your code that contains information about the freezed object. Then when the player freezes it, it copies the transform, the shape pointer, and the things like linear and angular velocity.
Then remove that body from the world, but not the shape, and then create a new one with the same transform that is a static body.
Do this before stepping the world.
Keep a pointer to that body and when the player tries to unfreeze it, remove the static body, use the information in the first-mentioned buffer to recreate the dynamic body and let the world continue.

It might just be a matter of changing flags, but that's a solution I see.

Top

 Post subject: Re: Stopping time for an objectPosted: Tue Jan 24, 2012 3:22 pm

Joined: Thu Jan 19, 2012 3:44 pm
Posts: 2
Hi!

Yes, I just tried that before reading you and It seems to work, at least it has worked in every test I've done.

The only difference is that I don't use a new body, I just change its parameters (mass, linear/angular velocity = 0) once it has been removed from the world and then re-introduce it. I use the same method when unfreezing the object.

Also when unfreezing the object I have to recalculate the localinertia

body->getCollisionShape()->calculateLocalInertia(mass,localInertia);

using (0,0,0) as localInertia.

Thank you for your help. I hope this helps someone else!

David

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: fractile, Google [Bot] and 3 guests

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

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities