No lightmap at models

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
BraX
Posts: 36
Joined: Fri Jul 16, 2010 4:39 pm

No lightmap at models

Post by BraX »

Hey, i am loading q3 bsp as main mesh for my game, the lightmaps on maps looks really amazing but they don't apply into models. My spawned models and models placed on maps are lighted even if there is black area in map. How to change that?

Here is my code for loading bsp:

Code: Select all

void bxGame::loadLevelData()
{
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
 
	device->getCursorControl()->setVisible(false);
	createLoadingScreen();
	updateLoadingScreen(1);

	backColor.set(255,0,0,0);
	inOutFader = device->getGUIEnvironment()->addInOutFader();
	inOutFader->setColor(backColor,	video::SColor ( 0, 230, 230, 230 ));
     	
	smgr->getParameters()->setAttribute(ALLOW_ZWRITE_ON_TRANSPARENT, true);
	quakeLevelMesh = (IQ3LevelMesh*) smgr->getMesh(LEVEL_1);
	updateLoadingScreen(2);
	if (quakeLevelMesh)
	{
		u32 i;
		core::matrix4 m;
		for ( i = 0; i!= E_Q3_MESH_SIZE; ++i )
			smgr->getMeshManipulator()->transform(quakeLevelMesh->getMesh(i), m);

		quakeLevelNode = smgr->addOctreeSceneNode(quakeLevelMesh->getMesh( E_Q3_MESH_GEOMETRY));
		if (quakeLevelNode)
		{    
			quakeLevelNode->setVisible(true);
			mapSelector = smgr->createOctreeTriangleSelector(quakeLevelMesh->getMesh(0),quakeLevelNode, 128);
			quakeLevelNode->setMaterialType ( EMT_LIGHTMAP_M4 );
            //quakeLevelNode->setMaterialType ( EMT_LIGHTMAP_LIGHTING );
		}
		additional_mesh = quakeLevelMesh->getMesh ( E_Q3_MESH_ITEMS );

		for ( i = 0; i!= additional_mesh->getMeshBufferCount (); ++i )
		{
			meshBuffer = additional_mesh->getMeshBuffer ( i );
			const video::SMaterial &material = meshBuffer->getMaterial();
			s32 shaderIndex = (s32) material.MaterialTypeParam2;
			const IShader *shader = quakeLevelMesh->getShader ( shaderIndex );
			if ( 0 == shader )
			{
				continue;
			}
			smgr->addQuake3SceneNode ( meshBuffer, shader );
		}
	}	
	// create collision
	metaSelector = smgr->createMetaTriangleSelector();
	metaSelector->addTriangleSelector(mapSelector);

	// load font
	device->getGUIEnvironment()->getSkin()->setFont(device->getGUIEnvironment()->getFont(FONT_IMAGE));
	device->getGUIEnvironment()->getSkin()->setColor(gui::EGDC_BUTTON_TEXT,video::SColor(255,100,100,100));	
	updateLoadingScreen(4);
		
    createSkyBox( smgr, driver );
    loadEntities( smgr, quakeLevelMesh );
//	updateLoadingScreen(4);
            	
	createPlayer( smgr, metaSelector, quakeLevelMesh );
	createHuds( device );	
	
	printf( "Level loaded\n" );
	inOutFader->fadeIn(2000);  
    
    progBox->remove();         	
}

Code for model:

Code: Select all

               	IAnimatedMeshSceneNode* model = smgr->addAnimatedMeshSceneNode(smgr->getMesh("models/test_anim.md3"));
                model->setPosition( pos - (500,50,50) );
                model->setFrameLoop(1,10);
                model->setAnimationSpeed(15);
                model->setLoopMode(true); // or true if you want to loop the animation	
                model->setMaterialFlag(EMF_LIGHTING, true);	


Here is pic:
Image
pepeshka
Posts: 29
Joined: Wed Jul 02, 2008 8:42 pm

Post by pepeshka »

quick bump, as I'm seeing the same :)

Using .x animated models, setting EMF_LIGHTING to true doesn't seem to apply lighting to the model
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Assuming that the models don't have a second texture coordinate, lightmaps could trun into one-point textures by this. You have to assure that your model has a second texture coordinate and a second texture assigned.
pepeshka
Posts: 29
Joined: Wed Jul 02, 2008 8:42 pm

Post by pepeshka »

I think you're right, as I can drop in the animated models from the example projects and they pick up the dynamic lights just fine...

I'm sorry, but could you show me which method(s) I could use to check if my model has a second texture co-ord?
pepeshka
Posts: 29
Joined: Wed Jul 02, 2008 8:42 pm

Post by pepeshka »

Hey all,

I messed around with this again today and discovered my .x models are also screwed up in CopperCube. After some experimentation, I discovered that clicking edit -> modify selection -> clear vertex colors would cause it to be lit up properly in CopperCube.

How can I emulate the same behavior in Irrlicht? I'm messing around with setVertexColors() in the MeshManipulator, but can't seem to "clear" the vertex colors. Does anyone know what this function does in CopperCube?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Clearing the vertex colours is just a matter of setting them all to white
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
pepeshka
Posts: 29
Joined: Wed Jul 02, 2008 8:42 pm

Post by pepeshka »

Thanks, that worked great! I also had to set emissive to black and normalize normals, but hey whatever works!
Post Reply