Revision: 1435
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1435&view=rev
Author: rorthomas
Date: 2010-07-13 19:32:43 +0000 (Tue, 13 Jul 2010)
Log Message:
-----------
added new ogre terrain heightfinder, we need to think about if its too slow...
Modified Paths:
--------------
trunk/source/main/heightfinder.h
Modified: trunk/source/main/heightfinder.h
===================================================================
--- trunk/source/main/heightfinder.h 2010-07-13 19:28:10 UTC (rev 1434)
+++ trunk/source/main/heightfinder.h 2010-07-13 19:32:43 UTC (rev 1435)
@@ -24,11 +24,10 @@
#include <OgreVector3.h>
#include "rormemory.h"
-// forward definitions
-//namespace Ogre {
-// class TerrainSceneManager;
-//};
+#include "OgreTerrain.h"
+#include "OgreTerrainGroup.h"
+using namespace Ogre;
/**
* This is the common Interface for all Scenemanager Specific Implementations
of the Heightfinder
*/
@@ -42,6 +41,44 @@
virtual void getNormalAt(float x, float y, float z, Ogre::Vector3
*result, float precision=0.1) = 0;
};
+// new terrain height finder. For the new terrain from Ogre 1.7
+class NTHeightFinder : public HeightFinder, public MemoryAllocatedObject
+{
+protected:
+ TerrainGroup *mTerrainGroup;
+ Vector3 mTerrainPos;
+public:
+ NTHeightFinder(TerrainGroup *tg, Vector3 tp) : mTerrainGroup(tg),
mTerrainPos(tp)
+ {
+ }
+
+ ~NTHeightFinder()
+ {
+ }
+
+ float getHeightAt(float x, float z)
+ {
+ Terrain *t=0;
+ return mTerrainGroup->getHeightAtWorldPosition(x, 1000, z, &t);
+ }
+
+ void getNormalAt(float x, float y, float z, Ogre::Vector3 *result,
float precision=0.1)
+ {
+ Vector3 left, down;
+
+ left.x = -precision;
+ left.y = getHeightAt( x - precision, z ) - y;
+ left.z = 0;
+
+ down.x = 0;
+ down.y = getHeightAt( x, z + precision ) - y;
+ down.z = precision;
+
+ *result = left.crossProduct( down );
+ result->normalise();
+ }
+};
+
// Scene-Manager Specific implementations
/**
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel