using System;
using RealmForge.Definitions.Templates;
using AxAxiom.Core;
using Axiom.MathLib;
using System.Drawing;
using RealmForge.SceneObjects;
using RealmForge.Primitives;
using RealmForge.Definitions.Infos;
using RealmForge.Definitions;
using RealmForge.Definitions.References;
namespace RealmForge.Scene{
/// <summary>
/// Scene object factory and state-driven builder for the progmatic construction of scenes for the Axiom rendering engine.
/// </summary>
public class AxiomSceneBuilder : SceneBuilder
{
#region Fields and Properties
protected Ax.SceneManager axiomScene;
public Ax.SceneManager AxiomScene { get { return axiomScene; } set{ axiomScene = value; } }
#endregion
#region Constructors
public AxiomSceneBuilder()
{
}
#endregion
#region Methods
protected override ICamera CreateCamera(string id) {
return new AxiomCamera(id);
}
protected override ISceneNode CreateSceneNode(string id) {
return new AxiomSceneNode(id);
}
protected override IRealm CreateRealm(string id) {
return new AxiomRealm(id);
}
protected override IRegion CreateRegion(string id) {
return new AxiomRegion(id);
}
protected override SceneNodeTemplate CreateSceneNodeTemplate() {
return new AxiomSceneNodeTemplate();
}
protected override SpriteTemplate CreateSpriteTemplate() {
return new AxiomSpriteTemplate();
}
protected override LightTemplate CreateLightTemplate() {
return new AxiomLightTemplate();
}
protected override EntityTemplate CreateEntityTemplate() {
return new AxiomEntityTemplate();
}
#endregion
#region Shapes
public override IPlaneEntity NewPlane(string id, PlaneInfo plane, string material) {
IPlaneEntity planeEnt = new AxiomPlane(id, plane);
if(material != null)
planeEnt.Material = material;
if(parentNode != null)
parentNode.AddChild(planeEnt);
return planeEnt;
}
public override ISceneNode NewTriangle(string id, Vector3 point1, Vector3 point2, Vector3 point3, Color color1, Color color2, Color color3, string material) {
AxiomPolygon poly = CreatePolygon(id, material);
poly.InitTriangle(point1, point2, point3, color1, color2, color3);
return poly;
}
public override ISceneNode NewPolygon(string id, AxisAlignedBox boundingBox, PolygonType renderType, Vector3[] vertices, Color[] colors, string material) {
AxiomPolygon poly = CreatePolygon(id, material);
poly.InitPolygon(renderType, boundingBox, vertices, colors);
return poly;
}
public override ISceneNode NewLine(string id, Vector3 startPoint, Vector3 endPoint, Color startColor, Color endColor, string material) {
AxiomPolygon poly = CreatePolygon(id, material);
poly.InitLine(startPoint, endPoint, startColor, endColor);
return poly;
}
protected AxiomPolygon CreatePolygon(string id, string material) {
string newMaterialName = material + "_" + id; //the name of the cloned material which is customized for use with a polygon
AxiomPolygon poly = new AxiomPolygon(id, material, newMaterialName);
if(parentNode != null)
parentNode.AddChild(poly);
return poly;
}
#endregion
#region Special Effects
protected override IParticleSystem CreateParticleSystem(string id, string sourceFile) {
return new AxiomParticleSystem(id, 0f, sourceFile);
}
#endregion
}
}
|