bertrand.remondin Posted April 2, 2015 Share Posted April 2, 2015 Hi, i'm trying to set dynamically, on input event, from cpp part, a mesh in script part, but get a crash. Here is my process : cpp part : //class member, Unigine::MeshPtr _currentElementMesh = Unigine::Mesh::create("meshes/pistol.mesh"); Unigine::Engine * engine = Unigine::Engine::get(); Unigine::Variable mesh; mesh.setMesh(engine->getWorldInterpreter(), _currentElementMesh, 0, 0); //send element information to script part engine->runWorldFunction(Unigine::Variable("setElement").get(), mesh); and script part : ObjectMeshStatic _mesh; void setElement(int mesh) { _mesh.setMesh(mesh); } The mesh in script part is enabled and drawed. When cpp function is called, I get a crash when _mesh.setMesh(mesh); is called in script part. I get a Vector bad index error. Here is my callstack : msvcr100.dll!__crt_debugger_hook() Inconnu msvcr100.dll!_call_reportfault() Inconnu msvcr100.dll!abort() Inconnu Unigine_x64d.dll!Log::fatal(const char * format, ...) Ligne 321 C++ Unigine_x64d.dll!ObjectMeshStatic::getBoundBox(int surface) Ligne 409 C++ Unigine_x64d.dll!Object::update_world_bounds() Ligne 1163 C++ Unigine_x64d.dll!Object::update_world_sector_bound() Ligne 1177 C++ Unigine_x64d.dll!Object::update_position() Ligne 1357 C++ Unigine_x64d.dll!WorldSpatial::update() Ligne 1740 C++ Unigine_x64d.dll!Engine::do_update() Ligne 2135 C++ Unigine_x64d.dll!App::update() Ligne 266 C++ Unigine_x64d.dll!AppWindow::doUpdate() Ligne 1217 C++ Any idea of what am I doing wrong ? Thanks. Link to comment
unclebob Posted April 3, 2015 Share Posted April 3, 2015 Hi Bertrand, This code looks good to me, do you have full version of it? One thing I want to mention is if you're going to change mesh of ObjectMeshStatic frequently you should create this node with dynamic flag enabled. Like so: ObjectMeshStatic _mesh = new ObjectMeshStatic(NULL,1); Link to comment
Recommended Posts