Exemple #1
0
        /// <summary>
        /// Traverses the control for rendering</summary>
        /// <param name="graphPath">The path leading to the control</param>
        /// <param name="action">Render action</param>
        /// <param name="list">Traverse list</param>
        public void Traverse(
            Stack <SceneNode> graphPath,
            IRenderAction action,
            ICollection <TraverseNode> list)
        {
            TraverseNode node = action.GetUnusedNode();

            node.Init(action.RenderObject, action.TopMatrix, graphPath, s_renderState);
            list.Add(node);
        }
Exemple #2
0
        /// <summary>
        /// Performs any traverse actions</summary>
        /// <param name="graphPath">The path leading to the RenderObject</param>
        /// <param name="renderAction">The render action used to dispatch the object</param>
        /// <param name="camera">The Camera used</param>
        /// <param name="traverseList">The traverse list used in the dispatch phase.
        /// RenderObjects participating in the dispatch phase need to push themselves onto the traverse list.</param>
        /// <returns>The TraverseState</returns>
        public virtual TraverseState Traverse(Stack <SceneNode> graphPath, IRenderAction renderAction, Camera camera, ICollection <TraverseNode> traverseList)
        {
            RenderState state = renderAction.RenderState;

            Box boundingBox = null;

            bool alpha = ((state.RenderMode & RenderMode.Alpha) != 0);

            if (alpha)
            {
                boundingBox = GetBoundingBoxObjectSpace();
                boundingBox.Transform(renderAction.TopMatrix);
            }

            if ((state.RenderMode & RenderMode.Smooth) != 0)
            {
                RenderMode origRenderMode = state.RenderMode;
                state.RenderMode &= ~(RenderMode.Wireframe | RenderMode.WireframeColor);

                TraverseNode node = renderAction.GetUnusedNode();
                node.Init(renderAction.RenderObject, renderAction.TopMatrix, graphPath, state);

                if (alpha)
                {
                    node.WorldSpaceBoundingBox = boundingBox;
                }

                traverseList.Add(node);
                state.RenderMode = origRenderMode;
            }

            if ((state.RenderMode & RenderMode.Wireframe) != 0)
            {
                RenderMode origRenderMode = state.RenderMode;
                state.RenderMode &= ~(RenderMode.Smooth | RenderMode.SolidColor |
                                      RenderMode.Textured | RenderMode.Lit);

                TraverseNode node = renderAction.GetUnusedNode();
                node.Init(renderAction.RenderObject, renderAction.TopMatrix, graphPath, state);

                if (alpha)
                {
                    node.WorldSpaceBoundingBox = boundingBox;
                }

                traverseList.Add(node);
                state.RenderMode = origRenderMode;
            }

            return(renderAction.TraverseState);
        }