I understand most of what's going on and I've been looking through the source, but I can't seem to discern how to detect a keypress. It looks like mh uses a third-party library called pyqt4 (which I had to install to compile). I've Googled and Googled but I just can't seem to find how to detect a keypress using this library or any other, at least not in any easy-to-understand way.
What I'm trying to do is switch the camera projection from ortho to perspective. I asked for this in features but I was rejected, so I've decided to figure out how to do it on my own. Setting the orbital camera's fovAngle to 45 and its projection to 1 seems to accomplish this, but zooming in will only zoom into the torso and the camera won't pan up when zoomed in. I understand this is because the camera is coded for orthographic usage, not perspective usage.
So what I've been trying to test is if, after you've got the camera zoomed and panned where you want it in ortho, when you switch the camera to a different projection mode and fov will it stay there with a perspective projection? I want to be able to press a key and change the fovAngle and projection values, then press a different key and change them back.
So far this is what I've got in the camera.py script at the end of the OrbitalCamera class:
- Code: Select all
def keyPressEvent(self, e):
if e.key() == QtCore.Qt.Key_M:
if self._projection == 0:
self._fovAngle = 45.0
self._projection = 1
if e.key() == QtCore.Qt.Key_N:
if self._projection == 1:
self._fovAngle = 90.0
self._projection = 0
I've imported PyQt4's QtCore, QtGui, QtOpenGL and qtui and qtgui (though I'm not sure I even need those).
Upon compile and trying to use these lines, nothing happens. Is there something I'm missing? Thanks!
Also, please don't tell me about not wanting to use perspective. I know, it's distorted and all that. I've been using 3D packages for years. But if they're the same fov (both this and 3ds at 45) then they come out more or less the same. I just want to be able to control facial morphs in a perspective projection so I know what I'm getting before sending it over to 3ds Max so I can avoid some trial and error. I'm sorry if this paragraph comes across as rude, I don't mean it to. But I know what I want, and I don't want orthographic all the time.
Please and thank you!