Removed IrrDriver::RTTProvider

This commit is contained in:
Elderme
2016-01-17 15:27:16 +01:00
parent 585f94d717
commit 14fa4f3def
2 changed files with 0 additions and 285 deletions

View File

@@ -2043,7 +2043,6 @@ bool IrrDriver::OnEvent(const irr::SEvent &event)
} // OnEvent
// ----------------------------------------------------------------------------
bool IrrDriver::supportsSplatting()
{
return CVS->isGLSL();
@@ -2051,219 +2050,6 @@ bool IrrDriver::supportsSplatting()
// ----------------------------------------------------------------------------
#if 0
#pragma mark -
#pragma mark RTT
#endif
// ----------------------------------------------------------------------------
/**
* THIS IS THE OLD OPENGL 1 RTT PROVIDER, USE THE SHADER-BASED
* RTT FOR NEW DEVELOPMENT
* Begins a rendering to a texture.
* \param dimension The size of the texture.
* \param name Name of the texture.
* \param persistent_texture Whether the created RTT texture should persist in
* memory after the RTTProvider is deleted
*/
IrrDriver::RTTProvider::RTTProvider(const core::dimension2du &dimension,
const std::string &name, bool persistent_texture)
{
m_persistent_texture = persistent_texture;
m_video_driver = irr_driver->getVideoDriver();
m_render_target_texture =
m_video_driver->addRenderTargetTexture(dimension,
name.c_str(),
video::ECF_A8R8G8B8);
if (m_render_target_texture != NULL)
{
m_video_driver->setRenderTarget(m_render_target_texture);
}
m_rtt_main_node = NULL;
m_camera = NULL;
m_light = NULL;
} // RTTProvider
// ----------------------------------------------------------------------------
IrrDriver::RTTProvider::~RTTProvider()
{
tearDownRTTScene();
if (!m_persistent_texture)
irr_driver->removeTexture(m_render_target_texture);
} // ~RTTProvider
// ----------------------------------------------------------------------------
/** Sets up a given vector of meshes for render-to-texture. Ideal to embed a 3D
* object inside the GUI. If there are multiple meshes, the first mesh is
* considered to be the root, and all following meshes will have their
* locations relative to the location of the first mesh.
*/
void IrrDriver::RTTProvider::setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
AlignedArray<Vec3>& mesh_location,
AlignedArray<Vec3>& mesh_scale,
const std::vector<int>& model_frames)
{
if (model_frames[0] == -1)
{
scene::ISceneNode* node =
irr_driver->getSceneManager()->addMeshSceneNode(mesh.get(0), NULL);
node->setPosition( mesh_location[0].toIrrVector() );
node->setScale( mesh_scale[0].toIrrVector() );
node->setMaterialFlag(video::EMF_FOG_ENABLE, false);
m_rtt_main_node = node;
}
else
{
scene::IAnimatedMeshSceneNode* node =
irr_driver->getSceneManager()->addAnimatedMeshSceneNode(
(scene::IAnimatedMesh*)mesh.get(0), NULL );
node->setPosition( mesh_location[0].toIrrVector() );
node->setFrameLoop(model_frames[0], model_frames[0]);
node->setAnimationSpeed(0);
node->setScale( mesh_scale[0].toIrrVector() );
node->setMaterialFlag(video::EMF_FOG_ENABLE, false);
m_rtt_main_node = node;
}
assert(m_rtt_main_node != NULL);
assert(mesh.size() == mesh_location.size());
assert(mesh.size() == model_frames.size());
const int mesh_amount = mesh.size();
for (int n=1; n<mesh_amount; n++)
{
if (model_frames[n] == -1)
{
scene::ISceneNode* node =
irr_driver->getSceneManager()->addMeshSceneNode(mesh.get(n),
m_rtt_main_node);
node->setPosition( mesh_location[n].toIrrVector() );
node->updateAbsolutePosition();
node->setScale( mesh_scale[n].toIrrVector() );
}
else
{
scene::IAnimatedMeshSceneNode* node =
irr_driver->getSceneManager()
->addAnimatedMeshSceneNode((scene::IAnimatedMesh*)mesh.get(n),
m_rtt_main_node );
node->setPosition( mesh_location[n].toIrrVector() );
node->setFrameLoop(model_frames[n], model_frames[n]);
node->setAnimationSpeed(0);
node->updateAbsolutePosition();
node->setScale( mesh_scale[n].toIrrVector() );
//Log::info("RTTProvider::setupRTTScene", "Set frame %d", model_frames[n]);
}
}
irr_driver->getSceneManager()->setAmbientLight(video::SColor(255, 35, 35, 35) );
const core::vector3df &spot_pos = core::vector3df(0, 30, 40);
m_light = irr_driver->getSceneManager()
->addLightSceneNode(NULL, spot_pos, video::SColorf(1.0f,1.0f,1.0f),
1600 /* radius */);
m_light->setLightType(video::ELT_SPOT);
m_light->setRotation((core::vector3df(0, 10, 0) - spot_pos).getHorizontalAngle());
m_light->updateAbsolutePosition();
m_rtt_main_node->setMaterialFlag(video::EMF_GOURAUD_SHADING , true);
m_rtt_main_node->setMaterialFlag(video::EMF_LIGHTING, true);
const int materials = m_rtt_main_node->getMaterialCount();
for (int n=0; n<materials; n++)
{
m_rtt_main_node->getMaterial(n).setFlag(video::EMF_LIGHTING, true);
// set size of specular highlights
m_rtt_main_node->getMaterial(n).Shininess = 100.0f;
m_rtt_main_node->getMaterial(n).SpecularColor.set(255,50,50,50);
m_rtt_main_node->getMaterial(n).DiffuseColor.set(255,150,150,150);
m_rtt_main_node->getMaterial(n).setFlag(video::EMF_GOURAUD_SHADING ,
true);
}
m_camera = irr_driver->getSceneManager()->addCameraSceneNode();
m_camera->setPosition( core::vector3df(0.0, 20.0f, 70.0f) );
if (CVS->isGLSL())
m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) );
else
m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) );
m_camera->setTarget( core::vector3df(0, 10, 0.0f) );
m_camera->setFOV( DEGREE_TO_RAD*50.0f );
m_camera->updateAbsolutePosition();
// Detach the note from the scene so we can render it independently
m_rtt_main_node->setVisible(false);
m_light->setVisible(false);
} // setupRTTScene
// ----------------------------------------------------------------------------
void IrrDriver::RTTProvider::tearDownRTTScene()
{
//if (m_rtt_main_node != NULL) m_rtt_main_node->drop();
if (m_rtt_main_node != NULL) m_rtt_main_node->remove();
if (m_light != NULL) m_light->remove();
if (m_camera != NULL) m_camera->remove();
m_rtt_main_node = NULL;
m_camera = NULL;
m_light = NULL;
} // tearDownRTTScene
// ----------------------------------------------------------------------------
/**
* Performs the actual render-to-texture
* \param target The texture to render the meshes to.
* \param angle (Optional) heading for all meshes.
* \return the texture that was rendered to, or NULL if RTT does not work on
* this computer
*/
video::ITexture* IrrDriver::RTTProvider::renderToTexture(float angle,
bool is_2d_render)
{
// m_render_target_texture will be NULL if RTT doesn't work on this computer
if (m_render_target_texture == NULL) return NULL;
// Rendering a 2d only model (using direct opengl rendering)
// does not work if setRenderTarget is called here again.
// And rendering 3d only works if it is called here :(
if(!is_2d_render)
m_video_driver->setRenderTarget(m_render_target_texture);
if (angle != -1 && m_rtt_main_node != NULL)
m_rtt_main_node->setRotation( core::vector3df(0, angle, 0) );
video::SOverrideMaterial &overridemat = m_video_driver->getOverrideMaterial();
overridemat.EnablePasses = scene::ESNRP_SOLID;
overridemat.EnableFlags = video::EMF_MATERIAL_TYPE;
overridemat.Material.MaterialType = video::EMT_SOLID;
if (m_rtt_main_node == NULL)
{
irr_driver->getSceneManager()->drawAll();
}
else
{
m_rtt_main_node->setVisible(true);
m_light->setVisible(true);
irr_driver->getSceneManager()->drawAll();
m_rtt_main_node->setVisible(false);
m_light->setVisible(false);
}
overridemat.EnablePasses = 0;
m_video_driver->setRenderTarget(0, false, false);
return m_render_target_texture;
}
// ----------------------------------------------------------------------------
void IrrDriver::applyObjectPassShader(scene::ISceneNode * const node, bool rimlit)
{
if (!CVS->isGLSL())

View File

@@ -626,77 +626,6 @@ public:
void uploadLightingData();
// --------------------- OLD RTT --------------------
/**
* THIS IS THE OLD OPENGL 1 RTT PROVIDER, USE THE SHADER-BASED
* RTT FOR NEW DEVELOPMENT
*
* Class that provides RTT (currently, only when no other 3D rendering
* in the main scene is required)
* Provides an optional 'setupRTTScene' method to make it quick and easy
* to prepare rendering of 3D objects but you can also manually set the
* scene/camera. If you use the factory 'setupRTTScene', cleanup can be
* done through 'tearDownRTTScene' (destructor will also do this). If
* you set it up manually, you need to clean it up manually.
*/
class RTTProvider
{
/** A pointer to texture on which a scene is rendered. Only used
* in between beginRenderToTexture() and endRenderToTexture calls. */
video::ITexture *m_render_target_texture;
bool m_persistent_texture;
/** Main node of the RTT scene */
scene::ISceneNode *m_rtt_main_node;
scene::ICameraSceneNode *m_camera;
scene::ILightSceneNode *m_light;
/** Irrlicht video driver. */
video::IVideoDriver *m_video_driver;
public:
RTTProvider(const core::dimension2du &dimension,
const std::string &name, bool persistent_texture);
~RTTProvider();
/**
* \brief Quick utility method to setup a scene from a plain list
* of models
*
* Sets up a given vector of meshes for render-to-texture. Ideal to
* embed a 3D object inside the GUI. If there are multiple meshes,
* the first mesh is considered to be the root, and all following
* meshes will have their locations relative to the location of the
* first mesh.
*
* \param mesh The list of meshes to add to the scene
* \param mesh_location Location of each fo these meshes
* \param model_frames For animated meshes, which frame to use
* (value can be -1 to set none)
* When frame is not -1, the corresponding
* IMesh must be an IAnimatedMesh.
* \pre The 3 vectors have the same size.
*/
void setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
AlignedArray<Vec3>& mesh_location,
AlignedArray<Vec3>& mesh_scale,
const std::vector<int>& model_frames);
/** Optional 'angle' parameter will rotate the object added
* *through setupRTTScene* */
video::ITexture* renderToTexture(float angle=-1,
bool is_2d_render=false);
void tearDownRTTScene();
};
}; // IrrDriver
extern IrrDriver *irr_driver;