fiesch
05-12-2005 14:27:16
i was wondering if you're planning to add these changes to your code:
http://www.ogre3d.org/phpBB2/viewtopic. ... &start=153
or if they were actually added already and I didn't see them...
fiesch
05-12-2005 14:27:16
tuan kuranes
05-12-2005 14:43:59
fiesch
05-12-2005 21:09:53
Jon
05-12-2005 21:10:57
fiesch
05-12-2005 21:51:56
fiesch
05-12-2005 22:03:08
? src/OgrePagingLandscapeVertexDataQuery.cpp
? src/OgrePagingLandscapeVertexDataQuery.h
Index: include/OgrePagingLandScapeIndexBuffer.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeIndexBuffer.h,v
retrieving revision 1.16
diff -u -p -r1.16 OgrePagingLandScapeIndexBuffer.h
--- include/OgrePagingLandScapeIndexBuffer.h 16 Nov 2005 10:44:14 -0000 1.16
+++ include/OgrePagingLandScapeIndexBuffer.h 5 Dec 2005 16:52:16 -0000
@@ -64,6 +64,9 @@ namespace Ogre
/// Internal method for generating triangle list terrain indexes
IndexData* generateTriListIndexes(const bool northStitch, const bool southStitch, const bool eastStitch, const bool westStitch, const int RenderLevel, PagingLandScapeRenderable** Neighbors) const;
+ //*******************
+ //Added by Fiesch adapted from a post by tonyhnz
+ IndexData* getRawIndexes(int renderLevel);
protected:
/** Returns the index into the height array for the given coordinates. */
Index: include/OgrePagingLandScapeRenderable.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderable.h,v
retrieving revision 1.22
diff -u -p -r1.22 OgrePagingLandScapeRenderable.h
--- include/OgrePagingLandScapeRenderable.h 17 Nov 2005 10:51:01 -0000 1.22
+++ include/OgrePagingLandScapeRenderable.h 5 Dec 2005 16:47:08 -0000
@@ -160,6 +160,10 @@ namespace Ogre
bool isInUse() const {return mInUse;};
+ IndexData* getRawIndexData(const int renderlevel);
+ void getRawVertexData(Vector3* pVerts);
+ const uint PagingLandScapeRenderable::getVertexCount();
+
protected:
VertexData* mCurrVertexes;
@@ -220,6 +224,8 @@ namespace Ogre
// did LOD level changes this frame
bool mChangedRenderLevel;
+ Vector3 _getvertex(const int x, const int z) const;
+
private :
Image::Box mRect;
Index: src/OgrePagingLandScapeIndexBuffer.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeIndexBuffer.cpp,v
retrieving revision 1.23
diff -u -p -r1.23 OgrePagingLandScapeIndexBuffer.cpp
--- src/OgrePagingLandScapeIndexBuffer.cpp 28 Nov 2005 15:37:16 -0000 1.23
+++ src/OgrePagingLandScapeIndexBuffer.cpp 5 Dec 2005 16:52:20 -0000
@@ -567,4 +567,41 @@ namespace Ogre
return numIndexes;
}
+ //*******************
+ //Added by Fiesch adapted from a post by tonyhnz
+ IndexData *PagingLandScapeIndexBufferManager::getRawIndexes(int renderLevel)
+ {
+ // no stitching is done
+ // used to expose terrain vertex data
+
+ if (renderLevel >= static_cast <int> (mNumIndexes))
+ renderLevel = static_cast <int> (mNumIndexes)-1;
+
+ if (renderLevel < 0)
+ renderLevel =0 ;
+
+ const uint stitchFlags = 0;
+
+ assert (mLevelIndex.size() > (uint)renderLevel);
+
+ IndexMap::iterator ii = mLevelIndex[ renderLevel ]->find( stitchFlags );
+ if ( ii == mLevelIndex[ renderLevel ]->end())
+ {
+ // Create
+ IndexData* indexData = generateTriListIndexes( false,
+ false,
+ false,
+ false,
+ renderLevel,
+ 0);
+ mLevelIndex[ renderLevel ]->insert(
+ IndexMap::value_type(stitchFlags, indexData));
+
+ return indexData;
+ }
+ else
+ {
+ return ii->second;
+ }
+ }
} //namespace
Index: src/OgrePagingLandScapeRenderable.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeRenderable.cpp,v
retrieving revision 1.45
diff -u -p -r1.45 OgrePagingLandScapeRenderable.cpp
--- src/OgrePagingLandScapeRenderable.cpp 28 Nov 2005 15:37:16 -0000 1.45
+++ src/OgrePagingLandScapeRenderable.cpp 5 Dec 2005 16:52:22 -0000
@@ -1093,4 +1093,39 @@ namespace Ogre
mParentNode->needUpdate();
}
}
+
+ Vector3 PagingLandScapeRenderable::_getvertex(const int x, const int z) const
+ {
+ const uint tilesize = mOpt->TileSize - 1;
+ Vector3 vertex;
+
+ vertex.x = ((mInfo->tileX * tilesize) + x )* mOpt->scale.x;
+ vertex.y = mHeightfield[((mInfo->tileX * tilesize) + x) +
+ ((mInfo->tileZ * tilesize) + z) * mOpt->PageSize ];
+ vertex.z = ((mInfo->tileZ * tilesize) + z)* mOpt->scale.z;
+
+ return vertex;
+ }
+
+ IndexData* PagingLandScapeRenderable::getRawIndexData(const int renderlevel)
+ {
+ return PagingLandScapeIndexBufferManager::getSingleton().getRawIndexes( renderlevel);
+ }
+
+ void PagingLandScapeRenderable::getRawVertexData(Vector3* pVerts)
+ {
+ // pVerts should be pre-allocated to tilesize*tilesize
+ // using getVertexCount()
+ const uint tilesize = mOpt->TileSize ;
+
+ Vector3 *vert = pVerts;
+ for (uint i=0; i<tilesize; ++i)
+ for (uint j=0; j<tilesize; ++j)
+ *vert++ = _getvertex(i, j);
+ }
+
+ const uint PagingLandScapeRenderable::getVertexCount()
+ {
+ return mOpt->TileSize * mOpt->TileSize ;
+ }
} //namespace
Index: src/OgrePagingLandScapeSceneManager.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeSceneManager.cpp,v
retrieving revision 1.52
diff -u -p -r1.52 OgrePagingLandScapeSceneManager.cpp
--- src/OgrePagingLandScapeSceneManager.cpp 28 Nov 2005 15:37:16 -0000 1.52
+++ src/OgrePagingLandScapeSceneManager.cpp 5 Dec 2005 22:00:29 -0000
@@ -52,6 +52,9 @@
#include "OgrePagingLandScapeHorizon.h"
+//added for Vertex data retrieval
+#include "OgrePagingLandscapeVertexDataQuery.h"
+
namespace Ogre
{
@@ -199,7 +202,7 @@ namespace Ogre
if (!mPageManager)
{
mPageManager = new PagingLandScapePageManager();
- mPageManager->setWorldGeometryRenderQueue (SceneManager::getWorldGeometryRenderQueue());
+ mPageManager->setWorldGeometryRenderQueue (static_cast<Ogre::RenderQueueGroupID>(SceneManager::getWorldGeometryRenderQueue()));
Root::getSingleton().addFrameListener(mPageManager);
mData2DManager->setPageManager();
}
@@ -1133,6 +1136,31 @@ namespace Ogre
* static_cast < Real * > (pDestValue) = mBrushScale;
return true;
}
+ //added for Vertex data retrieval
+ if (strKey == "PageGetTileVertexData")
+ {
+ //todo: add the actual code
+ PagingLandScapeVertexDataQuery* vertexQuery = static_cast < PagingLandScapeVertexDataQuery * > (pDestValue);
+ Ogre::PagingLandScapePage* page = PagingLandScapePageManager::getSingleton().getPage(vertexQuery->pageX,vertexQuery->pageZ);
+ if(page)
+ {
+ Ogre::PagingLandScapeTile* tile = page->getTile(vertexQuery->tileX,vertexQuery->tileZ);
+ if(tile)
+ {
+ Ogre::PagingLandScapeRenderable* rend = tile->getRenderable();
+ if(rend)
+ {
+ vertexQuery->numVertices = rend->getVertexCount();
+ vertexQuery->indices = rend->getRawIndexData(vertexQuery->lodLevel);
+ vertexQuery->vertices = new Ogre::Vector3[vertexQuery->numVertices];
+ rend->getRawVertexData(vertexQuery->vertices);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ //end of addition
if (mOptions.getOption(strKey, pDestValue) == false)
{
return PagingLandScapeOctreeSceneManager::getOption (strKey, pDestValue);
@@ -1195,6 +1223,12 @@ namespace Ogre
{
return true;
}
+ //added for Vertex data retrieval
+ if (strKey == "PageGetTileVertexData")
+ {
+ return true;
+ }
+ //end of addition
if (mOptions.hasOption(strKey) == false)
{
return PagingLandScapeOctreeSceneManager::hasOption (strKey);
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright © 2000-2004 The OGRE Team
Also see acknowledgements in Readme.html
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.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt.
-----------------------------------------------------------------------------
*/
/***************************************************************************
OgrePagingLandscapeVertexDataQuery.h - description
-------------------
begin : Mon Dec 05 2006
by : Matthias Fischaleck
email : m.fischaleck@gmx.net
***************************************************************************/
#ifndef _OGRE_PAGING_LANDSCAPE_VERTEX_DATA_QUERY_
#define _OGRE_PAGING_LANDSCAPE_VERTEX_DATA_QUERY_
#include <Ogre.h>
namespace Ogre
{
/**
* Helper class to pass a vertex data query through the getOption mechanism.
* As this is a very simple DataContainer i didn't use data hiding.
*/
class _OgrePagingLandScapeExport PagingLandScapeVertexDataQuery
{
private:
protected:
public:
IndexData* indices;
Ogre::Vector3* vertices;
Ogre::uint pageX;
Ogre::uint pageZ;
Ogre::uint tileX;
Ogre::uint tileZ;
Ogre::uint lodLevel;
Ogre::uint numVertices;
PagingLandScapeVertexDataQuery();
PagingLandScapeVertexDataQuery(Ogre::uint setPageX,Ogre::uint setPageZ,Ogre::uint setTileX,Ogre::uint setTileZ, Ogre::uint atLevel);
~PagingLandScapeVertexDataQuery();
};
}
#endif
#include "OgrePagingLandscapeVertexDataQuery.h"
using namespace Ogre;
/**
* Constructor. Simple var-init
*/
PagingLandScapeVertexDataQuery::PagingLandScapeVertexDataQuery()
{
pageX = 0;
pageZ = 0;
tileX = 0;
tileZ = 0;
lodLevel = 0;
numVertices = 0;
indices = NULL;
vertices = NULL;
}
/**
* Constructor. Simple var-init
* @param setPageX x value of the page to get the data for
* @param setPageY y value of the page to get the data for
* @param setTileX x value of the tile within the specified page to get the data for
* @param setTileY y value of the tile within the specified page to get the data for
* @param atLevel LodLevel to get the data at
*/
PagingLandScapeVertexDataQuery::PagingLandScapeVertexDataQuery(Ogre::uint setPageX,Ogre::uint setPageZ,Ogre::uint setTileX,Ogre::uint setTileZ, Ogre::uint atLevel)
{
pageX = setPageX;
pageZ = setPageZ;
tileX = setTileX;
tileZ = setTileZ;
lodLevel = atLevel;
numVertices = 0;
indices = NULL;
vertices = NULL;
}
/**
* Deconstructor. NOP
*/
PagingLandScapeVertexDataQuery::~PagingLandScapeVertexDataQuery()
{
}
fiesch
05-12-2005 22:08:45
fiesch
05-12-2005 22:19:55
fiesch
06-12-2005 11:45:13
------ Build started: Project: client_a2, Configuration: Release Win32 ------
Linking...
NewtonTerrainHelper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const Ogre::PagingLandScapeListener::`vftable'" (__imp_??_7PagingLandScapeListener@Ogre@@6B@) referenced in function "public: virtual __thiscall NewtonTerrainHelper::~NewtonTerrainHelper(void)" (??1NewtonTerrainHelper@@UAE@XZ)
Release/canipes.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\dev\client\Release\obj\BuildLog.htm"
client_a2 - 2 error(s), 0 warning(s)
------ Build started: Project: client_a2, Configuration: Debug Win32 ------
Linking...
NewtonTerrainHelper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Ogre::PagingLandScapeListener::PagingLandScapeListener(void)" (__imp_??0PagingLandScapeListener@Ogre@@QAE@XZ) referenced in function "public: __thiscall NewtonTerrainHelper::NewtonTerrainHelper(class OgreNewt::World *)" (??0NewtonTerrainHelper@@QAE@PAVWorld@OgreNewt@@@Z)
NewtonTerrainHelper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Ogre::PagingLandScapeListener::~PagingLandScapeListener(void)" (__imp_??1PagingLandScapeListener@Ogre@@UAE@XZ) referenced in function "public: virtual __thiscall NewtonTerrainHelper::~NewtonTerrainHelper(void)" (??1NewtonTerrainHelper@@UAE@XZ)
Debug/canipes.exe : fatal error LNK1120: 2 unresolved externals
fiesch
06-12-2005 12:54:45
tuan kuranes
06-12-2005 13:25:32
fiesch
06-12-2005 14:18:54
Index: include/OgrePagingLandScapeIndexBuffer.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeIndexBuffer.h,v
retrieving revision 1.16
diff -u -p -r1.16 OgrePagingLandScapeIndexBuffer.h
--- include/OgrePagingLandScapeIndexBuffer.h 16 Nov 2005 10:44:14 -0000 1.16
+++ include/OgrePagingLandScapeIndexBuffer.h 5 Dec 2005 16:52:16 -0000
@@ -64,6 +64,9 @@ namespace Ogre
/// Internal method for generating triangle list terrain indexes
IndexData* generateTriListIndexes(const bool northStitch, const bool southStitch, const bool eastStitch, const bool westStitch, const int RenderLevel, PagingLandScapeRenderable** Neighbors) const;
+ //*******************
+ //Added by Fiesch adapted from a post by tonyhnz
+ IndexData* getRawIndexes(int renderLevel);
protected:
/** Returns the index into the height array for the given coordinates. */
Index: include/OgrePagingLandScapeRenderable.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderable.h,v
retrieving revision 1.22
diff -u -p -r1.22 OgrePagingLandScapeRenderable.h
--- include/OgrePagingLandScapeRenderable.h 17 Nov 2005 10:51:01 -0000 1.22
+++ include/OgrePagingLandScapeRenderable.h 5 Dec 2005 16:47:08 -0000
@@ -160,6 +160,10 @@ namespace Ogre
bool isInUse() const {return mInUse;};
+ IndexData* getRawIndexData(const int renderlevel);
+ void getRawVertexData(Vector3* pVerts);
+ const uint PagingLandScapeRenderable::getVertexCount();
+
protected:
VertexData* mCurrVertexes;
@@ -220,6 +224,8 @@ namespace Ogre
// did LOD level changes this frame
bool mChangedRenderLevel;
+ Vector3 _getvertex(const int x, const int z) const;
+
private :
Image::Box mRect;
Index: include/OgrePagingLandScapeSceneManager.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeSceneManager.h,v
retrieving revision 1.27
diff -u -p -r1.27 OgrePagingLandScapeSceneManager.h
--- include/OgrePagingLandScapeSceneManager.h 9 Nov 2005 17:32:45 -0000 1.27
+++ include/OgrePagingLandScapeSceneManager.h 6 Dec 2005 13:25:47 -0000
@@ -328,6 +328,12 @@ namespace Ogre
uint mBrushSize;
Real mBrushScale;
+ uint requestPageX;
+ uint requestPageZ;
+ uint requestTileX;
+ uint requestTileZ;
+ uint requestLodLevel;
+
Real* mCraterArray;
Real* mBrushArray;
Index: src/OgrePagingLandScapeIndexBuffer.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeIndexBuffer.cpp,v
retrieving revision 1.23
diff -u -p -r1.23 OgrePagingLandScapeIndexBuffer.cpp
--- src/OgrePagingLandScapeIndexBuffer.cpp 28 Nov 2005 15:37:16 -0000 1.23
+++ src/OgrePagingLandScapeIndexBuffer.cpp 5 Dec 2005 16:52:20 -0000
@@ -567,4 +567,41 @@ namespace Ogre
return numIndexes;
}
+ //*******************
+ //Added by Fiesch adapted from a post by tonyhnz
+ IndexData *PagingLandScapeIndexBufferManager::getRawIndexes(int renderLevel)
+ {
+ // no stitching is done
+ // used to expose terrain vertex data
+
+ if (renderLevel >= static_cast <int> (mNumIndexes))
+ renderLevel = static_cast <int> (mNumIndexes)-1;
+
+ if (renderLevel < 0)
+ renderLevel =0 ;
+
+ const uint stitchFlags = 0;
+
+ assert (mLevelIndex.size() > (uint)renderLevel);
+
+ IndexMap::iterator ii = mLevelIndex[ renderLevel ]->find( stitchFlags );
+ if ( ii == mLevelIndex[ renderLevel ]->end())
+ {
+ // Create
+ IndexData* indexData = generateTriListIndexes( false,
+ false,
+ false,
+ false,
+ renderLevel,
+ 0);
+ mLevelIndex[ renderLevel ]->insert(
+ IndexMap::value_type(stitchFlags, indexData));
+
+ return indexData;
+ }
+ else
+ {
+ return ii->second;
+ }
+ }
} //namespace
Index: src/OgrePagingLandScapeRenderable.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeRenderable.cpp,v
retrieving revision 1.45
diff -u -p -r1.45 OgrePagingLandScapeRenderable.cpp
--- src/OgrePagingLandScapeRenderable.cpp 28 Nov 2005 15:37:16 -0000 1.45
+++ src/OgrePagingLandScapeRenderable.cpp 5 Dec 2005 16:52:22 -0000
@@ -1093,4 +1093,39 @@ namespace Ogre
mParentNode->needUpdate();
}
}
+
+ Vector3 PagingLandScapeRenderable::_getvertex(const int x, const int z) const
+ {
+ const uint tilesize = mOpt->TileSize - 1;
+ Vector3 vertex;
+
+ vertex.x = ((mInfo->tileX * tilesize) + x )* mOpt->scale.x;
+ vertex.y = mHeightfield[((mInfo->tileX * tilesize) + x) +
+ ((mInfo->tileZ * tilesize) + z) * mOpt->PageSize ];
+ vertex.z = ((mInfo->tileZ * tilesize) + z)* mOpt->scale.z;
+
+ return vertex;
+ }
+
+ IndexData* PagingLandScapeRenderable::getRawIndexData(const int renderlevel)
+ {
+ return PagingLandScapeIndexBufferManager::getSingleton().getRawIndexes( renderlevel);
+ }
+
+ void PagingLandScapeRenderable::getRawVertexData(Vector3* pVerts)
+ {
+ // pVerts should be pre-allocated to tilesize*tilesize
+ // using getVertexCount()
+ const uint tilesize = mOpt->TileSize ;
+
+ Vector3 *vert = pVerts;
+ for (uint i=0; i<tilesize; ++i)
+ for (uint j=0; j<tilesize; ++j)
+ *vert++ = _getvertex(i, j);
+ }
+
+ const uint PagingLandScapeRenderable::getVertexCount()
+ {
+ return mOpt->TileSize * mOpt->TileSize ;
+ }
} //namespace
Index: src/OgrePagingLandScapeSceneManager.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeSceneManager.cpp,v
retrieving revision 1.52
diff -u -p -r1.52 OgrePagingLandScapeSceneManager.cpp
--- src/OgrePagingLandScapeSceneManager.cpp 28 Nov 2005 15:37:16 -0000 1.52
+++ src/OgrePagingLandScapeSceneManager.cpp 6 Dec 2005 13:55:01 -0000
@@ -199,7 +199,7 @@ namespace Ogre
if (!mPageManager)
{
mPageManager = new PagingLandScapePageManager();
- mPageManager->setWorldGeometryRenderQueue (SceneManager::getWorldGeometryRenderQueue());
+ mPageManager->setWorldGeometryRenderQueue (static_cast<Ogre::RenderQueueGroupID>(SceneManager::getWorldGeometryRenderQueue()));
Root::getSingleton().addFrameListener(mPageManager);
mData2DManager->setPageManager();
}
@@ -852,6 +852,33 @@ namespace Ogre
// Now reload pages
//PagingLandScapePageManager::getSingleton().getPage(page.x, page.y)->reload();
}
+ //added for Vertex data retrieval
+ if (strKey == "PageGetVertexData_SourcePageX")
+ {
+ requestPageX = *static_cast < const uint * > (pValue);
+ return true;
+ }
+ if (strKey == "PageGetVertexData_SourcePageZ")
+ {
+ requestPageZ = *static_cast < const uint * > (pValue);
+ return true;
+ }
+ if (strKey == "PageGetVertexData_SourceTileX")
+ {
+ requestTileX = *static_cast < const uint * > (pValue);
+ return true;
+ }
+ if (strKey == "PageGetVertexData_SourceTileZ")
+ {
+ requestTileZ = *static_cast < const uint * > (pValue);
+ return true;
+ }
+ if (strKey == "PageGetVertexData_FromLodLevel")
+ {
+ requestLodLevel = *static_cast < const uint * > (pValue);
+ return true;
+ }
+ //addition ends
if (mOptions.setOption(strKey, pValue) == true)
{
return true;
@@ -1133,6 +1160,88 @@ namespace Ogre
* static_cast < Real * > (pDestValue) = mBrushScale;
return true;
}
+ //added for Vertex data retrieval
+ if (strKey == "PageGetVertexData_SourcePageX")
+ {
+ *static_cast < uint * > (pDestValue) = requestPageX;
+ return true;
+ }
+ if (strKey == "PageGetVertexData_SourcePageZ")
+ {
+ *static_cast < uint * > (pDestValue) = requestPageZ;
+ return true;
+ }
+ if (strKey == "PageGetVertexData_SourceTileX")
+ {
+ *static_cast < uint * > (pDestValue) = requestTileX;
+ return true;
+ }
+ if (strKey == "PageGetVertexData_SourceTileZ")
+ {
+ *static_cast < uint * > (pDestValue) = requestTileZ;
+ return true;
+ }
+ if (strKey == "PageGetVertexData_FromLodLevel")
+ {
+ *static_cast < uint * > (pDestValue) = requestLodLevel;
+ return true;
+ }
+ if (strKey == "PageGetTileVertexCount")
+ {
+ Ogre::PagingLandScapePage* page = PagingLandScapePageManager::getSingleton().getPage(requestPageX,requestPageZ);
+ if(page)
+ {
+ Ogre::PagingLandScapeTile* tile = page->getTile(requestTileX,requestTileZ);
+ if(tile)
+ {
+ Ogre::PagingLandScapeRenderable* rend = tile->getRenderable();
+ if(rend)
+ {
+ *static_cast < uint * > (pDestValue) = rend->getVertexCount();
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ if (strKey == "PageGetTileVertexData")
+ {
+ Ogre::PagingLandScapePage* page = PagingLandScapePageManager::getSingleton().getPage(requestPageX,requestPageZ);
+ if(page)
+ {
+ Ogre::PagingLandScapeTile* tile = page->getTile(requestTileX,requestTileZ);
+ if(tile)
+ {
+ Ogre::PagingLandScapeRenderable* rend = tile->getRenderable();
+ if(rend)
+ {
+ //warning! make sure that the allocated space for the vertices is big enough!
+ rend->getRawVertexData(*static_cast < Ogre::Vector3 ** > (pDestValue));
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ if (strKey == "PageGetTileVertexIndexData")
+ {
+ Ogre::PagingLandScapePage* page = PagingLandScapePageManager::getSingleton().getPage(requestPageX,requestPageZ);
+ if(page)
+ {
+ Ogre::PagingLandScapeTile* tile = page->getTile(requestTileX,requestTileZ);
+ if(tile)
+ {
+ Ogre::PagingLandScapeRenderable* rend = tile->getRenderable();
+ if(rend)
+ {
+ *static_cast < Ogre::IndexData** > (pDestValue) = rend->getRawIndexData(requestLodLevel);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ //end of addition
if (mOptions.getOption(strKey, pDestValue) == false)
{
return PagingLandScapeOctreeSceneManager::getOption (strKey, pDestValue);
@@ -1195,6 +1304,12 @@ namespace Ogre
{
return true;
}
+ //added for Vertex data retrieval
+ if (strKey == "PageGetTileVertexData")
+ {
+ return true;
+ }
+ //end of addition
if (mOptions.hasOption(strKey) == false)
{
return PagingLandScapeOctreeSceneManager::hasOption (strKey);
tuan kuranes
06-12-2005 14:56:23
fiesch
06-12-2005 15:07:31
fiesch
07-12-2005 13:11:03
tuan kuranes
07-12-2005 13:48:26
fiesch
07-12-2005 14:05:10
tuan kuranes
07-12-2005 14:25:13
fiesch
07-12-2005 15:30:50
tuan kuranes
07-12-2005 15:40:02
const uint pSize = mOptions->PageSize - 1;
vertex.x +=mInfo->pageX * pSize - mOptions->maxUnScaledX;
vertex.z += mInfo->pageZ * pSize - mOptions->maxUnScaledZ;
fiesch
07-12-2005 16:02:14
tuan kuranes
07-12-2005 17:13:49
const uint pSize = mOptions->PageSize - 1;
const uint tilesize = mOpt->TileSize - 1;
Vector3 vertex;
// change coordinate system for local tile to local page
vertex.x = (mInfo->tileX * tilesize) + x );
vertex.z = (mInfo->tileX * tilesize) + z );
// y is already scaled and worldspace
vertex.y = mHeightfield[vertex.x + vertex.z * mOpt->PageSize ];
// change coordinate system for local page to world space
vertex.x + =mInfo->pageX * pSize - mOptions->maxUnScaledX;
vertex.z + = mInfo->pageZ * pSize - mOptions->maxUnScaledZ;
// then scale it
vertex.x *= mOpt->scale.x;
vertex.z *= mOpt->scale.z;
fiesch
08-12-2005 11:42:12
Index: include/OgrePagingLandScapeIndexBuffer.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeIndexBuffer.h,v
retrieving revision 1.16
diff -u -p -r1.16 OgrePagingLandScapeIndexBuffer.h
--- include/OgrePagingLandScapeIndexBuffer.h 16 Nov 2005 10:44:14 -0000 1.16
+++ include/OgrePagingLandScapeIndexBuffer.h 5 Dec 2005 16:52:16 -0000
@@ -64,6 +64,9 @@ namespace Ogre
/// Internal method for generating triangle list terrain indexes
IndexData* generateTriListIndexes(const bool northStitch, const bool southStitch, const bool eastStitch, const bool westStitch, const int RenderLevel, PagingLandScapeRenderable** Neighbors) const;
+ //*******************
+ //Added by Fiesch adapted from a post by tonyhnz
+ IndexData* getRawIndexes(int renderLevel);
protected:
/** Returns the index into the height array for the given coordinates. */
Index: include/OgrePagingLandScapeRenderable.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderable.h,v
retrieving revision 1.22
diff -u -p -r1.22 OgrePagingLandScapeRenderable.h
--- include/OgrePagingLandScapeRenderable.h 17 Nov 2005 10:51:01 -0000 1.22
+++ include/OgrePagingLandScapeRenderable.h 5 Dec 2005 16:47:08 -0000
@@ -160,6 +160,10 @@ namespace Ogre
bool isInUse() const {return mInUse;};
+ IndexData* getRawIndexData(const int renderlevel);
+ void getRawVertexData(Vector3* pVerts);
+ const uint PagingLandScapeRenderable::getVertexCount();
+
protected:
VertexData* mCurrVertexes;
@@ -220,6 +224,8 @@ namespace Ogre
// did LOD level changes this frame
bool mChangedRenderLevel;
+ Vector3 _getvertex(const int x, const int z) const;
+
private :
Image::Box mRect;
Index: src/OgrePagingLandScapeIndexBuffer.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeIndexBuffer.cpp,v
retrieving revision 1.23
diff -u -p -r1.23 OgrePagingLandScapeIndexBuffer.cpp
--- src/OgrePagingLandScapeIndexBuffer.cpp 28 Nov 2005 15:37:16 -0000 1.23
+++ src/OgrePagingLandScapeIndexBuffer.cpp 5 Dec 2005 16:52:20 -0000
@@ -567,4 +567,41 @@ namespace Ogre
return numIndexes;
}
+ //*******************
+ //Added by Fiesch adapted from a post by tonyhnz
+ IndexData *PagingLandScapeIndexBufferManager::getRawIndexes(int renderLevel)
+ {
+ // no stitching is done
+ // used to expose terrain vertex data
+
+ if (renderLevel >= static_cast <int> (mNumIndexes))
+ renderLevel = static_cast <int> (mNumIndexes)-1;
+
+ if (renderLevel < 0)
+ renderLevel =0 ;
+
+ const uint stitchFlags = 0;
+
+ assert (mLevelIndex.size() > (uint)renderLevel);
+
+ IndexMap::iterator ii = mLevelIndex[ renderLevel ]->find( stitchFlags );
+ if ( ii == mLevelIndex[ renderLevel ]->end())
+ {
+ // Create
+ IndexData* indexData = generateTriListIndexes( false,
+ false,
+ false,
+ false,
+ renderLevel,
+ 0);
+ mLevelIndex[ renderLevel ]->insert(
+ IndexMap::value_type(stitchFlags, indexData));
+
+ return indexData;
+ }
+ else
+ {
+ return ii->second;
+ }
+ }
} //namespace
Index: src/OgrePagingLandScapeRenderable.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeRenderable.cpp,v
retrieving revision 1.45
diff -u -p -r1.45 OgrePagingLandScapeRenderable.cpp
--- src/OgrePagingLandScapeRenderable.cpp 28 Nov 2005 15:37:16 -0000 1.45
+++ src/OgrePagingLandScapeRenderable.cpp 8 Dec 2005 11:24:35 -0000
@@ -1093,4 +1093,65 @@ namespace Ogre
mParentNode->needUpdate();
}
}
+
+ Vector3 PagingLandScapeRenderable::_getvertex(const int x, const int z) const
+ {
+ const uint tilesize = mOpt->TileSize - 1;
+ const uint pSize = mOpt->PageSize -1;
+ Vector3 vertex;
+
+ vertex.x = (mInfo->tileX * tilesize) + x;
+
+ vertex.z = (mInfo->tileZ * tilesize) + z;
+
+ vertex.y = mHeightfield[static_cast<unsigned int>(vertex.x + (vertex.z *mOpt->PageSize) )];
+
+ vertex.x += mInfo->pageX * pSize - mOpt->maxUnScaledX;
+ vertex.z += mInfo->pageZ * pSize - mOpt->maxUnScaledZ;
+
+ vertex.x *= mOpt->scale.x;
+ vertex.z *= mOpt->scale.z;
+ return vertex;
+ }
+
+ /**
+ * This returns the actual Polygon assignments for this renderable at the given renderLevel
+ * @param renderlevel LODLevel to get the Index data at
+ * @return the queried IndexData
+ */
+ IndexData* PagingLandScapeRenderable::getRawIndexData(const int renderlevel)
+ {
+ return PagingLandScapeIndexBufferManager::getSingleton().getRawIndexes( renderlevel);
+ }
+
+ /**
+ * Returns the Vertices for this renderable in world space
+ * @param pVerts >Pre-allocated< buffer to hold the vertices. The number of Vertices can be
+ * retrieved by a call to getVertexCount
+ * @note no checking is done on the array whatsoever
+ */
+ void PagingLandScapeRenderable::getRawVertexData(Vector3* pVerts)
+ {
+ // pVerts should be pre-allocated to tilesize*tilesize
+ // using getVertexCount()
+ const uint tilesize = mOpt->TileSize -1 ;
+
+ Vector3 *vert = pVerts;
+ for (uint i=0; i<=tilesize; ++i)
+ {
+ for (uint j=0; j<=tilesize; ++j)
+ {
+ *vert++= _getvertex(i, j);
+ }
+ }
+ }
+
+ /**
+ * Returns the number of this Renderable's vertices
+ * @return the number of this Renderable's vertices
+ */
+ const uint PagingLandScapeRenderable::getVertexCount()
+ {
+ return mOpt->TileSize * mOpt->TileSize ;
+ }
} //namespace
Index: src/OgrePagingLandScapeSceneManager.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeSceneManager.cpp,v
retrieving revision 1.52
diff -u -p -r1.52 OgrePagingLandScapeSceneManager.cpp
--- src/OgrePagingLandScapeSceneManager.cpp 28 Nov 2005 15:37:16 -0000 1.52
+++ src/OgrePagingLandScapeSceneManager.cpp 8 Dec 2005 09:15:17 -0000
@@ -137,6 +137,8 @@ namespace Ogre
//-------------------------------------------------------------------------
void PagingLandScapeSceneManager::setWorldGeometry(DataStreamPtr& stream, const String& typeName)
{
+ if (!mListenerManager)
+ mListenerManager = new PagingLandScapeListenerManager();
// Clear out any existing world resources (if not default)
if (ResourceGroupManager::getSingleton().getWorldResourceGroupName() !=
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME)
@@ -199,7 +201,7 @@ namespace Ogre
if (!mPageManager)
{
mPageManager = new PagingLandScapePageManager();
- mPageManager->setWorldGeometryRenderQueue (SceneManager::getWorldGeometryRenderQueue());
+ mPageManager->setWorldGeometryRenderQueue (static_cast<Ogre::RenderQueueGroupID>(SceneManager::getWorldGeometryRenderQueue()));
Root::getSingleton().addFrameListener(mPageManager);
mData2DManager->setPageManager();
}
@@ -852,7 +854,7 @@ namespace Ogre
// Now reload pages
//PagingLandScapePageManager::getSingleton().getPage(page.x, page.y)->reload();
}
- if (mOptions.setOption(strKey, pValue) == true)
+ if (mOptions.setOption(strKey, pValue) == true)
{
return true;
}
@@ -1133,6 +1135,53 @@ namespace Ogre
* static_cast < Real * > (pDestValue) = mBrushScale;
return true;
}
+ //added for Vertex data retrieval
+ /**
+ * This is the optimized, yet a bit fuzzy implementation of the getVertexDataPatch
+ * Usage: Pass in a std::vector<void*> Pointer to the getOption call containing at least 5 Elements
+ * [0](Ogre::uint*) = X Index of the Page to retrieve data from
+ * [1](Ogre::uint*) = Z Index of the Page to retrieve data from
+ * [2](Ogre::uint*) = X Index of the Tile within the Page to retrieve data from
+ * [3](Ogre::uint*) = Z Index of the Tile within the Page to retrieve data from
+ * [4](Ogre::uint*) = LodLevel to get the data at (note that level 0 means highest detail)
+ * The getData call will then append 3 entries to the end of the vector. In Detail(in order)
+ * [End-2](Ogre::uint*) = Number of vertices returned
+ * [End-1] (Ogre::Vector3*) = The actual vertices, this is a array containing as many elements as returned in [End-2]
+ * [End] (Ogre::IndexData*) = The index data for the terrain polygons at the queried LodLevel
+ * @remark note that the caller is in charge of deleting the vector array
+ */
+ if (strKey == "PageGetTileVertexData_2")
+ {
+ uint requestPageX = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[0]);
+ uint requestPageZ = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[1]);
+ uint requestTileX = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[2]);
+ uint requestTileZ = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[3]);
+ uint requestLodLevel = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[4]);
+ Ogre::PagingLandScapePage* page = PagingLandScapePageManager::getSingleton().getPage(requestPageX,requestPageZ);
+ if(page)
+ {
+ Ogre::PagingLandScapeTile* tile = page->getTile(requestTileX,requestTileZ);
+ if(tile)
+ {
+ Ogre::PagingLandScapeRenderable* rend = tile->getRenderable();
+ if(rend)
+ {
+ Ogre::Vector3* tempPointer; //This will hold the vertexData and needs to be deleted by the caller
+ uint* numPtr = new uint;
+ *numPtr = rend->getVertexCount();
+ (*static_cast<std::vector<void*>*>(pDestValue)).push_back(numPtr);
+ tempPointer = new Ogre::Vector3[*numPtr];
+ //warning! make sure that the allocated space for the vertices is big enough!
+ rend->getRawVertexData(tempPointer);
+ (*static_cast<std::vector<void*>*>(pDestValue)).push_back(tempPointer);
+ (*static_cast<std::vector<void*>*>(pDestValue)).push_back(rend->getRawIndexData(requestLodLevel));
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ //end of addition
if (mOptions.getOption(strKey, pDestValue) == false)
{
return PagingLandScapeOctreeSceneManager::getOption (strKey, pDestValue);
@@ -1195,6 +1244,12 @@ namespace Ogre
{
return true;
}
+ //added for Vertex data retrieval
+ if (strKey == "PageGetTileVertexData")
+ {
+ return true;
+ }
+ //end of addition
if (mOptions.hasOption(strKey) == false)
{
return PagingLandScapeOctreeSceneManager::hasOption (strKey);
tuan kuranes
16-12-2005 14:26:18
dimatd
06-01-2006 22:42:08
cvs diff: Diffing include
Index: include/OgrePagingLandScapeRenderable.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderable.h,v
retrieving revision 1.23
diff -r1.23 OgrePagingLandScapeRenderable.h
166a167,168
> inline VertexData* getCurrVertexes(){return mCurrVertexes;}
>
cvs diff: Diffing misc
cvs diff: Diffing obj
cvs diff: Diffing obj/Debug
cvs diff: Diffing obj/Release
cvs diff: Diffing scripts
cvs diff: Diffing src
Index: src/OgrePagingLandScapeSceneManager.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeSceneManager.cpp,v
retrieving revision 1.56
diff -r1.56 OgrePagingLandScapeSceneManager.cpp
1194a1195,1230
> if (strKey == "PageGetTileCurrentVertexData")
> {
> uint requestPageX = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[0]);
> uint requestPageZ = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[1]);
> uint requestTileX = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[2]);
> uint requestTileZ = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[3]);
> uint requestLodLevel = *static_cast<uint *>((*static_cast<std::vector<void*>*>(pDestValue))[4]);
> Ogre::PagingLandScapePage* page = PagingLandScapePageManager::getSingleton().getPage(requestPageX,requestPageZ);
> if(page)
> {
> Ogre::PagingLandScapeTile* tile = page->getTile(requestTileX,requestTileZ);
> if(tile)
> {
> Ogre::PagingLandScapeRenderable* rend = tile->getRenderable();
> if(rend)
> {
> //Ogre::Vector3* tempPointer; //This will hold the vertexData and needs to be deleted by the caller
> //uint* numPtr = new uint;
> //*numPtr = rend->getVertexCount();
> //(*static_cast<std::vector<void*>*>(pDestValue)).push_back(numPtr);
> //tempPointer = new Ogre::Vector3[*numPtr];
> //warning! make sure that the allocated space for the vertices is big enough!
> //rend->getRawVertexData(tempPointer);
> static Ogre::Vector3 vera_tempPointer;
> //tempPointer = new Ogre::Vector3;
> vera_tempPointer = page->getPageNode()->getPosition();
> (*static_cast<std::vector<void*>*>(pDestValue)).push_back(rend->getCurrVertexes());
> (*static_cast<std::vector<void*>*>(pDestValue)).push_back(rend->getRawIndexData(requestLodLevel));
> (*static_cast<std::vector<void*>*>(pDestValue)).push_back(&vera_tempPointer);
> return true;
> }
> }
> }
> return false;
> }
tuan kuranes
07-01-2006 07:09:38
dimatd
16-01-2006 14:10:38
void VeraWorldManager::tileLoaded(PagingLandscapeEvent *p)
{
std::vector<void*> tile;
Ogre::uint *q = new Ogre::uint [5];
Ogre::String name;
q[0] = static_cast<Ogre::uint>(p->mPagex);
q[1] = static_cast<Ogre::uint>(p->mPagez);
q[2] = static_cast<Ogre::uint>(p->mTilex);
q[3] = static_cast<Ogre::uint>(p->mTilez);
q[4] = 2;
for(Ogre::uint i=0; i < 5; i++){
tile.push_back(&q[i]);
name += Ogre::StringConverter::toString(q[i]);
}
nxTile &nxtile = mapTiles[name];
if(!nxtile.isLoad()){
nxtile.setLoad();
nxtile.setName(name);
mSceneMgr->getOption("PageGetTileVertexData_2", &tile);
uint* count = static_cast<uint*>(tile[5]);
Ogre::Vector3 *vectex = static_cast<Ogre::Vector3 *>(tile[6]);
Ogre::IndexData *mIndex = static_cast<Ogre::IndexData *>(tile[7]);
Vera::TriangleShapeDesc tmp_mesh(vectex, *count, mIndex);
mSceneNodeDescManager->createSceneNodeDesc(tmp_mesh, name);
mScenes[MainScene]->createSceneNode(tiles++, name.c_str());
}
delete [] q;
}
TriangleShapeDesc::TriangleShapeDesc(Ogre::Vector3 *vertex, Ogre::uint size, Ogre::IndexData* _index)
{
size_t index_offset = 0;
Ogre::uint _numVertices = size;
Ogre::uint mIndexCount = static_cast<Ogre::uint>(_index->indexCount);
NxVec3* mMeshVertices = new NxVec3[_numVertices];
NxU32* mMeshFaces = new NxU32[mIndexCount];
for(Ogre::uint i=0; i < size; i++){
mMeshVertices[i] = NxTools::convert(vertex[i]);
}
size_t numTris = _index->indexCount / 3;
Ogre::HardwareIndexBufferSharedPtr ibuf = _index->indexBuffer;
bool use32bitindexes = (ibuf->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
if ( use32bitindexes ) {
unsigned int* pInt = static_cast<unsigned int*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
size_t offset = 0;
for ( size_t k = 0; k < numTris*3; ++k) {
mMeshFaces[index_offset++] = pInt[k];
}
}
else {
unsigned short* pShort = reinterpret_cast<unsigned short*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
size_t offset = 0;
for ( size_t k = 0; k < numTris*3; ++k) {
mMeshFaces[index_offset++] = static_cast<unsigned int>(pShort[k]);
}
}
ibuf->unlock();
NxTriangleMeshDesc terrainDesc;
terrainDesc.numVertices = _numVertices;
terrainDesc.numTriangles = mIndexCount / 3;
terrainDesc.pointStrideBytes = sizeof(NxVec3);
terrainDesc.triangleStrideBytes = 3*sizeof(NxU32);
terrainDesc.points = mMeshVertices;
terrainDesc.triangles = mMeshFaces;
terrainDesc.flags = 0;
terrainDesc.heightFieldVerticalAxis = NX_Y;
terrainDesc.heightFieldVerticalExtent = -1000.0f;
MemoryWriteBuffer buf;
bool status = NxCookTriangleMesh(terrainDesc, buf);
MemoryReadBuffer readBuffer(buf.data);
NxTriangleMesh *mterrainMesh = mPhysicsSDK->createTriangleMesh(readBuffer);
triangleShapeDesc.meshData = mterrainMesh;
//triangleShapeDesc.shapeFlags = NX_SF_FEATURE_INDICES;
delete [] mMeshVertices;
delete [] mMeshFaces;
}
NxActorDesc ActorDesc;
ActorDesc.shapes.pushBack(&triangleShapeDesc);
gTerrain = gScene->createActor(ActorDesc);
gTerrain->userData = (void*)0;
nScene->simulate(time); //Note: a real application would compute and pass the elapsed time here.
nScene->flushStream();
nScene->fetchResults(NX_RIGID_BODY_FINISHED, true);
int nbActors = nScene->getNbActors();
NxActor** actors = nScene->getActors();
while(nbActors--)
{
NxActor* actor = *actors++;
if(!actor->userData) continue;
Vera::SceneNode *mNode = static_cast<Vera::SceneNode *>(actor->userData);
mNode->simulate();
//mNode->setPosition( NxTools::convert( actor->getGlobalPosition()) ) ;
//mNode->setOrientation( NxTools::convert( actor->getGlobalOrientation() ) );
}
void SceneNode::simulate()
{
if(!type){
mSceneNode->setPosition( NxTools::convert( actor->getGlobalPosition()) ) ;
mSceneNode->setOrientation( NxTools::convert( actor->getGlobalOrientation() ) );
}
}
dimatd
16-01-2006 14:23:05
void VeraWorldManager::tileLoaded(PagingLandscapeEvent *p)
{
std::vector<void*> tile;
Ogre::uint *q = new Ogre::uint [5];
Ogre::String name;
q[0] = static_cast<Ogre::uint>(p->mPagex);
q[1] = static_cast<Ogre::uint>(p->mPagez);
q[2] = static_cast<Ogre::uint>(p->mTilex);
q[3] = static_cast<Ogre::uint>(p->mTilez);
q[4] = 2;
for(Ogre::uint i=0; i < 5; i++){
tile.push_back(&q[i]);
name += Ogre::StringConverter::toString(q[i]);
}
nxTile &nxtile = mapTiles[name];
if(!nxtile.isLoad()){
nxtile.setLoad();
nxtile.setName(name);
mSceneMgr->getOption("PageGetTileCurrentVertexData", &tile);
Ogre::VertexData *mVertex = static_cast<Ogre::VertexData *>(tile[5]);
Ogre::IndexData *mIndex = static_cast<Ogre::IndexData *>(tile[6]);
Ogre::Vector3 *pos = static_cast<Ogre::Vector3 *>(tile[7]);
Vera::TriangleShapeDesc tmp_mesh(mVertex, mIndex);
mSceneNodeDescManager->createSceneNodeDesc(tmp_mesh, name);
mScenes[MainScene]->createSceneNode(tiles++, name.c_str(), *pos,Ogre::Quaternion::IDENTITY,
Ogre::Vector3::UNIT_SCALE, STATIC_NODE);
}
delete [] q;
}
TriangleShapeDesc::TriangleShapeDesc(Ogre::VertexData *_vertex, Ogre::IndexData* _index)
{
size_t index_offset = 0;
Ogre::uint _numVertices = static_cast<Ogre::uint>(_vertex->vertexCount);
Ogre::uint mIndexCount = static_cast<Ogre::uint>(_index->indexCount);
NxVec3* mMeshVertices = new NxVec3[_numVertices];
NxU32* mMeshFaces = new NxU32[mIndexCount];
const Ogre::VertexElement* posElem = _vertex->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
Ogre::HardwareVertexBufferSharedPtr vbuf = _vertex->vertexBufferBinding->getBuffer(posElem->getSource());
unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
float* pReal;
for( size_t j = 0; j < _numVertices; ++j, vertex += vbuf->getVertexSize()) {
posElem->baseVertexPointerToElement(vertex, &pReal);
mMeshVertices[j] = NxVec3(pReal[0],pReal[1],pReal[2]);
}
vbuf->unlock();
size_t numTris = _index->indexCount / 3;
Ogre::HardwareIndexBufferSharedPtr ibuf = _index->indexBuffer;
bool use32bitindexes = (ibuf->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
if ( use32bitindexes ) {
unsigned int* pInt = static_cast<unsigned int*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
size_t offset = 0;
for ( size_t k = 0; k < numTris*3; ++k) {
mMeshFaces[index_offset++] = pInt[k];
}
}
else {
unsigned short* pShort = reinterpret_cast<unsigned short*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
size_t offset = 0;
for ( size_t k = 0; k < numTris*3; ++k) {
mMeshFaces[index_offset++] = static_cast<unsigned int>(pShort[k]);
}
}
ibuf->unlock();
NxTriangleMeshDesc terrainDesc;
terrainDesc.numVertices = _numVertices;
terrainDesc.numTriangles = mIndexCount / 3;
terrainDesc.pointStrideBytes = sizeof(NxVec3);
terrainDesc.triangleStrideBytes = 3*sizeof(NxU32);
terrainDesc.points = mMeshVertices;
terrainDesc.triangles = mMeshFaces;
terrainDesc.flags = 0;
terrainDesc.heightFieldVerticalAxis = NX_Y;
terrainDesc.heightFieldVerticalExtent = -1000.0f;
MemoryWriteBuffer buf;
bool status = NxCookTriangleMesh(terrainDesc, buf);
MemoryReadBuffer readBuffer(buf.data);
NxTriangleMesh *mterrainMesh = mPhysicsSDK->createTriangleMesh(readBuffer);
triangleShapeDesc.meshData = mterrainMesh;
triangleShapeDesc.shapeFlags = NX_SF_FEATURE_INDICES;
delete [] mMeshVertices;
delete [] mMeshFaces;
}
dimatd
16-01-2006 14:36:23
(and why not add a wiki topic on novodex integration http://www.ogre3d.org/wiki/index.php/Pa ... cs_engines)
tuan kuranes
17-01-2006 09:32:03
RB
30-01-2006 12:10:42
PLSM2Listener::PLSM2Listener( Ogre::PagingLandScapeSceneManager * _sceneManager) :
sceneManager ( _sceneManager)
{
YAKE_LOG("Entered to PLSM2 constructor");
loadTileDelegate = new Ogre::PagingLandscapeDelegate();
loadTileDelegate->bind( &(*this), &PLSM2Listener::tileLoaded);
mpageloadlistener = new Ogre::PagingLandscapeDelegate(&(*this),
&PLSM2Listener::pageLoaded);
// hardwareBufferManager = new Ogre::DefaultHardwareBufferManager();
sceneManager->setWorldGeometry("paginglandScape2.cfg");
sceneManager->setOption( "addLoadPageListener", mpageloadlistener );
sceneManager->setOption( "addLoadTileListener", loadTileDelegate);
sceneManager->setOption( "LoadNow", NULL);
}
int main()
{
Ogre::Root * root;
Ogre::PagingLandScapeSceneManager * sceneMgr;
root = new Ogre::Root( "yake.graphics.ogre_plugins.cfg", "yake.graphics.ogre.cfg", "Ogre_Server.log" );
setupResources();
Ogre::RenderWindow * mWindow;
if( root->showConfigDialog())
mWindow = root->initialise(true, "Terrain Server");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
sceneMgr = (Ogre::PagingLandScapeSceneManager *) root->getSceneManager( Ogre::ST_EXTERIOR_REAL_FAR);
....
physics::PLSM2Listener * plsmManager = new physics::PLSM2Listener( sceneMgr);
....
}
tuan kuranes
30-01-2006 16:11:18
The last question : can you help me with relationships of PLSM and Ogre::HardwareBufferManager classes?
RB
30-01-2006 16:41:21
... but tiles are vertex grouping as batch call to be faster under GPU uses.
tuan kuranes
30-01-2006 16:58:48
This means what tile geometry can't be accessible without camera object? Should i create some dummy camera for loading tiles?
Is there any chance what this approach could work on graphics card less systems?
RB
30-01-2006 17:10:16
tuan kuranes
30-01-2006 17:20:16
RB
30-01-2006 17:49:08