I've noticed something strange in a Collada DAE export from Blender. I've assigned Diffuse BDSF colors to 4 faces of a cube as shown here:


It renders fine in Blender but after exporting to the following DAE file the diffuse and ambient color's RGB values stay the same for all materials. Shouldn't each material block in DAE have different values? Do I need to do something more in Blender to save the material info?



2 Answers 2


Assuming your setup code remains unchanged, and after checking the source code for Assimp .NET, try this:

private void SetUpVertices()
    int count = oScene.MeshCount;
    vertexBuffers = new VertexBuffer[count]
    indexBuffers = new IndexBuffer[count]

    Mesh mMesh;
    // define objects for the meshes material and the color we are sampling
    Matrial mMaterial;
    Color4D color;
    for (int m = 0; m < count;m++)
        mMesh = oScene.Meshes[m];
        vertices = new VertexPositionColor[mMesh.VertexCount];
        indices = new  short[mMesh.FaceCount*3];

        // load the material
        mMaterial = oScene.Material[mMesh.MaterialIndex];
        // get the diffuse color for this material
        color = mMaterial.ColorDiffuse;

        int i=0;
        foreach (Vector3D mVec in mMesh.Vertices)
            // convert the Assimp Color4D data into an XNA Color
            vertices[i] = new VertexPositionColor(new Vector3(mVec.X, mVec.Y, mVec.Z), new Color(color.R, color.G, color.B, color.A));

        int f = 0;
        Face mFace;
        for (i = 0 ; i < mMesh.FaceCount*3 ; i=i+3) 
            mFace = mMesh.Faces[f];
            indices[i] = (short)mFace.Indices[0];
            indices[i + 1] = (short)mFace.Indices[1];
            indices[i + 2] = (short)mFace.Indices[2];

        vertexBuffer = new VertexBuffer(device, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);

        indexBuffer = new IndexBuffer(device, typeof(short), indices.Length, BufferUsage.None);

        vertexBuffers[m] = vertexBuffer;
        indexBuffers[m] = indexBuffer;

I've added comments so you can see the changes I've made, so hopefully you can understand how the added/changed code works, but basically I've loaded each meshes Material, grabbed the diffuse color from it, and instead of setting a default color, I've converted the Assimp Color4D to XNA Color inline when creating each vertex. Again, untested, so it may or may not work.

  • \$\begingroup\$ That code is pretty much what I was already using. But the problem is not with the code, its with the imported data. If you look at the dae file or when i write to console i see that diffusecolor RGB values are always 0.65 regardless of the MaterialIndex \$\endgroup\$ Commented May 9, 2014 at 13:19
  • \$\begingroup\$ Hmm, odd. I've just exported my own cube with several different materials, and the material properties are fine. What version of Blender are you using, and are you using a non standard Collada exporter? \$\endgroup\$
    – Seta
    Commented May 9, 2014 at 13:55
  • \$\begingroup\$ I'm using the default Collada exporter in Blender. I've noticed when I click on the menu option, the file browser window has an export collada setting section with options off by default like "include material textures" and "include UV textures". I've tried export with these on but get the same result. Am I supposed to choose something else here? Also, to set the materials ive just used the Materials panel, created the material, changed color and applied it. Do I need to do something more? Like baking? I'm using Blender 2.69 \$\endgroup\$ Commented May 9, 2014 at 15:48
  • 1
    \$\begingroup\$ I'm currently using 2.58.1, default exporter (no export options available). I've just created a few new materials, applied them to a face each on the default cube, and just exported as is. I've also Googled for issues with Blenders Collada exporter, and it does seem to be rather buggy in 2.5 onwards. A lot of unfixed issues, but nothing matching what your reporting. I'd say give 2.58.1 a go, see if that works for you. Having multiple installs isn't a bad thing. \$\endgroup\$
    – Seta
    Commented May 10, 2014 at 0:41
  • \$\begingroup\$ Thanks. 2.58(cant get .1 from site) only applies materials to object, not faces but 2.59 works. However, I've rotated the mesh in Blender before exporting but the object looks the same when rendered. I haven't changed the setupvertices/draw code and should not need to change the camera view right? \$\endgroup\$ Commented May 10, 2014 at 7:20

I Tried exporting from blender to MS word/Powerpoint, and I found that exporting using the option wavefront(.obj) helps because it crease an obj file and a an mtl file (texture file). Now in order to insure that when you open the obj file in MS word make sure the obj file and the mtl file are in the same folder.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .