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:
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
#define _OgreTerrainExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Specialisation of HardwareBuffer for a pixel buffer.
Class representing an image file.
Definition: OgreImage.h:62
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
Class exposing an interface to a blend map for a given layer.
void convertUVToWorldSpace(Real x, Real y, Vector3 *outWorldPos)
Helper method - convert a point in local space to worldspace based on the terrain settings.
void blit(const PixelBox &src)
Blits a set of values into the entire map.
void blit(const PixelBox &src, const Box &dstBox)
Blits a set of values into a region on the blend map.
Terrain * getParent() const
Get the parent terrain.
void loadImage(const Image &img)
Load an image into this blend layer.
void convertUVToImageSpace(Real x, Real y, size_t *outX, size_t *outY)
Convert local space values (0,1) to image space (0, imageSize).
float * getBlendPointer()
Get a pointer to the whole blend data.
void update()
Publish any changes you made to the blend data back to the blend map.
TerrainLayerBlendMap(Terrain *parent, uint8 layerIndex, HardwarePixelBuffer *buf)
Constructor.
void setBlendValue(size_t x, size_t y, float val)
Set a single value of blend information (0 = transparent, 255 = solid)
void convertImageToUVSpace(size_t x, size_t y, Real *outX, Real *outY)
Convert image space (0, imageSize) to local space values (0,1).
void loadImage(DataStreamPtr &stream, const String &ext=StringUtil::BLANK)
Load an image into this blend layer.
uint8 getLayerIndex() const
Get the index of the layer this is targeting.
void dirtyRect(const Rect &rect)
Indicate that a portion of the blend data is dirty and needs updating.
void convertWorldToUVSpace(const Vector3 &worldPos, Real *outX, Real *outY)
Helper method - convert a point in world space to UV space based on the terrain settings.
void convertImageToTerrainSpace(size_t x, size_t y, Real *outX, Real *outY)
Convert image space (0, imageSize) to terrain space values (0,1).
void convertTerrainToImageSpace(Real x, Real y, size_t *outX, size_t *outY)
Convert terrain space values (0,1) to image space (0, imageSize).
void loadImage(const String &filename, const String &groupName)
Load an image into this blend layer.
float getBlendValue(size_t x, size_t y)
Get a single value of blend information, in image space.
void dirty()
Indicate that all of the blend data is dirty and needs updating.
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:264
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
vector< TerrainLayerBlendMap * >::type TerrainLayerBlendMapList
unsigned char uint8
Definition: OgrePlatform.h:361
float Real
Software floating point type.
_StringBase String
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:660

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.