/// <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); } }
/// <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); } } }
/// <summary> /// Renders the event lines of this entity. /// </summary> /// <param name="transformation">Transformation to render event lines at.</param> protected override void RenderEventLines(Transformation transformation, CameraNode camera) { GraphicsManager.PushRenderState(); GraphicsManager.ClearRenderState(); GraphicsManager.DepthBufferEnabled = false; GraphicsManager.VertexColors.AllVertexs = _eventLineColor; // Normal. foreach (SceneNode node in _eventNodes) { EntityNode entityNode = node as EntityNode; if (entityNode == null) { continue; } Transformation relativeTransformation = entityNode.CalculateTransformation(camera); int x1 = (int)(transformation.X + ((_boundingRectangle.Width * transformation.ScaleX) / 2)); int y1 = (int)(transformation.Y + ((_boundingRectangle.Height * transformation.ScaleY) / 2)); int x2 = (int)(relativeTransformation.X + ((entityNode.BoundingRectangle.Width * relativeTransformation.ScaleX) / 2)); int y2 = (int)(relativeTransformation.Y + ((entityNode.BoundingRectangle.Height * relativeTransformation.ScaleY) / 2)); GraphicsManager.RenderLine(x1, y1, transformation.Z, x2, y2, relativeTransformation.Z); } // Our special ones! GraphicsManager.VertexColors.AllVertexs = _pathLineColor; if (_nextNode != null) { Transformation relativeTransformation = _nextNode.CalculateTransformation(camera); int x1 = (int)(transformation.X + ((_boundingRectangle.Width * transformation.ScaleX) / 2)); int y1 = (int)(transformation.Y + ((_boundingRectangle.Height * transformation.ScaleY) / 2)); int x2 = (int)(relativeTransformation.X + ((_nextNode._boundingRectangle.Width * relativeTransformation.ScaleX) / 2)); int y2 = (int)(relativeTransformation.Y + ((_nextNode._boundingRectangle.Height * relativeTransformation.ScaleY) / 2)); GraphicsManager.RenderLine(x1, y1, transformation.Z, x2, y2, relativeTransformation.Z); } GraphicsManager.PopRenderState(); }
public void ClearRenderState(ScriptThread thread) { GraphicsManager.ClearRenderState(); }
/// <summary> /// Renders the game in all its glory! /// </summary> public void Render() { /* GraphicsManager.BeginScene(); * GraphicsManager.ClearRenderState(); * GraphicsManager.Viewport = new Rectangle(0, 0, GraphicsManager.Resolution[0], GraphicsManager.Resolution[1]); * GraphicsManager.ClearColor = unchecked((int)0xFFFF0000); * GraphicsManager.ClearScene(); * * GraphicsManager.VertexColors[0] = unchecked((int)0xFFFFFFFF); * GraphicsManager.VertexColors[1] = unchecked((int)0xFF00FF00); * GraphicsManager.VertexColors[2] = unchecked((int)0xFFFF00FF); * GraphicsManager.VertexColors[3] = unchecked((int)0xFF0000FF); * GraphicsManager.RenderRectangle(5, 5, 0, 16, 16, true); * GraphicsManager.RenderRectangle(5, 37, 0, 16, 16, false); * * GraphicsManager.RenderOval(37, 5, 0, 16, 16, true); * GraphicsManager.RenderOval(37, 37, 0, 16, 16, false); * * GraphicsManager.RenderLine(74, 5, 0, 74 + 16, 5 + 16, 0); * GraphicsManager.RenderLine(74, 37, 0, 74 + 16, 37 + 16, 0); * * GraphicsManager.FinishScene(); * GraphicsManager.PresentScene(); * * return;*/ //HighPreformanceTimer timer = new HighPreformanceTimer(); // Don't try and render if we don't have a loading function. if (_renderLoadingScreen == true && (Fusion.GlobalInstance.GameScriptProcess == null || Fusion.GlobalInstance.GameScriptProcess.Process == null || Fusion.GlobalInstance.GameScriptProcess.Process.SymbolExists("OnLoadingRender") == false)) { return; } // Begin rendering. GraphicsManager.PushRenderState(); GraphicsManager.BeginScene(); GraphicsManager.ClearRenderState(); // GraphicsManager.ClearColor = unchecked((int)0xFFFF0000); GraphicsManager.ClearScene(); GraphicsManager.Viewport = new Rectangle(0, 0, GraphicsManager.Resolution[0], GraphicsManager.Resolution[1]); if (_renderThisFrame == true) { // Render the current scene graph. if (_renderSceneGraph == true) { GraphicsManager.PushRenderState(); Engine.GlobalInstance.Map.SceneGraph.Render(); GraphicsManager.PopRenderState(); } // Do we have a game script render function? if (_gameScriptRenderFunction != null) { GraphicsManager.PushRenderState(); Fusion.GlobalInstance.GameScriptProcess.Process[0].InvokeFunction(_gameScriptRenderFunction, true, true, true); GraphicsManager.PopRenderState(); } // Do we have a map script render function? if (_mapScriptRenderFunction != null) { GraphicsManager.PushRenderState(); Fusion.GlobalInstance.MapScriptProcess.Process[0].InvokeFunction(_mapScriptRenderFunction, true, true, true); GraphicsManager.PopRenderState(); } } else { _renderThisFrame = true; } // Render the loading screen if we have been asked to. if (_renderLoadingScreen == true && Fusion.GlobalInstance.GameScriptProcess != null && Fusion.GlobalInstance.GameScriptProcess.Process != null && Fusion.GlobalInstance.GameScriptProcess.Process.SymbolExists("OnLoadingRender")) { GraphicsManager.PushRenderState(); Fusion.GlobalInstance.GameScriptProcess.Process[0].InvokeFunction("OnLoadingRender", true, true, true); GraphicsManager.PopRenderState(); } // Tell plugins to render. Plugin.CallPluginMethod("Render"); // Render the console. GraphicsManager.Resolution = new int[] { ClientSize.Width, ClientSize.Height }; GraphicsManager.ResolutionOffset = new float[] { 0, 0 }; GraphicsManager.ResolutionScale = new float[] { 1.0f, 1.0f }; GraphicalConsole.Render(); GraphicsManager.FinishScene(); GraphicsManager.PresentScene(); GraphicsManager.PopRenderState(); //System.Console.WriteLine("R: " + (float)timer.DurationMillisecond); //System.Console.WriteLine("Spent " + Graphics.Image._tileTime); //Graphics.Image._tileTime = 0; }