|
|
@@ -114,6 +114,28 @@ public:
|
|
|
LEVEL_OF_DETAIL = 8
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * Interface for various terrain-specific events that can be handled.
|
|
|
+ */
|
|
|
+ class Listener
|
|
|
+ {
|
|
|
+ public:
|
|
|
+
|
|
|
+ virtual ~Listener() { }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Fired when a material is updated for the terrain or a patch within it.
|
|
|
+ *
|
|
|
+ * This method can be handled to override material parameters for the terrain.
|
|
|
+ * Note that this method will usually be fired several times since there are
|
|
|
+ * normally separate materials defined per patch.
|
|
|
+ *
|
|
|
+ * @param terrain The terrain firing the event.
|
|
|
+ * @param material The new material.
|
|
|
+ */
|
|
|
+ virtual void materialUpdated(Terrain* terrain, Material* material) = 0;
|
|
|
+ };
|
|
|
+
|
|
|
/**
|
|
|
* Loads a Terrain from the given properties file.
|
|
|
*
|
|
|
@@ -301,67 +323,91 @@ public:
|
|
|
*/
|
|
|
void transformChanged(Transform* transform, long cookie);
|
|
|
|
|
|
-private:
|
|
|
+ /**
|
|
|
+ * Adds a listener to this terrain.
|
|
|
+ *
|
|
|
+ * @param listener Listener to start receiving terrain events.
|
|
|
+ */
|
|
|
+ void addListener(Terrain::Listener* listener);
|
|
|
|
|
|
/**
|
|
|
- * Constructor.
|
|
|
+ * Removes a listener from this terrain.
|
|
|
+ *
|
|
|
+ * @param listener Listener to stop receiving terrain events.
|
|
|
*/
|
|
|
- Terrain();
|
|
|
+ void removeListener(Terrain::Listener* listener);
|
|
|
|
|
|
/**
|
|
|
- * Hidden copy constructor.
|
|
|
+ * Returns the world matrix of the terrain, factoring in terrain local scaling.
|
|
|
+ *
|
|
|
+ * @return The world matrix for the terrain.
|
|
|
*/
|
|
|
- Terrain(const Terrain&);
|
|
|
+ const Matrix& getWorldMatrix() const;
|
|
|
|
|
|
/**
|
|
|
- * Hidden copy assignment operator.
|
|
|
+ * Returns the terrain's inverse world matrix.
|
|
|
+ *
|
|
|
+ * @return The inverse world matrix for the terrain.
|
|
|
*/
|
|
|
- Terrain& operator=(const Terrain&);
|
|
|
+ const Matrix& getInverseWorldMatrix() const;
|
|
|
|
|
|
/**
|
|
|
- * Destructor.
|
|
|
+ * Returns a matrix to be used for transforming normal vectors for the terrain.
|
|
|
+ *
|
|
|
+ * @return The matrix used for normal vector transformation for the terrain.
|
|
|
*/
|
|
|
- ~Terrain();
|
|
|
+ const Matrix& getNormalMatrix() const;
|
|
|
|
|
|
/**
|
|
|
- * Internal method for creating terrain.
|
|
|
+ * Returns the world view matrix for the terrain, factoring in terrain local scaling.
|
|
|
+ *
|
|
|
+ * @return The world-view matrix for the terrain.
|
|
|
*/
|
|
|
- static Terrain* create(HeightField* heightfield, const Vector3& scale, unsigned int patchSize, unsigned int detailLevels, float skirtScale, const char* normalMapPath, Properties* properties);
|
|
|
+ const Matrix& getWorldViewMatrix() const;
|
|
|
|
|
|
/**
|
|
|
- * Internal method for creating terrain.
|
|
|
+ * Returns the world view projection matrix for the terrain, factoring in terrain local scaling.
|
|
|
+ *
|
|
|
+ * @return The world-view-projection matrix for the terrain.
|
|
|
*/
|
|
|
- static Terrain* create(const char* path, Properties* properties);
|
|
|
+ const Matrix& getWorldViewProjectionMatrix() const;
|
|
|
+
|
|
|
+private:
|
|
|
|
|
|
/**
|
|
|
- * Sets the node that the terrain is attached to.
|
|
|
+ * Constructor.
|
|
|
*/
|
|
|
- void setNode(Node* node);
|
|
|
+ Terrain();
|
|
|
|
|
|
/**
|
|
|
- * Returns the world matrix of the terrain, factoring in terrain local scaling.
|
|
|
+ * Hidden copy constructor.
|
|
|
*/
|
|
|
- const Matrix& getWorldMatrix() const;
|
|
|
+ Terrain(const Terrain&);
|
|
|
|
|
|
/**
|
|
|
- * Returns the terrain's inverse world matrix.
|
|
|
+ * Hidden copy assignment operator.
|
|
|
*/
|
|
|
- const Matrix& getInverseWorldMatrix() const;
|
|
|
+ Terrain& operator=(const Terrain&);
|
|
|
|
|
|
/**
|
|
|
- * Returns a matrix to be used for transforming normal vectors for the terrain.
|
|
|
+ * Destructor.
|
|
|
*/
|
|
|
- const Matrix& getNormalMatrix() const;
|
|
|
+ ~Terrain();
|
|
|
|
|
|
/**
|
|
|
- * Returns the world view matrix for the terrain, factoring in terrain local scaling.
|
|
|
+ * Internal method for creating terrain.
|
|
|
*/
|
|
|
- const Matrix& getWorldViewMatrix() const;
|
|
|
+ static Terrain* create(HeightField* heightfield, const Vector3& scale, unsigned int patchSize, unsigned int detailLevels, float skirtScale, const char* normalMapPath, Properties* properties);
|
|
|
|
|
|
/**
|
|
|
- * Returns the world view projection matrix for the terrain, factoring in terrain local scaling.
|
|
|
+ * Internal method for creating terrain.
|
|
|
*/
|
|
|
- const Matrix& getWorldViewProjectionMatrix() const;
|
|
|
+ static Terrain* create(const char* path, Properties* properties);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets the node that the terrain is attached to.
|
|
|
+ */
|
|
|
+ void setNode(Node* node);
|
|
|
|
|
|
HeightField* _heightfield;
|
|
|
Node* _node;
|
|
|
@@ -374,6 +420,7 @@ private:
|
|
|
mutable Matrix _normalMatrix;
|
|
|
mutable unsigned int _dirtyFlags;
|
|
|
BoundingBox _boundingBox;
|
|
|
+ std::vector<Terrain::Listener*> _listeners;
|
|
|
};
|
|
|
|
|
|
}
|