/// <summary>
        /// Recorre todo el arbol CSG hasta llegar a las primitivas y va actalizando la matriz de mundo para soportar jerarquia de transformaciones.
        /// </summary>
        private IEnumerable<DrawableElement> GetElementsFrom(Graphic graphic, mat4x4 currentWorld)
        {
            if (graphic is ModelGraphic)
                yield return new DrawableElement() { Model = graphic as ModelGraphic, World = currentWorld };

            if (graphic is TransformedGraphic)
                foreach (var innerelement in GetElementsFrom(((TransformedGraphic)graphic).Graphic, ((TransformedGraphic)graphic).Transform * currentWorld))
                    yield return innerelement;

            if (graphic is CSGGraphic)
            {
                CSGGraphic csg = graphic as CSGGraphic;
                if (csg.Operation == CSGOperation.Union)
                {
                    foreach (var innerelement in GetElementsFrom(csg.LeftOperand, currentWorld))
                        yield return innerelement;
                    foreach (var innerelement in GetElementsFrom(csg.RightOperand, currentWorld))
                        yield return innerelement;
                }
                else
                    throw new NotSupportedException(); /// Not supported full CSG in zBuffering. (Bonus for implementation).
            }
        }
Exemple #2
0
 public Ray Transformed(mat4x4 transform)
 {
     return Ray.FromTo((vec3)(new vec4(this.From,1) * transform), (vec3)(new vec4(this.From + this.Direction, 1) * transform));
 }
Exemple #3
0
 internal TransformedGraphic(Graphic graphic, mat4x4 transform)
 {
     this.Graphic = graphic;
     this.Transform = transform;
 }