Page 1 of 1

No lightmap at models

Posted: Mon Oct 25, 2010 3:47 pm
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

Posted: Fri Nov 05, 2010 7:36 pm
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

Posted: Fri Nov 05, 2010 9:27 pm
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.

Posted: Wed Nov 17, 2010 2:18 am
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?

Posted: Tue Feb 01, 2011 4:31 am
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?

Posted: Tue Feb 01, 2011 4:34 am
by bitplane
Clearing the vertex colours is just a matter of setting them all to white

Posted: Tue Feb 01, 2011 7:45 am
by pepeshka
Thanks, that worked great! I also had to set emissive to black and normalize normals, but hey whatever works!