opengl - Exporting 3d Models and their color information using Assimp -


we're working on custom 3d engine (opengl) in people can create, import , export custom 3d models, , using assimp our importing/exporting. @ point, importing works great, when comes exporting, unable save out materials other default. while assimp's website , others have loads of information on importing, there little no documentation on exporting. managed work out majority of export process, there doesn't seem way of setting assimp's aimaterials' color values.

assimp's documentation explains how color information existing materials, ie..

*aicolor3d color (0.f,0.f,0.f);

mat->get(ai_matkey_color_diffuse,color);*

http://assimp.sourceforge.net/lib_html/materials.html

but doesn't include on setting color information based on model's material. (fyi, of our models flat colors; no textures). if has experience in exporting materials/colors, appreciated. here have now..

//create assimp node element container object hold graphic information  scene.mrootnode = new ainode();  scene.mmaterials = new aimaterial*[ 1 ]; scene.mmaterials[ 0 ] = nullptr; scene.mnummaterials = 1;  mallchildren.clear(); //get children on scene (including down hierarchy) findallchildren(cscriptingutils::getdoc()->getscene()); std::vector<std::weak_ptr<cnode>> children = mallchildren; int size = (int)children.size(); scene.mmaterials[ 0 ] = new aimaterial();  scene.mrootnode->mmeshes = new unsigned int[ size ]; scene.mrootnode->mnummeshes = size; scene.mmeshes = new aimesh*[ size ]; scene.mnummeshes = size;  //iterate through children, retrieve graphical information , push assimp structure for(int = 0; < size; i++) {     std::shared_ptr<cnode> childnode = children[i].lock();     scene.mrootnode->mmeshes[ ] = i;     scene.mmeshes[ ] = nullptr;     scene.mmeshes[ ] = new aimesh();     scene.mmeshes[ ]->mmaterialindex = 0;      aimaterial* mat = scene.mmaterials[0]; 

and need like..

    mat.color = childnode.color;  

try that:

mat->addproperty<aicolor3d>(color, 1, ai_matkey_color_diffuse); 

it helps me. also, trying export textures

newmat->addproperty(matname, ai_matkey_name); newmat->addproperty(texturepath, ai_matkey_texture_diffuse(0)); 

where 'matname' , 'texturepath' types 'aistring'. additiional parameters (besides path of texture) needed correct displaying texture (because textures not displayed, color)?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -