예제 #1
0
        /// <summary>
        /// Rendering logic for lines renderings.
        /// </summary>
        private void RenderPass(
            RenderPassBase renderPass, PassSubscribionProperties subscriptions,
            RenderState renderState, ref List <SceneObject> invalidObjects)
        {
            if (subscriptions.Subscriptions.Count > 0)
            {
                if (renderPass != null)
                {
                    //Ensure loaded resources for transparency pass
                    if (!renderPass.IsLoaded)
                    {
                        renderPass.LoadResource();
                    }

                    //Render all subscriptions
                    renderPass.Apply(renderState);
                }
                try
                {
                    int subscriptionCount = subscriptions.Subscriptions.Count;
                    for (int loopPass = 0; loopPass < subscriptionCount; loopPass++)
                    {
                        RenderPassSubscription actSubscription = subscriptions.Subscriptions[loopPass];
                        try
                        {
                            actSubscription.RenderMethod(renderState);
                        }
                        catch (Exception ex)
                        {
                            GraphicsCore.PublishInternalExceptionInfo(
                                ex, InternalExceptionLocation.Rendering3DObject);

                            // Mark this object as invalid
                            if (invalidObjects == null)
                            {
                                invalidObjects = new List <SceneObject>();
                            }
                            invalidObjects.Add(actSubscription.SceneObject);
                        }
                    }
                }
                finally
                {
                    if (renderPass != null)
                    {
                        renderPass.Discard(renderState);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Handles invalid objects.
        /// </summary>
        /// <param name="invalidObjects">List containing all invalid objects to handle.</param>
        private void HandleInvalidObjects(List <SceneObject> invalidObjects)
        {
            foreach (SceneObject actObject in invalidObjects)
            {
                //Unload the object if it is loaded
                try { actObject.UnloadResources(); }
                catch (Exception ex)
                {
                    GraphicsCore.PublishInternalExceptionInfo(
                        ex, InternalExceptionLocation.UnloadingInvalid3DObject);
                }

                //Remove this object from this layer
                this.RemoveObject(actObject);
            }
        }
예제 #3
0
        /// <summary>
        /// Prepares rendering (Loads all needed resources).
        /// </summary>
        /// <param name="renderState">Current render state.</param>
        internal void PrepareRendering(RenderState renderState)
        {
            List <SceneObject> invalidObjects = null;

            // Load all resources
            int sceneObjectArrayLength = m_sceneObjects.Count;

            SceneObject[] sceneObjectArray = m_sceneObjects.GetBackingArray();
            for (int loop = 0; loop < sceneObjectArrayLength; loop++)
            {
                SceneObject actObject = sceneObjectArray[loop];

                try
                {
                    // Load all resources of the object
                    if (!actObject.IsLoaded(renderState.Device))
                    {
                        actObject.LoadResources(renderState.Device, renderState.CurrentResources);
                    }
                }
                catch (Exception ex)
                {
                    GraphicsCore.PublishInternalExceptionInfo(
                        ex, InternalExceptionLocation.Loading3DObject);

                    //Build list of invalid objects
                    if (invalidObjects == null)
                    {
                        invalidObjects = new List <SceneObject>();
                    }
                    invalidObjects.Add(actObject);
                }
            }

            //Remove all invalid objects
            if (invalidObjects != null)
            {
                HandleInvalidObjects(invalidObjects);
            }
        }