Hi,
I’ve had a browse through the archives and have managed to get rid of quite a few bugs from doing so, but I couldn’t find anythin on this, apologies if my search technique needs work.
I’m developing motion capture data modelling software, and initially that simply means converting motion capture files to 3D co-ordinates (done) and plotting them in opengl (done).
The sequences are animating correctly, in an acceptable time, however, I can’t seem to find a way of placing the camera in a way that is able to view an entire sequence generically. With a small amount of fiddling for a particular sequence it is relatively easy to gain a good camera position, however this is just over fitting a solution for a given parameter.
Anybody have any ideas?
I’m developing in Python and this is some relevant code:
self.limits is an array of the following:
[zmax,xmax,ymax,zmin,xmin,ymin]
(ZXY is a bizarre artifact of mocap sequences and they are stored in that order for this reason)
print self.limits
camerax,cameray,cameraz,zmiddle = self.findCamera()
perspective = cameraz-self.limits[3]
gluPerspective(1000,1.,1.,1000)
glMatrixMode(GL_MODELVIEW)
#Lights
self.setUpLights()
#Camera
gluLookAt(camerax,cameray,cameraz,
camerax,cameray,zmiddle,
0,-1,0)
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
#Action!
glutMainLoop()
Here is the function findCamera:
def findCamera(self):
temp = zeros(3)
for i in range(2) :
temp[i] = self.limits[i] - self.limits[i+2]
cameraz = (temp.max()*47.)/40.
cameray = (self.limits[2] + self.limits[5])/2.
camerax = (self.limits[1] + self.limits[4])/2.
zmiddle = (self.limits[0]+self.limits[3])/2
return camerax,cameray,cameraz,zmiddle