I am trying to use a small open source library called libnoise for generating (and modifying) procedural noise for textures, landscapes etc. The library is orginally written in c++, but it has been ported to C#/.NET. It’s a pretty small library so I figured it would be manageble to get it working in Unity.
Link: http://libnoisedotnet.codeplex.com/
Below is a simple noise modifier class from the library:
using System;
using System.Collections.Generic;
using System.Text;
namespace LibNoise.Modifiers
{
public class Add
: IModule
{
public IModule SourceModule1 { get; set; }
public IModule SourceModule2 { get; set; }
public Add(IModule sourceModule1, IModule sourceModule2)
{
if (sourceModule1 == null || sourceModule2 == null)
throw new ArgumentNullException("Source modules must be provided.");
SourceModule1 = sourceModule1;
SourceModule2 = sourceModule2;
}
public double GetValue(double x, double y, double z)
{
if (SourceModule1 == null || SourceModule2 == null)
throw new NullReferenceException("Source modules must be provided.");
return SourceModule1.GetValue(x, y, z) + SourceModule2.GetValue(x, y, z);
}
}
}
I dragged all the files into the asset manager to see what would happen. I had to do a global search&replace on all the empty get/set in the code, but I wouldn’t expect that to be a problem.
-
I have no idea how I would access this code. Doing something like “import Libnoise.Add;” doesn’t work. Is there a way to access non-MonoBehaviour classes? Or do I need to change their base classes to inherit from MonoBehaviour? (I’m not planning on attaching their code diretly on GameObjects - only as library calls from either UnityScript or C#).
-
They obviously wrap all their code in namespaces - is this a problem for Unity? I remember reading somewhere about Unity not supporting C# namespaces.
The library is pretty small, so making modification to all the code is not out of the question - I just need to know what to change it into. ![]()
They also provide a compiled .DLL, but I really see that as the last fallback option, since that would limit me to the Windows standalone platform.
I am using Unity Pro 2.x Trial, but expecting to upgrade to Unity Pro 3.0 later this week.