saw your level...seems....the gls had the textures, but only a single 1024x1024 lightmap for all...and a lot of little textures per area...
if find the time tomorrow, will try to make a mim of it
![Smile :)](./images/smilies/icon_smile.gif)
btw, nice viewer
![Smile :)](./images/smilies/icon_smile.gif)
Looks a bit more functional than my SimpleViewer (which I think was included with the MIM distribution...?).puh wrote:Here you can find a standard Irrlicht meshviewer
Hmm... did I not do that? :OTo Murphy: i've slightly modified the CMIrrMeshLoader.cpp to add root path for textures loading (i.e. the mim file itself). If you are interested i can send you the file. Just copy-paste from CDMFLoader.cpp...
Code: Select all
#include "dmfsupport.h"
........
bool CMIrrMeshLoader::ReadMeshBuffer(irr::io::IXMLReader * xml, scene::SMeshBufferLightMap * buffer, double scale, f32 x, f32 y, f32 z, io::IReadFile* file)
{
while (xml->read()) {
switch (xml->getNodeType()) {
case io::EXN_ELEMENT_END:
return true;
case io::EXN_ELEMENT:
if (core::stringw("polygon") == xml->getNodeName())
{
if (ReadPolygon(xml, buffer, scale, x, y, z) == false) return false;
}
else if (core::stringw("material") == xml->getNodeName())
{
// Read a material
/*
materialType="EMT_SOLID"
ambientColor="0xFFFFFFFF"
diffuseColor="0xFFFFFFFF"
emissiveColor="0x00000000"
specularColor="0x00000000"
shininess="0.0"
wireframe="0"
gouraudShading="1"
lighting="1"
zBuffer="1"
zWriteEnable="1"
backfaceCulling="1"
bilinearFilter="1"
trilinearFilter="0"
fogEnable="0"
textureFile1="..."
textureFile2="..."
*/
do { // Just used to break from
#define CHECK(__E) if (core::stringw(L#__E) == xml->getAttributeValueSafe(L"materialType")) { buffer->Material.MaterialType = irr::video::##__E; break;}
//UPDATE: Update when Irrlicht adds a material type
CHECK(EMT_SOLID);
CHECK(EMT_SOLID_2_LAYER);
CHECK(EMT_LIGHTMAP);
CHECK(EMT_LIGHTMAP_ADD);
CHECK(EMT_LIGHTMAP_M2);
CHECK(EMT_LIGHTMAP_M4);
CHECK(EMT_LIGHTMAP_LIGHTING);
CHECK(EMT_LIGHTMAP_LIGHTING_M2);
CHECK(EMT_LIGHTMAP_LIGHTING_M4);
CHECK(EMT_SPHERE_MAP);
CHECK(EMT_REFLECTION_2_LAYER);
CHECK(EMT_TRANSPARENT_ADD_COLOR);
CHECK(EMT_TRANSPARENT_ALPHA_CHANNEL);
CHECK(EMT_TRANSPARENT_VERTEX_ALPHA);
CHECK(EMT_TRANSPARENT_REFLECTION_2_LAYER);
#undef CHECK
// Assume material type was given as an integer
buffer->Material.MaterialType = (irr::video::E_MATERIAL_TYPE)xml->getAttributeValueAsInt(L"materialType");
} while (false);
buffer->Material.AmbientColor = ToSColorf(DefaultValue(xml->getAttributeValueSafe(L"ambientColor"), L"white")).toSColor();
buffer->Material.DiffuseColor = ToSColorf(DefaultValue(xml->getAttributeValueSafe(L"diffuseColor"), L"white")).toSColor();
buffer->Material.EmissiveColor = ToSColorf(xml->getAttributeValueSafe(L"emissiveColor")).toSColor();
buffer->Material.SpecularColor = ToSColorf(xml->getAttributeValueSafe(L"specularColor")).toSColor();
buffer->Material.Shininess = xml->getAttributeValueAsFloat(L"shininess");
buffer->Material.Wireframe = IsTrue(DefaultValue(xml->getAttributeValue(L"wireframe"), L"false"));
buffer->Material.GouraudShading = IsTrue(DefaultValue(xml->getAttributeValue(L"gouraudShading"), L"true"));
buffer->Material.Lighting = IsTrue(DefaultValue(xml->getAttributeValue(L"lighting"), L"true"));
buffer->Material.ZBuffer = IsTrue(DefaultValue(xml->getAttributeValue(L"zBuffer"), L"true"));
buffer->Material.ZWriteEnable = IsTrue(DefaultValue(xml->getAttributeValue(L"zWriteEnable"), L"true"));
buffer->Material.BackfaceCulling = IsTrue(DefaultValue(xml->getAttributeValue(L"backfaceCulling"), L"true"));
buffer->Material.BilinearFilter = IsTrue(DefaultValue(xml->getAttributeValue(L"bilinearFilter"), L"true"));
buffer->Material.TrilinearFilter = IsTrue(DefaultValue(xml->getAttributeValue(L"trilinearFilter"), L"false"));
buffer->Material.FogEnable = IsTrue(DefaultValue(xml->getAttributeValue(L"fogEnable"), L"false"));
u32 oldTextureFlags = GetTextureFlags();
SetTextureFlags(ParseTextureFlags(xml->getAttributeValueSafe(L"textureCreationFlags1"), oldTextureFlags));
// --- Get root path for textures ---
String path;
path = "";
StringList filepath = SubdivideString(String(file->getFileName()),"\\");
StringList filepath1 = SubdivideString(String(file->getFileName()),"/");
if(filepath1.size()>filepath.size())
{
filepath.clear();
filepath=filepath1;
}
for (int j=0; j<(int)(filepath.size()-1); j++)
path = path + filepath[j] + String("\\");
// --- End get root path for textures ---
if (wcslen(xml->getAttributeValueSafe(L"textureFile1"))) {
buffer->Material.Texture1 = Driver->getTexture(String(path+core::stringc(xml->getAttributeValueSafe(L"textureFile1"))).c_str());
}
SetTextureFlags(ParseTextureFlags(xml->getAttributeValueSafe(L"textureCreationFlags2"), oldTextureFlags));
if (wcslen(xml->getAttributeValueSafe(L"textureFile2"))) {
buffer->Material.Texture2 = Driver->getTexture(String(path+core::stringc(xml->getAttributeValueSafe(L"textureFile2"))).c_str());
}
SetTextureFlags(oldTextureFlags);
XMLSkip(xml);
}
else
{
// Skip unknown
XMLSkip(xml);
}
}
}
return false;
}
Code: Select all
//! Read a mesh buffer element
bool ReadMeshBuffer(irr::io::IXMLReader * xml, scene::SMeshBufferLightMap * buffer, double scale, f32 x, f32 y, f32 z, io::IReadFile* file);
I only have the latest version of the code here (in Visual Basic 6), and I don't think it currently builds (it's a work-in-progess with the ability to convert "smoothing groups" into vertex normals).puh wrote:Is it possible to get sources for OBJ2MIM-converter?
I'm just thinking it might be an easier workflow in some ways. OBJ+OBJ can be a bit tricky, and gile[s] apparently sometimes messes up the MTLs (maybe if you have multiple meshes?). And there are a couple free/cheap lightmapping tools that only support B3D, if I recall. But really I was just offering to give puh a hand and because I already have it partially complete.vermeer wrote:BTW...a b3d2mim..dunno, very few tools supporting b3d format...b3d2obj....which advantage would be it?The usual exported format is OBJ...as you can bake -now you truly can in blender, with certain plugin, to channel 1: Raybaker 2.0.
Yeah. I'm wondering if puh's result is due to having multiple meshes or something. That's why I wrote that gile[s] loading code last night -- to see if I could figure out how it might be different than your successful tests. But I got sort of stuck since the .gls didn't correspond to the problematic .objs.Giles export of OBJ+OBJ(its obj export luckily works PERFECT for OBJ2mim ) worked like charm for your MIM loader, if you remember inour tests...
You know I'm (slowly) working on it.What would be interesting is...a free lightmapped that would make the important stuff: support vertex normals, support curved surfaces, and...if possible, FSRAD automatic uv mapping and partitioning(lightmaps)...
You know I'm (slowly) working on it. Wink
I've currently got it loading OBJs, deciding how much UV space to allocate for each surface, and on Thursday I got the lightmap texture packer about half way done. I really don't have much time to work on it, but it's (very slowly) progressing. The first version will NOT be FSRad quality, but I'm looking forward to just having something working.
I think I mentioned it somewhere.puh wrote:Murphy - really nice, why you didn't tell me and Vermeer about it earlier?