OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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-2014 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 "OgreDataStream.h"
35 
36 namespace Ogre
37 {
38  class Image;
61  {
62  protected:
65  uint8 mChannel; // RGBA
66  uint8 mChannelOffset; // in pixel format
68  bool mDirty;
70  float* mData;
71 
72  void download();
73  void upload();
74 
75  public:
81  TerrainLayerBlendMap(Terrain* parent, uint8 layerIndex, HardwarePixelBuffer* buf);
82  virtual ~TerrainLayerBlendMap();
84  Terrain* getParent() const { return mParent; }
86  uint8 getLayerIndex() const { return mLayerIdx; }
87 
96  void convertWorldToUVSpace(const Vector3& worldPos, Real *outX, Real* outY);
97 
103  void convertUVToWorldSpace(Real x, Real y, Vector3* outWorldPos);
104 
107  void convertUVToImageSpace(Real x, Real y, size_t* outX, size_t* outY);
110  void convertImageToUVSpace(size_t x, size_t y, Real* outX, Real* outY);
113  void convertImageToTerrainSpace(size_t x, size_t y, Real* outX, Real* outY);
116  void convertTerrainToImageSpace(Real x, Real y, size_t* outX, size_t* outY);
117 
122  float getBlendValue(size_t x, size_t y);
123 
128  void setBlendValue(size_t x, size_t y, float val);
129 
136  float* getBlendPointer();
137 
140  void dirty();
141 
145  void dirtyRect(const Rect& rect);
146 
155  void blit(const PixelBox &src, const Box &dstBox);
156 
163  void blit(const PixelBox &src);
164 
167  void loadImage(const Image& img);
168 
173  void loadImage(DataStreamPtr& stream, const String& ext = BLANKSTRING);
174 
177  void loadImage(const String& filename, const String& groupName);
178 
183  void update();
184 
185 
186  };
187 
189 
193 }
194 
195 
196 
197 #endif
unsigned char uint8
Definition: OgrePlatform.h:422
float Real
Software floating point type.
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:265
const String BLANKSTRING
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreCommon.h:574
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:689
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...
#define _OgreTerrainExport
Terrain * getParent() const
Get the parent terrain.
vector< TerrainLayerBlendMap * >::type TerrainLayerBlendMapList
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
Class representing an image file.
Definition: OgreImage.h:60
Specialisation of HardwareBuffer for a pixel buffer.
uint8 getLayerIndex() const
Get the index of the layer this is targeting.
_StringBase String
Definition: OgreCommon.h:53