示例#1
0
 /// <summary>
 /// Creates a new scene hints object with the specified source hintable.
 /// </summary>
 /// <param name="source">Source hintable</param>
 public SceneHints(IHintable source)
 {
     _source     = source;
     _cullHint   = CullHint.Inherit;
     _lightHint  = LightCombineHint.Inherit;
     _transHint  = TransparencyType.Default;
     _pickHint   = PickingHint.Inherit;
     _orthoOrder = 0;
 }
示例#2
0
 /// <summary>
 /// Deserializes this SceneHints.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public void Read(ISavableReader input)
 {
     _cullHint   = input.ReadEnum <CullHint>();
     _pickHint   = input.ReadEnum <PickingHint>();
     _lightHint  = input.ReadEnum <LightCombineHint>();
     _transHint  = input.ReadEnum <TransparencyType>();
     _bucketType = input.ReadEnum <RenderBucketType>();
     _orthoOrder = input.ReadInt();
 }
示例#3
0
        /// <summary>
        /// Checks if the Spatial should be culled, if the Spatial is
        /// visible then Draw() will be called.
        /// </summary>
        /// <param name="renderer">BaseRenderer used to draw</param>
        public void OnDraw(IRenderer renderer)
        {
            CullHint hint = _sceneHints.CullHint;

            //Do trivial check
            if (hint == CullHint.Always)
            {
                _frustumIntersect = ContainmentType.Outside;
                return;
            }
            else if (hint == CullHint.Never)
            {
                _frustumIntersect = ContainmentType.Intersects;
                Draw(renderer);
                return;
            }

            //If dynamic, now check the frustum
            ICamera cam = renderer.CurrentCamera;

            //Set what our parent was, if any
            if (Parent != null)
            {
                _frustumIntersect = _parent.LastFrustumIntersect;
            }
            else
            {
                _frustumIntersect = ContainmentType.Intersects;
            }

            //If our parent intersects with the frustum, we need to check this Spatial since it may
            //be outside. If the parent was inside, then we are guaranteed to be contained as well.
            if (hint == CullHint.Dynamic && _frustumIntersect == ContainmentType.Intersects)
            {
                _frustumIntersect = cam.Contains(_worldBounding);
            }

            //If intersecting/inside, draw
            if (_frustumIntersect != ContainmentType.Outside)
            {
                Draw(renderer);
            }
        }