matrakim / opencollada

Automatically exported from code.google.com/p/opencollada
0 stars 0 forks source link

Fix for color sets not exporting in colladaMaya #136

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Make a mesh with per-vertex colors
2. export it
3. note that the color indices are all 0

I made the following changes to my local source and it now exports them 
correctly. Probably only the first change is needed:

in ColladaMayaGeometryExporter.cpp, exportColorSets.
The SourceInput was being constructed with the default index, -1.
This made the color index lookup later fail, since there is not a color set 
name for index -1.

            //-------------------------------------------------------------------------------
            // PMS BEGIN EDIT
            // MJB: Added ,i to the end of each input definitions
            if ( perVertexColor )
            {
                // Insert a per-vertex color set input
                mVertexSources.push_back ( SourceInput ( colorSource, COLLADASW::COLOR, i ) );
            }
            else
            {
                // Insert a per-face-vertex color set input
                mPolygonSources.push_back ( SourceInput ( colorSource, COLLADASW::COLOR, i ) );
            }
            // PMS END EDIT
            //-------------------------------------------------------------------------------

in colladaMayaGeometryPolygonExporter.cpp, writeVertexIndices
I changed the API used to match the API for the UV's, in the preceding switch 
case.

            case COLLADASW::COLOR:
                {
                    MString& colorSetName = mColorSetNames[vertexAttributes.getIdx()];
                    int colorIndex = 0;
                    {
                        //----------------------------------------------------------
                        // PMS BEGIN EDIT
                        // MJB: The API functions they use aren't working
                        // MJB: Try the same API as for texture co-ordinates, above
                        if( meshPolygonsIter.getColorIndex ( iteratorVertexIndex, colorIndex, &colorSetName )!= MStatus::kSuccess )
                        {
                            std::cerr << "Could not get color index for vertex " << iteratorVertexIndex << "in color set " << colorSetName << std::endl;
                        }
//#if MAYA_API_VERSION >= 700
//                        fnMesh.getColorIndex ( polyIndex, 
iteratorVertexIndex, colorIndex, &colorSetName );
//#else
//                        fnMesh.getFaceVertexColorIndex ( polyIndex, 
iteratorVertexIndex, colorIndex );
//#endif
                        // PMS END EDIT
                        //----------------------------------------------------------
                    }
                    primitivesBasePoly->appendValues ( colorIndex );
                }
                break;

Original issue reported on code.google.com by martin.b...@gmail.com on 19 Nov 2010 at 3:52

GoogleCodeExporter commented 8 years ago
Thanks for providing this fix. I have applied the first change in revision 784. 
I'm not sure if the second works for all maya API versions. This would require 
additional testing I currently do not have the time for.

Original comment by opencollada2@googlemail.com on 22 Nov 2010 at 8:38

GoogleCodeExporter commented 8 years ago

Original comment by opencollada2@googlemail.com on 19 Jan 2011 at 8:20