OgreTextureUnitState.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __TextureUnitState_H__
29 #define __TextureUnitState_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreCommon.h"
33 #include "OgreBlendMode.h"
34 #include "OgreMatrix4.h"
35 #include "OgreIteratorWrappers.h"
36 #include "OgreString.h"
37 #include "OgreTexture.h"
38 #include "OgreHeaderPrefix.h"
39 
40 namespace Ogre {
63  {
64  friend class RenderSystem;
65  public:
72  {
86  ET_TRANSFORM
87 
88  };
89 
96  {
104  ENV_NORMAL
105  };
106 
113  {
118  TT_ROTATE
119  };
120 
127  {
135  TAM_BORDER
136  };
137 
140  {
142  };
143 
147  {
148  CUBE_FRONT = 0,
149  CUBE_BACK = 1,
150  CUBE_LEFT = 2,
151  CUBE_RIGHT = 3,
152  CUBE_UP = 4,
153  CUBE_DOWN = 5
154  };
155 
158  struct TextureEffect {
160  int subtype;
161  Real arg1, arg2;
168  const Frustum* frustum;
169  };
170 
174 
177  TextureUnitState(Pass* parent);
178 
179  TextureUnitState(Pass* parent, const TextureUnitState& oth );
180 
181  TextureUnitState & operator = ( const TextureUnitState& oth );
182 
185  ~TextureUnitState();
186 
193  TextureUnitState( Pass* parent, const String& texName, unsigned int texCoordSet = 0);
194 
203  const String& getTextureName(void) const;
204 
210  void setTextureName( const String& name, TextureType ttype = TEX_TYPE_2D);
211 
217  void setTexture( const TexturePtr& texPtr);
218 
265  void setCubicTextureName( const String& name, bool forUVW = false );
266 
311  void setCubicTextureName( const String* const names, bool forUVW = false );
312 
357  void setCubicTexture( const TexturePtr* const texPtrs, bool forUVW = false );
358 
380  void setAnimatedTextureName( const String& name, unsigned int numFrames, Real duration = 0 );
381 
403  void setAnimatedTextureName( const String* const names, unsigned int numFrames, Real duration = 0 );
404 
407  std::pair< size_t, size_t > getTextureDimensions( unsigned int frame = 0 ) const;
408 
416  void setCurrentFrame( unsigned int frameNumber );
417 
422  unsigned int getCurrentFrame(void) const;
423 
429  const String& getFrameTextureName(unsigned int frameNumber) const;
430 
440  void setFrameTextureName(const String& name, unsigned int frameNumber);
441 
448  void addFrameTextureName(const String& name);
457  void deleteFrameTextureName(const size_t frameNumber);
462  unsigned int getNumFrames(void) const;
463 
464 
467  {
469  BT_FRAGMENT = 0,
473  BT_VERTEX = 1,
475  BT_GEOMETRY = 2,
477  BT_TESSELATION_HULL = 3,
479  BT_TESSELATION_DOMAIN = 4,
481  BT_COMPUTE = 5
482  };
486  {
488  CONTENT_NAMED = 0,
490  CONTENT_SHADOW = 1,
492  CONTENT_COMPOSITOR = 2
493  };
494 
504  void setBindingType(BindingType bt);
505 
508  BindingType getBindingType(void) const;
509 
515  void setContentType(ContentType ct);
517  ContentType getContentType(void) const;
518 
525  bool isCubic(void) const;
526 
531  bool is3D(void) const;
532 
537  TextureType getTextureType(void) const;
538 
541  void setDesiredFormat(PixelFormat desiredFormat);
542 
545  PixelFormat getDesiredFormat(void) const;
546 
549  void setNumMipmaps(int numMipmaps);
550 
553  int getNumMipmaps(void) const;
554 
557  void setIsAlpha(bool isAlpha);
558 
561  bool getIsAlpha(void) const;
562 
564  Real getGamma() const { return mGamma; }
566  void setGamma(Real gamma) { mGamma = gamma; }
567 
569  void setHardwareGammaEnabled(bool enabled);
571  bool isHardwareGammaEnabled() const;
572 
577  unsigned int getTextureCoordSet(void) const;
578 
586  void setTextureCoordSet(unsigned int set);
587 
603  void setTextureTransform(const Matrix4& xform);
604 
612  const Matrix4& getTextureTransform(void) const;
613 
628  void setTextureScroll(Real u, Real v);
629 
634  void setTextureUScroll(Real value);
636  Real getTextureUScroll(void) const;
637 
642  void setTextureVScroll(Real value);
644  Real getTextureVScroll(void) const;
645 
650  void setTextureUScale(Real value);
652  Real getTextureUScale(void) const;
653 
658  void setTextureVScale(Real value);
660  Real getTextureVScale(void) const;
661 
675  void setTextureScale(Real uScale, Real vScale);
676 
686  void setTextureRotate(const Radian& angle);
688  const Radian& getTextureRotate(void) const;
689 
695  const UVWAddressingMode& getTextureAddressingMode(void) const;
696 
710  void setTextureAddressingMode( TextureAddressingMode tam);
711 
718  void setTextureAddressingMode( TextureAddressingMode u,
719  TextureAddressingMode v, TextureAddressingMode w);
720 
727  void setTextureAddressingMode( const UVWAddressingMode& uvw);
728 
736  void setTextureBorderColour(const ColourValue& colour);
737 
743  const ColourValue& getTextureBorderColour(void) const;
744 
809  void setColourOperationEx(
811  LayerBlendSource source1 = LBS_TEXTURE,
812  LayerBlendSource source2 = LBS_CURRENT,
813 
814  const ColourValue& arg1 = ColourValue::White,
815  const ColourValue& arg2 = ColourValue::White,
816 
817  Real manualBlend = 0.0);
818 
837  void setColourOperation( const LayerBlendOperation op);
838 
858  void setColourOpMultipassFallback( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
859 
862  const LayerBlendModeEx& getColourBlendMode(void) const;
863 
866  const LayerBlendModeEx& getAlphaBlendMode(void) const;
867 
870  SceneBlendFactor getColourBlendFallbackSrc(void) const;
871 
874  SceneBlendFactor getColourBlendFallbackDest(void) const;
875 
901  void setAlphaOperation(LayerBlendOperationEx op,
902  LayerBlendSource source1 = LBS_TEXTURE,
903  LayerBlendSource source2 = LBS_CURRENT,
904  Real arg1 = 1.0,
905  Real arg2 = 1.0,
906  Real manualBlend = 0.0);
907 
919  void addEffect(TextureEffect& effect);
920 
947  void setEnvironmentMap(bool enable, EnvMapType envMapType = ENV_CURVED);
948 
959  void setScrollAnimation(Real uSpeed, Real vSpeed);
960 
969  void setRotateAnimation(Real speed);
970 
990  void setTransformAnimation( const TextureTransformType ttype,
991  const WaveformType waveType, Real base = 0, Real frequency = 1, Real phase = 0, Real amplitude = 1 );
992 
993 
1014  void setProjectiveTexturing(bool enabled, const Frustum* projectionSettings = 0);
1015 
1018  void removeAllEffects(void);
1019 
1025  void removeEffect( const TextureEffectType type );
1026 
1032  bool isBlank(void) const;
1033 
1036  void setBlank(void);
1037 
1040  bool isTextureLoadFailing() const { return mTextureLoadFailed; }
1041 
1044  void retryTextureLoad() { mTextureLoadFailed = false; }
1045 
1047  const EffectMap& getEffects(void) const;
1049  Real getAnimationDuration(void) const;
1050 
1061  void setTextureFiltering(TextureFilterOptions filterType);
1068  void setTextureFiltering(FilterType ftype, FilterOptions opts);
1080  void setTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter);
1082  FilterOptions getTextureFiltering(FilterType ftpye) const;
1083 
1084  void setTextureCompareEnabled(bool enabled);
1085  bool getTextureCompareEnabled() const;
1086 
1087  void setTextureCompareFunction(CompareFunction function);
1088  CompareFunction getTextureCompareFunction() const;
1089 
1097  void setTextureAnisotropy(unsigned int maxAniso);
1099  unsigned int getTextureAnisotropy() const;
1100 
1114  void setTextureMipmapBias(float bias) { mMipmapBias = bias; }
1118  float getTextureMipmapBias(void) const { return mMipmapBias; }
1119 
1130  void setCompositorReference(const String& compositorName, const String& textureName, size_t mrtIndex = 0);
1131 
1133  const String& getReferencedCompositorName() const { return mCompositorRefName; }
1135  const String& getReferencedTextureName() const { return mCompositorRefTexName; }
1137  size_t getReferencedMRTIndex() const { return mCompositorRefMrtIndex; }
1138 
1140  Pass* getParent(void) const { return mParent; }
1141 
1143  void _prepare(void);
1145  void _unprepare(void);
1147  void _load(void);
1149  void _unload(void);
1151  bool hasViewRelativeTextureCoordinateGeneration(void) const;
1152 
1154  bool isLoaded(void) const;
1156  void _notifyNeedsRecompile(void);
1157 
1163  void setName(const String& name);
1165  const String& getName(void) const { return mName; }
1166 
1171  void setTextureNameAlias(const String& name);
1174  const String& getTextureNameAlias(void) const { return mTextureNameAlias;}
1175 
1190  bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true);
1191 
1193  void _notifyParent(Pass* parent);
1194 
1196  const TexturePtr& _getTexturePtr(void) const;
1198  const TexturePtr& _getTexturePtr(size_t frame) const;
1199 
1201  void _setTexturePtr(const TexturePtr& texptr);
1203  void _setTexturePtr(const TexturePtr& texptr, size_t frame);
1204 
1205  size_t calculateSize(void) const;
1206 
1210  Controller<Real>* _getAnimController() const { return mAnimController; }
1211 protected:
1212  // State
1214  unsigned int mCurrentFrame;
1215 
1218  bool mCubic;
1219 
1223 
1227 
1231 
1233  mutable bool mTextureLoadFailed;
1234  bool mIsAlpha;
1235  bool mHwGamma;
1237 
1238  mutable bool mRecalcTexMatrix;
1239  Real mUMod, mVMod;
1240  Real mUScale, mVScale;
1243 
1250 
1253 
1255  unsigned int mMaxAniso;
1258 
1267 
1268  //-----------------------------------------------------------------------------
1269  // Complex members (those that can't be copied using memcpy) are at the end to
1270  // allow for fast copying of the basic members.
1271  //
1280  //-----------------------------------------------------------------------------
1281 
1282  //-----------------------------------------------------------------------------
1283  // Pointer members (those that can't be copied using memcpy), and MUST
1284  // preserving even if assign from others
1285  //
1288  //-----------------------------------------------------------------------------
1289 
1290 
1293  void recalcTextureMatrix(void) const;
1294 
1297  void createAnimController(void);
1298 
1301  void createEffectController(TextureEffect& effect);
1302 
1304  void ensurePrepared(size_t frame) const;
1306  void ensureLoaded(size_t frame) const;
1307 
1308 
1309  };
1310 
1314 } // namespace Ogre
1315 
1316 #include "OgreHeaderSuffix.h"
1317 
1318 #endif // __TextureUnitState_H__

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 23 2013 06:57:26