stuffmatic / blam

🚨 No longer maintained. Check out fSpy instead 🚨 A camera and projector calibration toolkit for Blender that also does automatic 3D reconstruction of geometry with rectangular faces.
https://fspy.io/
GNU General Public License v3.0
644 stars 95 forks source link

Lens shift in BGE #13

Closed ghost closed 6 years ago

ghost commented 9 years ago

Hi, After successful 'BLAM'ing an using object using a data projector the object shifts in game mode. This appears to be due to the lens shift not working in game engine. I tried the code here: http://wiki.blender.org/index.php/Doc:2.6/Manual/Game_Engine/Camera (correcting the "shitfy" typo) and it didn't help. I'm using blender 2.72b

Stef777 commented 9 years ago

The script in the wiki doesn't work in the current blender but works in older blender.

Have a look at this thread: http://blenderartists.org/forum/showthread.php?255148-BGE-camera-lens-shift-broken

I've tested the blend you'll find there (which is based on the wiki code you mentionned). It fails in 2.72b but works at least in 2.60a. I haven't tried other versions yet.

Stef777 commented 9 years ago

I've found the problem ! It works in 2.72a now.

Follow these steps :

  1. First of all, in the script which is on the wiki you must replace shiftx or shifty by a number.
  2. Then you must change the code like that : camatrix[2][0] becomes camatrix [0] [2] camatrix[2][1] becomes camatrix [1] (2] You have to do that to make it work because the way matrices are indexed changed in 2.62 (instead of [column] [row] now it's [row] [column]...).

I advise you to still download the blend in the thread I mentionned in my first post. The script is slightly more sophisticated and interesting (it allows you to set the shiftx and shifty value by pressing the arrow keys). Don't forget to change the code as told in step 2.

ghost commented 9 years ago

Thanks Steff777! That worked like a charm!