Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::TerrainRenderable Class Reference

Represents a terrain tile. More...

#include <OgreTerrainRenderable.h>

Inheritance diagram for Ogre::TerrainRenderable:

Ogre::Renderable Ogre::MovableObject List of all members.

Public Types

enum  Neighbor {
  NORTH = 0, SOUTH = 1, EAST = 2, WEST = 3,
  HERE = 4
}

Public Methods

 TerrainRenderable ()
 ~TerrainRenderable ()
void deleteGeometry ()
void init (TerrainOptions &options)
 Initializes the TerrainRenderable with the given options. More...

virtual const String & getName (void) const
 Returns the name of the TerrainRenderable. More...

virtual const String getMovableType (void) const
 Returns the type of the movable. More...

const AxisAlignedBox & getBoundingBox (void) const
 Returns the bounding box of this TerrainRenderable. More...

virtual void _notifyCurrentCamera (Camera *cam)
 Updates the level of detail to be used for rendering this TerrainRenderable based on the passed in Camera. More...

virtual void _updateRenderQueue (RenderQueue *queue)
 Internal method by which the movable object must add Renderable subclass instances to the rendering queue. More...

virtual void getRenderOperation (RenderOperation &rend)
 Constructs a RenderOperation to render the TerrainRenderable. More...

virtual Material * getMaterial (void) const
 Retrieves a pointer to the material this renderable object uses. More...

virtual void getWorldTransforms (Matrix4 *xform)
 Gets the world transform matrix / matrices for this renderable object. More...

int getSize ()
 Returns the size of the TerrainRenderable. More...

int getRenderLevel ()
 Returns the mipmap level that will be rendered for this frame. More...

void setForcedRenderLevel (int i)
 Forces the LOD to the given level from this point on. More...

int getNumMipMaps ()
 Returns the maximum number of mipmaps used for LOD. More...

void _getNormalAt (float x, float y, Vector3 *result)
 Calculates the normal at the given location. More...

float getHeightAt (float x, float y)
 Returns the terrain height at the given coordinates. More...

bool intersectSegment (const Vector3 &start, const Vector3 &end, Vector3 *result)
 Intersects the segment witht he terrain tile. More...

void _setNeighbor (Neighbor n, TerrainRenderable *t)
 Sets the appropriate neighbor for this TerrainRenderable. More...

TerrainRenderable * _getNeighbor (Neighbor n)
 Returns the neighbor TerrainRenderable. More...

void setMaterial (Material *m)
void _alignNeighbors ()
 Aligns mipmap levels between neighbors so that only 1 LOD level separates neighbors. More...

void _calculateNormals ()
 Calculates static normals for lighting the terrain. More...

void _generateVertexLighting (const Vector3 &sun, ColourValue ambient)
 Generates terrain shadows and lighting using vertex colors. More...

Real getSquaredViewDepth (const Camera *cam) const
 Overridden, see Renderable. More...

virtual unsigned short getNumWorldTransforms (void)
 Returns the number of world transform matrices this renderable requires. More...

virtual bool useIdentityProjection (void)
 Returns whether or not to use an 'identity' projection. More...

virtual bool useIdentityView (void)
 Returns whether or not to use an 'identity' projection. More...

virtual SceneDetailLevel getRenderDetail ()
 Returns the preferred rasterisation mode of this renderable. More...

virtual SceneNode * getParentNode (void)
 Returns the node to which this object is attached. More...

virtual void _notifyAttached (SceneNode *parent)
 Internal method called to notify the object that it has been attached to a node. More...

virtual bool isAttached (void) const
 Returns true if this object is attached to a SceneNode. More...

virtual void setVisible (bool visible)
 Tells this object whether to be visible or not, if it has a renderable component. More...

virtual bool isVisible (void) const
 Returns whether or not this object is supposed to be visible or not. More...

virtual void setUserObject (UserDefinedObject *obj)
 Call this to associate your own custom user object instance with this MovableObject. More...

virtual UserDefinedObject * getUserObject (void)
 Retrieves a pointer to a custom application object associated with this movable by an earlier call to setUserObject. More...

virtual void setRenderQueueGroup (RenderQueueGroupID queueID)
 Sets the render queue group this entity will be rendered through. More...

virtual RenderQueueGroupID getRenderQueueGroup (void)
 Gets the queue group for this entity, see setRenderQueueGroup for full details. More...


Static Public Attributes

int mRenderedTris = 0

Protected Methods

int _index (int x, int z)
 Returns the index into the height array for the given coords. More...

float _vertex (int x, int z, int n)
 Returns the vertex coord for the given coordinates. More...

int _numNeighbors ()
bool _hasNeighborRenderLevel (int i)
void _adjustRenderLevel (int i)
void _initLevelIndexes ()
bool _checkSize (int n)
void _calculateMinLevelDist2 (Real C)
Real _calculateCFactor ()

Protected Attributes

GeometryData mTerrain
int mNumMipMaps
int mRenderLevel
Real * mMinLevelDistSqr
TerrainRenderable * mNeighbors [4]
AxisAlignedBox mBounds
Vector3 mCenter
Vector3 mScale
int mSize
int mWorldSize
String mName
Material * mMaterial
bool mRenderLevelChanged
bool mInit
int mNearPlane
int mMaxPixelError
int mVertResolution
Real mTopCoord
Real old_L
Real current_L
bool mColored
bool mLit
int mForcedRenderLevel
SceneNode * mParentNode
 node to which this object is attached. More...

bool mVisible
 Is this object visible? More...

UserDefinedObject * mUserObject
 User defined object which is linked to this object. More...

RenderQueueGroupID mRenderQueueID
 The render queue to use when rendering this object. More...


Static Protected Attributes

String mType = "TerrainMipMap"
LevelArray mLevelIndex
bool mLevelInit = false

Detailed Description

Represents a terrain tile.

Remarks:
A TerrainRenderable represents a tile used to render a block of terrain using the geomipmap approach for LOD.
Author:
Jon Anderson


Member Enumeration Documentation

enum Ogre::TerrainRenderable::Neighbor
 

Enumeration values:
NORTH 
SOUTH 
EAST 
WEST 
HERE 


Constructor & Destructor Documentation

Ogre::TerrainRenderable::TerrainRenderable (    ) 
 

Ogre::TerrainRenderable::~TerrainRenderable (    ) 
 


Member Function Documentation

void Ogre::TerrainRenderable::_adjustRenderLevel (  int    i )  [protected]
 

void Ogre::TerrainRenderable::_alignNeighbors (    ) 
 

Aligns mipmap levels between neighbors so that only 1 LOD level separates neighbors.

Real Ogre::TerrainRenderable::_calculateCFactor (    )  [protected]
 

void Ogre::TerrainRenderable::_calculateMinLevelDist2 (  Real    C )  [protected]
 

void Ogre::TerrainRenderable::_calculateNormals (    ) 
 

Calculates static normals for lighting the terrain.

bool Ogre::TerrainRenderable::_checkSize (  int    n )  [protected]
 

void Ogre::TerrainRenderable::_generateVertexLighting (  const Vector3 &    sun,
ColourValue    ambient
) 
 

Generates terrain shadows and lighting using vertex colors.

TerrainRenderable* Ogre::TerrainRenderable::_getNeighbor (  Neighbor    n )  [inline]
 

Returns the neighbor TerrainRenderable.

void Ogre::TerrainRenderable::_getNormalAt (  float    x,
float    y,
Vector3 *    result
) 
 

Calculates the normal at the given location.

bool Ogre::TerrainRenderable::_hasNeighborRenderLevel (  int    i )  [inline, protected]
 

int Ogre::TerrainRenderable::_index (  int    x,
int    z
)  [inline, protected]
 

Returns the index into the height array for the given coords.

void Ogre::TerrainRenderable::_initLevelIndexes (    )  [protected]
 

void Ogre::MovableObject::_notifyAttached (  SceneNode *    parent )  [virtual, inherited]
 

Internal method called to notify the object that it has been attached to a node.

Reimplemented in Ogre::SimpleRenderable.

void Ogre::TerrainRenderable::_notifyCurrentCamera (  Camera *    cam )  [virtual]
 

Updates the level of detail to be used for rendering this TerrainRenderable based on the passed in Camera.

Implements Ogre::MovableObject.

int Ogre::TerrainRenderable::_numNeighbors (    )  [inline, protected]
 

void Ogre::TerrainRenderable::_setNeighbor (  Neighbor    n,
TerrainRenderable *    t
)  [inline]
 

Sets the appropriate neighbor for this TerrainRenderable.

Neighbors are necessary to know when to bridge between LODs.

void Ogre::TerrainRenderable::_updateRenderQueue (  RenderQueue *    queue )  [virtual]
 

Internal method by which the movable object must add Renderable subclass instances to the rendering queue.

Remarks:
The engine will call this method when this object is to be rendered. The object must then create one or more Renderable subclass instances which it places on the passed in Queue for rendering.

Implements Ogre::MovableObject.

float Ogre::TerrainRenderable::_vertex (  int    x,
int    z,
int    n
)  [inline, protected]
 

Returns the vertex coord for the given coordinates.

void Ogre::TerrainRenderable::deleteGeometry (    ) 
 

const AxisAlignedBox& Ogre::TerrainRenderable::getBoundingBox (  void    )  const [inline, virtual]
 

Returns the bounding box of this TerrainRenderable.

Implements Ogre::MovableObject.

float Ogre::TerrainRenderable::getHeightAt (  float    x,
float    y
) 
 

Returns the terrain height at the given coordinates.

virtual Material* Ogre::TerrainRenderable::getMaterial (  void    )  const [inline, virtual]
 

Retrieves a pointer to the material this renderable object uses.

Implements Ogre::Renderable.

virtual const String Ogre::TerrainRenderable::getMovableType (  void    )  const [inline, virtual]
 

Returns the type of the movable.

Implements Ogre::MovableObject.

virtual const String& Ogre::TerrainRenderable::getName (  void    )  const [inline, virtual]
 

Returns the name of the TerrainRenderable.

Implements Ogre::MovableObject.

int Ogre::TerrainRenderable::getNumMipMaps (  void    )  [inline]
 

Returns the maximum number of mipmaps used for LOD.

virtual unsigned short Ogre::Renderable::getNumWorldTransforms (  void    )  [inline, virtual, inherited]
 

Returns the number of world transform matrices this renderable requires.

Remarks:
When a renderable uses vertex blending, it uses multiple world matrices instead of a single one. Each vertex sent to the pipeline can reference one or more matrices in this list with given weights. If a renderable does not use vertex blending this method returns 1, which is the default for simplicity.

Reimplemented in Ogre::SubEntity.

SceneNode * Ogre::MovableObject::getParentNode (  void    )  [virtual, inherited]
 

Returns the node to which this object is attached.

Remarks:
An object is not visible in the scene unless attached to a SceneNode.

Attaching an object is done via the SceneNode::attachObject method.

Reimplemented in Ogre::SimpleRenderable.

virtual SceneDetailLevel Ogre::Renderable::getRenderDetail (    )  [inline, virtual, inherited]
 

Returns the preferred rasterisation mode of this renderable.

Reimplemented in Ogre::SubEntity.

int Ogre::TerrainRenderable::getRenderLevel (    )  [inline]
 

Returns the mipmap level that will be rendered for this frame.

void Ogre::TerrainRenderable::getRenderOperation (  RenderOperation &    rend )  [virtual]
 

Constructs a RenderOperation to render the TerrainRenderable.

Remarks:
Each TerrainRenderable has a block of vertices that represent the terrain. Index arrays are dynamically created for mipmap level, and then cached.

Implements Ogre::Renderable.

RenderQueueGroupID Ogre::MovableObject::getRenderQueueGroup (  void    )  [virtual, inherited]
 

Gets the queue group for this entity, see setRenderQueueGroup for full details.

int Ogre::TerrainRenderable::getSize (  void    )  [inline]
 

Returns the size of the TerrainRenderable.

Real Ogre::TerrainRenderable::getSquaredViewDepth (  const Camera *    cam )  const [virtual]
 

Overridden, see Renderable.

Implements Ogre::Renderable.

virtual UserDefinedObject* Ogre::MovableObject::getUserObject (  void    )  [inline, virtual, inherited]
 

Retrieves a pointer to a custom application object associated with this movable by an earlier call to setUserObject.

void Ogre::TerrainRenderable::getWorldTransforms (  Matrix4 *    xform )  [virtual]
 

Gets the world transform matrix / matrices for this renderable object.

Remarks:
If the object has any derived transforms, these are expected to be up to date as long as all the SceneNode structures have been updated before this is called.

This method will populate xform with 1 matrix if it does not use vertex blending. If it does use vertex blending it will fill the passed in pointer with an array of matrices, the length being the value returned from getNumWorldTransforms.

Implements Ogre::Renderable.

void Ogre::TerrainRenderable::init (  TerrainOptions &    options ) 
 

Initializes the TerrainRenderable with the given options.

bool Ogre::TerrainRenderable::intersectSegment (  const Vector3 &    start,
const Vector3 &    end,
Vector3 *    result
) 
 

Intersects the segment witht he terrain tile.

bool Ogre::MovableObject::isAttached (  void    )  const [virtual, inherited]
 

Returns true if this object is attached to a SceneNode.

bool Ogre::MovableObject::isVisible (  void    )  const [virtual, inherited]
 

Returns whether or not this object is supposed to be visible or not.

void Ogre::TerrainRenderable::setForcedRenderLevel (  int    i )  [inline]
 

Forces the LOD to the given level from this point on.

void Ogre::TerrainRenderable::setMaterial (  Material *    m )  [inline]
 

void Ogre::MovableObject::setRenderQueueGroup (  RenderQueueGroupID    queueID )  [virtual, inherited]
 

Sets the render queue group this entity will be rendered through.

Remarks:
Render queues are grouped to allow you to more tightly control the ordering of rendered objects. If you do not call this method, all Entity objects default to RENDER_QUEUE_MAIN which is fine for most objects. You may want to alter this if you want this entity to always appear in front of other objects, e.g. for a 3D menu system or such.

See RenderQueue for more details.

Parameters:
queueID  Enumerated value of the queue group to use.

virtual void Ogre::MovableObject::setUserObject (  UserDefinedObject *    obj )  [inline, virtual, inherited]
 

Call this to associate your own custom user object instance with this MovableObject.

Remarks:
By simply making your game / application object a subclass of UserDefinedObject, you can establish a link between an OGRE instance of MovableObject and your own application classes. Call this method to establish the link.

void Ogre::MovableObject::setVisible (  bool    visible )  [virtual, inherited]
 

Tells this object whether to be visible or not, if it has a renderable component.

Reimplemented in Ogre::Light.

virtual bool Ogre::Renderable::useIdentityProjection (  void    )  [inline, virtual, inherited]
 

Returns whether or not to use an 'identity' projection.

Remarks:
Usually Renderable objects will use a projection matrix as determined by the active camera. However, if they want they can cancel this out and use an identity projection, which effectively projects in 2D using a {-1, 1} view space. Useful for overlay rendering. Normal renderables need not override this.

Reimplemented in Ogre::GuiElement.

virtual bool Ogre::Renderable::useIdentityView (  void    )  [inline, virtual, inherited]
 

Returns whether or not to use an 'identity' projection.

Remarks:
Usually Renderable objects will use a view matrix as determined by the active camera. However, if they want they can cancel this out and use an identity matrix, which means all geometry is assumed to be relative to camera space already. Useful for overlay rendering. Normal renderables need not override this.

Reimplemented in Ogre::GuiElement.


Member Data Documentation

Real Ogre::TerrainRenderable::current_L [protected]
 

AxisAlignedBox Ogre::TerrainRenderable::mBounds [protected]
 

Vector3 Ogre::TerrainRenderable::mCenter [protected]
 

bool Ogre::TerrainRenderable::mColored [protected]
 

int Ogre::TerrainRenderable::mForcedRenderLevel [protected]
 

bool Ogre::TerrainRenderable::mInit [protected]
 

LevelArray Ogre::TerrainRenderable::mLevelIndex [static, protected]
 

bool Ogre::TerrainRenderable::mLevelInit = false [static, protected]
 

bool Ogre::TerrainRenderable::mLit [protected]
 

Material* Ogre::TerrainRenderable::mMaterial [protected]
 

int Ogre::TerrainRenderable::mMaxPixelError [protected]
 

Real* Ogre::TerrainRenderable::mMinLevelDistSqr [protected]
 

String Ogre::TerrainRenderable::mName [protected]
 

int Ogre::TerrainRenderable::mNearPlane [protected]
 

TerrainRenderable* Ogre::TerrainRenderable::mNeighbors[ 4 ] [protected]
 

int Ogre::TerrainRenderable::mNumMipMaps [protected]
 

SceneNode* Ogre::MovableObject::mParentNode [protected, inherited]
 

node to which this object is attached.

int Ogre::TerrainRenderable::mRenderedTris = 0 [static]
 

int Ogre::TerrainRenderable::mRenderLevel [protected]
 

bool Ogre::TerrainRenderable::mRenderLevelChanged [protected]
 

RenderQueueGroupID Ogre::MovableObject::mRenderQueueID [protected, inherited]
 

The render queue to use when rendering this object.

Vector3 Ogre::TerrainRenderable::mScale [protected]
 

int Ogre::TerrainRenderable::mSize [protected]
 

GeometryData Ogre::TerrainRenderable::mTerrain [protected]
 

Real Ogre::TerrainRenderable::mTopCoord [protected]
 

String Ogre::TerrainRenderable::mType = "TerrainMipMap" [static, protected]
 

UserDefinedObject* Ogre::MovableObject::mUserObject [protected, inherited]
 

User defined object which is linked to this object.

int Ogre::TerrainRenderable::mVertResolution [protected]
 

bool Ogre::MovableObject::mVisible [protected, inherited]
 

Is this object visible?

int Ogre::TerrainRenderable::mWorldSize [protected]
 

Real Ogre::TerrainRenderable::old_L [protected]
 

Copyright © 2002 by The OGRE Team