Yes, exactly, at least that's the way it looks. It's obvious with the method of adding Rotate-Instructions for every principal axis and just updating the angles. But my aim is to always rotate the view in the same way, i.e. around the x- and y-axis with both in the screen plane.
Currently, however, I am using the method of rotating the modelview matrix, which works about as well. It works roughly as follows:
I) At the beginning, the modelview is set up using the look_at method.
m = Matrix()
pos = self._position * -1
m = m.look_at(pos[0], pos[1], pos[2], v[0], v[1], v[2],
self.up[0], self.up[1], self.up[2])
self.modelview_matrix = m
(This is an excerpt out of nskrypnik's code.)
II) For rotation the current modelview matrix is rotated:
a) Back up old MV
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
self.touch_start_pos = touch.pos
self.old_mv = self.camera.modelview_matrix
touch.grab(self)
return True
b) Calculate current rotation
def on_touch_move(self, touch):
if touch.grab_current is self:
dx = touch.pos[0] - self.touch_start_pos[0]
dy = touch.pos[1] - self.touch_start_pos[1]
r = sqrt(power(dx, 2) + power(dy, 2))
self.rotmat.identity()
self.rotmat.rotate(float(r)*0.02, dy/r, dx/r, 0.0)
self.camera.modelview_matrix = self.old_mv.multiply(self.rotmat)
self.camera.update()
return True
c) Save current view
def on_touch_up(self, touch):
if touch.grab_current is self:
self.touch_start_pos = None
self.old_mv = self.camera.modelview_matrix
touch.ungrab(self)
return True
But as I said, I still get the same effect as before.
Also, this approach seems un-kivyish to me, since there are the Rotate-Instructions for this. Thus my question also aims at the right way (read: most/resonably efficient) to do this. Since I just saw instructions can also be inserted at any index, my next try will be adding single Rotate-Instructions to the instruction group for every rotation. But isn't this going to cost much memory, when many rotations are done?
Thank you for the hint with vispy, I will definitely have a look.