2012-09-14 12:34:18 +00:00
|
|
|
#ifndef OENGINE_SELECTIONBUFFER_H
|
|
|
|
#define OENGINE_SELECTIONBUFFER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <OgreTexture.h>
|
|
|
|
#include <OgreRenderTarget.h>
|
|
|
|
#include <OgreMaterialManager.h>
|
2014-02-19 17:40:29 +00:00
|
|
|
#include <OgreColourValue.h>
|
2012-09-14 12:34:18 +00:00
|
|
|
|
|
|
|
namespace OEngine
|
|
|
|
{
|
|
|
|
namespace Render
|
|
|
|
{
|
|
|
|
|
|
|
|
struct cmp_ColourValue
|
|
|
|
{
|
|
|
|
bool operator()(const Ogre::ColourValue &a, const Ogre::ColourValue &b) const
|
|
|
|
{
|
|
|
|
return a.getAsBGRA() < b.getAsBGRA();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-04 14:32:53 +00:00
|
|
|
class SelectionBuffer : public Ogre::MaterialManager::Listener, public Ogre::ManualResourceLoader
|
2012-09-14 12:34:18 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SelectionBuffer(Ogre::Camera* camera, int sizeX, int sizeY, int visibilityFlags);
|
|
|
|
virtual ~SelectionBuffer();
|
|
|
|
|
|
|
|
int getSelected(int xPos, int yPos);
|
|
|
|
///< @return ID of the selected object
|
|
|
|
|
|
|
|
void update();
|
|
|
|
|
2014-08-04 14:32:53 +00:00
|
|
|
virtual void loadResource(Ogre::Resource* resource);
|
|
|
|
|
2012-09-14 12:34:18 +00:00
|
|
|
virtual Ogre::Technique* handleSchemeNotFound (
|
|
|
|
unsigned short schemeIndex, const Ogre::String &schemeName, Ogre::Material *originalMaterial,
|
|
|
|
unsigned short lodIndex, const Ogre::Renderable *rend);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ogre::TexturePtr mTexture;
|
|
|
|
Ogre::RenderTexture* mRenderTarget;
|
|
|
|
|
|
|
|
Ogre::Image mBuffer;
|
|
|
|
|
|
|
|
std::map<Ogre::ColourValue, int, cmp_ColourValue> mColourMap;
|
|
|
|
|
|
|
|
Ogre::ColourValue mCurrentColour;
|
|
|
|
|
2014-08-04 14:32:53 +00:00
|
|
|
Ogre::Camera* mCamera;
|
|
|
|
int mVisibilityFlags;
|
|
|
|
|
2012-09-14 12:34:18 +00:00
|
|
|
void getNextColour();
|
2014-08-04 14:32:53 +00:00
|
|
|
|
|
|
|
void setupRenderTarget();
|
2012-09-14 12:34:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|