📄 ogrepaginglandscaperenderable.h
字号:
/***************************************************************************
OgrePagingLandScapeRenderable.h - description
-------------------
begin : Thu Feb 27 2003
copyright : (C) 2003 by Jose A Milan
email : spoke2@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 PAGINGLANDSCAPERENDERABLE_H
#define PAGINGLANDSCAPERENDERABLE_H
#include <vector>
#include <OgreRenderable.h>
#include <OgreMovableObject.h>
#include <OgreString.h>
#include <OgreVertexIndexData.h>
#include <OgreNode.h>
#include "OgrePagingLandScapePageData2D.h"
namespace Ogre
{
/** Represents a landscape page.
@remarks
A LandScapeRenderable represents a page used to render a block of landscape using the procedural terrain approach for LOD.
*/
class PagingLandScapeRenderable : public Renderable, public MovableObject
{
public:
enum eMorphStatus
{
DEMORPHED = 0,
DEMORPHING = 1,
MORPHING = 2,
MORPHED = 3
};
/** Initializes the LandScapeRenderable with the given options and the starting coords of this block.
*/
PagingLandScapeRenderable( );
~PagingLandScapeRenderable();
void init( PagingLandScapePageData2D *Data, const float PosX, const float PosZ, const float offSetX, const float offSetZ, const int Nivel );
bool InUse();
void release();
//movable object methods
/** Returns the name of the LandScapeRenderable
*/
const String& getName( void ) const
{
return mName;
};
/** Returns the type of the movable.
*/
const String& getMovableType( void ) const
{
return mType;
};
/** Returns the bounding box of this LandScapeRenderable
*/
const AxisAlignedBox& getBoundingBox( void ) const
{
return mBounds;
};
/** Updates the level of detail to be used for rendering this PagingLandScapeRenderable based on the passed in Camera
*/
void _notifyCurrentCamera( Camera* cam );
//void _notifyAttached(Node* parent, bool isTagPoint = false);
void _updateRenderQueue( RenderQueue* queue );
/** Overridden from MovableObject */
Real getBoundingRadius(void) const { return 0; /* not needed */ };
/** Constructs a RenderOperation to render the LandScapeRenderable.
@remarks
Each LandScapeRenderable has a block of vertices that represent the landscape.
*/
void getRenderOperation( RenderOperation& rend );
Material* getMaterial( void ) const
{
return mMaterial;
};
void getWorldTransforms( Matrix4* xform ) const;
const Quaternion& getWorldOrientation(void) const;
const Vector3& getWorldPosition(void) const;
void setMaterial( Material *m )
{
mMaterial = m;
};
static int mRenderedTris;
/** Overridden, see Renderable */
Real getSquaredViewDepth(const Camera* cam) const;
/** @copydoc Renderable::getLights */
const LightList& getLights(void) const;
SceneDetailLevel getRenderDetail()
{
return SDL_SOLID;
};
void update( bool Top, bool Right, bool Down, bool Left );
/** Morph this renderable between LOD.
*/
void Morph( );
eMorphStatus getMorphStatus();
void setMorphStatus( eMorphStatus e );
void StartMorphing();
Vector3& getCenter() { return mCenter;}
//JEFF
/** Get the real world height at a particular position within the renderable data
@remarks
Method is used to get the terrain height at a position based on x and z that is local to this renderable.
This method figures out the height using bilinear interpretation between three heights that form a triangle around the point.
The method is static so that a calculation can be made even if the tile is not loaded but the page is preloaded.
Also, the method does not acces the VBO since it is a penalty hit in performance if it does and only four vertices are needed.
@par
the float returned is the height based on the data passed. If the height could
not be determined then -1 is returned and this would only occur if the page was not preloaded or loaded.
The height value must be scaled to the world value by the caller since the method has no access to the world scale
@param Data PagingLandScapePageData2D data used to provide coordinates for the interpolation
@param x x position within the renderable PagingLandScapePageData2D data
@param z z position within the renderable PagingLandScapePageData2D data
@param render_size size of the renderable in heightfield coordinates
*/
static float getRealWorldHeight(PagingLandScapePageData2D *Data, float x, float z, int render_size);
/** This return the error introduced in this renderable, due to LOD
*/
const float getError();
protected:
//movable object variables
String mName;
static String mType;
AxisAlignedBox mBounds;
PagingLandScapePageData2D *mPageData2D;
Material *mMaterial;
unsigned short *mIndex;
bool mTop;
bool mRight;
bool mDown;
bool mLeft;
int mNivel;
float mError;
bool mInUse;
bool mColored;
bool mLit;
RenderOperation mRend;
Vector3 mScale;
Vector3 mCenter;
Real mMorphStep[8];
int mNumMorph;
int mMaxMorphSteps;
eMorphStatus mMorphStatus;
void _getNormalAt( int x, int z, Vector3 * result );
void _buildMorph( Real *pVertices, int index, int vert, int vert1, int vert2 );
void _buildError( const float offSetX, const float offSetZ, const int step );
};
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -