To use the plugin in your own app:
plugin binary is compiled for ogre 1.4.6 so it should be compatible with 1.4.6+ but not with Ogre 1.5.0 dlls.
first declare in your 'plugins.cfg':
#Myrddin landscape plugin
Plugin=Plugin_LandscapeSceneManager
#encrypted/zip-compressed library plugin
Plugin=PLugin_ZPK
copy all 'Datas' directory in your own app directory
copy following dll in your app directory: QuickGUI.dll (plugin internally uses abstract GUI wrapper to bind controls with plugin settings)
and add following lines in your 'resources.cfg':
[General]
# plugin common resources
FileSystem=./Datas
FileSystem=./Datas/fonts
FileSystem=./Datas/materials/programs
FileSystem=./Datas/materials/scripts
FileSystem=./Datas/materials/textures
FileSystem=./Datas/models
FileSystem=./Datas/gui/default
# plugin terrain common resources
FileSystem=./Datas/terrain/materials/scripts
FileSystem=./Datas/terrain/materials/textures/splatting
FileSystem=./Datas/terrain/materials/textures/sky
FileSystem=./Datas/terrain/materials/textures/water
Zip=./Datas/terrain/materials/textures/water/WaterCaustic.zip
Zpk=./Datas/terrain/materials/shaders.zpk
#one resource group per terrain data (heightmap+splatting masks+lightmaps+colormaps)
[land2]
FileSystem=./Datas/terrain/land2
now in your app, you can call InitializeAllResourceGroups() to initialize resources groups declared in 'resources.cfg'
or manually initialize them if you prefer.
now the app code: you can initialize and use plugin like any other ogre scene manager plugin;
for instance, here is sample of code picked from the demo - sorry only C#
Code: Select all
protected override void ChooseSceneManager()
{
// get the landscape scene manager
sceneMgr = root.CreateSceneManager(SceneType.ST_EXTERIOR_FAR, "LandSceneManager"); //here only SceneType.ST_EXTERIOR_FAR is important:
//note that Myrddin plugin will be selected only if
//you use ST_EXTERIOR_* constants
}
protected override void CreateScene()
{
camera.AspectRatio = ((float)viewport.ActualWidth) / ((float)viewport.ActualHeight);
//load terrain geometry from config file
{
GameSystem.GameGUI.LoadingBar loadingBar = new GameSystem.GameGUI.LoadingBar();
loadingBar.Start(window, 0, 1, 0.0F);
StringBuilder sLevelFileName = new StringBuilder(NameLevel);
sLevelFileName.Append(".xml");
ResourceGroupManager.Singleton.WorldResourceGroupName = NameLevel;
ResourceGroupManager.Singleton.LinkWorldGeometryToResourceGroup(NameLevel,sLevelFileName.ToString(),sceneMgr);
ResourceGroupManager.Singleton.LoadResourceGroup(NameLevel);
loadingBar.Finish();
}
//! or you can use sceneMgr.SetWorldGeometry( NameLevel+".xml" );
//get sun light
if (sceneMgr.HasLight("Sun"))
mLightSun = sceneMgr.GetLight("Sun");
else
{
mLightSun = sceneMgr.CreateLight("Sun");
mLightSun.DiffuseColour = new ColourValue(1.0f, 1.0f, 1.0f);
mLightSun.SpecularColour = new ColourValue(1.0f, 1.0f, 1.0f);
mLightSun.Type = Light.LightTypes.LT_DIRECTIONAL;
mLightSun.CastShadows = true;
}
//create point light
if (sceneMgr.HasLight("Cursor"))
mLightCursor = sceneMgr.GetLight("Cursor");
else
{
mLightCursor = sceneMgr.CreateLight("Cursor");
mLightCursor.DiffuseColour = new ColourValue(0.2f, 1.0f, 0.2f);
mLightCursor.SpecularColour = new ColourValue(1.0f, 1.0f, 1.0f);
mLightCursor.Type = Light.LightTypes.LT_POINT;
mLightCursor.SetAttenuation(2000.0f, 0.0f, 0.0f, 0.00001f);
mLightCursor.CastShadows = false;
mLightCursor.Visible = true;
}
//create spot light
if (sceneMgr.HasLight("TorchLamp"))
mLightSpot = sceneMgr.GetLight("TorchLamp");
else
{
mLightSpot = sceneMgr.CreateLight("TorchLamp");
mLightSpot.DiffuseColour = new ColourValue(1.0f, 1.0f, 0.2f);
mLightSpot.SpecularColour = new ColourValue(0.2f, 0.2f, 0.2f);
mLightSpot.Type = Light.LightTypes.LT_SPOTLIGHT;
mLightSpot.Position = camera.Position;
Vector3 dir = camera.Direction;
dir.Normalise();
mLightSpot.SetAttenuation(2000.0f, 0.0f, 0.0f, 0.000001f);
mLightSpot.Direction = dir;
mLightSpot.SetSpotlightRange(new Radian(new Degree(45.0f)), new Radian(new Degree(70.0f)), 2.0f);
mLightSpot.CastShadows = false;
mLightSpot.Visible = true;
}
//create landscape camera ray scene query
mRsqWorldGeometry = sceneMgr.CreateRayQuery(new Ray(camera.Position, Vector3.NEGATIVE_UNIT_Y));
mRsqWorldGeometry.SetSortByDistance(true);
mRsqWorldGeometry.QueryTypeMask = SceneManager.WORLD_GEOMETRY_TYPE_MASK;
//create cursor ray scene query
mRsqCursor = sceneMgr.CreateRayQuery(new Ray(camera.Position, camera.Direction));
mRsqCursor.SetSortByDistance(true);
mRsqCursor.QueryTypeMask = (uint)SceneManager.WORLD_GEOMETRY_TYPE_MASK | SceneManager.ENTITY_TYPE_MASK;
}
/// <summary>
/// get world gometry y coordinate at x and z coordinates
/// </summary>
/// <param name="x">x world coordinate</param>
/// <param name="z">z world coordinate</param>
protected float GetHeightAt(float x, float z)
{
mRsqWorldGeometry.Ray = new Ray(new Vector3(x, 10000, z), Vector3.NEGATIVE_UNIT_Y); //note that axis y ray casts are faster than
//generic ray casts because implemented as heightmap direct read
mRsqWorldGeometry.Execute();
RaySceneQueryResult result = mRsqWorldGeometry.GetLastResults();
if ((!result.IsEmpty) && result.Front.worldFragment != null)
{
if (result.Front.worldFragment.fragmentType == SceneQuery.WorldFragmentType.WFT_SINGLE_INTERSECTION)
{
return result.Front.worldFragment.singleIntersection.y; //note that normal is stored in
//result.Front.worldFragment.planes.Back.normal
}
}
return 0.0f;
}
if you want to apply dynamic fog to your own objects, you need to add dynamic fog pass to object material
look at this code:
Code: Select all
Entity ent = sceneMgr.CreateEntity("column", "column.mesh");
bool bDynamicFog = false;
sceneMgr.GetOption("ALSIsDynamicFogEnabled", out bDynamicFog); //you can use sceneMgr.SetOption("ALSEnableDynamicFog",true) to enable/disable dynamic fog
if (bDynamicFog)
{
string matName = ent.GetSubEntity(0).MaterialName;
sceneMgr.SetOption("ALSAddDynamicFogPass", matName); //this will add dynamic fog pass at the end of all material techniques
//note that that works only if material uses vertex/fragment programs yet
//and as dynamic fog pass is generated using highest shader version (up to vs_3_0/ps_3_0),
//entity material shaders need to use same version too.
}
full user doc will be included with LGPL and commercial plugin version so please be patient...