Add data to the volume attribute


What is the proper way to fill data of a volume attribute for rendering? I am not using the Blender, but try to create custom application for rendering some volumetric data where Cycles used as the render engine. I try to use the same code as in blender_mesh.cpp:

Attribute *attr = mesh->attributes.add(ATTR_STD_VOLUME_DENSITY);
VoxelAttribute *volume_data = attr->data_voxel();

and next I should add data to the volume attribute by using

volume_data->slot = scene->image_manager->add_image(…)

All parameters of the method add_image are clear except the second one: void *builtin_data. As I understand this parameter is the pointer to some data structure with all necessary information of voxels (dimensions, channels and so on). So, the question: how I should create this structure? May be there are some examples, or fragments of source code, where the similar stuff is implemented?

I don’t have a simple code example, but basically you need to set some callbacks in the image manager: builtin_image_info_cb and builtin_image_float_pixels_cb. These will be called during scene synchronization, with the builtin_data pointer to identify the volume to be loaded.

builtin_image_info_cb needs to set metadata about the image/volume, and builtin_image_float_pixels_cb loads the actual pixel/voxel data.;9fd0060c0f3458e53b38003d1388f16cb56f45d8$140-142

Thank you very much. It seems I figured out how it works.