EagleEye
21-01-2006 21:03:13
First, set up your main landscape config file. Mine is called "paginglandscape2.cfg". This is in the root bin folder.
In the bin/media folder, you will have a config file called ps_height_1k.cfg (or any of the other kinds that are commented out above using the #).
Here is a copy of my ps_height_1k.cfg
In the bin/media/ps_height_1k folder, you will find all of the files required. You will also want to make sure you have your splatting material files in the bin/media folder.
The plugins.cfg in the bin folder contains:
You'll note here I created a subfolder of bin for plugins (bin/Plugins) where I put all of my plugins. This is just for organization. If you want to use the root bin folder, set "PluginFolder=."
The plugins listed are just the ones I use. The important one for this purpose is the last one.
Your resources.cfg must have a PLSM group, as mentioned in the paginglandscape2.cfg.
With me so far?
Okay, now to the actual code.
Create your scene as normal, with an instance of Root, RenderWindow, and SceneManager. Create your cameras and viewports, etc...
When you initialize your scene:
This is a good one to use for a PLSM2 world. Skydomes are better than skyboxes because they remain centered on the camera, and you won't hit the edge.
This is the entry point for PLSM2. It starts with that config, and that config directs the entire plugin on what terrain to load. You'll note in the config file there it mentions "DefaultMap=puget_sound". This seems kinda odd, because it's defining a name for the terrain, and then the next line says that "puget_sound=ps_height_1k", defining the actual data source config file for that named default terrain. It's a chain of logic that I don't really see the purpose for, but that's the way it is.
So, PLSM sees the default map as puget_sound, then looks up what puget_sound has for its data source name (ps_height_1k), and it finds that config file (the data source name plus ".cfg"). So it loads ps_height_1k.cfg.
It goes in to that .cfg file and gets all of the configuration information. Because of your PLSM resource group, it has the ps_height_1k folder loaded and has the images available to use.
That's all that should be required!
Note, you don't have to add the PLSM dll file in your resources area of the solution explorer. The PLSM is loaded as an Ogre plugin, and as a result, doesn't need to be wrapped, or otherwise exposed to the VB.NET environment. Ogre handles it seamlessly.
DefaultMap=puget_sound
puget_sound=ps_height_1k
#grand_canyon=gcanyon_height_4k2k
#terragen_generated=terragen16bits
#European_Alpes=Alpes
# resource group name where to find map definition
GroupName=PLSM2
In the bin/media folder, you will have a config file called ps_height_1k.cfg (or any of the other kinds that are commented out above using the #).
Here is a copy of my ps_height_1k.cfg
### WARNING
## read Data2dLoader.txt, Mapsplitterreadme.txt
## in ogreaddons paginglandscape root folder before anything here.
##
# resource group name
GroupName=PLSM2
##
##
################## HeightMap OPTIONS.
#
# Before using the paginglandscape2 plugins,
# you'll have to split your big heightmap file into pages.
# Use the Mapsplitter tool for that
# Base file name for the landscape heightfield data
# The file name MUST be LandScapeFileName.x.z.LandScapeExtension (ex: landscape.0.0.png)
# and MUST be squared.
LandScapeFileName=ps_height_1k
LandScapeExtension=png
# Height and Width of the landscape in number of pages
Width=4
Height=4
#
# Size of the Heightfiled in pixels (must be (power of 2) + 1)
PageSize=257
#
# Size of the Heightfiled in pixels
TileSize=65
#
## so if map is 2048x1024, with pagesize=257 and TileSize=64
# it gives 32 pages (8 pages width, 4 pages width), each 16 tiles so it's 512 tiles on the whole map.
#
# Especialized 2D data loader.
# Currently the only available loaders are 'HeightField', 'HeightFieldTC' and 'SplineField'.
#
# 8bits, grayscale images. (png, jpg, etc) or 16 bits (raw)
Data2DFormat=HeightField
# 32bits, RGBA images. (png, jpg, etc) RGB is normal information, in alpha we store heightmap
#Data2DFormat=HeightFieldN
#
# The HeightField TC is a compresed format and need to know the value range from where the
# heightfield file was compressed
MaxValue=3000
MinValue=0
# # 8bits, grayscale images. (png, jpg, etc) or 16 bits (raw)
#Data2DFormat=HeightFieldTC
# 32bits, RGBA images. (png, jpg, etc) RGB is normal information, in alpha we store heightmap
#Data2DFormat=HeightFieldNTC
#experimental spline terrain
#Data2DFormat=SplineField
#
# Scale values
# Beware that scaling is pagesize and heighmap definition range indepedant.
ScaleX=90000
ScaleY=30000
ScaleZ=90000
# if Deformation is no use for you, you can gain fps by saying no here.
Deformable=no
# experimental VRAM saves. need instant base texture and vertex shader support
# "vertex displacment mapping"
VertexCompression=yes
# Use vertex program to morph LODs, if available
VertexProgramMorph=no
# The proportional distance range at which the LOD morph starts to take effect
# This is as a proportion of the distance between the current LODs effective range,
# and the effective range of the next lower LOD
LODMorphStart=0.2
# The maximum error allowed when determining which LOD to use
MaxPixelError=15
################## LIGHTING OPTIONS.
# For lighting
# For better looking deformed texture (instantbase)
# for shader (needed to get slope)
VertexNormals=yes
############### TEXTURING OPTIONS
#
TextureExtension=png
#
#
#
# Especialized texture loader.
#
#(no pregenerated maps needed)
# Real-time (no pregenerated maps needed) splatting => splatting (needs DX9) and splatting5 (need shaders)
# Real-time (no pregenerated maps needed)Coloring => basetexture.
#
#(pregenerated maps needed)
# Deformable splatting => splatting5 (need shaders)
# Deformable Coloring => instantbasetexture.
#
#(pregenerated maps only)
# splatting => splatting2, (needs DX9) splatting3 (opengl)
# Coloring => basetexture2
# Image => Image (generated by any terrain texture generator terragen, T2, etc)
#
#
#
#DX = BaseTexture, BaseTexture2, InstantBaseTexture, Splatting, Splatting2, Splatting4, Splatting6, Splatting7
#GL = BaseTexture, BaseTexture2, InstantBaseTexture, Splatting3
#Both = BaseTexture, BaseTexture2, InstantBaseTexture, Splatting5
#
TextureFormat=Image
ImageFilename=ps_texture_1k
BigImage=no
## realtime splatting
#TextureFormat=BaseTexture
## (need to generate maps with mapsplitter)
#TextureFormat=InstantBaseTexture
# Shader Splatting
# Needs pixel shader
#TextureFormat=Splatting5
#need DIRECTX
#TextureFormat=Splatting
## precalc static splatting
## (need to generate maps with mapsplitter)
#TextureFormat=BaseTexture2
#need DIRECTX
#TextureFormat=Splatting2
# Need Multitexturing Hardware DIRECTX
#TextureFormat=Splatting7
### Experimentals splatting techniques
#need DIRECTX
#TextureFormat=Splatting4
### Experimentals splatting techniques
#need OPENGL
#TextureFormat=Splatting3
#need DIRECTX
#TextureFormat=Splatting4
#²²
# For splatting3 and perhaps a pass less in splatting2 and splatting4
VertexColors=no
# For splatting3
CoverageVertexColor=no
# Forsplatting4
BaseVertexColor=no
#
BaseVertexShadow=no
#
BaseVertexInstantColor=no
#
# Splatting
# We are allowing 4 textures to build the terrain texture
# MaterialHeight to change alpha weights ( using percentages )
# for Real-time textureformat and deformable (instantbasetexture, splatting5)
MaterialHeight1=12
MaterialHeight2=60
#needs to be in Search Path directory (resources.cfg)
SplatFilename0=splatting_snow.jpg
SplatFilename1=splatting_sand.jpg
SplatFilename2=splatting_grass.jpg
SplatFilename3=splatting_rock.jpg
################## PERFORMANCES OPTIONS.
#
#
#
# Visible renderables
# This is the number of visible renderables from the current camera position
# to the border of the visible terrain. (The radius of renderables)
VisibleRenderables=80
#
# LOD : LEVEL OF DETAIL
#
# Distance LOD
# This is the number of renderables in the higher LOD.
#
DistanceLOD=5
#
# if not set, it's precomputed to the max possible at this TileSize.
# Must be (2^MaxRendervel < TileSize)
MaxRenderLevel=3
#
#
# FPS Processing limit
# number of renderables loading in a single frame (if needed)
NumRenderablesLoading=50
#
# WINDOWING AROUND CAMERA
#
# Num of adjacent loaded landscape pages.
MaxAdjacentPages=3
#
# Num of adjacent preloaded landscape pages.
# Must be bigger than MaxAdjacentPages + 1, the textures are loaded in a separate thread.
MaxPreloadedPages=4
#
#
# Pages Load Factor
# Pages will be load/unload when they are about PageSize^2 * ChangeFactor
ChangeFactor=1.5
#
#
# Camera Threshold
# If the last camera position minus current camera position is >= CameraTheshold
# then the scene is trasverse to check LOD.
CameraThreshold=5
#
# Memory Pool Initial Usage Values (pre-allocated renderables and tiles.)
# use debug mode to check your needs.
MaxNumRenderables=200
IncrementRenderables=200
MaxNumTiles=200
IncrementTiles=200
# Horizon Visibility computing:
# enable it if your map have moutains, cliff... not if it's mainly plane.
# everything hidden will not be send to GPU saving framerates.
HorizonVisibilityComputing=yes
In the bin/media/ps_height_1k folder, you will find all of the files required. You will also want to make sure you have your splatting material files in the bin/media folder.
The plugins.cfg in the bin folder contains:
# Defines plugins to load
# Define plugin folder
PluginFolder=./Plugins
# Define plugins
Plugin=RenderSystem_Direct3D9
Plugin=RenderSystem_GL
Plugin=Plugin_ParticleFX
Plugin=Plugin_CgProgramManager
Plugin=Plugin_BSPSceneManager
Plugin=Plugin_OctreeSceneManager
Plugin=Plugin_PagingLandScapeSceneManager2You'll note here I created a subfolder of bin for plugins (bin/Plugins) where I put all of my plugins. This is just for organization. If you want to use the root bin folder, set "PluginFolder=."
The plugins listed are just the ones I use. The important one for this purpose is the last one.
Your resources.cfg must have a PLSM group, as mentioned in the paginglandscape2.cfg.
[Bootstrap]
Zip=C:/OgreSDK/media/packs/OgreCore.zip
# Resource locations to be added to the default path
[General]
Zip=C:/OgreSDK/media/packs/skybox.zip
FileSystem=media/fonts
FileSystem=media/particle
FileSystem=media/models
FileSystem=media/materials/textures
FileSystem=media/materials/scripts
FileSystem=media/materials/programs
FileSystem=media/gui
[PLSM2]
FileSystem=Media
FileSystem=Media/ps_height_1k
FileSystem=Media/datasrcs
FileSystem=Media/SplatWith me so far?
Okay, now to the actual code.
Create your scene as normal, with an instance of Root, RenderWindow, and SceneManager. Create your cameras and viewports, etc...
When you initialize your scene:
Scene.SetSkyDome(True, "Examples/CloudySky", 10, 1)
This is a good one to use for a PLSM2 world. Skydomes are better than skyboxes because they remain centered on the camera, and you won't hit the edge.
Scene.SetWorldGeometry("paginglandscape2.cfg")This is the entry point for PLSM2. It starts with that config, and that config directs the entire plugin on what terrain to load. You'll note in the config file there it mentions "DefaultMap=puget_sound". This seems kinda odd, because it's defining a name for the terrain, and then the next line says that "puget_sound=ps_height_1k", defining the actual data source config file for that named default terrain. It's a chain of logic that I don't really see the purpose for, but that's the way it is.
So, PLSM sees the default map as puget_sound, then looks up what puget_sound has for its data source name (ps_height_1k), and it finds that config file (the data source name plus ".cfg"). So it loads ps_height_1k.cfg.
It goes in to that .cfg file and gets all of the configuration information. Because of your PLSM resource group, it has the ps_height_1k folder loaded and has the images available to use.
That's all that should be required!
Note, you don't have to add the PLSM dll file in your resources area of the solution explorer. The PLSM is loaded as an Ogre plugin, and as a result, doesn't need to be wrapped, or otherwise exposed to the VB.NET environment. Ogre handles it seamlessly.