Page 1 of 1

specular highlights not working in .NET? (+fix)

Posted: Thu Sep 07, 2006 9:38 am
by mark.mccormack
After wondering why specular highlights don't appear to be working in Irrlicht.NET I think there is some code missing from two functions in the file at http://irrlicht.cvs.sourceforge.net/irr ... onverter.h.

The functions getNETMaterial() and getNativeMaterial() don't handle .SpecularColor or .Shininess material variables which has the effect of the actual Irrlicht DLL getting a Material structure with these variables always set to zero. I've recompiled Irrlicht.NET after adding the missing assignments and specular is now working for me.

These are the functions after my changes:

inline static Irrlicht::Video::Material getNETMaterial(irr::video::SMaterial& material)
{
Irrlicht::Video::Material mat;
mat.AmbientColor.color = material.AmbientColor.color;
mat.DiffuseColor.color = material.DiffuseColor.color;
mat.EmissiveColor.color = material.EmissiveColor.color;
mat.SpecularColor.color = material.SpecularColor.color;
mat.Shininess = material.Shininess;
mat.Type = (Irrlicht::Video::MaterialType)material.MaterialType;
mat.Texture1 = material.Texture1 ? new Irrlicht::Video::ITexture(material.Texture1) : 0;
mat.Texture2 = material.Texture2 ? new Irrlicht::Video::ITexture(material.Texture2) : 0;
mat.Texture3 = material.Texture3 ? new Irrlicht::Video::ITexture(material.Texture3) : 0;
mat.Texture4 = material.Texture4 ? new Irrlicht::Video::ITexture(material.Texture4) : 0;

for (int i=0; i<irr::video::EMF_MATERIAL_FLAG_COUNT; ++i)
mat.Flags = material.Flags;

return mat;
}

inline static irr::video::SMaterial getNativeMaterial(Irrlicht::Video::Material& material)
{
irr::video::SMaterial mat;
mat.AmbientColor.color = material.AmbientColor.color;
mat.DiffuseColor.color = material.DiffuseColor.color;
mat.EmissiveColor.color = material.EmissiveColor.color;
mat.SpecularColor.color = material.SpecularColor.color;
mat.Shininess = material.Shininess;
mat.MaterialType = (irr::video::E_MATERIAL_TYPE)material.Type;
mat.Texture1 = material.Texture1 ? material.Texture1->get_NativeTexture() : 0;
mat.Texture2 = material.Texture2 ? material.Texture2->get_NativeTexture() : 0;
mat.Texture3 = material.Texture3 ? material.Texture3->get_NativeTexture() : 0;
mat.Texture4 = material.Texture4 ? material.Texture4->get_NativeTexture() : 0;

for (int i=0; i<irr::video::EMF_MATERIAL_FLAG_COUNT; ++i)
mat.Flags = material.Flags;

return mat;
}

Posted: Wed Jan 24, 2007 11:29 pm
by Kiwsa
Can we get a copy of this illustrious (no pun intended) fix precompiled for those of us who are cpp deficient?

Thanks in advance,
Kiwsa