Jump to content

[SOLVED] Problem in ObjectMesh::setMaterial function


photo

Recommended Posts

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

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

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

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

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
×
×
  • Create New...