#region usings using System.Collections.Generic; using OpenTK.Graphics.ES11; using SM.Base; using SM.Base.Scene; using SM.Base.Windows; using SM.OGL.Mesh; using PrimitiveType = OpenTK.Graphics.OpenGL4.PrimitiveType; #endregion namespace SM.Base.Drawing { /// /// Contains general basis systems for drawing objects. /// public abstract class DrawingBasis : IShowItem, IModelItem { /// /// The material it should use. /// public Material Material = new Material(); /// /// The mesh it should use. /// public GenericMesh Mesh { get; set; } = SMRenderer.DefaultMesh; public ShaderArguments ShaderArguments => Material.ShaderArguments; public TextureTransformation TextureTransform = new TextureTransformation(); /// public object Parent { get; set; } /// public string Name { get; set; } = "Unnamed draw object"; /// public ICollection Flags { get; set; } public PrimitiveType? ForcedMeshType { get; set; } /// /// This value determents if the object should draw something. /// public bool Active { get; set; } = true; public bool RenderActive { get; set; } = true; /// public void Draw(DrawContext context) { context.Material = Material; context.Mesh = Mesh; DrawContext(ref context); } /// public virtual void OnAdded(object sender) { } /// public virtual void OnRemoved(object sender) { } /// /// Draws the context, that was given to them. /// /// protected virtual void DrawContext(ref DrawContext context) { context.ForcedType = ForcedMeshType; context.TextureMatrix *= TextureTransform.GetMatrix(); context.LastObject = this; } } /// /// Contains general basis systems for drawing objects. /// /// The transformation type public abstract class DrawingBasis : DrawingBasis, IShowTransformItem where TTransformation : GenericTransformation, new() { /// /// The current transformation. /// public TTransformation Transform { get; set; } = new TTransformation(); /// protected override void DrawContext(ref DrawContext context) { base.DrawContext(ref context); Transform.LastMaster = context.ModelMatrix; context.ModelMatrix = Transform.InWorldSpace; } } }