📄 ogrepaginglandscapedata2d.h
字号:
/***************************************************************************
OgrePagingLandScapeData2D.h - description
-------------------
begin : Wen Mar 5 2003
copyright : (C) 2002 by Jose A Milan
email : spoke@supercable.es
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
#ifndef PAGINGLANDSCAPEDATA2D_H
#define PAGINGLANDSCAPEDATA2D_H
#include "OgrePagingLandScapePrerequisites.h"
namespace Ogre
{
/**
* A simple class for encapsulating 2D Data reading.
*/
class PagingLandScapeData2D
{
public:
PagingLandScapeData2D();
virtual ~PagingLandScapeData2D();
virtual void load( const float mX, const float mZ);
virtual void load();
virtual void load(Image *newHeightmap);
virtual void unload();
/**
* Method that deform Height Data of the terrain.
* \param &deformationPoint
* Where modification is, in world coordinates
* \param &modificationHeight
* What modification do to terrain
* \param info
* Give some info on tile to
* help coordinate system change
*/
const Real DeformHeight(const Vector3 &deformationPoint,
const Real &modificationHeight,
PagingLandScapeTileInfo* info);
/**
*
* Method that deform Height Data of the terrain.
* \param &x
* x Position on 2d height grid
* \param &z
* z Position on 2d height grid
* \param &modificationHeight
* What modification do to terrain
*/
const Real PagingLandScapeData2D::DeformHeight(const uint &x,
const uint &z,
const Real &modificationHeight);
virtual Vector3 getNormalAt (const float mX, const float mZ){return Vector3::UNIT_Y;};
virtual ColourValue getBase (const float mX, const float mZ){return ColourValue::White;};
virtual ColourValue getCoverage (const float mX, const float mZ){return ColourValue::White;};
const Real getHeightAbsolute(const float x, const float z, PagingLandScapeTileInfo* info);
inline const Real getHeight( const float x, const float z )
{
if ( mHeightData )
{
uint Pos = uint (( z * mSize )+ x);
if ( mMaxArrayPos > Pos )
return mHeightData[ Pos ];
}
return 0.0f;
};
inline const Real getHeight( const uint x, const uint z )
{
if ( mHeightData )
{
uint Pos = z * mSize + x;
if ( mMaxArrayPos > Pos )
return mHeightData[ Pos ];
}
return 0.0f;
};
inline const Real getHeight( const int x, const int z )
{
if ( mHeightData )
{
int Pos = z * mSize + x;
if ( mMaxArrayPos > (uint) Pos )
return mHeightData[ Pos ];
}
return 0.0f;
};
void setHeight( const uint x, const uint z, const Real h );
inline const Real getMaxHeight(){return mMaxheight;};
Real *getHeightData(){return mHeightData;};
bool isLoaded();
bool addNewHeight(Sphere newHeight);
bool removeNewHeight(Sphere oldHeight);
protected:
std::vector< Sphere > mNewHeight;
virtual void _load(const float x, const float z) = 0;
virtual void _load(Image *newHeightmap) = 0;
virtual void _load() = 0;
virtual void _unload() = 0;
// computed Height Data (scaled)
Real *mHeightData;
// maximum position in Array
uint mMaxArrayPos;
// data side maximum size
uint mSize;
// image data maximum size
uint mMax;
// maximum page/data2d height. (scaled)
Real mMaxheight;
// if data loaded or not
bool mIsLoaded;
bool _checkSize( int s )
{
// ispow2 - 1
s -= 1;
// ispow2
return ((s & (s - 1)) == 0);
// for (int i = 0; i < 256; i++ )
// {
//#ifdef _DEBUG
// printf( "Checking...%d\n", ( 1 << i ) + 1 );
//#endif
// if ( s == ( 1 << i ) + 1 )
// {
// return true;
// }
// }
// return false;
}
};
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -