# zoom and rotate world or scene

Hi there,
I would like to write python code which can:
i. zooms in (or out) on my world (or is it scene ?)
ii: and rotate it.
This would be similar to either pressing the mouse button wheel and moving the mouse for rotating, or scolling the mouse wheel for zooming in or out.

Thank you very very much !
: *)

this is not super easy, if your just starting out your probably better off moving a camera around. otherwise look up the API docs for Window.ViewQuat, Window.ViewOffset… or you can can use GetViewMatrix() and modify it - thats probably the only way to zoom.

2. copy the camera’s matrix to Window.GetViewMatrix()
3. dont use a camera, just set Window.GetViewMatrix() direct. even though it gets the matrix, adjusting it should adjust the view. just make sure you modify original values…

Window.GetViewMatrix()[:] = [mat[0], mat[1], mat[2], mat[3]]

Cool thanks for the pushoff.
I was wondering if anyone had any examples of using the GetViewMatrix() or theViewQuat().
I see now that I can move my world around and then print out the values of GetViewMatrix().
I would like to better understand the mathematical rules behind how this matrix changes, as well as how ViewQuat() changes.
For instance, let’s say I wanted to rotate the world 360 degrees along, say, the Y axis, but I wanted to to do it in specific increments.
So after every 5 frames, for example, I’d like to rotate the world 5 degrees.
I saw with manipulating armatures one can set the degrees as in:

e = Mathutils.Euler(30, 0, 0)
mat = e.toMatrix()
pose_bone = pose.bones[pointerC]
pose_bone.localMatrix = mat
pose_bone.insertKey(ob, frame, Object.Pose.ROT)

I’m wondering if there is some way to do this with rotating the world.
Thanks again,

Rotation matrices are used everywhere in graphics programming. If you like to understand the mathematical rules, there are a lot of general tutorials on them (usually geared towards beginner OpenGL or Direct3D programmers). Don’t be afraid of sines and cosines though… Personally I like nehe.gamedev.net very much (ignore the stuff on setting up OpenGL contexts).