I have added a UV mapped screen to my world (dmf file) and set the camera in front of the stage. (I used my avatar to set the camera postion)
The relevant code is below:
Code: Select all
[b]int main[/b]
//Screen mesh
scene::IAnimatedMeshSceneNode* test = smgr->addAnimatedMeshSceneNode(
smgr->getMesh("media/vidscreen.dmf"));
test->setPosition(core::vector3df(550,-1475,1650));
test->setMaterialFlag(video::EMF_LIGHTING, false); // enable dynamic lighting
test->getMaterial(0).Shininess = 20.0f; // set size of specular highlights
// add white light-in theater
scene::ILightSceneNode* light1 = smgr->addLightSceneNode(0,
core::vector3df(550,-1575,950), video::SColorf(1.0f, 1.0f, 1.0f));
//==========My Video Screen=======render to texture===========
// create render target
video::ITexture* rt = 0;
scene::ICameraSceneNode* fixedCam = 0;
//Screen texture
if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
{
rt = driver->createRenderTargetTexture(core::dimension2d<s32>(840,840));
test->setMaterialTexture(0, driver->getTexture("media/screen.jpg"));
test->setMaterialTexture(0, rt); // set material of cube to render target
test->getMaterial(0).Shininess = 20.0f; // set size of specular highlights
// add fixed camera
fixedCam= smgr->addCameraSceneNode(0, core::vector3df(550,-1795,1250),
core::vector3df(0,0,0));
}
if (rt)
{
// draw scene into render target
// set render target texture
driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255));
// make cube invisible and set fixed camera as active camera
test->setVisible(false);
smgr->setActiveCamera(fixedCam);
// set back old render target
driver->setRenderTarget(0);
// make the cube visible and set the user controlled camera as active one
test->setVisible(true);
smgr->setActiveCamera(camera);
}
smgr->drawAll();
My eyes hurt from staring at code. Anyone see a problem I don't?