Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

# OgreRenderable.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __Renderable_H__
    00030 #define __Renderable_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreCommon.h"
    00034
    00035 #include "OgreRenderOperation.h"
    00036 #include "OgreMatrix4.h"
    00037 #include "OgreMaterial.h"
    00038 #include "OgrePlane.h"
    00039 #include "OgreGpuProgram.h"
    00040 #include "OgreVector4.h"
    00041 #include "OgreException.h"
    00042
    00043 namespace Ogre {
    00044
    00056     class _OgreExport Renderable
    00057     {
    00058     public:
    00059         Renderable() : mPolygonModeOverrideable(true), mUseIdentityProjection(false), mUseIdentityView(false) {}
    00061         virtual ~Renderable() { }
    00067         virtual const MaterialPtr& getMaterial(void) const = 0;
    00073         virtual Technique* getTechnique(void) const { return getMaterial()->getBestTechnique(); }
    00076         virtual void getRenderOperation(RenderOperation& op) = 0;
    00089         virtual void getWorldTransforms(Matrix4* xform) const = 0;
    00095         virtual const Quaternion& getWorldOrientation(void) const = 0;
    00101         virtual const Vector3& getWorldPosition(void) const = 0;
    00102
    00111         virtual unsigned short getNumWorldTransforms(void) const { return 1; }
    00112
    00122         void setUseIdentityProjection(bool useIdentityProjection)
    00123         {
    00124             mUseIdentityProjection = useIdentityProjection;
    00125         }
    00126
    00136         bool getUseIdentityProjection(void) const { return mUseIdentityProjection; }
    00137
    00147         void setUseIdentityView(bool useIdentityView)
    00148         {
    00149             mUseIdentityView = useIdentityView;
    00150         }
    00151
    00161         bool getUseIdentityView(void) const { return mUseIdentityView; }
    00162
    00168         virtual Real getSquaredViewDepth(const Camera* cam) const = 0;
    00169
    00171         virtual bool getNormaliseNormals(void) const { return false; }
    00172
    00177         virtual const LightList& getLights(void) const = 0;
    00178
    00179         virtual const PlaneList& getClipPlanes() const { return msDummyPlaneList; };
    00180
    00187         virtual bool getCastsShadows(void) const { return false; }
    00188
    00204         void setCustomParameter(size_t index, const Vector4& value)
    00205         {
    00206             mCustomParameters[index] = value;
    00207         }
    00208
    00213         const Vector4& getCustomParameter(size_t index) const
    00214         {
    00215             CustomParameterMap::const_iterator i = mCustomParameters.find(index);
    00216             if (i != mCustomParameters.end())
    00217             {
    00218                 return i->second;
    00219             }
    00220             else
    00221             {
    00222                 OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
    00223                     "Parameter at the given index was not found.",
    00224                     "Renderable::getCustomParameter");
    00225             }
    00226         }
    00227
    00252         virtual void _updateCustomGpuParameter(
    00253             const GpuProgramParameters::AutoConstantEntry& constantEntry,
    00254             GpuProgramParameters* params) const
    00255         {
    00256             CustomParameterMap::const_iterator i = mCustomParameters.find(constantEntry.data);
    00257             if (i != mCustomParameters.end())
    00258             {
    00259                 params->_writeRawConstant(constantEntry.physicalIndex, i->second,
    00260                     constantEntry.elementCount);
    00261             }
    00262         }
    00263
    00269         virtual void setPolygonModeOverrideable(bool override)
    00270         {
    00271             mPolygonModeOverrideable = override;
    00272         }
    00273
    00277         virtual bool getPolygonModeOverrideable(void) const
    00278         {
    00279             return mPolygonModeOverrideable;
    00280         }
    00281
    00282
    00283     protected:
    00284         static const PlaneList msDummyPlaneList;
    00285         typedef std::map<size_t, Vector4> CustomParameterMap;
    00286         CustomParameterMap mCustomParameters;
    00287         bool mPolygonModeOverrideable;
    00288         bool mUseIdentityProjection;
    00289         bool mUseIdentityView;
    00290     };
    00291
    00292
    00293
    00294 }
    00295
    00296 #endif //__Renderable_H__

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 30 10:50:57 2007