All,
I am using Panda3D as a playback engine for data. I have a list of X,Y,Z positions in an HDF5 file. I can position the actor in the correct X,Y,Z positions but am having trouble setting the actors heading.
Code:
...more code above...
try:
#gets current position
prevPos = self.ralph.getPos()
#gets next position
currPos = Point3(self.positions[task.frame][0], self.positions[task.frame][1],self.positions[task.frame][2])
#returns heading vector
heading = currPos - prevPos
print "Heading: ", heading
self.ralph.setHpr(heading)
self.ralph.setPos(currPos)
except IndexError, e:
print "End of positions"
I would make sure that the place you want the actor to point is really in currPos. I mean, Maybe you are setting currPos to the last location in the playback list instead of the next? When the actor is at A, you would aim it at B, but if it is at B, you must aim it away from A to get the right effect, and I suspect that’s what is wrong.
Or perhaps your actor is modeled so that he is looking down the -Y axis, instead of down the +Y axis. This is a common problem, because people like to model actors so that they look them in the face in the modeling package, but that means the actor is looking backward–which is down the -Y axis.
In order to fix this, you can either turn the actor around in your modeling package (so that you’re looking at his backside when he animates), or you can turn it around in Panda by putting him under another node and setting a 180 degree heading on the actor itself, then using the parent node for your setPos() and lookAt().