jiaxin Posted March 17, 2016 Share Posted March 17, 2016 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
maxi Posted March 18, 2016 Share Posted March 18, 2016 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
jiaxin Posted March 20, 2016 Author Share Posted March 20, 2016 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
maxi Posted March 21, 2016 Share Posted March 21, 2016 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
jiaxin Posted March 21, 2016 Author Share Posted March 21, 2016 Hi maxi, Well, then,i will consider use other methods. but still thanks. Link to comment
Recommended Posts