示例#1
0
        /// <summary>
        ///		Sets the rendering state so that all children of this
        ///		camera are drawn correctly.
        /// </summary>
        /// <param name="position">Position where this entity's parent node was rendered.</param>
        public override void Render(Transformation transformation, CameraNode camera, int layer)
        {
            //Statistics.StoreInt("Nodes Rendered", Statistics.ReadInt("Nodes Rendered") + 1);

            Transformation relativeTransformation = CalculateRelativeTransformation(transformation);

            SetupRenderingState(relativeTransformation);

            GraphicsManager.ClearColor = _clearColor;
            GraphicsManager.Viewport   = _viewport;
            GraphicsManager.ClearScene();

            if (_backgroundImage != null)
            {
                GraphicsManager.ScaleFactor = new float[] { _zoom, _zoom, 1.0f };
                GraphicsManager.TileImage(_backgroundImage, relativeTransformation.X, relativeTransformation.Y, relativeTransformation.Z);

                // Clear up the depth buffer so this image is always at the back.
                GraphicsManager.ClearDepthBuffer();
            }

            // Set the audio listener position at this cameras current position.
            Audio.AudioManager.ListenerPosition = new Vector((-relativeTransformation.X) + (_viewport.Width / 2), -(relativeTransformation.Y) + (_viewport.Height / 2), 0.0f);

            RenderChildren(relativeTransformation, camera, layer);
        }
示例#2
0
        /// <summary>
        ///     Renders a given layer of the scene graph.
        /// </summary>
        /// <param name="layer">Layer of scene graph to render.</param>
        public void Render(int layer)
        {
            // Render all the camera views.
            foreach (CameraNode camera in _cameraList)
            {
                GraphicsManager.ClearRenderState();

                // camera.Render(new Transformation(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), camera, 0);
                Transformation cameraTransformation = camera.CalculateTransformation();

                // Clear the depth buffer so that this layer renders ontop of all others.
                GraphicsManager.ClearDepthBuffer();

                // Clear the depth buffer so this layer is drawn above all others.
                _rootNode.Render(cameraTransformation, camera, layer);
            }
        }
示例#3
0
        /// <summary>
        ///		Renders all nodes in this scene graph.
        /// </summary>
        public void Render()
        {
            // Work out what layers we need to render.
            ArrayList layers = new ArrayList();

            foreach (SceneNode node in _nodeList)
            {
                if (node as EntityNode != null)
                {
                    if (!layers.Contains(((EntityNode)node).DepthLayer))
                    {
                        layers.Add(((EntityNode)node).DepthLayer);
                    }
                }
            }
            layers.Sort();

            // Render all the camera views.
            foreach (CameraNode camera in _cameraList)
            {
                GraphicsManager.ClearRenderState();

                camera.Render(new Transformation(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), camera, 0);
                Transformation cameraTransformation = camera.CalculateTransformation();

                // Render each layer.
                for (int i = 0; i < layers.Count; i++)
                {
                    // What layer will we render?
                    int layer = (int)layers[i];

                    // Clear the depth buffer so that this layer renders ontop of all others.
                    GraphicsManager.ClearDepthBuffer();

                    // Clear the depth buffer so this layer is drawn above all others.
                    _rootNode.Render(cameraTransformation, camera, layer);
                }
            }
        }
示例#4
0
 public void ClearDepthBuffer(ScriptThread thread)
 {
     GraphicsManager.ClearDepthBuffer();
 }