* Terrain filters! - Think photoshop-style filters for terrain.
* Terrain filters may be written in either C# or JavaScript and loaded at runtime Use: terrain csfilter somefile.cs -- Loads a C# filter terrain jsfilter somefile.js -- Loads a JavaScript filter Once a terrain filter has been loaded, you can use the command as normal, eg terrain demofilterSugilite
parent
267348c5d1
commit
34c7a0e43a
|
@ -124,6 +124,15 @@ namespace OpenGrid.Framework.Communications.OGS1
|
|||
return neighbours;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
|
||||
/// </summary>
|
||||
/// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
|
||||
/// <param name="minX">Minimum X value</param>
|
||||
/// <param name="minY">Minimum Y value</param>
|
||||
/// <param name="maxX">Maximum X value</param>
|
||||
/// <param name="maxY">Maximum Y value</param>
|
||||
/// <returns>Hashtable of hashtables containing map data elements</returns>
|
||||
private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY)
|
||||
{
|
||||
Hashtable param = new Hashtable();
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace OpenGrid.Framework.Communications
|
|||
{
|
||||
public class GridInfo
|
||||
{
|
||||
public string GridServerURI = "http://grid:8001/";
|
||||
public string GridServerURI = "http://grid.deepgrid.com:8001/"; // Temporarily hardcoded.
|
||||
public string GridServerSendKey = "badger";
|
||||
public string GridServerRecvKey = "badger";
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
|
@ -6,7 +6,8 @@
|
|||
<ProjectGuid>{2270B8FE-0000-0000-0000-000000000000}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon></ApplicationIcon>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>OpenSim.Terrain.BasicTerrain</AssemblyName>
|
||||
|
@ -15,9 +16,11 @@
|
|||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder></AppDesignerFolder>
|
||||
<AppDesignerFolder>
|
||||
</AppDesignerFolder>
|
||||
<RootNamespace>OpenSim.Terrain.BasicTerrain</RootNamespace>
|
||||
<StartupObject></StartupObject>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
</PropertyGroup>
|
||||
|
@ -28,7 +31,8 @@
|
|||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<DocumentationFile></DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>False</Optimize>
|
||||
|
@ -37,7 +41,8 @@
|
|||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoWarn></NoWarn>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||
|
@ -46,7 +51,8 @@
|
|||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DocumentationFile></DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>True</Optimize>
|
||||
|
@ -55,30 +61,32 @@
|
|||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoWarn></NoWarn>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="libTerrain-BSD.dll" >
|
||||
<Reference Include="libTerrain-BSD.dll">
|
||||
<HintPath>..\..\bin\libTerrain-BSD.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="openjpegnet.dll" >
|
||||
<Reference Include="Microsoft.JScript" />
|
||||
<Reference Include="openjpegnet.dll">
|
||||
<HintPath>..\..\bin\openjpegnet.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" >
|
||||
<Reference Include="System">
|
||||
<HintPath>System.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" >
|
||||
<Reference Include="System.Data">
|
||||
<HintPath>System.Data.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" >
|
||||
<Reference Include="System.Drawing">
|
||||
<HintPath>System.Drawing.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" >
|
||||
<Reference Include="System.Xml">
|
||||
<HintPath>System.Xml.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
|
@ -92,6 +100,7 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TerrainFilter.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -47,6 +47,11 @@ namespace OpenSim.Terrain
|
|||
|
||||
public class TerrainEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Plugin library for scripts
|
||||
/// </summary>
|
||||
public FilterHost customFilters = new FilterHost();
|
||||
|
||||
/// <summary>
|
||||
/// A [normally] 256x256 heightmap
|
||||
/// </summary>
|
||||
|
@ -193,8 +198,10 @@ namespace OpenSim.Terrain
|
|||
resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n";
|
||||
resultText += "terrain erode thermal <talus> <rounds> <carry>\n";
|
||||
resultText += "terrain multiply <val> - multiplies a terrain by <val>\n";
|
||||
resultText += "terrain revert - reverts the terrain to the stored original";
|
||||
resultText += "terrain bake - saves the current terrain into the revert map";
|
||||
resultText += "terrain revert - reverts the terrain to the stored original\n";
|
||||
resultText += "terrain bake - saves the current terrain into the revert map\n";
|
||||
resultText += "terrain csfilter <filename.cs> - loads a new filter from the specified .cs file\n";
|
||||
resultText += "terrain jsfilter <filename.js> - loads a new filter from the specified .js file\n";
|
||||
return false;
|
||||
|
||||
case "revert":
|
||||
|
@ -285,9 +292,25 @@ namespace OpenSim.Terrain
|
|||
}
|
||||
break;
|
||||
|
||||
case "csfilter":
|
||||
customFilters.LoadFilterCSharp(args[1]);
|
||||
break;
|
||||
case "jsfilter":
|
||||
customFilters.LoadFilterJScript(args[1]);
|
||||
break;
|
||||
|
||||
default:
|
||||
resultText = "Unknown terrain command";
|
||||
return false;
|
||||
// Run any custom registered filters
|
||||
if (customFilters.filters.ContainsKey(command))
|
||||
{
|
||||
customFilters.filters[command].Filter(heightmap, args);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultText = "Unknown terrain command";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using System.CodeDom.Compiler;
|
||||
using System.CodeDom;
|
||||
using Microsoft.CSharp;
|
||||
using Microsoft.JScript;
|
||||
|
||||
using libTerrain;
|
||||
|
||||
namespace OpenSim.Terrain
|
||||
{
|
||||
public interface ITerrainFilter
|
||||
{
|
||||
void Filter(Channel heightmap, string[] args);
|
||||
string Register();
|
||||
}
|
||||
|
||||
public class TestFilter : ITerrainFilter
|
||||
{
|
||||
public void Filter(Channel heightmap, string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello world");
|
||||
}
|
||||
|
||||
public string Register()
|
||||
{
|
||||
return "demofilter";
|
||||
}
|
||||
}
|
||||
|
||||
public class FilterHost
|
||||
{
|
||||
public Dictionary<string, ITerrainFilter> filters = new Dictionary<string, ITerrainFilter>();
|
||||
|
||||
private void LoadFilter(ICodeCompiler compiler, string filename)
|
||||
{
|
||||
CompilerParameters compilerParams = new CompilerParameters();
|
||||
CompilerResults compilerResults;
|
||||
compilerParams.GenerateExecutable = false;
|
||||
compilerParams.GenerateInMemory = true;
|
||||
compilerParams.IncludeDebugInformation = false;
|
||||
compilerParams.ReferencedAssemblies.Add("libTerrain-BSD.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Terrain.BasicTerrain.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("System.dll");
|
||||
|
||||
compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
|
||||
|
||||
if (compilerResults.Errors.Count > 0)
|
||||
{
|
||||
Console.WriteLine("Compile errors:");
|
||||
foreach (CompilerError error in compilerResults.Errors)
|
||||
{
|
||||
Console.WriteLine(error.Line.ToString() + ": " + error.ErrorText.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
|
||||
{
|
||||
Type testInterface = pluginType.GetInterface("ITerrainFilter",true);
|
||||
|
||||
if (testInterface != null)
|
||||
{
|
||||
ITerrainFilter filter = (ITerrainFilter)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
|
||||
|
||||
string filterName = filter.Register();
|
||||
Console.WriteLine("Plugin: " + filterName + " loaded.");
|
||||
|
||||
if (!filters.ContainsKey(filterName))
|
||||
{
|
||||
filters.Add(filterName, filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
filters[filterName] = filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void LoadFilterCSharp(string filename)
|
||||
{
|
||||
CSharpCodeProvider compiler = new CSharpCodeProvider();
|
||||
LoadFilter(compiler.CreateCompiler(), filename);
|
||||
}
|
||||
|
||||
public void LoadFilterJScript(string filename)
|
||||
{
|
||||
JScriptCodeProvider compiler = new JScriptCodeProvider();
|
||||
LoadFilter(compiler.CreateCompiler(), filename);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -434,11 +434,14 @@ namespace OpenSim
|
|||
break;
|
||||
|
||||
case "terrain":
|
||||
//string result = "";
|
||||
/* if (!((World)m_localWorld).Terrain.RunTerrainCmd(cmdparams, ref result))
|
||||
{
|
||||
m_log.Error( result);
|
||||
}*/
|
||||
string result = "";
|
||||
for (int i = 0; i < m_localWorld.Count; i++)
|
||||
{
|
||||
if (!((Scene)m_localWorld[i]).Terrain.RunTerrainCmd(cmdparams, ref result))
|
||||
{
|
||||
m_log.Error(result);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "shutdown":
|
||||
|
|
Loading…
Reference in New Issue