I am trying to change the colors for my mesh
but
mesh.SetVertex(0, ON_3dPoint(xoffset + 0.0, yoffset + 0.0, zoffset + zdim));
mesh.SetVertexNormal(0, ON_3dVector(0.0, 0.0, 1.0));
mesh.m_c[0]=ON_Color(255, 0, 0); //CRASHES HERE
I cannot ever see where / how to modify m_c
Do you do it after : AddMeshObject? The m_c count was still 0, is there a way to turn the flag on?
Oh I see … I been plugging for an hour then thought of it…
mesh.m_C.Reserve(mesh.m_V.Count());
mesh.m_C.Append (ON_Color(255, 0, 0)); // for each vertex
dale
(Dale Fugier)
August 7, 2014, 5:10pm
3
Other methods:
const int count = mesh.m_V.Count();
mesh.m_C.SetCapacity(count);
for (int i = 0; i < count; i++)
mesh.m_C.Append(ON_Color(255, 0, 0));
or
const int count = mesh.m_V.Count();
mesh.m_C.SetCapacity(count);
mesh.m_C.SetCount(count);
for (int i = 0; i < count; i++)
mesh.m_C[i] = ON_Color(255, 0, 0);