3D_Gostek Posted July 16 Share Posted July 16 Hello Guys, can someone please help me on how to do it? In my project I have a Node (NodeDummy) with a C++ component attached. In this script I want to set material of the child of this node (ObjectMeshStatic "LED" which has a mesh "box_1.mesh"). This is the only child of the node. // here I can see that the child exists, and it of a type ObjectMeshStatic Log::message(" "); Log::message("Sensor Beam Children %d .", node->getNumChildren()); //"1" Log::message("Child 0 Name %s .", node->getChild(0)->getName()); //"LED" Log::message("Child 0 Type %d .", (node->getChild(0)->getType())); // " 36" Log::message("Child 0 Type %s .", (node->getChild(0)->getTypeName())); // "ObjectMeshStatic" //But the code below doesnt work node->getChild(0)->setMaterialPath("vr_sample/props/Conveyors/materials/sensor-beam.mat", "*"); My question is why setMaterialPath can't be used here but can be used for meshes generated with code like below? if (obj) { Math::Vec3 p = intersection->getPoint(); mesh = ObjectMeshDynamic::create(); mesh->setWorldTransform(translate(Vec3(0.0f, 0.0f, 0.3f))); mesh->addTriangleQuads(1); mesh->addVertex(vec3(0.0f, -1.0f, 0.0f)); mesh->addTexCoord(vec4(0, 0, 0, 0)); mesh->addVertex(vec3(0.03f, -1.0f, 0.0f)); mesh->addTexCoord(vec4(1, 0, 0, 0)); mesh->addVertex(vec3(0.03f, 1.0f, 0.0f)); mesh->addTexCoord(vec4(1, 1, 0, 0)); mesh->addVertex(vec3(0.0f, 1.0f, 0.0f)); mesh->addTexCoord(vec4(0, 1, 0, 0)); mesh->updateTangents(); mesh->updateBounds(); // Set Material.. mesh->setMaterialPath("Materials/plane_0_mesh_base_0.mat", "*"); } Link to comment
silent Posted July 18 Share Posted July 18 Just copying answer from discrod: int SurfaceNum = 0; Unigine::ObjectPtr CPtr = Unigine::static_ptr_cast<Unigine::Object>(node->getChild(0)); CPtr->setMaterial("Path", SurfaceNum); 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts