Good evening to everybody.
I’m posting this in order to ask a question. I’m trying to implement a softbody which is able to be modified in runtime. In order to achieve this, I’ve succesfully implemented a softbody ball object as you see in the screenshot 1. The problem is when I execute the following code to the softbody ball I get 0 elements in the geom node collection. The funny thing is that When I load a simple model in a RigidBody it works fine as you can see in the other screenshot with a Thorus model. In order to use the code I use an instance called “ball”, it has an attribute which stores the nodepath and I retrieve it using GetNP() method.
#ball.GetNP() => nodepath to the ball in world
gnodecoll = ball.GetNP().findAllMatches('**/+GeomNode')
print "Number of geommodelcollection "+str(len(gnodecoll))
for nodepath in gnodecoll:
gNode = nodepath.node()
for i in range(gNode.getNumGeoms()):
geom = gNode.modifyGeom(i)
vdata = geom.modifyVertexData()
vertex = GeomVertexRewriter(vdata, 'vertex')
while not vertex.isAtEnd():
v = vertex.getData3f()
So my question is, am I accesing the geommodel collection in a wrong way? Is a mistake in the softbody ball implementation? Or I just cant modify the softbodyball geometry?
This is how I’ve implemented the SoftBody objects class
def __init__(self,info, ele, face, node):
elem,facem,nodem geometry information (from tetgen)
info is the world attribute
elem = file(ele, 'r').read()
facem = file(face, 'r').read()
nodem = file(node, 'r').read()
self._node = BulletSoftBodyNode.makeTetMesh(info, elem, facem, nodem)
#Configuracion de la rigidez del modelo
#Presion interna del modelo
#Coeficiente de friccion
#Coeficiente de elasticidad
After getting the softbody instance i add it using the “attachSoftBody” method with the softbody ball node.
In case of scene graph question I strongly encourage using the np.ls() method (where np is a NodePath). It prints the subgraph starting at the np). Looking at the output on the console often gives great insight.
There reason why you do not see any entry in the NodePathCollection is that “**/+type” searches the subgraph BELOW the node path called upon. Below means “excluding the node path itself”.
BulletSoftBodyNode is derived from GeomNode. So the geoms are not below the NodePath returned by GetNP(), it is the node itself. You can - in theory - modify the geometry of this node. But it is useless, since Bullet re-writes the geometry each frame and your modifications would be lost again. Even worse, you might crash you app.
Sorry, the soft body geometry is not intended to be modified by hand.
Ok, Thanks a Lot for your answer. The point is that I was trying to create an implementation where the user could modify the softbodyball geometry moving a vertex or an anchor point related to a vertex, for example using a rigidbody box. But If I cant choose a vertex to get its position and move it donamically I guess I can close this experiment.
I don’t understand what you actually want to achieve. Do you try to build an editor for creating or modifying the soft body geometry? Or do you want to deform the softbody without having it morph back to it’s original shape? i think I have seen samples where a barrel has been shot at, and the barrel deformed from the impact, but kept this way.
Some of these things might be possible from Python. From C++ almost everything which can be done with Bullet is possible, since the wrapped Bullet objects are accessible via getters (C++ only!).
Hello again and thanks for your answer. This is a kind of experiment. In this escenary the user should be able to pinch and stretch a softbody from a point. The aproximation to the solution was to associate a vertex to an anchor which should be movable with the keyboards using the “acceptbehaviour” method. The purpose of the experiment is to simulate a softbody object in order to develop a project where the user will manipulate some parts of the human heart(mitral valve)