OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreTerrainLayerBlendMap.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-2011 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 
29 #ifndef __Ogre_TerrainLayerBlendMap_H__
30 #define __Ogre_TerrainLayerBlendMap_H__
31 
33 #include "OgreCommon.h"
34 #include "OgreVector3.h"
35 #include "OgreDataStream.h"
36 
37 namespace Ogre
38 {
39  class Image;
62  {
63  protected:
66  uint8 mChannel; // RGBA
67  uint8 mChannelOffset; // in pixel format
69  bool mDirty;
71  float* mData;
72 
73  void download();
74  void upload();
75 
76  public:
83  TerrainLayerBlendMap(Terrain* parent, uint8 layerIndex, HardwarePixelBuffer* buf);
86  Terrain* getParent() const { return mParent; }
88  uint8 getLayerIndex() const { return mLayerIdx; }
89 
98  void convertWorldToUVSpace(const Vector3& worldPos, Real *outX, Real* outY);
99 
105  void convertUVToWorldSpace(Real x, Real y, Vector3* outWorldPos);
106 
109  void convertUVToImageSpace(Real x, Real y, size_t* outX, size_t* outY);
112  void convertImageToUVSpace(size_t x, size_t y, Real* outX, Real* outY);
115  void convertImageToTerrainSpace(size_t x, size_t y, Real* outX, Real* outY);
118  void convertTerrainToImageSpace(Real x, Real y, size_t* outX, size_t* outY);
119 
124  float getBlendValue(size_t x, size_t y);
125 
130  void setBlendValue(size_t x, size_t y, float val);
131 
138  float* getBlendPointer();
139 
142  void dirty();
143 
147  void dirtyRect(const Rect& rect);
148 
157  void blit(const PixelBox &src, const Box &dstBox);
158 
165  void blit(const PixelBox &src);
166 
169  void loadImage(const Image& img);
170 
175  void loadImage(DataStreamPtr& stream, const String& ext = StringUtil::BLANK);
176 
179  void loadImage(const String& filename, const String& groupName);
180 
185  void update();
186 
187 
188  };
189 
191 
195 }
196 
197 
198 
199 #endif
unsigned char uint8
Definition: OgrePlatform.h:248
float Real
Software floating point type.
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:261
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:633
Class exposing an interface to a blend map for a given layer.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Terrain * getParent() const
Get the parent terrain.
vector< TerrainLayerBlendMap * >::type TerrainLayerBlendMapList
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Class representing an image file.
Definition: OgreImage.h:61
Specialisation of HardwareBuffer for a pixel buffer.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:180
uint8 getLayerIndex() const
Get the index of the layer this is targetting.
_StringBase String
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.