コード例 #1
0
ファイル: RenderTransform.cs プロジェクト: Joxx0r/ATF
        /// <summary>
        /// Traverses the specified graph path</summary>
        /// <param name="graphPath">The graph path</param>
        /// <param name="action">The render action</param>
        /// <param name="camera">The camera</param>
        /// <param name="list">The list</param>
        /// <returns></returns>
        public override TraverseState Traverse(Stack<SceneNode> graphPath, IRenderAction action, Camera camera, ICollection<TraverseNode> list)
        {
            // Get the "top matrix" before we push a new matrix on to it, just in case we need
            //  it for the bounding box test.
            Matrix4F parentToWorld = action.TopMatrix;

            // Push matrix onto the matrix stack even if we're not visible because this class
            //  implements the marker interface ISetsLocalTransform.
            action.PushMatrix(m_node.Transform, true);

            // If node is invisible then cull
            if (!m_node.Visible)
                return TraverseState.Cull;

            TraverseState dResult = action.TraverseState;
            if (dResult == TraverseState.None)
            {
                // Test if bounding sphere is contained in frustum
                if (s_enableVFCull)
                {
                    // Construct bounding box
                    Box box = new Box();
                    box.Extend(m_node.BoundingBox);

                    // Transform the bounding box into view space
                    Matrix4F localToView = Matrix4F.Multiply(parentToWorld, camera.ViewMatrix);
                    box.Transform(localToView);

                    if (!camera.Frustum.Contains(box))
                        dResult = TraverseState.Cull;
                }
            }
            return dResult;
        }
コード例 #2
0
ファイル: Node.cs プロジェクト: Joxx0r/ATF
        /// <summary>
        /// Calculates bounding box of node's children</summary>
        /// <returns>Bounding box of children</returns>
        public Box CalculateBoundingBox()
        {
            var box = new Box();
            foreach (IBoundable boundable in DomNode.Children.AsIEnumerable<IBoundable>())
                box.Extend(boundable.BoundingBox);

            box.Transform(Transform);
            DomNodeUtil.SetBox(DomNode, Schema.nodeType.boundingBoxAttribute, box);

            return box;
        }
コード例 #3
0
ファイル: Node.cs プロジェクト: Joxx0r/ATF
        private Box CalculateBoundingBox()
        {
            // compute box.
            var box = new Box();
            
            foreach (InstanceGeometry instGeom in GetChildList<InstanceGeometry>(Schema.node.instance_geometryChild))
            {                
                box.Extend(instGeom.Geometry.BoundingBox);
            }

            foreach (InstanceController instCtrl in GetChildList<InstanceController>(Schema.node.instance_controllerChild))
            {                
                box.Extend(instCtrl.Geometry.BoundingBox);
            }

            foreach (Node nd in GetChildList<Node>(Schema.node.nodeChild))
            {                
                box.Extend(nd.BoundingBox);
            }

            box.Transform(Transform);
            return box;
           
        }