Converting blender’s camera focal length for use in jme3

So blender cameras aren’t directly supported but the spatial nodes do come in so found a semi simple algorithm for converting blender’s focal distances (based on 35mm film camera) into frustum settings for jme3 cameras.

[java]

float blenderFocalLength = 50f;

//film back for a 35mm camera is 36x24mm

float filmBackRatio = FastMath.sqrt(FastMath.pow(36f, 2) + FastMath.pow(24f, 2f));

float frustumSize = 0.02075f * filmBackRatio / blenderFocalLength;

float aspect = (float) cam.getWidth() / cam.getHeight();

camera.setFrustum(0.1f, 1000f, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize);

[/java]

Tested and working for all my stuff coming from Blender via blender2ogre

2 Likes

Thanks! Maybe @Kaelthas can make use of this for his blender importer.