2
$\begingroup$

I want to make my camera to act like my illustration below with just some python scripting, because I want this to be changed during runtime. This is for a school project.

I'm very sceptic if this is possible, but I hope so.

The orhtographic illustration is from the back of two cameras with images below, where the left is regular and the other one is modified. The two images on the bottom is the desired result.

Image illustration

This is for a kind of "point of view" tweaking. Like if you were looking on the image from the side, it would still appear as it was facing you.

If this does not work, then maybe my next idea is possible.

This is two cameras from the top view where the right one is modified.

Image illustration 2

Thanks!

$\endgroup$
1
$\begingroup$

There is no built-in functionality for that. However, You can setup a custom camera view matrix using a bit of Python.

import bge
scene = bge.logic.getCurrentScene()
cam = scene.active_camera
# get projection matrix
camatrix = cam.projection_matrix
#modifying the camera projection matrix by modifying the x and y terms of the 3rd row to obtain a shift of the rendered area 
camatrix[2][0] = 2*shiftx
camatrix[2][1] = 2*shitfy
cam.projection_matrix = camatrix

See this for detail.

$\endgroup$
  • $\begingroup$ That was the only solution I found! Just forgot to add my own answer! But you're correct and your code works. It was actually the result I was looking for. $\endgroup$ – Christopher Janzon Mar 5 '14 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.