OGRE  1.9.0
OgreTerrainLayerBlendMap.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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
37namespace 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
98
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
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.
Reference-counted shared pointer, used for objects where implicit destruction is required.
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.
Terrain * getParent() const
Get the parent terrain.
void blit(const PixelBox &src, const Box &dstBox)
Blits a set of values into a region on the blend map.
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).
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.
float * getBlendPointer()
Get a pointer to the whole blend data.
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.
Standard 3-dimensional vector.
Definition OgreVector3.h:52
vector< TerrainLayerBlendMap * >::type TerrainLayerBlendMapList
_StringBase String
Structure used to define a box in a 3-D integer space.
Definition OgreCommon.h:660
std::vector< T, A > type