Hello again,
I need a bit more help 
Basically, the mesh I generate is based on an image. I need now to apply a material to this mesh, and use this image as texture.
I managed to create the material and assign it as texture:
Material *mat = BKE_material_add( bmain, DATA_( "Material" ) );
ED_node_shader_default( C, &mat->id );
assign_material( bmain, ob_mesh, mat, ob_mesh->actcol, BKE_MAT_ASSIGN_EXISTING );
By doing it manually on Blender, I’ve undestood that I also need to use nodes and use as “Base Color” an “Image Texture”, and I’ve managed to do this with this code:
mat->use_nodes = true;
bNode *imanode;
bNodeTree *ntree = mat->nodetree;
imanode = nodeAddStaticNode( C, ntree, SH_NODE_TEX_IMAGE );
imanode->id = &image->id;
nodeSetActive( ntree, imanode );
bNode *in_node = ntreeFindType( ntree, SH_NODE_BSDF_PRINCIPLED );
bNode *out_node = imanode;
if ( in_node != NULL )
{
bNodeSocket *out_sock = nodeFindSocket( out_node, SOCK_OUT, "Color" );
bNodeSocket *in_sock = nodeFindSocket( in_node, SOCK_IN, "Base Color" );
bNodeLink *link = in_sock ? in_sock->link : NULL;
if ( in_sock != NULL && link == NULL )
{
nodeAddLink( ntree, out_node, out_sock, in_node, in_sock );
nodePositionRelative( out_node, in_node, out_sock, in_sock );
}
}
ntreeUpdateTree( CTX_data_main( C ), ntree );
However, this is not enough. I need also to set “Vector” in “Base Color” as “Texture Coordinates | Generated”. I can do that manually, but I cannot understand how to do that with the code. Any suggestion?