OgreTerrainLayerBlendMap.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Ogre_TerrainLayerBlendMap_H__
#define __Ogre_TerrainLayerBlendMap_H__
#include "OgreTerrainPrerequisites.h"
#include "OgreCommon.h"
#include "OgreVector3.h"
#include "OgreDataStream.h"
namespace Ogre
{
class Image;
class _OgreTerrainExport TerrainLayerBlendMap : public TerrainAlloc
{
protected:
Terrain* mParent;
uint8 mLayerIdx;
uint8 mChannel; // RGBA
uint8 mChannelOffset; // in pixel format
Box mDirtyBox;
bool mDirty;
HardwarePixelBuffer* mBuffer;
float* mData;
void download();
void upload();
public:
TerrainLayerBlendMap(Terrain* parent, uint8 layerIndex, HardwarePixelBuffer* buf);
virtual ~TerrainLayerBlendMap();
Terrain* getParent() const { return mParent; }
uint8 getLayerIndex() const { return mLayerIdx; }
void convertWorldToUVSpace(const Vector3& worldPos, Real *outX, Real* outY);
void convertUVToWorldSpace(Real x, Real y, Vector3* outWorldPos);
void convertUVToImageSpace(Real x, Real y, size_t* outX, size_t* outY);
void convertImageToUVSpace(size_t x, size_t y, Real* outX, Real* outY);
void convertImageToTerrainSpace(size_t x, size_t y, Real* outX, Real* outY);
void convertTerrainToImageSpace(Real x, Real y, size_t* outX, size_t* outY);
float getBlendValue(size_t x, size_t y);
void setBlendValue(size_t x, size_t y, float val);
float* getBlendPointer();
void dirty();
void dirtyRect(const Rect& rect);
void blit(const PixelBox &src, const Box &dstBox);
void blit(const PixelBox &src);
void loadImage(const Image& img);
void loadImage(DataStreamPtr& stream, const String& ext = StringUtil::BLANK);
void loadImage(const String& filename, const String& groupName);
void update();
};
typedef vector<TerrainLayerBlendMap*>::type TerrainLayerBlendMapList;
}
#endif
Ogre::TerrainLayerBlendMap::mBuffer
HardwarePixelBuffer * mBuffer
Definition: OgreTerrainLayerBlendMap.h:70
OgreVector3.h
Ogre::HardwarePixelBuffer
Specialisation of HardwareBuffer for a pixel buffer.
Definition: OgreHardwarePixelBuffer.h:53
Ogre::TerrainLayerBlendMap::mChannel
uint8 mChannel
Definition: OgreTerrainLayerBlendMap.h:66
Ogre::TerrainLayerBlendMap::mDirtyBox
Box mDirtyBox
Definition: OgreTerrainLayerBlendMap.h:68
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::TerrainLayerBlendMap::mDirty
bool mDirty
Definition: OgreTerrainLayerBlendMap.h:69
Ogre::TRect< long >
Ogre::TerrainLayerBlendMap::mData
float * mData
Definition: OgreTerrainLayerBlendMap.h:71
OgreDataStream.h
Ogre::TerrainLayerBlendMap::getParent
Terrain * getParent() const
Get the parent terrain.
Definition: OgreTerrainLayerBlendMap.h:85
Ogre::TerrainLayerBlendMap::mLayerIdx
uint8 mLayerIdx
Definition: OgreTerrainLayerBlendMap.h:65
Ogre::Box
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:659
OgreCommon.h
Ogre::TerrainLayerBlendMap::getLayerIndex
uint8 getLayerIndex() const
Get the index of the layer this is targeting.
Definition: OgreTerrainLayerBlendMap.h:87
Ogre::Terrain
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:262
Ogre::TerrainLayerBlendMap::mChannelOffset
uint8 mChannelOffset
Definition: OgreTerrainLayerBlendMap.h:67
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::uint8
unsigned char uint8
Definition: OgrePlatform.h:361
_OgreTerrainExport
#define _OgreTerrainExport
Definition: OgreTerrainPrerequisites.h:58
Ogre::TerrainLayerBlendMapList
vector< TerrainLayerBlendMap * >::type TerrainLayerBlendMapList
Definition: OgreTerrainLayerBlendMap.h:189
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::TerrainLayerBlendMap
Class exposing an interface to a blend map for a given layer.
Definition: OgreTerrainLayerBlendMap.h:61
Ogre::Image
Class representing an image file.
Definition: OgreImage.h:61
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::SharedPtr< DataStream >
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreTerrainPrerequisites.h
Ogre::TerrainLayerBlendMap::mParent
Terrain * mParent
Definition: OgreTerrainLayerBlendMap.h:64
Ogre::PixelBox
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
Definition: OgrePixelFormat.h:304
Ogre::StringUtil::BLANK
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58

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