PDA

View Full Version : Show 3D model on 2D background



Hau Vo
08-28-2012, 04:05 AM
Hi all,
I have 1 problem with show 3d model on 2D background. I used draw2DImage of Irrlicht but the background isn't show. I try add overlayentity and after that i added 3DS mode but overlayEntity is cover all screen and 3D model cannot display.

Below code draw2DImage:


//mesh = pScene->getMesh( (GetBaseAppPath() + "game/sydney.md2").c_str());
video::IVideoDriver* driver = GetIrrlichtManager()->GetDriver();

video::ITexture* images = driver->getTexture( (GetBaseAppPath() + "game/background/bg.rttex").c_str());
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));

driver->draw2DImage(images, core::position2d<s32>(0,0),
core::rect<s32>(0,0,1024,600), 0,
video::SColor(255,255,255,255), true);

//mesh = pScene->getMesh( (GetBaseAppPath() + "game/squirrel.x").c_str());
mesh = pScene->getMesh( (GetBaseAppPath() + "game/model/1.3ds").c_str());

IAnimatedMeshSceneNode* node =pScene->addAnimatedMeshSceneNode( mesh );

if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
//node->setMD2Animation(scene::EMAT_STAND);
//driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS , false);

//node->setMaterialTexture( 0,GetIrrlichtManager()->GetDriver()->getTexture( (GetBaseAppPath() + "game/sydney.bmp").c_str() ));
node->setMaterialTexture( 0,GetIrrlichtManager()->GetDriver()->getTexture( (GetBaseAppPath() + "game/texture/1.rttex").c_str() ));
//node->setMaterialTexture( 0,GetIrrlichtManager()->GetDriver()->getTexture( (GetBaseAppPath() + "game/squirrel_skin.rttex").c_str() ));
//driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS , true);

/*
node->setFrameLoop(0, 31);
node->setAnimationSpeed(30);
*/
node->setRotation(core::vector3df(0,0,0));
node->setPosition(core::vector3df(0,0,0));

//1.3ds
node->setScale(core::vector3df(0.05,0.05,0.05));
}


Any help would be appreciate. Big thanks all for view this thread.

Seth
08-28-2012, 12:24 PM
Yes, there is a way to cause Irrlicht to Render AFTER the Proton GUI is rendered.

Just call this AFTER your GUI stuff is rendered (after BaseApp::Draw(); inside of App::Draw(), or inside a component's OnRender() function)


GetIrrlichtManager()->BeginScene(); //turn on irrlicht's 3d mode renderstates
GetIrrlichtManager()->Render(); //render its scenegraph
GetIrrlichtManager()->EndScene();

Seth
08-28-2012, 12:28 PM
Actually, never mind, I miss-read the question. Hmm, I'm not sure where to plug in the Draw2D calls, I haven't used the 2D part of Irrlicht really yet, sorry. Will have to play it first.

Hau Vo
08-29-2012, 04:35 AM
Actually, never mind, I miss-read the question. Hmm, I'm not sure where to plug in the Draw2D calls, I haven't used the 2D part of Irrlicht really yet, sorry. Will have to play it first.

Thanks Seth, I will try it and inform you the result :)