Box2D Forums

It is currently Sat May 25, 2013 4:51 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Scaling bodies
PostPosted: Tue Dec 07, 2010 2:05 am 
Offline

Joined: Tue Dec 07, 2010 1:38 am
Posts: 2
Hey everyone!

I'm pretty new to Box2D but I succeeded putting together a body constructor which reads infos from 2 XML's. I have one XML which contains all bodies (with their own shapes). And one XML which makes instances of these bodies and eventually overrides their properties such as x and y position and rotation.

Another feature I'd like to add is the scale of each body instances.

Resizing the body's shapes would be easy if the body would have circle or rectangle shapes. But it also has polygons. That complicates this procedure

So in theory I'd like to take a body (with all shapes already set) and scale it - let's say - to 50%. How can I do that without recalculating the points from it's shapes?

I appreciate any help.


Top
 Profile  
 
 Post subject: Re: Scaling bodies
PostPosted: Wed Dec 08, 2010 12:32 am 
Offline

Joined: Mon Nov 29, 2010 3:35 am
Posts: 6
i'm not sure aboute a built in scale method in box2d
but recalculating the points of a scaled polygon seems pretty easy
(pt - center) * ratio


Top
 Profile  
 
 Post subject: Re: Scaling bodies
PostPosted: Wed Dec 08, 2010 2:24 am 
Offline

Joined: Tue Dec 07, 2010 1:38 am
Posts: 2
Yea... I did this. Now all my bodies are scalable at loading time.
I thought a real-time scaling without much effort (getting all shapes of body and recalculating all their points) would be nice :) Looks like we'd have to wait for another version for that :)

Thanks for replying though ;)


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 0 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