ramendeus.chris Posted June 4 Posted June 4 My Unigine version is 2.7 . I can drag and drop a dae file into asset browser and it can works in editor and scene with no problem. And now I need to do same thing in the C++ code by using below code sample ,but failed . These codes are copied from offical documents. Unigine::String filepath_node; bool ret = Unigine::Import::get()->import("D:\\test.dae", "../data/", filepath_node); // create a node reference using the .node file generated Unigine::NodeReferencePtr noderef = Unigine::NodeReference::create(filepath_node.get()); noderef.get()->setWorldPosition(Unigine::Math::Vec3(1,2,3)); But the return value is 0 and it seems no objects generated in the scene . Thanks for any suggestion and reply . Especailly @silent
bmyagkov Posted June 6 Posted June 6 On 6/4/2024 at 9:40 PM, ramendeus.chris said: My Unigine version is 2.7 . I can drag and drop a dae file into asset browser and it can works in editor and scene with no problem. And now I need to do same thing in the C++ code by using below code sample ,but failed . These codes are copied from offical documents. Unigine::String filepath_node; bool ret = Unigine::Import::get()->import("D:\\test.dae", "../data/", filepath_node); // create a node reference using the .node file generated Unigine::NodeReferencePtr noderef = Unigine::NodeReference::create(filepath_node.get()); noderef.get()->setWorldPosition(Unigine::Math::Vec3(1,2,3)); But the return value is 0 and it seems no objects generated in the scene . Thanks for any suggestion and reply . Especailly @silent Hello! The log file might help shed light on this issue but most likely the FbxImporter plugin is not initialized for some reason. Therefore, make sure you run it properly using the following argument: -extern_plugin "FbxImporter". Moreover, runtime import through the API is a SIM feature which might not be available for the edition you have. Thanks! 1
ramendeus.chris Posted June 6 Author Posted June 6 Thanks . My Unigine version is SIM .And added -extern_plugin "Collada,FbxImporter" However , can't find importer related codes are : const char* import_path = "d:\\material_ball.dae"; const char* output_dir = "../data/"; Importer* importer = Import::get()->createImporterByFileName(import_path); if (importer) { if (importer->init(import_path, ~0)) { create_unique_meshes_names(importer->getScene()); if (importer->import(output_dir)) Log::message("Import done.\n"); } }
ramendeus.chris Posted June 6 Author Posted June 6 (edited) Thanks bmyagkov. You are correct. I found that my version is SIM ,however evaluation version. I fixed that ,and the import plugin can work fine now. The new problem ,is I try to add node reference to editor ,however the scene seems no object added. bool ret = Unigine::Import::get()->import(import_path, output_dir, filepath_node); Unigine::NodeReferencePtr noderef = Unigine::NodeReference::create(filepath_node.get()); //noderef.get()->setWorldPosition(Unigine::Math::Vec3(block.origin.x, block.origin.y, block.origin.z)); noderef.get()->setWorldPosition(Unigine::Math::Vec3(10.0,0.0,0.0)); noderef.get()->release(); Editor::get()->addNode(noderef.get()->getNode()); Thanks for reply Edited June 6 by ramendeus.chris 1
bmyagkov Posted June 6 Posted June 6 3 hours ago, ramendeus.chris said: The new problem ,is I try to add node reference to editor ,however the scene seems no object added. This might be related to the "scale" parameter, so it would be advisable to give it a comprehensive check :)
Recommended Posts