I am trying to enable simple physics behaviour using the internal physic engine, which should be enough for my needs.
I have a generated model, built vertex per vertex (using GeomVertexData...). I need this model to be affected by a gravity force.
The problem is, the section of the manual is quite unclear and uses python code, even in the c++ version.
I have tried to "translate" into c++ but that does not work. My code is as follow :
- Code: Select all
PT(GeomNode) gn = c->generate();
pm = new PhysicsManager();
NodePath test = window->get_render().attach_new_node(gn);
ActorNode an("an-physics");
NodePath anp = test.attach_new_node(&an);
test.set_pos(0,0,1.0);
test.set_scale(1.0,1.0,1.0);
ForceNode gravityFN("world-forces");
NodePath gravityFNP = test.attach_new_node(&gravityFN);
LinearVectorForce gravityForce(0,0,-9.81);
gravityForce.set_mass_dependent(true);
gravityFN.add_force(&gravityForce);
pm->attach_physical_node(&an);
an.get_physics_object()->set_mass(136.077);
an.get_physical(0)->add_linear_force(&gravityForce);
This simply does nothing. Using PhysicsManager.debug_output() gives me this :
- Code: Select all
PhysicsManager li0 ai0
_physicals 1
_linear_forces (1 forces)
LinearVectorForce:
_fvec 0 0 -9.81
LinearForce(id 0030FA8C)
_amplitude 1
_mass_dependent 1
_x_mask 1
_y_mask 1
_z_mask 1
BaseForce (id 0030FA8C):
_force_node render/gn*/world-forces
_active 1
_angular_forces 0
I'm running out of ideas here, if anyone got one...
Thanks in advance !
