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

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
mark.mccormack
Posts: 1
Joined: Thu Sep 07, 2006 9:33 am

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

Post 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;
}
Kiwsa
Posts: 2
Joined: Fri Jan 12, 2007 5:46 pm
Location: bfe, USA

Post 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
(swipes hand slowly in a left-right motion)
"This is not the code your looking for...."
Post Reply