So far we have two example scenes for two different Blender versions.
Blender 3.0.0:
blend_info blend/factory_v300.blend | grep " Camera (len=" -A 26
Camera (len=576) {
ID id;
AnimData *adt;
char type;
char dtx;
short flag;
float passepartalpha;
float clipsta;
float clipend;
float lens;
float ortho_scale;
float drawsize;
float sensor_x;
float sensor_y;
float shiftx;
float shifty;
float YF_dofdist;
Ipo *ipo;
Object *dof_ob;
GPUDOFSettings gpu_dof;
CameraDOFSettings dof;
ListBase bg_images;
char sensor_fit;
char _pad[7];
CameraStereoSettings stereo;
Camera_Runtime runtime;
}
Blender 2.79:
blend_info blend/factory_v279.blend | grep " Camera (len=" -A 23
Camera (len=248) {
ID id;
AnimData *adt;
char type;
char dtx;
short flag;
float passepartalpha;
float clipsta;
float clipend;
float lens;
float ortho_scale;
float drawsize;
float sensor_x;
float sensor_y;
float shiftx;
float shifty;
float YF_dofdist;
Ipo *ipo;
Object *dof_ob;
GPUDOFSettings gpu_dof;
char sensor_fit;
char pad[7];
CameraStereoSettings stereo;
}
As a first step towards a re-usable library extract those parts useful for the rs-pbrt
project and the Arnold
renderer, which can be used to define cameras for both renderers.
For both structs (
Camera
) the first entry is of typeID
:Blender 3.0.0:
blend_info blend/factory_v300.blend | grep " ID (len=" -A 20 ID (len=176) { void *next; void *prev; ID *newid; Library *lib; AssetMetaData *asset_data; char name[66]; short flag; int tag; int us; int icon_id; int recalc; int recalc_up_to_undo_push; int recalc_after_undo_push; int session_uuid; IDProperty *properties; IDOverrideLibrary *override_library; ID *orig_id; void *py_instance; LibraryWeakReference *library_weak_reference; }Blender 2.79:
blend_info blend/factory_v279.blend | grep " ID (len=" -A 12 ID (len=120) { void *next; void *prev; ID *newid; Library *lib; char name[66]; short flag; short tag; short pad_s1; int us; int icon_id; IDProperty *properties; }
Jan Walter referenced this ticket in commit c68816d.
Jan Walter referenced this ticket in commit f22aff0.
For the
Camera
struct the Rust code calculates the proper size (in bytes).Blender 3.0.0:
blend_info blend/factory_v300.blend ... === TMP === Camera 576 struct Camera { ID id; // 176 AnimData *adt; // 8 char type; // 1 char dtx; // 1 short flag; // 2 float passepartalpha; // 4 float clipsta; // 4 float clipend; // 4 float lens; // 4 float ortho_scale; // 4 float drawsize; // 4 float sensor_x; // 4 float sensor_y; // 4 float shiftx; // 4 float shifty; // 4 float YF_dofdist; // 4 Ipo *ipo; // 8 Object *dof_ob; // 8 GPUDOFSettings gpu_dof; // 32 CameraDOFSettings dof; // 32 ListBase bg_images; // 16 char sensor_fit; // 1 char _pad[7]; // 7 CameraStereoSettings stereo; // 24 Camera_Runtime runtime; // 216 }; // 576 === TMP ===Blender 2.79:
blend_info blend/factory_v279.blend ... === TMP === Camera 248 struct Camera { ID id; // 120 AnimData *adt; // 8 char type; // 1 char dtx; // 1 short flag; // 2 float passepartalpha; // 4 float clipsta; // 4 float clipend; // 4 float lens; // 4 float ortho_scale; // 4 float drawsize; // 4 float sensor_x; // 4 float sensor_y; // 4 float shiftx; // 4 float shifty; // 4 float YF_dofdist; // 4 Ipo *ipo; // 8 Object *dof_ob; // 8 GPUDOFSettings gpu_dof; // 24 char sensor_fit; // 1 char pad[7]; // 7 CameraStereoSettings stereo; // 24 }; // 248 === TMP ===Time to think about which struct members are needed and how to extract the data.
Let's start with 5 values we use in
parse_blend_file.rs
(part of the rs-pbrt project):
- lens
- sensor_x
- sensor_y
- clipsta
- clipend (currently not used by
parse_blend_file.rs
, but if we useclipsta
, we should useclipend
as well)
Jan Walter referenced this ticket in commit d7314a2.
E.g.
$ ./target/release/blend_info -n Camera.lens blend/factory_v279.blend lens = 35_f32 $ ./target/release/blend_info -n Camera.lens blend/factory_v300.blend lens = 50_f32 $ ./target/release/blend_info -n Camera.clipsta blend/factory_v279.blend clipsta = 0.1_f32 $ ./target/release/blend_info -n Camera.clipsta blend/factory_v300.blend clipsta = 0.1_f32 $ ./target/release/blend_info -n Camera.clipend blend/factory_v279.blend clipend = 100_f32 $ ./target/release/blend_info -n Camera.clipend blend/factory_v300.blend clipend = 100_f32 $ ./target/release/blend_info -n Camera.sensor_x blend/factory_v279.blend sensor_x = 32_f32 $ ./target/release/blend_info -n Camera.sensor_x blend/factory_v300.blend sensor_x = 36_f32 $ ./target/release/blend_info -n Camera.sensor_y blend/factory_v279.blend sensor_y = 18_f32 $ ./target/release/blend_info -n Camera.sensor_y blend/factory_v300.blend sensor_y = 24_f32
For both, the
rs-pbrt
project and theArnold
renderer, we would also need to know the transform or matrix used for the camera, but in Blender that's stored as part of theObject
, not theCamera
:$ ./target/release/blend_info -n Object blend/factory_v300.blend | grep obmat float obmat[4][4]; // 64Therefore let's close this ticket and open another one for extracting the matrix for any
Object
(not just theCamera
) ...
Jan Walter referenced this ticket in commit d7314a2.
Jan Walter referenced this ticket in commit d7314a2.
Jan Walter referenced this ticket in commit d7314a2.
Jan Walter referenced this ticket in commit d7314a2.
Jan Walter referenced this ticket in commit d7314a2.
Jan Walter referenced this ticket in commit d7314a2.