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-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 
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:
82  TerrainLayerBlendMap(Terrain* parent, uint8 layerIndex, HardwarePixelBuffer* buf);
83  virtual ~TerrainLayerBlendMap();
85  Terrain* getParent() const { return mParent; }
87  uint8 getLayerIndex() const { return mLayerIdx; }
88 
97  void convertWorldToUVSpace(const Vector3& worldPos, Real *outX, Real* outY);
98 
104  void convertUVToWorldSpace(Real x, Real y, Vector3* outWorldPos);
105 
108  void convertUVToImageSpace(Real x, Real y, size_t* outX, size_t* outY);
111  void convertImageToUVSpace(size_t x, size_t y, Real* outX, Real* outY);
114  void convertImageToTerrainSpace(size_t x, size_t y, Real* outX, Real* outY);
117  void convertTerrainToImageSpace(Real x, Real y, size_t* outX, size_t* outY);
118 
123  float getBlendValue(size_t x, size_t y);
124 
129  void setBlendValue(size_t x, size_t y, float val);
130 
137  float* getBlendPointer();
138 
141  void dirty();
142 
146  void dirtyRect(const Rect& rect);
147 
156  void blit(const PixelBox &src, const Box &dstBox);
157 
164  void blit(const PixelBox &src);
165 
168  void loadImage(const Image& img);
169 
174  void loadImage(DataStreamPtr& stream, const String& ext = StringUtil::BLANK);
175 
178  void loadImage(const String& filename, const String& groupName);
179 
184  void update();
185 
186 
187  };
188 
190 
194 }
195 
196 
197 
198 #endif
Specialisation of HardwareBuffer for a pixel buffer.
float Real
Software floating point type.
Terrain * getParent() const
Get the parent terrain.
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:659
uint8 getLayerIndex() const
Get the index of the layer this is targeting.
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:262
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
unsigned char uint8
Definition: OgrePlatform.h:361
#define _OgreTerrainExport
vector< TerrainLayerBlendMap * >::type TerrainLayerBlendMapList
_StringBase String
Class exposing an interface to a blend map for a given layer.
Class representing an image file.
Definition: OgreImage.h:61
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...

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 Sun Oct 9 2016 22:12:54