/// <summary>
 ///    Internal method to put the contents onto the render queue.
 /// </summary>
 /// <param name="queue">Current render queue.</param>
 public virtual void UpdateRenderQueue(RenderQueue queue)
 {
     if (isVisible)
     {
         queue.AddRenderable(this, (ushort)zOrder, RenderQueueGroupID.Overlay);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="queue"></param>
 public override void UpdateRenderQueue(RenderQueue queue)
 {
     // add ourself to the render queue
     // we render late, since most of the ocean will be rendered over by terrain, and
     // we will benefit from early out in the pixel shader due to z-test
     queue.AddRenderable(this, 1, RenderQueueGroupID.Nine);
 }
Example #3
0
 public override void UpdateRenderQueue(RenderQueue queue)
 {
     UpdateIndexBuffer();
     if (indexData.indexCount > 0)
     {
         queue.AddRenderable(this, RenderQueue.DEFAULT_PRIORITY, renderQueueID);
     }
 }
Example #4
0
        /// <summary>
        ///		Internal method which locates any visible objects attached to this node and adds them to the passed in queue.
        /// </summary>
        /// <param name="camera">Active camera.</param>
        /// <param name="queue">Queue to which these objects should be added.</param>
        /// <param name="includeChildren">If true, cascades down to all children.</param>
        /// <param name="displayNodes">Renders the local axes for the node.</param>
        /// <param name="onlyShadowCasters"></param>
        public virtual void FindVisibleObjects(Camera camera, RenderQueue queue, bool includeChildren, bool displayNodes,
                                               bool onlyShadowCasters)
        {
            // if we aren't visible, then quit now
            // TODO: Make sure sphere is calculated properly for all objects, then switch to cull using that
            if (!camera.IsObjectVisible(this.worldAABB))
            {
                return;
            }

            // add visible objects to the render queue
            //objectListMeter.Enter();
            foreach (var obj in this.objectList.Values)
            {
                // tell attached object about current camera in case it wants to know
                //notifyCameraMeter.Enter();
                obj.NotifyCurrentCamera(camera);
                //notifyCameraMeter.Exit();

                // if this object is visible, add it to the render queue
                if (obj.IsVisible && (!onlyShadowCasters || obj.CastShadows))
                {
                    //updateQueueMeter.Enter();
                    obj.UpdateRenderQueue(queue);
                    //updateQueueMeter.Exit();
                }
            }
            //objectListMeter.Exit();

            //childListMeter.Enter();
            if (includeChildren)
            {
                // ask all child nodes to update the render queue with visible objects
                foreach (SceneNode childNode in childNodes.Values)
                {
                    if (childNode.IsVisible)
                    {
                        childNode.FindVisibleObjects(camera, queue, includeChildren, displayNodes, onlyShadowCasters);
                    }
                }
            }
            //childListMeter.Exit();

            // if we wanna display nodes themself..
            if (displayNodes)
            {
                // hey, lets just add ourself right to the render queue
                queue.AddRenderable(GetDebugRenderable());
            }

            // do we wanna show our beautiful bounding box?
            // do it if either we want it, or the SceneManager dictates it
            if (this.showBoundingBox || (this.creator != null && this.creator.ShowBoundingBoxes))
            {
                AddBoundingBoxToQueue(queue);
            }
        }
Example #5
0
 /// <summary>
 ///   Add children to the render queue
 /// </summary>
 /// <param name="queue"> </param>
 /// <param name="group"> </param>
 /// <param name="camSquaredDistance"> </param>
 public void AddRenderables(RenderQueue queue, RenderQueueGroupID group, float camSquaredDistance)
 {
     // Determine the current material technique
     mTechnique = mMaterial.GetBestTechnique(mMaterial.GetLodIndex(camSquaredDistance));
     foreach (GeometryBucket iter in mGeometryBucketList)
     {
         queue.AddRenderable(iter, group);
     }
 }
        public override void UpdateRenderQueue(RenderQueue queue)
        {
            Debug.Assert(inBoundary);

            if (isVisible)
            {
                queue.AddRenderable(this);
            }
        }
Example #7
0
        public override void UpdateRenderQueue(RenderQueue queue)
        {
            UpdateIndexBuffer();

            if (this.indexData.indexCount > 0)
            {
                queue.AddRenderable(this);
            }
        }
Example #8
0
        /// <summary>
        ///		Adds this nodes bounding box (wireframe) to the RenderQueue.
        /// </summary>
        /// <param name="queue"></param>
        public void AddBoundingBoxToQueue(RenderQueue queue)
        {
            if (this.wireBox == null)
            {
                this.wireBox = new WireBoundingBox();
            }

            // add the wire bounding box to the render queue
            this.wireBox.BoundingBox = this.worldAABB;
            queue.AddRenderable(this.wireBox);
        }
        /// <summary>
        ///		Adds this nodes bounding box (wireframe) to the RenderQueue.
        /// </summary>
        /// <param name="queue"></param>
        public void AddBoundingBoxToQueue(RenderQueue queue)
        {
            if (wireBox == null)
            {
                wireBox = new WireBoundingBox();
            }

            // add the wire bounding box to the render queue
            wireBox.InitAABB(worldAABB);
            queue.AddRenderable(wireBox);
        }
Example #10
0
 public void AddRenderables(RenderQueue queue, RenderQueueGroupID group, float camDistanceSquared)
 {
     if (material != null)
     {
         // determine the current material technique
         technique = material.GetBestTechnique(material.GetLodIndexSquaredDepth(camDistanceSquared));
         foreach (GeometryBucket gbucket in geometryBucketList)
         {
             queue.AddRenderable(gbucket, RenderQueue.DEFAULT_PRIORITY, group);
         }
     }
 }
        /// <summary>
        ///    Overriden from Panel.
        /// </summary>
        /// <param name="queue"></param>
        public override void UpdateRenderQueue(RenderQueue queue)
        {
            // Add self twice to the queue
            // Have to do this to allow 2 materials
            if (isVisible)
            {
                // add border first
                queue.AddRenderable(borderRenderable, (ushort)zOrder, RenderQueueGroupID.Overlay);

                // do inner last so the border artifacts don't overwrite the children
                // Add inner
                base.UpdateRenderQueue(queue);
            }
        }
Example #12
0
        public override void UpdateRenderQueue(RenderQueue queue)
        {
#if _VisibilityCheck
            if (mustRender == false)
            {
                return;
            }
#endif
            if (inUse && isLoaded && inFrustum)
            {
                RenderableManager.Instance.AddVisible();
                queue.AddRenderable(this);
            }
        }
Example #13
0
        public override void UpdateRenderQueue(RenderQueue queue)
        {
            if (isVisible)
            {
                if (tile.Hilight)
                {
                    material = tile.HilightMaterial;
                }
                else
                {
                    material = normalMaterial;
                }

                if (renderOp.vertexData == null)
                {
                    // the object is visible so we had better make sure it has vertex and index buffers
                    renderOp.vertexData = buildVertexData();
                    renderOp.indexData  = IndexBufferManager.Instance.GetTileIndexBuffer(numSamples);
                }

                if (WorldManager.Instance.DrawTiles)
                {
                    queue.AddRenderable(this);
                }

                if (stitchRenderable == null)
                {
                    tile.Stitch();
                }

                if (WorldManager.Instance.DrawStitches && (stitchRenderable != null))
                {
                    queue.AddRenderable(stitchRenderable);
                }
            }
        }
Example #14
0
        public void QueuePatches(RenderQueue queue)
        {
            var idx = 0;

            for (var i = 0; i < Levels; i++)
            {
                var level = _levels[i];

                var mask = i == 0 ? PatchLocations.PatchSelection.Everything :PatchLocations.PatchSelection.Outer;

                if (i != 0)
                {
                    mask |= PatchLocations.PatchSelection.OuterDegenerated;
                }

                mask |= level.Bottom ? PatchLocations.PatchSelection.InteriorBottom : PatchLocations.PatchSelection.InteriorTop;
                mask |= level.Left ? PatchLocations.PatchSelection.InteriorLeft : PatchLocations.PatchSelection.InteriorRight;

                var subX = level.Position.X.Fraction * 2.0f - 1.0f;
                var intX = level.Position.X.Integer;
                var subY = level.Position.Y.Fraction * 2.0f - 1.0f;
                var intY = level.Position.Y.Integer;
                var texX = (intX * 2) & N;
                var texY = (intY * 2) & N;

                foreach (var p in Locations.Select(mask))
                {
                    PatchRenderable pp;
                    if (_queueCache.Count <= idx)
                    {
                        pp = new PatchRenderable(p.Patch, _shader);
                        _queueCache.Add(pp);
                    }
                    else
                    {
                        pp = _queueCache[idx];
                    }
                    idx++;


                    // queue the patch for rendering
                    pp.ScaleFactor     = new Vector4(p.X + subX, p.Y + subY, level.Scale, level.Scale);
                    pp.FineBlockOrigin = new Vector4(p.X - Hx - texX, p.Y - Hx - texY, (float)InverseD, (float)InverseD);
                    pp.Level           = level;
                    queue.AddRenderable(pp);
                }
            }
        }
        public override void UpdateRenderQueue(RenderQueue queue)
        {
            if (isVisible)
            {
                if (TerrainManager.Instance.DrawTerrain)
                {
                    if (renderOp.vertexData == null)
                    {
                        // the object is visible so we had better make sure it has vertex and index buffers
                        buildVertexData();
                    }

                    // put terrain in its own render queue for easier profiling
                    queue.AddRenderable(this, RenderQueue.DEFAULT_PRIORITY, RenderQueueGroupID.Main);
                }
            }
        }
Example #16
0
            public void AddRenderables(RenderQueue queue, RenderQueueGroupID group, Real lodValue)
            {
                // Get batch instance
#warning OGRE-1.6 BatchInstance Implementation
                //BatchInstance batchInstance = Parent.Parent;

                // Get material lod strategy
                var materialLodStrategy = Material.LodStrategy;

                // If material strategy doesn't match, recompute lod value with correct strategy
#warning OGRE-1.6 BatchInstance Implementation needed
                //if ( materialLodStrategy != batchInstance.LodStrategy )
                //    lodValue = materialLodStrategy.GetValue( batchInstance, batchInstance.Camera );

                // determine the current material technique
                this.technique = this.material.GetBestTechnique(this.material.GetLodIndex(lodValue));
                foreach (var gbucket in this.geometryBucketList)
                {
                    queue.AddRenderable(gbucket, RenderQueue.DEFAULT_PRIORITY, group);
                }
            }
Example #17
0
        /*
         *      // Recursively walk the zones, adding all visible SceneNodes to the list of visible nodes.
         */

        public override void FindVisibleNodes(PCZCamera camera, ref List <PCZSceneNode> visibleNodeList, RenderQueue queue,
                                              VisibleObjectsBoundsInfo visibleBounds, bool onlyShadowCasters,
                                              bool displayNodes, bool showBoundingBoxes)
        {
            //return immediately if nothing is in the zone.
            if (mHomeNodeList.Count == 0 && mVisitorNodeList.Count == 0 && mPortals.Count == 0)
            {
                return;
            }

            // Else, the zone is automatically assumed to be visible since either
            // it is the camera the zone is in, or it was reached because
            // a connecting portal was deemed visible to the camera.

            // enable sky if called to do so for this zone
            if (HasSky)
            {
                // enable sky
                mPCZSM.EnableSky(true);
            }

            // find visible nodes at home in the zone
            bool vis;

            foreach (PCZSceneNode pczsn in mHomeNodeList)
            {
                //PCZSceneNode pczsn = *it;
                // if the scene node is already visible, then we can skip it
                if (pczsn.LastVisibleFrame != mLastVisibleFrame || pczsn.LastVisibleFromCamera != camera)
                {
                    FrustumPlane fPlane;
                    // for a scene node, check visibility using AABB
                    vis = camera.IsObjectVisible(pczsn.WorldAABB, out fPlane);
                    if (vis)
                    {
                        // add it to the list of visible nodes
                        visibleNodeList.Add(pczsn);
                        // add the node to the render queue
                        pczsn.AddToRenderQueue(camera, queue, onlyShadowCasters, visibleBounds);
                        // if we are displaying nodes, add the node renderable to the queue
                        if (displayNodes)
                        {
                            queue.AddRenderable(pczsn.GetDebugRenderable());
                        }
                        // if the scene manager or the node wants the bounding box shown, add it to the queue
                        if (pczsn.ShowBoundingBox || showBoundingBoxes)
                        {
                            pczsn.AddBoundingBoxToQueue(queue);
                        }
                        // flag the node as being visible this frame
                        pczsn.LastVisibleFrame      = mLastVisibleFrame;
                        pczsn.LastVisibleFromCamera = camera;
                    }
                }
            }
            // find visible visitor nodes

            foreach (PCZSceneNode pczsn in mVisitorNodeList)
            {
                // if the scene node is already visible, then we can skip it
                if (pczsn.LastVisibleFrame != mLastVisibleFrame || pczsn.LastVisibleFromCamera != camera)
                {
                    FrustumPlane fPlane;
                    // for a scene node, check visibility using AABB
                    vis = camera.IsObjectVisible(pczsn.WorldAABB, out fPlane);
                    if (vis)
                    {
                        // add it to the list of visible nodes
                        visibleNodeList.Add(pczsn);
                        // add the node to the render queue
                        pczsn.AddToRenderQueue(camera, queue, onlyShadowCasters, visibleBounds);
                        // if we are displaying nodes, add the node renderable to the queue
                        if (displayNodes)
                        {
                            queue.AddRenderable(pczsn.GetDebugRenderable());
                        }
                        // if the scene manager or the node wants the bounding box shown, add it to the queue
                        if (pczsn.ShowBoundingBox || showBoundingBoxes)
                        {
                            pczsn.AddBoundingBoxToQueue(queue);
                        }
                        // flag the node as being visible this frame
                        pczsn.LastVisibleFrame      = mLastVisibleFrame;
                        pczsn.LastVisibleFromCamera = camera;
                    }
                }
            }

            // find visible portals in the zone and recurse into them
            foreach (Portal portal in mPortals)
            {
                FrustumPlane fPlane;
                // for portal, check visibility using world bounding sphere & direction
                vis = camera.IsObjectVisible(portal, out fPlane);
                if (vis)
                {
                    // portal is visible. Add the portal as extra culling planes to camera
                    int planes_added = camera.AddPortalCullingPlanes(portal);
                    // tell target zone it's visible this frame
                    portal.getTargetZone().LastVisibleFrame      = mLastVisibleFrame;
                    portal.getTargetZone().LastVisibleFromCamera = camera;
                    // recurse into the connected zone
                    portal.getTargetZone().FindVisibleNodes(camera, ref visibleNodeList, queue, visibleBounds, onlyShadowCasters,
                                                            displayNodes, showBoundingBoxes);
                    if (planes_added > 0)
                    {
                        // Then remove the extra culling planes added before going to the next portal in this zone.
                        camera.RemovePortalCullingPlanes(portal);
                    }
                }
            }
        }
            /// <summary>
            /// 
            /// </summary>
            /// <param name="queue"></param>
            /// <param name="group"></param>
            public void AddSelfToRenderQueue(RenderQueue queue, RenderQueueGroupID group) {
                if (mBuild) {
                    //Update material technique based on camera distance
                    Debug.Assert(material != null);
#warning missing function getLodIndexSquaredDepth
                    mBestTechnique = material.GetBestTechnique(material.GetLodIndex(mParent.MinDistanceSquared));

                    //Add to render queue
                    queue.AddRenderable(this, group);
                }
            }
Example #19
0
        private void WalkOctree(PCZCamera camera, ref List <PCZSceneNode> visibleNodeList, RenderQueue queue, Octree octant,
                                VisibleObjectsBoundsInfo visibleBounds, bool foundvisible, bool onlyShadowCasters,
                                bool displayNodes, bool showBoundingBoxes)
        {
            //return immediately if nothing is in the node.
            if (octant.NunodeList == 0)
            {
                return;
            }

            Visibility v = Visibility.None;

            if (foundvisible)
            {
                v = Visibility.Full;
            }

            else if (octant == this.rootOctree)
            {
                v = Visibility.Partial;
            }

            else
            {
                AxisAlignedBox box = octant.Box;

                v = camera.GetVisibility(box);
            }


            // if the octant is visible, or if it's the root node...
            if (v != Visibility.None)
            {
                //Add stuff to be rendered;

                bool vis = true;

                foreach (PCZSceneNode sn in octant.NodeList.Values)
                {
                    // if the scene node is already visible, then we can skip it
                    if (sn.LastVisibleFrame != mLastVisibleFrame || sn.LastVisibleFromCamera != camera)
                    {
                        // if this octree is partially visible, manually cull all
                        // scene nodes attached directly to this level.
                        if (v == Visibility.Partial)
                        {
                            vis = camera.IsObjectVisible(sn.WorldAABB);
                        }
                        if (vis)
                        {
                            // add the node to the render queue
                            sn.AddToRenderQueue(camera, queue, onlyShadowCasters, visibleBounds);
                            // add it to the list of visible nodes
                            visibleNodeList.Add(sn);
                            // if we are displaying nodes, add the node renderable to the queue
                            if (displayNodes)
                            {
                                queue.AddRenderable(sn.GetDebugRenderable());
                            }
                            // if the scene manager or the node wants the bounding box shown, add it to the queue
                            if (sn.ShowBoundingBox || showBoundingBoxes)
                            {
                                sn.AddBoundingBoxToQueue(queue);
                            }
                            // flag the node as being visible this frame
                            sn.LastVisibleFrame      = mLastVisibleFrame;
                            sn.LastVisibleFromCamera = camera;
                        }
                    }
                }

                Octree child;
                bool   childfoundvisible = (v == Visibility.Full);
                if ((child = octant.Children[0, 0, 0]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[1, 0, 0]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[0, 1, 0]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[1, 1, 0]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[0, 0, 1]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[1, 0, 1]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[0, 1, 1]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[1, 1, 1]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }
            }
        }
Example #20
0
        public void QueuePatches(RenderQueue queue)
        {
            var idx = 0;

            for (var i = 0; i < Levels; i++)
            {
                var level = _levels[i];

                var mask = i == 0 ? PatchLocations.PatchSelection.Everything :PatchLocations.PatchSelection.Outer;

                if (i != 0)
                    mask |= PatchLocations.PatchSelection.OuterDegenerated;

                mask |= level.Bottom ? PatchLocations.PatchSelection.InteriorBottom : PatchLocations.PatchSelection.InteriorTop;
                mask |= level.Left ? PatchLocations.PatchSelection.InteriorLeft : PatchLocations.PatchSelection.InteriorRight;

                var subX = level.Position.X.Fraction * 2.0f - 1.0f;
                var intX = level.Position.X.Integer;
                var subY = level.Position.Y.Fraction * 2.0f - 1.0f;
                var intY = level.Position.Y.Integer;
                var texX = (intX * 2) & N;
                var texY = (intY * 2) & N;

                foreach (var p in Locations.Select(mask))
                {
                    PatchRenderable pp;
                    if (_queueCache.Count <= idx)
                    {
                        pp = new PatchRenderable(p.Patch, _shader);
                        _queueCache.Add(pp);
                    } else
                        pp = _queueCache[idx];
                    idx++;

                    // queue the patch for rendering
                    pp.ScaleFactor = new Vector4(p.X + subX, p.Y + subY, level.Scale, level.Scale);
                    pp.FineBlockOrigin = new Vector4(p.X - Hx - texX, p.Y - Hx - texY, (float)InverseD, (float)InverseD);
                    pp.Level = level;
                    queue.AddRenderable(pp);
                }
            }
        }
 public override void UpdateRenderQueue(RenderQueue queue)
 {
     queue.AddRenderable(this);
 }