24#include <OgreCamera.h>
25#include <OgreSceneManager.h>
26#include <OgreTextureManager.h>
27#include <OgreTechnique.h>
28#include <OgreMaterialManager.h>
29#include <OgreRenderTexture.h>
30#include <OgreViewport.h>
31#include <OgreHardwarePixelBuffer.h>
54 SetValues(
"CameraTexture", name, permanent);
62 unsigned int texture_size = 256;
72 ReportError(
"Error creating camera texture:\nTexture with the name '" + name +
"' already exists.");
78 texture = Ogre::TextureManager::getSingleton().createManual(
texturename,
"General", Ogre::TEX_TYPE_2D, texture_size, texture_size, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
84 camera->setNearClipDistance(0.1);
85 camera->setFarClipDistance(0.0);
86 camera->setAspectRatio(1.0);
95 if (use_rotation ==
true)
103 renderTexture->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Black);
109 material->setLightingEnabled(
false);
122 catch (Ogre::Exception &e)
124 ReportError(
"Error creating camera texture:\n" + e.getDescription());
150 if (type ==
"ElevatorCar")
152 else if (type ==
"Floor")
154 else if (type ==
"Shaft Level")
156 else if (type ==
"Stairwell Level")
183 if (angle > 0 && angle < 179.63)
195 return (
float)(
camera->getFOVy().valueDegrees() *
camera->getAspectRatio());
217 camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
219 camera->setProjectionType(Ogre::PT_PERSPECTIVE);
227 texture->convertToImage(image,
false);
234 if (!
camera || value <= 0)
238 Ogre::Affine3 vmatrix =
camera->getViewMatrix();
241 vmatrix[0][0] /=
zoom;
242 vmatrix[1][2] /=
zoom;
246 vmatrix[0][0] *=
zoom;
247 vmatrix[1][2] *=
zoom;
250 camera->setCustomViewMatrix(
true, vmatrix);
Ogre::RenderTexture * renderTexture
void EnableOrthographic(bool value)
void GetImage(Ogre::Image &image)
void LookAt(const Vector3 &position)
CameraTexture(Object *parent, const std::string &name, int quality, Real fov, const Vector3 &position, bool use_rotation, const Vector3 &rotation, bool permanent=false)
void SetFOVAngle(Real angle)
const std::string & GetName()
virtual bool ReportError(const std::string &message)
virtual void Report(const std::string &message)
virtual void SetRotation(const Vector3 &rotation)
virtual void Move(const Vector3 &vector, Real speed=1.0)
SceneNode * GetSceneNode()
void SetValues(const std::string &type, const std::string &name, bool is_permanent, bool is_movable=true)
const std::string & GetType()
Ogre::SceneManager * mSceneManager
void UnregisterCameraTexture(CameraTexture *camtex)
void RegisterCameraTexture(CameraTexture *camtex)
TextureManager * GetTextureManager()
void DetachObject(Ogre::MovableObject *object)
void AttachObject(Ogre::MovableObject *object)
void LookAt(const Vector3 &point)
bool UnloadMaterial(const std::string &name, const std::string &group)
Ogre::MaterialPtr CreateMaterial(const std::string &name, const std::string &path)
Ogre::TexturePtr GetTextureByName(const std::string &name, const std::string &group="General")
bool UnloadTexture(const std::string &name, const std::string &group)
void RegisterTextureInfo(const std::string &name, const std::string &material_name, const std::string &filename, Real widthmult, Real heightmult, bool enable_force, bool force_mode, size_t tex_size, size_t mat_size)
bool UnregisterTextureInfo(std::string name, std::string material_name="")
void IncrementTextureCount()
Ogre::TextureUnitState * BindTextureToMaterial(Ogre::MaterialPtr mMat, std::string texture_name, bool has_alpha)
Ogre::MaterialPtr GetMaterialByName(const std::string &name, const std::string &group="General")
std::string ToString(int number)