awaytools / AwayExtensions-3dsmax

17 stars 6 forks source link

Export Vertex Color #22

Closed liaocheng closed 9 years ago

liaocheng commented 9 years ago

Hello Robin I'm trying to implement vertex color exporting based on your plugins. But I am troubled by a question. This is not a question about your plugin but about 3ds max plugin. Here's my question:

  1. Select any mesh image
  2. Select Vertex in Editable Mesh image
  3. Scroll down to Surface Properties image
  4. Select any vertex on the mesh image
  5. Set color and alpha on Surface Properties pannel image Now this vertex on the mesh should have the color with alpha value. And then in plugin (maxawdexporter_geometry.cpp), I can get the color value by mesh.vertCol[vIdx] (vIdx is the index of the vertex) However I don't know how to get the alpha value. I tried mesh.setVDataSupport(VDATA_ALPHA); mesh.vertexFloat(VDATA_ALPHA)[vIdx]; But it didn't work ( mesh.vertexFloat(VDATA_ALPHA)[vIdx] always was 1.0) .

I'm sorry to bother you. Any suggestion is appreciated. Regards

80prozent commented 9 years ago

hey liaocheng I am working on the plugin + libawd right now, and will upload a new version for both in next days. To get the vertex-color and vertex-alpha, i would try to use the IGameMesh-interface instead of the Mesh-interface. Right now i cannot test, becausei have some refactoring going on that prevents me from compile... To get the alpha and color for a vertex, i suspect it will work something like this:

FaceEx * f=facelist[idx];    // get pointer to face - is already in the code.
for (v=2; v>=0; v--) {        // loop over verts of face - is already in the code
    Point3 vertexColor=igame_mesh->GetColorVertex(f->color[v]); // returns (-1,-1,-1) if no color is set for vertex
    float vertexAlpha=igame_mesh->GetAlphaVertex(f->alpha[v]); // return -1 if no alpha is set for vertex
}
liaocheng commented 9 years ago

You are right. It works for me now. Thank you very much, Robin!