physics engine problem(getMass)

can anyone tell me why getMass() function dosen’t work in my code? thanks in advence.

self.an = ActorNode(‘plane’)
self.anp = render.attachNewNode(self.an)

``````    self.plane = loader.loadModelCopy('boeing707.egg')
self.plane.setPos(0,0,40)
self.plane.reparentTo(self.anp)
self.plane.setScale(0.1)

base.camLens.setNearFar(1.0, 1000.0)

base.physicsMgr.attachPhysicalNode(self.an)

base.enableParticles()

self.fn = ForceNode('pull')
self.fnp = render.attachNewNode(self.fn)
self.pull = LinearVectorForce(0, 3, 0)
self.phy=self.an.getPhysicsObject()
#problem is here!!! no matter what parameter i assign to setMass(), the acceleration of actorNode dosen't change at all. why???
self.phy.setMass(10)

``````

by the way, how can i set moment of inertia in panda? setMoment() or something else?

The default is for a force to be not mass-dependent (which I guess makes it technically an acceleration, like gravity, not a force in the Newtonian sense). If you call:

``base.pull.setMassDependent(1)``

then its effect should vary according to the mass of the objects you apply it to.

I don’t know about the moment. I don’t think Panda’s angular physics system is presently sophisticated enough to deal with moment.

David

the code works fine

I was playing with the rotational acceleration system a bit this weekend. As best I can tell, there isn’t (unfortunately) any apparent way to apply a torquing force to a body automatically; if you want torque effects, you’ll have to do the componentwise-vector-cross-product calculations by hand. If anyone knows of a way, by all means let me know!

If there isn’t a way to do this right now, this would be a great place for someone who wants to get their hands dirty to extend the engine. Currently, the engine chokes if you assign a linear force to the angular set using addAngularForce. A useful extension to the Panda library might be to accept linear forces in that context and treat them as torques by doing the cross-product calculation between the ForceNode that contains the force and the parent of the ActorNode that accepts the force. Assuming it isn’t already possible, that’d be a really useful improvement to the physics system!

Take care,
Mark

This confuses me… pull doesn’t exist within base. Shouldn’t it be:
self.pull.setMassDependent(1)?

And, if that’s the case, it causes a problem for me. My gravity works before I add that line. Afterwards, objects that should fall, don’t.

EDIT

Ok, so now what I need to know is how units work… I changed my gravity vector to <0,0,-32> because Panda3D’s coordinates are measured in feet… so it makes sense that gravity should be -32 (ft/s)/s. Right?

But here’s something weird… the HIGHER I set my object’s mass, the slower it falls. Why?

Strictly speaking, gravity is an acceleration, not a force. And as Galileo computed, and apocryphally demonstrated by dropping two differently-sized rocks from the leaning tower of Pisa, objects accelerate under gravity at the precisely same speed, regardless of any difference of mass. (We perceive that heavier objects fall faster only because they meet less air resistance.)

But, if you apply a force, rather than an acceleration–think of a rocket booster–then the higher an object’s mass, the more force it will require to move it. That’s why when you set your object with more mass, it falls more slowly. Clearly, you are using a force, rather than an acceleration, to define your gravity.

David