LMTSFileLoader (lightmaps in Irrlicht)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

success!!!

I hadn't re-saved the lightmap tga!! Or better said, I resaved it with acdsee since I don't have photoshop but it didn't fix it so I tried to resave it with Irfanview and Voila!!! success, sweet success!

Now I can move on to collision. I agree that this is the first free alternative to Quake3 maps-lightmaps!

Jox, helluva job!!! let us know of any improvements.
Nitroman, let's keep in touch, your help was very valuable!

Image

cheers!
Image
nitroman

Post by nitroman »

glad to help :D
nitroman

Post by nitroman »

By the way, great map (as usual) :D
nitroman

Post by nitroman »

new problem :(

I tried to add collision detection code and it crash...
it seems that addOctTreeSceneNode can't be used with lmts maps unlike bsp... :(
I tried a lot of things but nothing work... the rest of the code don't work more anyway but I think it is because my lmts is not in an octree...

I'm not enough good at coding to solve the problem :(
and Jox leave us for 10 days (as he said in the other forum.
Ok, unfortunately right now I'm a little stressed with (other) work and tomorrow I'll be out (of country) for about 10 days...
please tell me if you get more succes than me.
if not, we will need to wait 10 days and still use bsp during this time...
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

thnx for the comment nitro, but it's merely a sample map to check things were working ok. I'll make something more interesting later. But many thnx!

now the good news! Collision worked ok! the bad news, I'm getting weird artifacts with the textures like flipped nornals and ghost zones that let you see-thru.

Let me know where I can send you the code I used.

check the missing faces in the beam and how it passes thru the column:
Image

arghhhhhhhhh!!!

I thought everything was ok!!!
Image
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

well, good news again, ha ha ha h :D

It seems like I was using the wrong dll again. I recompiled it and replaced the old one and now everything is back into shape. Unless it mutates on its own, ha ha hah a. Hopefully things will stay this way.

my dear Nitroman, here's the code:

Code: Select all

//Lmts level test
//by Alvaro F. Celis "afecelis" 

/*  The Irrlicht Engine License

Copyright © 2002-2003 Nikolaus Gebhardt

This software is provided 'as-is', without any express or implied warranty. 
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, 
and to alter it and redistribute it freely, subject to the following restrictions:
1.The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 
If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2.Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3.This notice may not be removed or altered from any source distribution.*/
//-----------------------------------------------------------------------------------------------//

#include <irrlicht.h>
#include <stdio.h>
#include <windows.h> 
#include "CLMTSMeshFileLoader.h"


using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")


int main()
{
	IrrlichtDevice *device =
	createDevice(video:: EDT_OPENGL , core::dimension2d<s32>(640, 480), 32, false,false,0);
	
//-----------------------------------------------------------------------------------------------//	
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	IFileSystem* fs = device->getFileSystem(); 
	driver->setTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY,true );
//-----------------------------------------------------------------------------------------------//
	//lmts map loader
		scene::CLMTSMeshFileLoader* lmts_loader = new scene::CLMTSMeshFileLoader(fs, driver);
		smgr->addExternalMeshLoader(lmts_loader); 
//-----------------------------------------------------------------------------------------------//
	//lmts textures
		lmts_loader->setTexturePath("data\\"); 
//-----------------------------------------------------------------------------------------------//
	//load the map
   IAnimatedMesh* mesh = 0;
   mesh = smgr->getMesh("data\\lmts.3.lmts"); 	

//-----------------------------------------------------------------------------------------------//
   //add map to the scene
   IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); 
//-----------------------------------------------------------------------------------------------//	
	//wasd navigation
	SKeyMap keyMap[8];

	keyMap[1].Action = EKA_MOVE_FORWARD;
	keyMap[1].KeyCode = KEY_KEY_W;

	keyMap[3].Action = EKA_MOVE_BACKWARD;
	keyMap[3].KeyCode = KEY_KEY_S;

	keyMap[5].Action = EKA_STRAFE_LEFT;
	keyMap[5].KeyCode = KEY_KEY_A;

	keyMap[7].Action = EKA_STRAFE_RIGHT;
	keyMap[7].KeyCode = KEY_KEY_D;
//-----------------------------------------------------------------------------------------------//
	//selector

	scene::ITriangleSelector* selector = 0;
	
	if (node)
	{		
		selector = smgr->createOctTreeTriangleSelector(mesh->getMesh(0), node, 128);
		node->setTriangleSelector(selector);
		selector->drop();
	}

//-----------------------------------------------------------------------------------------------//	
	//fps cam

	scene::ICameraSceneNode* camera = 0; 
	camera = smgr->addCameraSceneNodeFPS(0,80.0f,300.0f,-1, keyMap, 8); //1st value= obligatory 0-2nd value= mouse sensitivity-3rd value handles cam speed
	camera->setPosition(core::vector3df(-220,100,50)); //x,y,z,pos
	camera->setFarValue (50000.0f) ; //sets the distance for the clipping plane, the bigger the farther
	camera->setFOV(1.4f); // a value of 0.5 makes it look alienish
	camera->setRotation(core::vector3df(0,90,0)); //rotate the camera x,y,z degrees

	//collision animator
	scene::ISceneNodeAnimator* anim = 0; 
	anim = smgr->createCollisionResponseAnimator(selector, camera, core::vector3df(30,50,30),
	core::vector3df(0,-100,0), 100.0f, 
	core::vector3df(0,50,0));
	camera->addAnimator(anim);
	anim->drop();

//-----------------------------------------------------------------------------------------------//	
	// disable mouse cursor

	device->getCursorControl()->setVisible(false);

//-----------------------------------------------------------------------------------------------//	
	// automatic picking

	scene::ISceneNode* selectedSceneNode = 0;
	scene::ISceneNode* lastSelectedSceneNode = 0;

	
	int lastFPS = -1;

	while(device->run())
	{
		driver->beginScene(true, true, 0);

		smgr->drawAll();

//-----------------------------------------------------------------------------------------------//	
	//draw everything

		driver->endScene();

		int fps = driver->getFPS();

		if (lastFPS != fps)
		{
			wchar_t tmp[1024];
			swprintf(tmp, 1024, L"Lmts file test (fps:%d) Triangles:%d", 
				fps, driver->getPrimitiveCountDrawn());

			device->setWindowCaption(tmp);
			lastFPS = fps;
		}
	}

	device->drop();
	
	return 0;
}

hope it helps!!! cheers!
Image
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

another thing, Nitroman: do you know how to get color lightmaps to work?
Image
Nitroman

Post by Nitroman »

Good news! :D
I finally got it to work!
I had a lot of problems with my programs compiled with mingw (I do not know if it's the dll or something else... ) and it crashed a lot...

So I found the solution to all my problems!
I switched to VisualC++ toolkit (with relo IDE) !!!
BTW Thanks a LOT for your great tutorial :wink: :D
Now it works perfectly and I can use DirectX :D

Also I changed in your source the following line:
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
to:
ISceneNode* node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
And I increased the fps a little bit...
another thing, Nitroman: do you know how to get color lightmaps to work?
I don't exactly understand your question...

If your mean how to create lights with color before compiling your map with lmtools, I don't know exactly for the moment because until now I only used the sample map... I will try to create my own map later... Maybe this info is in the lmtools manuals...

If your question is how to load lmts with color lightmaps, it is supposed to work already... Try to load the sample map, set the position of the camera to (500,150,-300) and it will be in the room at the top of the stairs (you can't reach it otherwise because the door can't open...)

you should see something like this:
Image

LMTools support color lightmaps, so it should work. :wink:
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

man! I'm glad the VCtoolkit+relo thing worked!!! It's great, isn't it?
Relo is one of my favorite IDEs and you get to use the visualstudio stuff in Irrlicht and also directX. I think it kicks ass! (I don't know why people still use DevC++ or MinGw if they can use Relo+VCtoolkit 2003, the only thing would be to compile Dlls)

About the line of code u changed, you're making the node static so you'll get an increase in fps but if you're planning to use additional dynamic lights these models won't cast any shadows, so keep that in mind.

About the color lights, yep, I guess it's a matter of checking lmtools documentation.

Anyway, we learned a lot today, didn't we? I had a great afternoon! Thanks man!

ps. @jox: thanks for writing the loader!!!
Image
nitroman

Post by nitroman »

Relo is one of my favorite IDEs and you get to use the visualstudio stuff in Irrlicht and also directX. I think it kicks ass!
I agree at 120%!! :D
but if you're planning to use additional dynamic lights these models won't cast any shadows, so keep that in mind.
Ok, I didn't know it... But I think I won't use dynamic lights for my scene (because it's already lighted with the lightmap...)
Anyway, if I change my mind I will just change this line as it was before.

Code: Select all

Anyway, we learned a lot today, didn't we? I had a great afternoon!
It's very fun when it finally works! :)
And I also discovered a great compiler :wink:
I had a great afternoon too! :D
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

Jox:

In your screenshots I saw you got color lightmaps to work. Can you give me a hand with that?
I only get white lightmaps although I export colored lights with the script for 3dsmax. Dunno what I'm doing wrong.

cheers!
Image
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

Hi there! I'm glad you find the loader usefull. Is there still any issues with it?

@mm765: thanx for the note! It's right, I havn't considered the case of no textures or lightmaps.

@afecelis: mhh, dunno, should normaly work. Maybe check the *.scr file and look for the color settings of the lights in there!

BTW I have found out the reason why the TGA images created by LM Tools get messed up in Irrlicht. They get loaded vertically flipped. It's a bug in the TGA loader of irrlicht. You can also notice it with the textures of the (LM Tools-)sample map that have text on it. I have reported the bug:

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=3503
Last edited by jox on Sat Aug 14, 2004 6:36 pm, edited 1 time in total.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

Hey Jox, I'm glad you're back!!!

Well, so far collision works properly and the models load up ok. About color lightmaps, I wrote Lord Trancos about it and sent him my scr files: he checked them and told me everything was ok: the problem is in the tools so he also told me to wait cause it would be fixed in version 1.2 so I'm waiting for his next release.

otherwise, it's the best alternative I've found so far to using Q3 bsps-lightmaps.

any updates on your loader?


cheers!
Image
ZDimitor
Posts: 202
Joined: Fri Jul 16, 2004 3:27 am
Location: Russia

Post by ZDimitor »

Hi to all!

I used LMTools and get some problem (not because of Irrlicht).

LGen generating cool lightmaps only for rectangular objects.
For curved surfaces (spheres, cones e.t.c.) it generate ugly lightmaps, so they looks like flat shaded.
Seems it not smoothing normals while creating light maps.

Does any have this problem, or solve it.

Please post it!
cmoibenlepro
Posts: 237
Joined: Thu May 27, 2004 3:18 pm
Location: Canada

Post by cmoibenlepro »

Does any have this problem, or solve it.
Wait until Lord Trancos release the next version of LMTools during the next weeks (look the long thread in the beginners forum)
Post Reply