1

Hi, everyone, I've run into a problem when manipulating a rigged mesh model in Panda3D. I loaded a mesh model which has an armature modifier consisting of two adjoint bones( one for the palm, one for a collection of four fingers, namely index, middle, ring and little finger ), which looks like this original unchanged hand model; then I transform the latter bone ( joint ) to fold the four fingers inward, using actor's 'controlJoint' method. Codes here :

self.handActor = Actor( r'/d/3DModels/TestHand.egg' )
self.handJoint1 = self.handActor.controlJoint( None,
                                               'modelRoot',
                                               'Bone1'
                                               )
self.handJoint2 = self.handActor.controlJoint( None,
                                               'modelRoot',
                                               'Bone2'
                                               )
self.handJoint2.setP( 90 )

Then I accessed the vertex info of the the current transformed mesh, with code like this below :

geomNodeCollection = self.handActor.findAllMatches( '**/+GeomNode' )
geomNodePath = geomNodeCollection[ 0 ]
geomNode = geomNodePath.node()
geom = geomNode.getGeom( 0 )
vData = geom.getVertexData()
reader_vertex = GeomVertexReader( vData, 'vertex' )
reader_normal = GeomVertexReader( vData, 'normal' )

vertexList = list()
normalList = list()

for i in xrange( 2000 ) :

    vertex = reader_vertex.getData3f()
    normal = reader_normal.getData3f()

    vertexList.append( vertex )
    normalList.append( normal )

Then I marked each of these positions with an smiley sphere, expecting to see a cloud of these smileys positioned just fitting around the deformed hand. However, I got a point cloud of the original hand shape, which is flattened, like this :deformed hand model and vertices obtained shown a point cloud Any idea about how to obtain the vertices positions exactly matching the deformed hand mesh? Thanks!

Hawk Rong
  • 165
  • 1
  • 9

1 Answers1

1

I think you need to call animateVertices on the GeomVertexData, such as:

vData = geom.getVertexData().animateVertices(True, Thread.getCurrentThread())

Panda will automatically cache the animated GeomVertexData.

rdb
  • 1,488
  • 1
  • 14
  • 24
  • Thanks a lot, rdb! You are right. I tried as you suggested and it worked. Apart from this, I found that a call of "PartBundle.forceUpdate()" right after rotating any joint is neccessary also. – Hawk Rong Mar 23 '17 at 00:42
  • 1
    Yes, normally placing the character in the scene makes Panda automatically call `character.update()`, but if you extract the geometry yourself then you need to call it yourself. If you liked my answer consider clicking the accept button to accept this answer. – rdb Mar 23 '17 at 11:42
  • Thanks! It's done! Functions like these are truely useful, but takes time to find exploring throught Panda3D's documentation. Lucky to got an answer from an expert like you, thanks again! – Hawk Rong Mar 24 '17 at 09:05