Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# OgreTextureUnitState.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://ogre.sourceforge.net/
    00006
    00007 Copyright © 2000-2003 The OGRE Team
    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 */
    00025 #ifndef __TextureUnitState_H__
    00026 #define __TextureUnitState_H__
    00027
    00028 #include "OgrePrerequisites.h"
    00029 #include "OgreCommon.h"
    00030 #include "OgreBlendMode.h"
    00031 #include "OgreMatrix4.h"
    00032 #include "OgreIteratorWrappers.h"
    00033 #include "OgreString.h"
    00034 #include "OgreTexture.h"
    00035
    00036 namespace Ogre {
    00052     class _OgreExport TextureUnitState
    00053     {
    00054         friend class RenderSystem;
    00055     public:
    00061         enum TextureEffectType
    00062         {
    00064             ET_ENVIRONMENT_MAP,
    00066             ET_PROJECTIVE_TEXTURE,
    00068             ET_SCROLL,
    00070             ET_ROTATE,
    00072             ET_TRANSFORM
    00073
    00074         };
    00075
    00081         enum EnvMapType
    00082         {
    00084             ENV_PLANAR,
    00086             ENV_CURVED,
    00088             ENV_REFLECTION,
    00090             ENV_NORMAL
    00091         };
    00092
    00098         enum TextureTransformType
    00099         {
    00100             TT_TRANSLATE_U,
    00101             TT_TRANSLATE_V,
    00102             TT_SCALE_U,
    00103             TT_SCALE_V,
    00104             TT_ROTATE
    00105         };
    00106
    00112         enum TextureAddressingMode
    00113         {
    00115             TAM_WRAP,
    00117             TAM_MIRROR,
    00119             TAM_CLAMP
    00120         };
    00121
    00124         enum TextureCubeFace
    00125         {
    00126             CUBE_FRONT = 0,
    00127             CUBE_BACK = 1,
    00128             CUBE_LEFT = 2,
    00129             CUBE_RIGHT = 3,
    00130             CUBE_UP = 4,
    00131             CUBE_DOWN = 5
    00132         };
    00133
    00136         struct TextureEffect {
    00137             TextureEffectType type;
    00138             int subtype;
    00139             Real arg1, arg2;
    00140             WaveformType waveType;
    00141             Real base;
    00142             Real frequency;
    00143             Real phase;
    00144             Real amplitude;
    00145             Controller<Real>* controller;
    00146             const Frustum* frustum;
    00147         };
    00148
    00149
    00152         TextureUnitState(Pass* parent);
    00153
    00154         TextureUnitState(Pass* parent, const TextureUnitState& oth );
    00155
    00156         TextureUnitState & operator = ( const TextureUnitState& oth );
    00157
    00160         ~TextureUnitState();
    00161
    00168         TextureUnitState( Pass* parent, const String& texName, unsigned int texCoordSet = 0);
    00169
    00178         const String& getTextureName(void) const;
    00179
    00185         void setTextureName( const String& name, TextureType ttype = TEX_TYPE_2D );
    00186
    00233         void setCubicTextureName( const String& name, bool forUVW = false );
    00234
    00281         void setCubicTextureName( const String* const names, bool forUVW = false );
    00282
    00304         void setAnimatedTextureName( const String& name, unsigned int numFrames, Real duration = 0 );
    00305
    00327         void setAnimatedTextureName( const String* const names, unsigned int numFrames, Real duration = 0 );
    00328
    00331         std::pair< uint, uint > getTextureDimensions( unsigned int frame = 0 ) const;
    00332
    00340         void setCurrentFrame( unsigned int frameNumber );
    00341
    00346         unsigned int getCurrentFrame(void) const;
    00347
    00352         const String& getFrameTextureName(unsigned int frameNumber) const;
    00353
    00358         unsigned int getNumFrames(void) const;
    00359
    00366         bool isCubic(void) const;
    00367
    00372         bool is3D(void) const;
    00373
    00378         TextureType getTextureType(void) const;
    00379
    00384         unsigned int getTextureCoordSet(void) const;
    00385
    00393         void setTextureCoordSet(unsigned int set);
    00394
    00410         void setTextureTransform(const Matrix4& xform);
    00411
    00419         const Matrix4& getTextureTransform(void);
    00420
    00433         void setTextureScroll(Real u, Real v);
    00434
    00439         void setTextureUScroll(Real value);
    00440         // get texture uscroll value
    00441         Real getTextureUScroll(void) const;
    00442
    00447         void setTextureVScroll(Real value);
    00448         // get texture vscroll value
    00449         Real getTextureVScroll(void) const;
    00450
    00455         void setTextureUScale(Real value);
    00456         // get texture uscale value
    00457         Real getTextureUScale(void) const;
    00458
    00463         void setTextureVScale(Real value);
    00464         // get texture vscale value
    00465         Real getTextureVScale(void) const;
    00466
    00480         void setTextureScale(Real uScale, Real vScale);
    00481
    00491         void setTextureRotate(const Radian& angle);
    00492 #ifndef OGRE_FORCE_ANGLE_TYPES
    00493         inline void setTextureRotate(Real angle) {
    00494             setTextureRotate ( Degree(angle) );
    00495         }
    00496 #endif//OGRE_FORCE_ANGLE_TYPES
    00497         // get texture rotation effects angle value
    00498         const Radian& getTextureRotate(void) const;
    00499
    00504         TextureAddressingMode getTextureAddressingMode(void) const;
    00505
    00512         void setTextureAddressingMode( TextureAddressingMode tam);
    00513
    00578         void setColourOperationEx(
    00579             LayerBlendOperationEx op,
    00580             LayerBlendSource source1 = LBS_TEXTURE,
    00581             LayerBlendSource source2 = LBS_CURRENT,
    00582
    00583             const ColourValue& arg1 = ColourValue::White,
    00584             const ColourValue& arg2 = ColourValue::White,
    00585
    00586             Real manualBlend = 0.0);
    00587
    00606         void setColourOperation( const LayerBlendOperation op);
    00607
    00627         void setColourOpMultipassFallback( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
    00628
    00631         const LayerBlendModeEx& getColourBlendMode(void) const;
    00632
    00635         const LayerBlendModeEx& getAlphaBlendMode(void) const;
    00636
    00639         SceneBlendFactor getColourBlendFallbackSrc(void) const;
    00640
    00643         SceneBlendFactor getColourBlendFallbackDest(void) const;
    00644
    00670         void setAlphaOperation(LayerBlendOperationEx op,
    00671             LayerBlendSource source1 = LBS_TEXTURE,
    00672             LayerBlendSource source2 = LBS_CURRENT,
    00673             Real arg1 = 1.0,
    00674             Real arg2 = 1.0,
    00675             Real manualBlend = 0.0);
    00676
    00688         void addEffect(TextureEffect& effect);
    00689
    00717         void setEnvironmentMap(bool enable, EnvMapType envMapType = ENV_CURVED);
    00718
    00729         void setScrollAnimation(Real uSpeed, Real vSpeed);
    00730
    00739         void setRotateAnimation(Real speed);
    00740
    00760         void setTransformAnimation( const TextureTransformType ttype,
    00761             const WaveformType waveType, Real base = 0, Real frequency = 1, Real phase = 0, Real amplitude = 1 );
    00762
    00773         void setAlphaRejectSettings( const CompareFunction func, unsigned char value );
    00774
    00777         CompareFunction getAlphaRejectFunction(void) const;
    00778
    00781         unsigned char getAlphaRejectValue(void) const;
    00782
    00801         void setProjectiveTexturing(bool enabled, const Frustum* projectionSettings = 0);
    00802
    00805         void removeAllEffects(void);
    00806
    00812         void removeEffect( const TextureEffectType type );
    00813
    00819         bool isBlank(void) const;
    00820
    00823         void setBlank(void);
    00824
    00825         // get texture effects in a multimap paired array
    00826         std::multimap<TextureEffectType, TextureEffect> getEffects(void) const;
    00827         // get the animated-texture animation duration
    00828         Real getAnimationDuration(void) const;
    00829
    00839         void setTextureFiltering(TextureFilterOptions filterType);
    00844         void setTextureFiltering(FilterType ftype, FilterOptions opts);
    00853         void setTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter);
    00854         // get the texture filtering for the given type
    00855         FilterOptions getTextureFiltering(FilterType ftpye) const;
    00856
    00862         void setTextureAnisotropy(unsigned int maxAniso);
    00863         // get this layer texture anisotropy level
    00864         unsigned int getTextureAnisotropy() const;
    00865
    00867         Pass* getParent(void) { return mParent; }
    00868
    00870         void _load(void);
    00872         void _unload(void);
    00874         bool hasViewRelativeTextureCoordinateGeneration(void);
    00875
    00876         // Is this loaded?
    00877         bool isLoaded(void);
    00879         void _notifyNeedsRecompile(void);
    00880
    00881
    00882 protected:
    00883         Pass* mParent;
    00884
    00885         // State
    00886 #define MAX_FRAMES 32
    00887
    00889         unsigned int mNumFrames;
    00891         unsigned int mCurrentFrame;
    00892         // String mFrames[MAX_FRAMES] is at the end of the class
    00893
    00895         Real mAnimDuration;
    00896         Controller<Real>* mAnimController;
    00897         bool mCubic; // is this a series of 6 2D textures to make up a cube?
    00898         TextureType mTextureType;
    00899
    00900         unsigned int mTextureCoordSetIndex;
    00901         TextureAddressingMode mAddressMode;
    00902
    00903         LayerBlendModeEx colourBlendMode;
    00904         SceneBlendFactor colourBlendFallbackSrc;
    00905         SceneBlendFactor colourBlendFallbackDest;
    00906
    00907         LayerBlendModeEx alphaBlendMode;
    00908         bool mIsBlank;
    00909
    00910         bool mRecalcTexMatrix;
    00911         Real mUMod, mVMod;
    00912         Real mUScale, mVScale;
    00913         Radian mRotate;
    00914         Matrix4 mTexModMatrix;
    00915         CompareFunction mAlphaRejectFunc;
    00916         unsigned char mAlphaRejectVal;
    00917
    00918         // Animation, will be set up as Controllers
    00919         Real mUScrollAnim, mVScrollAnim;
    00920         Real mRotateAnim;
    00921
    00923         FilterOptions mMinFilter;
    00925         FilterOptions mMagFilter;
    00927         FilterOptions mMipFilter;
    00929         unsigned int mMaxAniso;
    00930
    00931         bool mIsDefaultAniso;
    00932         bool mIsDefaultFiltering;
    00933
    00934
    00935         //-----------------------------------------------------------------------------
    00936         // Complex members (those that can't be copied using memcpy) are at the end to
    00937         // allow for fast copying of the basic members.
    00938         //
    00939         String mFrames[MAX_FRAMES]; // Names of frames
    00940
    00941         typedef std::multimap<TextureEffectType, TextureEffect> EffectMap;
    00942         EffectMap mEffects;
    00943         //-----------------------------------------------------------------------------
    00944
    00945
    00946
    00949         void recalcTextureMatrix(void);
    00950
    00953         void createAnimController(void);
    00954
    00957         void createEffectController(TextureEffect& effect);
    00958
    00959
    00960     };
    00961
    00962
    00963 }
    00964
    00965 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:50 2004