pramod.s Posted August 6, 2012 Share Posted August 6, 2012 Hello, I am trying to assign a material through ObjectMesh object using setMaterial() with following mentioned values, but it is not reflecting onto the mesh. I am programically adding the mesh & assigning the materials for each mesh created. How can I assign a color as material properly. I have taken the "players_red" value from the editor just for testing purpose. ObjectMesh.setMaterial("players_red", "*"); //This material is not applying on the mesh ObjectMesh.setWorldTransform(myvalue); //This changes according to the myvalue. Can any one help me here. Thanks Link to comment
ivan.cuevas Posted August 6, 2012 Share Posted August 6, 2012 Hi, Have you ensured "players_red" material is previously loaded before its assignation? Check in your log file if the corresponding material library is loaded with your world. Check engine.materials functions if you want to load that library programatically. Another way to change material color is using Object::setMaterialParameter() Review Materials and mesh_base sections in documentation, and have a look to samples (for example transparent_00) Link to comment
pramod.s Posted August 7, 2012 Author Share Posted August 7, 2012 Hey, I was able to add the materials, but now I am having a different issue. I have add my own Init(), Update(), shutdown() function, but when I add #include < samples/materials/common/materials.h> it give an parsing error because init(), update() are already defined in materials.h. Can anyone tell me how to override these function, so that I can use my init(), update() function instead of materials. Is it that I have to rewrite the materials functionality without using materials.h? Thanks Link to comment
ivan.cuevas Posted August 7, 2012 Share Posted August 7, 2012 In this moment I don't have access to sources, but I think you only have to implement update_scene and create_scene functions. Link to comment
pramod.s Posted August 7, 2012 Author Share Posted August 7, 2012 neither do I have source code. I am trying to solve by adding my own functions Thanks for your help guyzz Link to comment
ivan.cuevas Posted August 7, 2012 Share Posted August 7, 2012 If you are making your own test and you include "samples/materials/common/materials.h", you should implement (From materials.h file) create_scene: // create scene string text = call("create_scene"); update_scene: // update scene if(is_function("update_scene")) { thread("update_scene"); } clear_scene: // clear scene if(is_function("clear_scene")) { call("clear_scene"); } Link to comment
pramod.s Posted August 7, 2012 Author Share Posted August 7, 2012 Hey, I have added my funcationality for init(), update() & shutdown() & are been called properly. As I am very new to the Unigine, I am bit confused in assigning the material through string paramter for first agrument in ObjectMesh::setMaterial(). Where should the .dds file need to be stored for applying them as materials & where should .mat file need to be placed. Because currently my script is not able to find the mentioned materials. Currently I have placed *.mat file at ./ folder (current folder) & textures at ./materials/textures/ & have given the same path in the *.mat file for the textures. I am getting Object::setMaterial(): can't find "materials_****" material error in log file Can anyone help me out? Thanks Link to comment
manguste Posted August 8, 2012 Share Posted August 8, 2012 Providing a test scene will be helpful - so we can help you. Link to comment
pramod.s Posted August 9, 2012 Author Share Posted August 9, 2012 Hey attached is the sample which contain the above mentioned issue. Please check for the mistake & suggest the solution. Thanks TestMaterials.zip Link to comment
pramod.s Posted August 10, 2012 Author Share Posted August 10, 2012 Has any one able to check the sample for the error? Link to comment
manguste Posted August 14, 2012 Share Posted August 14, 2012 You did not load a material library to start with. Without it, materials cannot be loaded. You can either: Load it via engine.materials.addWorldLibrary() or Load it from script or in the editor and save the world. In this case a material library associated with the world will be written into *.world file. Link to comment
Recommended Posts