29 #ifndef __Ogre_TerrainGroup_H__
30 #define __Ogre_TerrainGroup_H__
81 Real terrainWorldSize);
257 virtual void loadTerrain(
long x,
long y,
bool synchronous =
false);
387 : hit(_hit), terrain(_terrain), position(_pos) {}
#define _OgreTerrainExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Variant type that can hold Any other type.
A 3D box aligned with the x/y/z axes.
Concrete IteratorWrapper for const access to the underlying key-value container.
Class representing an image file.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Representation of a ray in space, i.e.
Manages the organisation and rendering of a 'scene' i.e.
A sphere primitive, mostly used for bounds checking.
Utility class providing helper methods for reading / writing structured data held in a DataStream.
Terrain automatic LOD loading.
Helper class to assist you in managing multiple terrain instances that are connected to each other.
bool canHandleRequest(const WorkQueue::Request *req, const WorkQueue *srcQ)
WorkQueue::RequestHandler override.
void unpackIndex(uint32 key, long *x, long *y)
Convert a packed integer index to coordinates.
void saveAllTerrains(bool onlyIfModified, bool replaceManualFilenames=true)
Save all terrain instances using the assigned file names, or via the filename convention.
void convertTerrainSlotToWorldPosition(long x, long y, Vector3 *pos) const
Convert a slot location to a world position at the centre.
void updateGeometry()
Performs an update on all terrain geometry.
virtual Terrain::ImportData & getDefaultImportSettings()
Retrieve a shared structure which will provide the base settings for all terrains created via this gr...
virtual void defineTerrain(long x, long y)
Define a 'slot' in the terrain grid - in this case to be loaded from a generated file name.
MapIterator< TerrainSlotMap > TerrainIterator
float getHeightAtWorldPosition(Real x, Real y, Real z, Terrain **ppTerrain=0)
Get the height data for a given world position (projecting the point down on to the terrain underneat...
void sphereIntersects(const Sphere &sphere, TerrainList *resultList) const
Test intersection of a sphere with the terrain.
const String & getResourceGroup() const
Get the resource group in which files will be located.
static const uint16 CHUNK_VERSION
virtual TerrainSlotDefinition * getTerrainDefinition(long x, long y) const
Get the definition of a slot in the terrain.
TerrainSlot * getTerrainSlot(long x, long y) const
TerrainGroup(SceneManager *sm)
Alternate constructor.
virtual Real getTerrainWorldSize() const
Retrieve the world size of each terrain instance.
virtual void defineTerrain(long x, long y, const Image *img, const Terrain::LayerInstanceList *layers=0)
Define the content of a 'slot' in the terrain grid.
void boxIntersects(const AxisAlignedBox &box, TerrainList *resultList) const
Test intersection of a box with the terrain.
String mFilenameExtension
void saveGroupDefinition(const String &filename)
Save the group data only in native form to a file.
virtual void defineTerrain(long x, long y, const String &filename)
Define the content of a 'slot' in the terrain grid.
void loadGroupDefinition(const String &filename)
Load the group definition only in native form from a file.
ConstTerrainIterator getTerrainIterator() const
Get an iterator over the defined terrains (const)
WorkQueue::Response * handleRequest(const WorkQueue::Request *req, const WorkQueue *srcQ)
WorkQueue::RequestHandler override.
void increaseLodLevel(long x, long y, bool synchronous=false)
Loads terrain's next LOD level.
void decreaseLodLevel(long x, long y)
Removes terrain's highest LOD level.
virtual void defineTerrain(long x, long y, float constantHeight)
Define a 'slot' in the terrain grid - in this case a flat terrain.
const String & getFilenameExtension() const
float getHeightAtWorldPosition(const Vector3 &pos, Terrain **ppTerrain=0)
Get the height data for a given world position (projecting the point down on to the terrain).
virtual void setTerrainWorldSize(Real newWorldSize)
Set the world size of terrain.
void autoUpdateLodAll(bool synchronous, const Any &data)
TerrainSlotMap mTerrainSlots
void convertWorldPositionToTerrainSlot(const Vector3 &pos, long *x, long *y) const
Convert a world position to terrain slot coordinates.
const String & getFilenamePrefix() const
Terrain::ImportData mDefaultImportData
void handleResponse(const WorkQueue::Response *res, const WorkQueue *srcQ)
WorkQueue::ResponseHandler override.
virtual void defineTerrain(long x, long y, const Terrain::ImportData *importData)
Define the content of a 'slot' in the terrain grid.
void saveGroupDefinition(StreamSerialiser &stream)
Save the group data only in native form to a serializing stream.
virtual const Vector3 & getOrigin() const
Retrieve the centre position of the grid of terrain.
void freeTemporaryResources()
Free as many resources as possible for optimal run-time memory use for all terrain tiles.
ConstMapIterator< TerrainSlotMap > ConstTerrainIterator
virtual void defineTerrain(long x, long y, const float *pFloat, const Terrain::LayerInstanceList *layers=0)
Define the content of a 'slot' in the terrain grid.
void setFilenameExtension(const String &extension)
virtual uint16 getTerrainSize() const
Retrieve the size of each terrain instance in number of vertices down one side.
TerrainGroup(SceneManager *sm, Terrain::Alignment align, uint16 terrainSize, Real terrainWorldSize)
Constructor.
String generateFilename(long x, long y) const
Generate a file name based on the current naming convention.
Terrain::Alignment mAlignment
map< uint32, TerrainSlot * >::type TerrainSlotMap
Packed map, signed 16 bits for each axis from -32767 to +32767.
TerrainSlot * getTerrainSlot(long x, long y, bool createIfMissing)
Retrieve a slot, potentially allocate one.
static const uint16 WORKQUEUE_LOAD_REQUEST
Vector3 getTerrainSlotPosition(long x, long y)
Get the position of a terrain instance.
bool isDerivedDataUpdateInProgress() const
Calls Terrain::isDerivedDataUpdateInProgress on each loaded instance and returns true if any of them ...
void loadTerrainImpl(TerrainSlot *slot, bool synchronous)
virtual void loadTerrain(long x, long y, bool synchronous=false)
Load a specific terrain slot based on the definition that has already been supplied.
void setFilenamePrefix(const String &prefix)
SceneManager * mSceneManager
virtual Terrain::Alignment getAlignment() const
Retrieve the alignment of the grid of terrain (cannot be modified after construction).
void loadGroupDefinition(StreamSerialiser &stream)
Load the group definition only in native form from a serializing stream.
TerrainIterator getTerrainIterator()
Get an iterator over the defined terrains.
void setResourceGroup(const String &grp)
Set the resource group in which files will be located.
void setAutoUpdateLod(TerrainAutoUpdateLod *updater)
virtual void setOrigin(const Vector3 &pos)
Define the centre position of the grid of terrain.
void update(bool synchronous=false)
Trigger the update process for all terrain instances.
virtual void removeTerrain(long x, long y)
Remove a specific terrain slot.
void setFilenameConvention(const String &prefix, const String &extension)
Set the naming convention for file names in this terrain group.
void autoUpdateLod(long x, long y, bool synchronous, const Any &data)
Automatically checks if terrain's LOD level needs to be updated.
virtual void loadAllTerrains(bool synchronous=false)
Load any terrain instances that have been defined but not loaded yet.
RayResult rayIntersects(const Ray &ray, Real distanceLimit=0) const
Test for intersection of a given ray with any terrain in the group.
Terrain::DefaultGpuBufferAllocator mBufferAllocator
bool canHandleResponse(const WorkQueue::Response *res, const WorkQueue *srcQ)
WorkQueue::ResponseHandler override.
virtual void setTerrainSize(uint16 newTerrainSize)
Set the size of each terrain instance in number of vertices down one side.
TerrainAutoUpdateLod * mAutoUpdateLod
uint32 packIndex(long x, long y) const
Convert coordinates to a packed integer index.
virtual SceneManager * getSceneManager() const
Retrieve the SceneManager being used for this group.
virtual Terrain * getTerrain(long x, long y) const
Get the terrain instance at a given slot, if loaded.
void connectNeighbour(TerrainSlot *slot, long offsetx, long offsety)
static const uint32 CHUNK_ID
void updateDerivedData(bool synchronous=false, uint8 typeMask=0xFF)
Updates derived data for all terrains (LOD, lighting) to reflect changed height data.
vector< Terrain * >::type TerrainList
virtual void unloadTerrain(long x, long y)
Unload a specific terrain slot.
void removeAllTerrains()
Remove all terrain instances.
Standard implementation of a buffer allocator which re-uses buffers.
The main containing class for a chunk of terrain.
vector< LayerInstance >::type LayerInstanceList
Alignment
The alignment of the terrain.
Standard 3-dimensional vector.
Interface definition for a handler of requests.
General purpose request structure.
Interface definition for a handler of responses.
Interface to a general purpose request / response style background work queue.
float Real
Software floating point type.
Structure for holding the load request.
static uint loadingTaskNum
_OgreTerrainExport friend std::ostream & operator<<(std::ostream &o, const LoadRequest &r)
Result from a terrain ray intersection with the terrain group.
Vector3 position
Position at which the intersection occurred.
RayResult(bool _hit, Terrain *_terrain, const Vector3 &_pos)
bool hit
Whether an intersection occurred.
Terrain * terrain
Which terrain instance was hit, if any.
Definition of how to populate a 'slot' in the terrain group.
Terrain::ImportData * importData
Import data, if this is to be defined based on importing.
void useImportData()
Set to use import data.
void useFilename()
Set to use file name.
String filename
Filename, if this is to be loaded from a file.
void freeImportData()
Destroy temp import resources.
Slot for a terrain instance, together with its definition.
TerrainSlot(long _x, long _y)
long x
The coordinates of the terrain slot relative to the centre slot (signed).
Terrain * instance
Actual terrain instance.
TerrainSlotDefinition def
Definition used to load the terrain.
Structure encapsulating import data that you may use to bootstrap the terrain without loading from a ...
General purpose response structure.