* 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;
|
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)
|
private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY)
|
||||||
{
|
{
|
||||||
Hashtable param = new Hashtable();
|
Hashtable param = new Hashtable();
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace OpenGrid.Framework.Communications
|
||||||
{
|
{
|
||||||
public class GridInfo
|
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 GridServerSendKey = "badger";
|
||||||
public string GridServerRecvKey = "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>
|
<PropertyGroup>
|
||||||
<ProjectType>Local</ProjectType>
|
<ProjectType>Local</ProjectType>
|
||||||
<ProductVersion>8.0.50727</ProductVersion>
|
<ProductVersion>8.0.50727</ProductVersion>
|
||||||
|
@ -6,7 +6,8 @@
|
||||||
<ProjectGuid>{2270B8FE-0000-0000-0000-000000000000}</ProjectGuid>
|
<ProjectGuid>{2270B8FE-0000-0000-0000-000000000000}</ProjectGuid>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ApplicationIcon></ApplicationIcon>
|
<ApplicationIcon>
|
||||||
|
</ApplicationIcon>
|
||||||
<AssemblyKeyContainerName>
|
<AssemblyKeyContainerName>
|
||||||
</AssemblyKeyContainerName>
|
</AssemblyKeyContainerName>
|
||||||
<AssemblyName>OpenSim.Terrain.BasicTerrain</AssemblyName>
|
<AssemblyName>OpenSim.Terrain.BasicTerrain</AssemblyName>
|
||||||
|
@ -15,9 +16,11 @@
|
||||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder></AppDesignerFolder>
|
<AppDesignerFolder>
|
||||||
|
</AppDesignerFolder>
|
||||||
<RootNamespace>OpenSim.Terrain.BasicTerrain</RootNamespace>
|
<RootNamespace>OpenSim.Terrain.BasicTerrain</RootNamespace>
|
||||||
<StartupObject></StartupObject>
|
<StartupObject>
|
||||||
|
</StartupObject>
|
||||||
<FileUpgradeFlags>
|
<FileUpgradeFlags>
|
||||||
</FileUpgradeFlags>
|
</FileUpgradeFlags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -28,7 +31,8 @@
|
||||||
<ConfigurationOverrideFile>
|
<ConfigurationOverrideFile>
|
||||||
</ConfigurationOverrideFile>
|
</ConfigurationOverrideFile>
|
||||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||||
<DocumentationFile></DocumentationFile>
|
<DocumentationFile>
|
||||||
|
</DocumentationFile>
|
||||||
<DebugSymbols>True</DebugSymbols>
|
<DebugSymbols>True</DebugSymbols>
|
||||||
<FileAlignment>4096</FileAlignment>
|
<FileAlignment>4096</FileAlignment>
|
||||||
<Optimize>False</Optimize>
|
<Optimize>False</Optimize>
|
||||||
|
@ -37,7 +41,8 @@
|
||||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<NoWarn></NoWarn>
|
<NoWarn>
|
||||||
|
</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||||
|
@ -46,7 +51,8 @@
|
||||||
<ConfigurationOverrideFile>
|
<ConfigurationOverrideFile>
|
||||||
</ConfigurationOverrideFile>
|
</ConfigurationOverrideFile>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<DocumentationFile></DocumentationFile>
|
<DocumentationFile>
|
||||||
|
</DocumentationFile>
|
||||||
<DebugSymbols>False</DebugSymbols>
|
<DebugSymbols>False</DebugSymbols>
|
||||||
<FileAlignment>4096</FileAlignment>
|
<FileAlignment>4096</FileAlignment>
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
|
@ -55,13 +61,15 @@
|
||||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<NoWarn></NoWarn>
|
<NoWarn>
|
||||||
|
</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="libTerrain-BSD.dll">
|
<Reference Include="libTerrain-BSD.dll">
|
||||||
<HintPath>..\..\bin\libTerrain-BSD.dll</HintPath>
|
<HintPath>..\..\bin\libTerrain-BSD.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.JScript" />
|
||||||
<Reference Include="openjpegnet.dll">
|
<Reference Include="openjpegnet.dll">
|
||||||
<HintPath>..\..\bin\openjpegnet.dll</HintPath>
|
<HintPath>..\..\bin\openjpegnet.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
|
@ -92,6 +100,7 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="TerrainFilter.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
@ -47,6 +47,11 @@ namespace OpenSim.Terrain
|
||||||
|
|
||||||
public class TerrainEngine
|
public class TerrainEngine
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Plugin library for scripts
|
||||||
|
/// </summary>
|
||||||
|
public FilterHost customFilters = new FilterHost();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A [normally] 256x256 heightmap
|
/// A [normally] 256x256 heightmap
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -193,8 +198,10 @@ namespace OpenSim.Terrain
|
||||||
resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n";
|
resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n";
|
||||||
resultText += "terrain erode thermal <talus> <rounds> <carry>\n";
|
resultText += "terrain erode thermal <talus> <rounds> <carry>\n";
|
||||||
resultText += "terrain multiply <val> - multiplies a terrain by <val>\n";
|
resultText += "terrain multiply <val> - multiplies a terrain by <val>\n";
|
||||||
resultText += "terrain revert - reverts the terrain to the stored original";
|
resultText += "terrain revert - reverts the terrain to the stored original\n";
|
||||||
resultText += "terrain bake - saves the current terrain into the revert map";
|
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;
|
return false;
|
||||||
|
|
||||||
case "revert":
|
case "revert":
|
||||||
|
@ -285,10 +292,26 @@ namespace OpenSim.Terrain
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "csfilter":
|
||||||
|
customFilters.LoadFilterCSharp(args[1]);
|
||||||
|
break;
|
||||||
|
case "jsfilter":
|
||||||
|
customFilters.LoadFilterJScript(args[1]);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
// Run any custom registered filters
|
||||||
|
if (customFilters.filters.ContainsKey(command))
|
||||||
|
{
|
||||||
|
customFilters.filters[command].Filter(heightmap, args);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
resultText = "Unknown terrain command";
|
resultText = "Unknown terrain command";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -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;
|
break;
|
||||||
|
|
||||||
case "terrain":
|
case "terrain":
|
||||||
//string result = "";
|
string result = "";
|
||||||
/* if (!((World)m_localWorld).Terrain.RunTerrainCmd(cmdparams, ref result))
|
for (int i = 0; i < m_localWorld.Count; i++)
|
||||||
|
{
|
||||||
|
if (!((Scene)m_localWorld[i]).Terrain.RunTerrainCmd(cmdparams, ref result))
|
||||||
{
|
{
|
||||||
m_log.Error(result);
|
m_log.Error(result);
|
||||||
}*/
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "shutdown":
|
case "shutdown":
|
||||||
|
|
Loading…
Reference in New Issue