Jump to content

[SOLVED] how to use addColor() function work of ObjectMeshDynamic class


photo

Recommended Posts

Hello,

 

I use unigine sim 2.0, when i use addColor() function of ObjectMeshDynamic class it can not work,the code like below:

int init() { ObjectMeshDynamic mesh = new ObjectMeshDynamic(); // Create a dynamic mesh and add it into the editor. engine.editor.addNode(node_remove(mesh));     mesh.setWorldTransform(translate(Vec3(0.0f,0.0f,2.0f))); mesh.setMaterial("mesh_base","*"); mesh.setProperty("surface_base","*");        mesh.addTriangleQuads(1); // Allocate space in a vertex buffer and create vertex indices.   mesh.addVertex(vec3(-1.0f,-1.0f,0.0f)); // Add vertices and assign texture coordinates, if necessary. mesh.addColor(vec4(1,0,0,1));     mesh.addVertex(vec3(1.0f,-1.0f,0.0f)); mesh.addColor(vec4(1,1,0,1));     mesh.addVertex(vec3(1.0f,1.0f,0.0f)); mesh.addColor(vec4(1,1,1,1));     mesh.addVertex(vec3(-1.0f,1.0f,0.0f)); mesh.addColor(vec4(0,0,0,1));     mesh.updateTangents(); // Calculate tangent vectors. mesh.updateIndices(); // Optimize vertex and index buffers, if necessary.       mesh.updateBounds(); // Calculate a mesh bounding box.     return 1;}

How can i use it for work?

 

Thanks.

Link to comment

Hi Jiaxin,

 

Your code is correct, but you need to tune up an assigned material. Firstly assign an editable material to ObjectDynamic, then enable its state: "vertex_color" and set "vertex_albedo" state to rgb.

Link to comment

Hi Jiaxin,

 

Your code is correct, but you need to tune up an assigned material. Firstly assign an editable material to ObjectDynamic, then enable its state: "vertex_color" and set "vertex_albedo" state to rgb.

Hi maxi,

 

Thanks very much for you reply,i could not find the "vertex_color" state  parameter, or  do I need to customize and configure this parameter?

 

 

Thanks.

Link to comment

Hi jiaxin,

 

Sorry, i didn't mention, that this state was introduced with latest 2.2 release. The only way to visualize this in 2.0 is to write custom shader. Sorry for the inconvenience caused.

Link to comment
×
×
  • Create New...