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: