Ejemplo n.º 1
0
        public override void Apply(IGeode geode)
        {
            if (false == Enter(geode))
            {
                return;
            }

            foreach (var drawable in geode.Drawables)
            {
                Intersect(drawable);
            }

            Leave();
        }
Ejemplo n.º 2
0
 public override void Apply(IGeode geode)
 {
     base.Apply(geode);
 }
Ejemplo n.º 3
0
        public override void Apply(IGeode geode)
        {
            var bb = geode.GetBoundingBox();

            if (IsCulled(bb, ModelMatrixStack.Peek()))
            {
                return;
            }

            IPipelineState pso = null;

            // Node specific state
            if (geode.HasPipelineState)
            {
                pso = geode.PipelineState;
            }

            // Shared State
            else if (PipelineStateStack.Count != 0)
            {
                pso = PipelineStateStack.Peek();
            }

            // Fallback
            else
            {
                pso = PipelineState.Create();
            }

            foreach (var drawable in geode.Drawables)
            {
                if (IsCulled(drawable.GetBoundingBox(), ModelMatrixStack.Peek()))
                {
                    continue;
                }

                var drawablePso = pso;
                if (drawable.HasPipelineState)
                {
                    drawablePso = drawable.PipelineState;
                }

                //
                // This allocates / updates vbo/ibos
                //
                drawable.ConfigureDeviceBuffers(GraphicsDevice, ResourceFactory);

                var renderElementCache = new Dictionary <IRenderGroupState, RenderGroupElement>();

                foreach (var pset in drawable.PrimitiveSets)
                {
                    if (IsCulled(pset.GetBoundingBox(), ModelMatrixStack.Peek()))
                    {
                        continue;
                    }

                    //
                    // Sort into appropriate render group
                    //
                    IRenderGroupState renderGroupState = null;
                    if (drawablePso.BlendStateDescription.AttachmentStates.Contains(BlendAttachmentDescription.AlphaBlend))
                    {
                        renderGroupState = TransparentRenderGroup.GetOrCreateState(drawablePso, pset.PrimitiveTopology, drawable.VertexLayout);
                    }
                    else
                    {
                        renderGroupState = OpaqueRenderGroup.GetOrCreateState(drawablePso, pset.PrimitiveTopology, drawable.VertexLayout);
                    }

                    if (false == renderElementCache.TryGetValue(renderGroupState, out var renderElement))
                    {
                        renderElement = new RenderGroupElement()
                        {
                            ModelViewMatrix = GetModelViewMatrix(),
                            VertexBuffer    = drawable.GetVertexBufferForDevice(GraphicsDevice),
                            IndexBuffer     = drawable.GetIndexBufferForDevice(GraphicsDevice),
                            PrimitiveSets   = new List <IPrimitiveSet>()
                        };
                        renderGroupState.Elements.Add(renderElement);

                        renderElementCache.Add(renderGroupState, renderElement);
                    }
                    renderElement.PrimitiveSets.Add(pset);
                }
            }
        }
Ejemplo n.º 4
0
 //
 // Default implementation for Geometry Node
 //
 public virtual void Apply(IGeode geode)
 {
     Apply((INode)geode);
 }