Box2D Forums

It is currently Sun May 19, 2013 12:20 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: body SetMassFromShapes()
PostPosted: Fri Sep 21, 2012 6:34 am 
Offline

Joined: Fri Sep 21, 2012 6:19 am
Posts: 3
Hello from PerĂº!
I want to create a compound body in box2dWeb, what i need is a maze, this maze can rotate using keyboard. I saw an example of compound bodies in AS3 but i can not find this function: body.SetMassFromShapes().
This is may code:
Code:
....
for (var j=0; j<9; j++) {
         for (var i=0; i<9; i++) {
            if (maze[j][i]==1) {
               console.log("pos i="+i+" j="+j);
               var boxDef = new b2FixtureDef();
               boxDef.density=1.0;
               boxDef.friction=0.5;
               boxDef.restitution=0.2;
               boxDef.shape = new b2PolygonShape();
               boxDef.shape.SetAsOrientedBox(1.5,1.5,new b2Vec2(i, j), 0);
               body.CreateFixture(boxDef);
               
            }
         }
      }
      console.log(body);
      body.SetMassFromShapes();// ERROR

Can someone help me?
Sorry by my english :P


Top
 Profile  
 
PostPosted: Fri Sep 21, 2012 1:01 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
I think SetMassFromShapes is from the older version of Box2D. It should be ok with just CreateFixture... are you seeing some problem?


Top
 Profile  
 
PostPosted: Fri Sep 21, 2012 1:27 pm 
Offline

Joined: Fri Sep 21, 2012 6:19 am
Posts: 3
Thansk for reply.
The problem is that i can not see the compound body, i only see one box.
Image
Console for body:
m_I: 1966815.9
m_angularDamping: 0
m_angularVelocity: -5.98947528548628e-18
m_contactList: Ia
m_controllerCount: 0
m_controllerList: null
m_fixtureCount: 50
m_fixtureList: ba
m_flags: 38
m_force: r
m_inertiaScale: 1
m_invI: 5.084359954584463e-7
m_invMass: 0.000045351473922902495


Top
 Profile  
 
PostPosted: Fri Sep 21, 2012 8:58 pm 
Offline

Joined: Fri Sep 21, 2012 6:19 am
Posts: 3
well, SetMassFromShapes is from the older version of Box2DFlash and in box2DFlash 2.1a does not work but it is not necessary.
I had to change my code to box2DFlash 2.1a and works perfectly :D .
But the same code in Box2DWeb does not work, very strange. :(


Attachments:
maze.png
maze.png [ 29.1 KiB | Viewed 926 times ]
Top
 Profile  
 
PostPosted: Thu Jan 17, 2013 1:19 pm 
Offline

Joined: Mon Aug 13, 2012 8:42 pm
Posts: 1
You can see the topic http://box2d.org/forum/viewtopic.php?f=9&t=7699

Greetings from Peru


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: No registered users 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