Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
806 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using Hyperion.Core.Interfaces; | ||
using Hyperion.Core.Tools; | ||
using Hyperion.Core.Geometry; | ||
|
||
namespace Hyperion.Core.PluginSystem | ||
{ | ||
/// <summary> | ||
/// Plugin for all kinds of cameras. | ||
/// </summary> | ||
public class AcceleratorPlugin : Plugin | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public delegate IPrimitive CreateAcceleratorDelegate (List<IPrimitive> primitives, ParameterSet paramSet); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public CreateAcceleratorDelegate CreateAccelerator; | ||
|
||
/// <summary> | ||
/// Initialize the plugin and it's name | ||
/// </summary> | ||
/// <param name="name"> | ||
/// The plugin's name | ||
/// </param> | ||
public AcceleratorPlugin (string name) : base("Accelerators", name) | ||
{ | ||
MethodInfo methodInfo = GetMethod ("CreateAccelerator"); | ||
CreateAccelerator = Delegate.CreateDelegate (typeof(CreateAcceleratorDelegate), methodInfo) as CreateAcceleratorDelegate; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using Hyperion.Core.Interfaces; | ||
using Hyperion.Core.Tools; | ||
using Hyperion.Core.Geometry; | ||
|
||
namespace Hyperion.Core.PluginSystem | ||
{ | ||
/// <summary> | ||
/// Plugin for all kinds of cameras. | ||
/// </summary> | ||
public class AreaLightPlugin : Plugin | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public delegate ILight CreateAreaLightDelegate (Transform objectToWorld, ParameterSet parameters, IShape shape); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public CreateAreaLightDelegate CreateAreaLight; | ||
|
||
/// <summary> | ||
/// Initialize the plugin and it's name | ||
/// </summary> | ||
/// <param name="name"> | ||
/// The plugin's name | ||
/// </param> | ||
public AreaLightPlugin (string name) : base("Lights", name) | ||
{ | ||
MethodInfo methodInfo = GetMethod ("CreateAreaLight"); | ||
CreateAreaLight = Delegate.CreateDelegate (typeof(CreateAreaLightDelegate), methodInfo) as CreateAreaLightDelegate; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
using System; | ||
using System.Reflection; | ||
using Hyperion.Core.Interfaces; | ||
using Hyperion.Core.Tools; | ||
using Hyperion.Core.Geometry; | ||
|
||
namespace Hyperion.Core.PluginSystem | ||
{ | ||
/// <summary> | ||
/// Plugin for all kinds of cameras. | ||
/// </summary> | ||
public class CameraPlugin : Plugin | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public delegate ICamera CreateCameraDelegate (ParameterSet paramSet, Transform worldToCamera, IFilm film); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public CreateCameraDelegate CreateCamera; | ||
|
||
/// <summary> | ||
/// Initialize the plugin and it's name | ||
/// </summary> | ||
/// <param name="name"> | ||
/// The plugin's name | ||
/// </param> | ||
public CameraPlugin (string name) : base("Cameras", name) | ||
{ | ||
MethodInfo methodInfo = GetMethod ("CreateCamera"); | ||
CreateCamera = Delegate.CreateDelegate (typeof(CreateCameraDelegate), methodInfo) as CreateCameraDelegate; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
using System; | ||
using System.Reflection; | ||
using Hyperion.Core.Interfaces; | ||
using Hyperion.Core.Tools; | ||
using Hyperion.Core.Geometry; | ||
|
||
namespace Hyperion.Core.PluginSystem | ||
{ | ||
/// <summary> | ||
/// Plugin for all kinds of films. | ||
/// </summary> | ||
public class FilmPlugin : Plugin | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public delegate IFilm CreateFilmDelegate (ParameterSet paramSet, IFilter filter); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public CreateFilmDelegate CreateFilm; | ||
|
||
/// <summary> | ||
/// Initialize the plugin and it's name | ||
/// </summary> | ||
/// <param name="name"> | ||
/// The plugin's name | ||
/// </param> | ||
public FilmPlugin (string name) : base("Films", name) | ||
{ | ||
MethodInfo methodInfo = GetMethod ("CreateFilm"); | ||
CreateFilm = Delegate.CreateDelegate (typeof(CreateFilmDelegate), methodInfo) as CreateFilmDelegate; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
using System; | ||
using System.Reflection; | ||
using Hyperion.Core.Interfaces; | ||
using Hyperion.Core.Tools; | ||
using Hyperion.Core.Geometry; | ||
|
||
namespace Hyperion.Core.PluginSystem | ||
{ | ||
/// <summary> | ||
/// Plugin for all kinds of films. | ||
/// </summary> | ||
public class FilterPlugin : Plugin | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public delegate IFilter CreateFilterDelegate (ParameterSet paramSet); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public CreateFilterDelegate CreateFilter; | ||
|
||
/// <summary> | ||
/// Initialize the plugin and it's name | ||
/// </summary> | ||
/// <param name="name"> | ||
/// The plugin's name | ||
/// </param> | ||
public FilterPlugin (string name) : base("Filters", name) | ||
{ | ||
MethodInfo methodInfo = GetMethod ("CreateFilter"); | ||
CreateFilter = Delegate.CreateDelegate (typeof(CreateFilterDelegate), methodInfo) as CreateFilterDelegate; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
using System; | ||
using System.Reflection; | ||
using Hyperion.Core.Interfaces; | ||
using Hyperion.Core.Tools; | ||
using Hyperion.Core.Geometry; | ||
|
||
namespace Hyperion.Core.PluginSystem | ||
{ | ||
/// <summary> | ||
/// Plugin for all kinds of cameras. | ||
/// </summary> | ||
public class LightPlugin : Plugin | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public delegate ILight CreateLightDelegate (Transform lightToWorld, ParameterSet paramSet); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public CreateLightDelegate CreateLight; | ||
|
||
/// <summary> | ||
/// Initialize the plugin and it's name | ||
/// </summary> | ||
/// <param name="name"> | ||
/// The plugin's name | ||
/// </param> | ||
public LightPlugin (string name) : base("Lights", name) | ||
{ | ||
MethodInfo methodInfo = GetMethod ("CreateLight"); | ||
CreateLight = Delegate.CreateDelegate (typeof(CreateLightDelegate), methodInfo) as CreateLightDelegate; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
using System; | ||
using System.Reflection; | ||
using Hyperion.Core.Interfaces; | ||
using Hyperion.Core.Tools; | ||
using Hyperion.Core.Geometry; | ||
|
||
namespace Hyperion.Core.PluginSystem | ||
{ | ||
/// <summary> | ||
/// Plugin for all kinds of cameras. | ||
/// </summary> | ||
public class MaterialPlugin : Plugin | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public delegate IMaterial CreateMaterialDelegate (Transform objectToWorld, TextureParameterSet parameters); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public CreateMaterialDelegate CreateMaterial; | ||
|
||
/// <summary> | ||
/// Initialize the plugin and it's name | ||
/// </summary> | ||
/// <param name="name"> | ||
/// The plugin's name | ||
/// </param> | ||
public MaterialPlugin (string name) : base("Materials", name) | ||
{ | ||
MethodInfo methodInfo = GetMethod ("CreateMaterial"); | ||
CreateMaterial = Delegate.CreateDelegate (typeof(CreateMaterialDelegate), methodInfo) as CreateMaterialDelegate; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
|
||
using System; | ||
using System.IO; | ||
using System.Reflection; | ||
|
||
namespace Hyperion.Core.PluginSystem | ||
{ | ||
/// <summary> | ||
/// This is the basic Plugin class. So far, a plugin holds track | ||
/// of it's name and a library handle. To use a plugin, the pluginclass | ||
/// has to inherit from Plugin and provide a Creation Method. Afterwards it | ||
/// can be used like this: | ||
/// | ||
/// <code> | ||
/// ICamera cam = PluginManager.CreateCamera ("PerspectiveCamera"); | ||
/// </code> | ||
/// | ||
/// Therefore your class must contain this (again, the camera as an example): | ||
/// | ||
/// <code> | ||
/// public class CameraPlugin : Plugin | ||
/// { | ||
/// delegate ICamera CreateCameraDelegate (); | ||
/// public CreateCameraDelegate CreateCamera; | ||
/// } | ||
/// </code> | ||
/// </summary> | ||
public class Plugin | ||
{ | ||
/// <summary> | ||
/// The plugin's name | ||
/// </summary> | ||
private string _name; | ||
|
||
/// <summary> | ||
/// The plugin's assembly | ||
/// </summary> | ||
private Assembly _assembly; | ||
|
||
/// <summary> | ||
/// Initialize the plugin and it's name | ||
/// </summary> | ||
/// <param name="name"> | ||
/// The plugin's name | ||
/// </param> | ||
public Plugin (string category, string name) | ||
{ | ||
_name = name; | ||
|
||
string currentDirectory = Directory.GetCurrentDirectory (); | ||
string[] files = Directory.GetFiles (currentDirectory); | ||
string assemblyPath = string.Empty; | ||
|
||
foreach (string file in files) | ||
{ | ||
if (file.Contains (category + "." + name + ".dll")) | ||
{ | ||
assemblyPath = file; | ||
break; | ||
} | ||
} | ||
|
||
_assembly = Assembly.LoadFile (assemblyPath); | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves a pointer to a method in the plugin's assembly | ||
/// </summary> | ||
/// <param name="methodName"> | ||
/// The method's name | ||
/// </param> | ||
/// <returns> | ||
/// The method info | ||
/// </returns> | ||
public MethodInfo GetMethod (string methodName) | ||
{ | ||
Type[] types = null; | ||
try | ||
{ | ||
types = _assembly.GetTypes (); | ||
} | ||
catch (ReflectionTypeLoadException e) | ||
{ | ||
types = e.Types; | ||
} | ||
|
||
foreach (Type type in types) | ||
{ | ||
if (type.Name == _name) | ||
return type.GetMethod (methodName); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.