MapSplitter

wizumwalt

24-02-2009 02:37:06

Still trying to get PLSM2 to run on linux and I've got some questions about MapSplitter so I can verify my terrain files are ok. I know if I run MapSplitter from my ./ogreaddons/paginglandscape/Samples/Common/bin, it goes straight to work on create alpesX.X.png, etc... images. Are each one of these numbered images a tile in the overall terrain? I don't have these for my terrain?

How exactly do I use it? I have a 513x513 image I use for a height map. Am I supposed to split this image up in some way? How do I tell MapSplitter I want to split up a specific image I have in mind for my terrain?

guru

24-02-2009 11:49:25

Did you see this page in the wiki?: http://www.ogre3d.org/wiki/index.php/Pa ... nfig_files

wizumwalt

24-02-2009 19:48:35

Thanks for the link, it was useful. But I'm getting segfaults. So here's what I did trying to get something running ...

In ogreaddons/paginglandscape/Samples/Common/bin/maptool.cfg I have as follows.

DefaultMap=Test

Test=testland.gen

# resource group name
GroupName=PLSM2

#do you want to run it on all maps listed here
BatchMode=no


I've added a 4096x4096 testland.png file to ogreaddons/paginglandscape/Samples/Media/paginglandscape2/datasrcs.

In ogreaddons/paginglandscape/Samples/Media/paginglandscape2/terrains I copied TsmTerrain.cfg to test.cfg and made slight changes ...

GroupName=PLSM2

Width=1
Height=1

Data2DFormat=HeightField
LandScapeFileName=test

FileSystem=TestLand
TextureStretchFactor=1

NumTextureFormatSupported=9

TextureFormatSupported0=ImagePaging
TextureFormatSupported1=Base
TextureFormatSupported2=InstantBase
TextureFormatSupported3=Splatting
TextureFormatSupported4=Splatting5
TextureFormatSupported5=Splatting2
TextureFormatSupported6=Splatting7
TextureFormatSupported7=SplattingShader
TextureFormatSupported8=ImagePagingLight
TextureFormatSupported8=PLSplattingShaderLitDecompress

TextureFormat=ImagePagingLight
ImageFilename=terrain_texture

ScaleX=15000
ScaleY=1000
ScaleZ=15000

Deformable=yes
VertexCompression=no
VertexProgramMorph=no
VertexNormals=no

NumMatHeightSplat=4
Height1=15
Height2=50
SplatFilename0=splatting_sand.png
SplatFilename1=splatting_grass.png
SplatFilename2=splatting_rock.png
SplatFilename3=splatting_snow.png

# where to put camera on load.
BaseCameraViewpoint.x=935.0f
BaseCameraViewpoint.y=24000.0f
BaseCameraViewpoint.z=-432.0f


Copied TsmTerrain.cfg to test.gen.cfg w/ slight changes ...

GroupName=PLSM2
LandScapeFileName=test
TextureStretchFactor=1

ScaleX=1.5
ScaleY=1
ScaleZ=1.5

OutDirectory=TestLand

Data2DFormat=HeightField

ColorMapName=terrain_texture.jpg
ColorMapSplit=yes

HeightMap=yes
BaseMap=yes
CoverageMap=yes
AlphaMaps=yes
ZHorizon=yes

LightMap=yes
Sunx=0.0f
Suny=0.88f
Sunz=0.47f
Ambient=0.5f
Diffuse=0.5f
Blur=0.0f

MiniMap=yes
MiniMapWidth=64
MiniMapHeight=64

NumMatHeightSplat=5

MaterialHeight1=12
MaterialHeight2=35
MaterialHeight3=80
MaterialHeight4=100

AvgColorsExists=yes

#Sand
MaterialColor0=0.0f 0.0f 1.0f 1.0f
#Grass
MaterialColor1=0.145f 0.624f 0.0f 1.0f
#Rock
MaterialColor2=0.411764f 0.811764f 0.811764f 1.0f
#Rock2
MaterialColor3=0.411764f 0.811764f 0.811764f
#Snow
MaterialColor4=1.0f 0.0f 0.0f 1.0f



I then created a dir called TestLand within Samples/Media/paginglandscape2/terrains to match the OutDirectory .

And the FileSystem 'TestLand' has been added to resources.cfg in ogreaddons/paginglandscape/Samples/Common/bin.

Then I run MapSplitter and get the following after several minutes ...

created : test.HSN.7.3.png
created : test.HSN.7.4.png
created : test.HSN.7.5.png
created : test.HSN.7.6.png
created : test.HSN.7.7.png
*-*-* OGRE Shutdown
Unregistering ResourceManager for type Compositor
Unregistering ResourceManager for type Font
Unregistering ResourceManager for type Skeleton
Unregistering ResourceManager for type Mesh
Unregistering ResourceManager for type HighLevelGpuProgram
Unloading library Plugin_PagingLandScape2
Segmentation fault


Any ideas about what it's doing at this point? Or maybe how to build it in debug?

guru

26-02-2009 10:54:19

I'm not really sure but did you try using your terrain although MapSplitter segfaulted? I think it segfaulted with the demo terrain also and this was working anyway...

wizumwalt

26-02-2009 22:55:55

Yes, it even segfaults w/ the demo terrain if I just run MapSplitter out of the box after a build.

So I thought I'd try w/ something simpler and I made a sample 4096x4096 *.png and tried a configuration on it thinking I would learn in more detail what might be going on, but same thing.

If it's working for other people on linux, there's no reason why it shouldn't eventually work for me on my distro, even if it takes a bit more tinkering. I'm sure it's something simple once I can find a way to figure out what's going on. Ugh, this sux!

dermont

27-02-2009 03:58:31

For the MapSplitter seg fault how are you loading the plugin, from code or the plugins.cfg file?. Do you by chance have the following code in MapUtil.cpp:

Root::getSingleton().loadPlugin("Plugin_PagingLandScape2");

and in plugins.cfg:

Plugin=Plugin_PagingLandScape2


If so try updating MapUtil.cpp to only load the plugin from the plugins.cfg file.


#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32

#ifdef _DEBUG
Root::getSingleton().loadPlugin("Plugin_PagingLandScapeSceneManager2_d");
#else
Root::getSingleton().loadPlugin("Plugin_PagingLandScapeSceneManager2");
#endif
#endif

wizumwalt

28-02-2009 03:38:26

Here is my plugins.cfg file ...

# Defines plugins to load

# Define plugin folder
PluginFolder=/usr/local/lib/OGRE

# Define D3D rendering implementation plugin
Plugin=RenderSystem_GL
Plugin=Plugin_ParticleFX
Plugin=Plugin_BSPSceneManager
Plugin=Plugin_OctreeSceneManager
Plugin=Plugin_PagingLandScape2


And here is my MapUtil.cpp file ...

void MapUtil::init()
{
#ifndef _MAPEDITOR
if (mRoot == 0)
{

mRoot = new Root("plugins.cfg", "ogre.cfg", "MapSplitter.log");
#ifdef _DEBUG
Root::getSingleton().loadPlugin("Plugin_PagingLandScapeSceneManager2_d");
#else
//Root::getSingleton().loadPlugin("Plugin_PagingLandScapeSceneManager2");
Root::getSingleton().loadPlugin("Plugin_PagingLandScape2");
#endif


Did I do that right?

MapUtil.cpp tries to load Plugin_PagingLandScape2 because Plugin_PagingLandScapeSceneManager2 doesn't exist on linux, rather, it's built as Plugin_PagingLandScape2 as shown below, then I create the sym link.

/usr/local/lib/OGRE$ ls -l
total 32800
-rwxr-xr-x 1 root root 1554 Feb 24 18:01 Plugin_BSPSceneManager.la
-rwxr-xr-x 1 root root 2728745 Feb 24 18:01 Plugin_BSPSceneManager.so
-rwxr-xr-x 1 root root 1560 Feb 24 18:01 Plugin_CgProgramManager.la
-rwxr-xr-x 1 root root 815225 Feb 24 18:01 Plugin_CgProgramManager.so
-rwxr-xr-x 1 root root 1572 Feb 24 18:01 Plugin_OctreeSceneManager.la
-rwxr-xr-x 1 root root 3490533 Feb 24 18:01 Plugin_OctreeSceneManager.so
-rwxr-xr-x 1 root root 1627 Feb 24 18:01 Plugin_OctreeZone.la
-rwxr-xr-x 1 root root 2435870 Feb 24 18:01 Plugin_OctreeZone.so
-rw-r--r-- 1 root root 7217108 Feb 27 21:31 Plugin_PagingLandScape2.a
-rwxr-xr-x 1 root root 1551 Feb 27 21:31 Plugin_PagingLandScape2.la
-rwxr-xr-x 1 root root 2759829 Feb 27 21:31 Plugin_PagingLandScape2.so
lrwxrwxrwx 1 root root 26 Feb 18 20:12 Plugin_PagingLandScapeSceneManager2.so -> Plugin_PagingLandScape2.so
-rwxr-xr-x 1 root root 1524 Feb 24 18:01 Plugin_ParticleFX.la
-rwxr-xr-x 1 root root 3056739 Feb 24 18:01 Plugin_ParticleFX.so
-rwxr-xr-x 1 root root 1678 Feb 24 18:01 RenderSystem_GL.la
-rwxr-xr-x 1 root root 7742043 Feb 24 18:01 RenderSystem_GL.so
-rwxr-xr-x 1 root root 1572 Feb 24 18:01 libPlugin_PCZSceneManager.la
-rwxr-xr-x 1 root root 3285129 Feb 24 18:01 libPlugin_PCZSceneManager.so


However, if I do comment out the Plugin_PagingLandScape2 line in MapUtil.cpp for Plugin_PagingLandScapeSceneManager and/or comment out the Plugin=Plugin_PagingLandScape2 in plugins.cfg, I get the following error.

Loading library /usr/local/lib/OGRE/Plugin_PagingLandScape2
SceneManagerFactory for type 'PagingLandScapeSceneManager' registered.
*-*-* OGRE Initialising
*-*-* Version 1.6.0 (Shoggoth)
Loading library Plugin_PagingLandScapeSceneManager2
terminate called after throwing an instance of 'Ogre::InternalErrorException'
what(): OGRE EXCEPTION(7:InternalErrorException): Could not load dynamic library Plugin_PagingLandScapeSceneManager2. System Error: Plugin_PagingLandScapeSceneManager2.so: cannot open shared object file: No such file or directory in DynLib::load at OgreDynLib.cpp (line 80)
Aborted


Any ideas?

dermont

28-02-2009 04:35:52

It should be as simple as:

1. Update MapUtil.cpp to only load the plugin in code from windows:

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#ifdef _DEBUG
Root::getSingleton().loadPlugin("Plugin_PagingLandScapeSceneManager2_d");
#else
Root::getSingleton().loadPlugin("Plugin_PagingLandScapeSceneManager2");
#endif
#endif


2. plugins.cfg file:

# Defines plugins to load

# Define plugin folder
PluginFolder=/usr/local/lib/OGRE

# Define D3D rendering implementation plugin
Plugin=RenderSystem_GL
Plugin=Plugin_ParticleFX
Plugin=Plugin_BSPSceneManager
Plugin=Plugin_OctreeSceneManager
Plugin=Plugin_PagingLandScape2


3. Remove your Plugin_PagingLandScapeSceneManager2.so sym link

wizumwalt

28-02-2009 05:29:42

Wow, well, I got it to run MapSplitter w/o segfaults. Thanks so much. But still have some issues w/ it. I found this error in my output when running my application.


PLSM2 : Cannot find map named testland.0.0.png


So I went to the files that MapSplitter generated for me and I found a file named testland0.0.png. It's missing a '.' before the first 0.

I found other files name ...

testland.Light.0.0.png
testland.Coverage.0.0.png
testland.HS.0.0.png

And so on, correct '.' before 0's, but it looks like testland0.0.png is named wrong.

I renamed a few of the files and land is showing, but there are so many to rename.

Another problem is that the land is all flat. I've run MapSplitter on several *.png's (including examples that came in datasrcs) to split up, but I don't see the heightmap taking effect, it's all one big flat plane.

DragonM

22-03-2009 20:54:08

Wow, well, I got it to run MapSplitter w/o segfaults. Thanks so much. But still have some issues w/ it. I found this error in my output when running my application.


PLSM2 : Cannot find map named testland.0.0.png


So I went to the files that MapSplitter generated for me and I found a file named testland0.0.png. It's missing a '.' before the first 0.

I found other files name ...

testland.Light.0.0.png
testland.Coverage.0.0.png
testland.HS.0.0.png

And so on, correct '.' before 0's, but it looks like testland0.0.png is named wrong.

I renamed a few of the files and land is showing, but there are so many to rename.

Here is a patch to the MapSplitter that fixes this problem:

Index: MapUtil.cpp
===================================================================
--- MapUtil.cpp (revision 2654)
+++ MapUtil.cpp (working copy)
@@ -867,7 +887,7 @@
{
mSplitter->setTerrainSave(true);
mSplitter->setRawSave (StringUtil::match(mExt, "raw", false));
- mSplitter->saveAndSpaceAndSplitHeightData (mPureFilename,
+ mSplitter->saveAndSpaceAndSplitHeightData (mPureFilename+ String("."),
mData,
mWidth,
mHeight);
As usual, this code can be saved as a patch file, such as mapsplit.patch, and easily applied using TortoiseSVN in Windows or patch in Linux.

Another problem is that the land is all flat. I've run MapSplitter on several *.png's (including examples that came in datasrcs) to split up, but I don't see the heightmap taking effect, it's all one big flat plane.
I'm having the same problem, and haven't found a solution yet. I did discover that the terrain.x.x.png files had to be in the resource group specified in the config file, while the other files such as alpha and base maps don't, but that still hasn't solved the problem. A solution would be appreciated.

DM

tuan kuranes

23-03-2009 17:05:39

DragonM: Thanks. Fixed in SVN.

DanielSefton

23-03-2009 17:33:24

DragonM: Thanks. Fixed in SVN.
I know this isn't related, but could you also apply DragonM's other patch to fix camera destruction in PLSM:

Index: OgrePagingLandScapeOctreeSceneManager.cpp
===================================================================
--- OgrePagingLandScapeOctreeSceneManager.cpp (revision 2654)
+++ OgrePagingLandScapeOctreeSceneManager.cpp (working copy)
@@ -591,7 +591,8 @@
void PagingLandScapeOctreeSceneManager::destroyCamera(Camera *cam)
{
unregisterCamera (static_cast <PagingLandScapeOctreeCamera *> (cam));
- SceneManager::destroyCamera(cam);
+ mDestRenderSystem->_notifyCameraRemoved(cam);
+ delete cam;
}
//-----------------------------------------------------------------------
void PagingLandScapeOctreeSceneManager::destroyCamera(const String& name)
Index: OgrePagingLandScapeSceneManager.cpp
===================================================================
--- OgrePagingLandScapeSceneManager.cpp (revision 2654)
+++ OgrePagingLandScapeSceneManager.cpp (working copy)
@@ -1793,6 +1793,8 @@
{
mOptions->setPrimaryCamera (0);
}
+ CameraList::iterator i = mCameras.find(cam->getName());
+ mCameras.erase(i);

#ifndef _PLSM_OCTREE
OctreeSceneManager::destroyCamera(cam);


I didn't want to see this patch disappear off the radar. It solves so many problems. :wink:

tuan kuranes

23-03-2009 17:50:38

DanielSefton : thx, done.

DragonM

24-03-2009 00:55:46

DragonM: Thanks. Fixed in SVN.
I know this isn't related, but could you also apply DragonM's other patch to fix camera destruction in PLSM:

Index: OgrePagingLandScapeOctreeSceneManager.cpp
===================================================================
--- OgrePagingLandScapeOctreeSceneManager.cpp (revision 2654)
+++ OgrePagingLandScapeOctreeSceneManager.cpp (working copy)
@@ -591,7 +591,8 @@
void PagingLandScapeOctreeSceneManager::destroyCamera(Camera *cam)
{
unregisterCamera (static_cast <PagingLandScapeOctreeCamera *> (cam));
- SceneManager::destroyCamera(cam);
+ mDestRenderSystem->_notifyCameraRemoved(cam);
+ delete cam;
}
//-----------------------------------------------------------------------
void PagingLandScapeOctreeSceneManager::destroyCamera(const String& name)
Index: OgrePagingLandScapeSceneManager.cpp
===================================================================
--- OgrePagingLandScapeSceneManager.cpp (revision 2654)
+++ OgrePagingLandScapeSceneManager.cpp (working copy)
@@ -1793,6 +1793,8 @@
{
mOptions->setPrimaryCamera (0);
}
+ CameraList::iterator i = mCameras.find(cam->getName());
+ mCameras.erase(i);

#ifndef _PLSM_OCTREE
OctreeSceneManager::destroyCamera(cam);


I didn't want to see this patch disappear off the radar. It solves so many problems. :wink:

Er. Truthfully, I don't think my patch is as good as the one here:
Found and solved a bug when destroying cameras.

Problem and solution: http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=6860

I missed it when I went through the bugs thread. What I did probably duplicates what the Ogre SceneManager parent class does, but it might not. I'm inclined to think that the SceneManager's own implementation is less likely to miss something. It didn't occur to me that it was an inheritance problem.

DM

venomjiamer

12-11-2009 13:13:43

:( :( I need help~

I am a new boy in OGRE.
I use Freeworld to generate a height map.(16bits.raw,size:1024X1024)

When I use mapsplitter to split this map, I always get this error log:RAW size (2101250) does not agree with configuration settings..

Is anybody who can help me with this?

Thank you~~~~