Are you using lightmapping?

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

sorry, I'm too tired now....tomorrow I'll see.


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 :)

btw, nice viewer :)
Finally making games again!
http://www.konekogames.com
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

puh wrote:Here you can find a standard Irrlicht meshviewer
Looks a bit more functional than my SimpleViewer (which I think was included with the MIM distribution...?). :)
To 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...
Hmm... did I not do that? :O
Sure, post the code or PM it or whatever. :) If it's small, posting it seems like a good idea since I'm not sure when I'll be doing another MIM release. If you want to email it, I think there's an email address in the MIM code or readme. PM me if you need it.

I guess I really should do another release of MIM, since its ability to hold things like bumpmapping and stuff makes it somewhat unique and hopefully useful...
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

This is fix for the mim-loader to use mim file path as a root for loading all included textures (now the root is exe-program folder)

You can download already patched files from here: http://www.irrforge.org/images/4/4b/CMIrrMeshLoader.zip [9 KB]

Don't forget to add #include "dmfsupport.h" in top...

Change function bool CMIrrMeshLoader::ReadMeshBuffer in file CMIrrMeshLoader.cpp (from line 393, changes are in parameters and from line with comment "// --- Get root path for textures ---"):

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;
}
and change it's declaration in CMIrrMeshLoader.h (line 122)

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);
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

Hi, Murphy!

Is it possible to get sources for OBJ2MIM-converter?
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

puh wrote:Is it possible to get sources for OBJ2MIM-converter?
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).

Just so you know, no amount of fixing OBJ2MIM would correct your OBJ from gile[s]! The problem isn't with OBJ2MIM -- it's with the OBJ! Well, actually the MTL. Open up the lightmapped OBJ in anything and it looks all screwy. :(

If this is what you want the source for... hmm... if you want to try exporting it to B3D and sending me the result, I'll try converting THAT to a MIM. If it works out, I'll release a B3D2MIM or B3D2OBJ.
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

Puh: This is sort of weird...
I wrote a simple gile[s] .gls to .obj converter tonight to try to look into the problem you're having with the wrong lightmap texture showing up on some surfaces when you've got multiple lightmap textures.
But... the level01.gls file you included isn't the same map as the walk.obj/walk.mim!

The .gls only has one lightmap (like Vermeer mentioned). It looks fine. This is it:
Image

The .obj/.mim has two lightmaps, though, and looks sort of screwed up (you can't tell that much from this angle, but the lightmaps are definitely screwy). This is it:
Image

Want to upload the correct .gls and have me take a look?
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

yup, I looked at it really quicly and i ensure you: only there was a lightmap, with a lot of textures, "childs" of that lightmap.

giles has a peculiar way of working, maybe you haven't got the grips of it yet... ;)

Upload again the gls file, I'll have a look at an hou rmore decent than the other day , I was virtually sleeping...

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.

MIM is a nice format, imho. I don't understand programming, but is there problems for game coders to use the loader?

A pair of inbetween(or intermediate, as you prefer to call) formats, quite good, and supported partially in a few applications, for levels are : ASE (camera lights, vertex colors, materials, etc...) Vrml 2.0 (camera, lights, materials, etc...)


And probably one or both does support also camera animation, lights animation, etc...none of em support bone sor weights, but I'm talking only bout levels.

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...

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)...
Finally making games again!
http://www.konekogames.com
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

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.
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. :)
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...
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. :)
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. ;)
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. :D
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

Hello, Murphy and Vermeer and sorry for late reply!

Don't loose your time to me, as Vermeer said obj+obj=mim works perfectly now, i dunno what was my error, maybe i did not correct assign lightmaps to different textures... Anyway now i have a little bit more experience with gile and have quite nice results.

And concerning sources for OBJ2MIM - i just want to write a small gui-based converter as i tired to edit .bat file everytime...

P.S. Murphy, i'm very sorry for messing the .gls file, too bad now it's not the same version, but if you want i can send it to you, now it's all right.

P.P.S. Murphy, easy come easy go! I've like to read the progress of your ligtmapper!
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

Glad to hear you got it working!

As for a graphical interface... hmm... try holding down shift or control or alt or something and double click the icon. The latest versions of some of my tools had a simple graphical interface built in if you held down some key while starting it.. Not sure which ones or if they were released, though. Next time I pull together a release, they'll all have it...
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

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.

Extremely good to hear all that :) 8)

hey, free projects are done for the joy of it, or for curiosity, so, any pace is good :)

Yup, the b3d exporting tools you mention may be Slimshady and Mapplet...I consider them a nice gift but somehow there are at least a pair of others with some advantages over them(no b3d based) And today, I consider better option other workflows, even free ones.But none with the features you are putting to yours :) One way or the other, even if you don't get the results you pretend, I am allways interested in anything that outputs lightmaps :) Even having a bunch of comercial purchased tool at home, lol. Even more discovering certain free one does the stuff better than comercial ones, lol...

Anyway, if the lightmapper does export a lightmapped level, and obj+obj way does rock for this and other game engines...There's much more tools that can edit an obj than b3d...Just imagine one wrecks omething...blender, lithunwrap, max, maya, xsi, wings, metasequouia, every modeler out there has the ability to fix an obj.
imho the important stuff is the actual lightmapper...

Oh, probably the version he has is the one I uploaded, but I was not able to find the one that did that dialog box thing when shift pressed, so probably he's using an older one.
Anyway, the command tool has pretty all needed functionality, and as he said, is pretty useful to do a bat file that u edit as needed...


Puh, yup, I think you only asigned a lightmap, and probably asigned other lightmaps as textures ...that also may have messed the obj exporter in giles, much specially the mtl part. Anyway, seems you have it already ironed.
Finally making games again!
http://www.konekogames.com
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

Oh, probably the version he has is the one I uploaded, but I was not able to find the one that did that dialog box thing when shift pressed
Vermeer, just try to press Ctrl while starting OBJ2MIM.exe

Murphy - really nice, why you didn't tell me and Vermeer about it earlier? :lol:
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

puh wrote:Murphy - really nice, why you didn't tell me and Vermeer about it earlier? :lol:
I think I mentioned it somewhere. :? Possibly hidden in the readme or on the incredibly-long-MIM-thread-of-doom. Either way, yeah... probably a bit hard to find. Now you know. :)

I guess in the future, I should have a commandline argument to run it in commandline mode (since you have to be passing stuff on the commandline anyway) and have it default to the mini-GUI.
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

So, tonight I think I got the first version of all the UV generation and texture packing done. It's pretty inefficient with triangulated models (I think it'd be better with a model with quads and stuff, but both of my test models are all triangles), but it seems to be generating the coordinates right and allocating texture space okay.

So now I've basically got to actually put in a (simple) lighting model and do the lightmap "cleanup" code (fixes edges when they're interpolated) and then hopefully I'll have a screenshot to show!

Oh, and I'll also need to figure out a way of placing lights. Hmm... hey, puh, you mind if I use your level01.gls as a test model? I might be able to steal your light placements out of it...
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

Sure, no problem :)
Waiting for the first screen!
Post Reply