yiskang / assimp-net

Automatically exported from code.google.com/p/assimp-net
0 stars 1 forks source link

It is impossible to add diffuse texture at export #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I try to implement export to .OBJ format. My material has diffuse textures, and 
I do the following:

TextureSlot t = new TextureSlot();
t.FilePath = dst_texture_file_name;
t.TextureType = TextureType.Diffuse;
t.TextureIndex = 0;

assimp_material.TextureDiffuse = t;

After that, assimp_material.TextureDiffuse.FilePath remains null, 
assimp_material.HasTextureDiffuse continues to show false.

Expected output is 'map_Kd lenna.tga' string it resulting .OBJ file, but it is 
missing.

I use version 3.3.1 on Windows 7.

This is C++ code of assimp:

aiString s;
if(AI_SUCCESS == mat->Get(AI_MATKEY_TEXTURE_DIFFUSE(0),s)) {
    mOutputMat << "map_kd " << s.data << endl;
}

Look like all is OK there. Something is wrong in C#. Thanks.

Original issue reported on code.google.com by a.merez...@gmail.com on 25 Jan 2015 at 3:00

GoogleCodeExporter commented 9 years ago
Should be fixed in r128, the well known properties on material were using fully 
qualified rather than base name when adding the properties. You could still 
have used the AddProperty API to manually add the diffuse texture though.

Original comment by nicholas.woodfield on 22 Feb 2015 at 5:21

GoogleCodeExporter commented 9 years ago
I grabbed the latest binaries (AssimpNet.3.3.1) I could find a couple of weeks 
ago, but it doesn't appear to have this fix. I tested in code and I have to use 
the following to get it to work:

                material.AddProperty(new MaterialProperty(/*Assimp.Unmanaged.AiMatKeys.NAME_BASE*/ "?mat.name", meshName + "-" + m.ToString()));
                material.AddProperty(new MaterialProperty(/*Assimp.Unmanaged.AiMatKeys.COLOR_DIFFUSE_BASE*/ "$clr.diffuse", colorDiffuse));
                material.AddProperty(new MaterialProperty(Assimp.Unmanaged.AiMatKeys.TEXTURE_BASE, GetTextureName(file.m_axModels[0], m), TextureType.Diffuse, 0));

When I try the same way as the OP, these return true, but HasTextureDiffuse and 
HasColorDiffuse show as false.

I think I obtained the binaries from NuGet.  Is that definitely up to date?

Original comment by andrew.f...@gmail.com on 5 Apr 2015 at 11:37