ashwin.sudhir Posted June 21, 2011 Posted June 21, 2011 This snippet from our code shows how we use the return value of runSystem() to return a vec3 from UnigineScript Unigine::Variable var = GLib::GetSingletonImpl()->GetEngine()->runSystem( "Model::GetPosition", Unigine::Variable(m_idNode) ); Unigine:::vec3 vPos = var.getVec3() etc. and this works just fine But this fails when we try to return a Node through a Unigine::Variable Unigine::Variable var = GLib::GetSingletonImpl()->GetEngine()->runSystem( "Model::SetColorScale", Unigine::Variable(m_idNode), CGLibHelper::CVector3DToVariable(vColor) ); followed by var.getNode() causes an access violation. Is returning a NodePtr through runSystem's return value not supported? UnigineScript =================== Node SetColorScale(int idNode, vec3 vColor) { Node node = engine.world.getNode(idNode); Object obj = node_cast(node); if( obj.getNumSurfaces() > 0 ) obj.setMaterialParameter("color_scale", vec4(vColor, 0.f), 0); return node; } Thanks, Ashwin.
Guest anet Posted June 22, 2011 Posted June 22, 2011 Add Engine::pushSystem() before calling runSystem() and Engine::popSystem() after it. It will set appropriate runtime. See details here (Create Variable in Extern Function section)
ashwin.sudhir Posted June 22, 2011 Author Posted June 22, 2011 Add Engine::pushSystem() before calling runSystem() and Engine::popSystem() after it. It will set appropriate runtime. See details here (Create Variable in Extern Function section) Thanks! that did it.
Recommended Posts