Ejemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
#if DEBUG
            StatisticsProfiler.BeginDraw(gameTime);
#endif

            Graphics.GraphicsDevice.Clear(Color.Black);

            GraphicsDevice.RasterizerState = RasterizerState.CullNone;

            foreach (Process process in ProcessManager.Processes)
            {
                RenderProcess renderProcess = process as RenderProcess;
                if (renderProcess != null)
                {
                    renderProcess.Render((float)gameTime.ElapsedGameTime.TotalSeconds
                                         * CVars.Get <float>("debug_update_time_scale")
                                         * (CVars.Get <bool>("debug_pause_game_updates") ? 0 : 1));
                }
            }

#if DEBUG
            StatisticsProfiler.EndDraw();
#endif

            base.Draw(gameTime);
        }
Ejemplo n.º 2
0
 void remoteProcess_OnExit(RenderProcess process)
 {
     if (process == this.remoteProcess)
     {
         this.remoteBrowser = null;
         this.remoteProcess = null;
     }
 }
Ejemplo n.º 3
0
 public void RemoteProcessExited(RenderProcess process)
 {
     if (process == this.remoteProcess)
     {
         this.remoteBrowser = null;
         this.remoteProcess = null;
     }
 }
Ejemplo n.º 4
0
        public LightGlowPrimitive(LightViewer lightViewer, RenderProcess renderProcess, Light light)
            : base(light)
        {
            Debug.Assert(light.Type == LightType.Glow, "LightGlowPrimitive is only for LightType.Glow lights.");

            if (VertexDeclaration == null)
            {
                VertexDeclaration = new VertexDeclaration(renderProcess.GraphicsDevice, LightGlowVertex.VertexElements);
            }
            if (VertexBuffer == null)
            {
                var vertexData = new LightGlowVertex[6 * StateCount];
                SetUpTransitions((state, stateIndex1, stateIndex2) =>
                {
                    var state1 = Light.States[stateIndex1];
                    var state2 = Light.States[stateIndex2];

#if DEBUG_LIGHT_TRANSITIONS
                    Console.WriteLine("    Transition {0} is from state {1} to state {2} over {3:F1}s", state, stateIndex1, stateIndex2, state1.Duration);
#endif

                    // FIXME: Is conversion of "azimuth" to a normal right?

                    var position1 = state1.Position; position1.Z *= -1;
                    var normal1   = Vector3.Transform(Vector3.Transform(-Vector3.UnitZ, Matrix.CreateRotationX(MathHelper.ToRadians(-state1.Elevation.Y))), Matrix.CreateRotationY(MathHelper.ToRadians(-state1.Azimuth.Y)));
                    var color1    = new Color()
                    {
                        PackedValue = state1.Color
                    }.ToVector4();

                    var position2 = state2.Position; position2.Z *= -1;
                    var normal2   = Vector3.Transform(Vector3.Transform(-Vector3.UnitZ, Matrix.CreateRotationX(MathHelper.ToRadians(-state2.Elevation.Y))), Matrix.CreateRotationY(MathHelper.ToRadians(-state2.Azimuth.Y)));
                    var color2    = new Color()
                    {
                        PackedValue = state2.Color
                    }.ToVector4();

                    vertexData[6 * state + 0] = new LightGlowVertex(new Vector2(1, 1), position1, position2, normal1, normal2, color1, color2, state1.Radius, state2.Radius);
                    vertexData[6 * state + 1] = new LightGlowVertex(new Vector2(0, 0), position1, position2, normal1, normal2, color1, color2, state1.Radius, state2.Radius);
                    vertexData[6 * state + 2] = new LightGlowVertex(new Vector2(1, 0), position1, position2, normal1, normal2, color1, color2, state1.Radius, state2.Radius);
                    vertexData[6 * state + 3] = new LightGlowVertex(new Vector2(1, 1), position1, position2, normal1, normal2, color1, color2, state1.Radius, state2.Radius);
                    vertexData[6 * state + 4] = new LightGlowVertex(new Vector2(0, 1), position1, position2, normal1, normal2, color1, color2, state1.Radius, state2.Radius);
                    vertexData[6 * state + 5] = new LightGlowVertex(new Vector2(0, 0), position1, position2, normal1, normal2, color1, color2, state1.Radius, state2.Radius);
                });
                VertexBuffer = new VertexBuffer(renderProcess.GraphicsDevice, typeof(LightGlowVertex), vertexData.Length, BufferUsage.WriteOnly);
                VertexBuffer.SetData(vertexData);
            }
            if (IndexBuffer == null)
            {
                var indexData = new short[] {
                    0, 1, 2, 3, 4, 5
                };
                IndexBuffer = new IndexBuffer(renderProcess.GraphicsDevice, typeof(short), indexData.Length, BufferUsage.WriteOnly);
                IndexBuffer.SetData(indexData);
            }

            UpdateState(lightViewer);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public SkyPrimitive(RenderProcess renderProcess)
 {
     // Initialize the vertex and point-index buffers
     vertexList          = new VertexPositionNormalTexture[numVertices];
     triangleListIndices = new short[indexCount];
     // Sky dome
     DomeVertexList(0, skyRadius, 1.0f);
     DomeTriangleList(0, 0);
     // Cloud dome
     DomeVertexList((numVertices - 4) / 2, skyRadius - cloudDomeRadiusDiff, 0.4f);
     DomeTriangleList((short)((indexCount - 6) / 2), 1);
     // Moon quad
     MoonLists(numVertices - 5, indexCount - 6);
     // Meshes have now been assembled, so put everything into vertex and index buffers
     InitializeVertexBuffers(renderProcess.GraphicsDevice);
 }
Ejemplo n.º 6
0
        /// <summary>
        ///

        /// Constructor
        public MSTSSkyMesh(RenderProcess renderProcess)
        {
            // Initialize the vertex and point-index buffers
            vertexList          = new VertexPositionNormalTexture[numVertices];
            triangleListIndices = new short[indexCount];
            // Sky dome
            //MSTSSkyDomeVertexList((numVertices - 4) / 2, mstsskyRadius, 0f, mstsskytextureu, mstsskytexturev);
            MSTSSkyDomeVertexList(0, mstsskyRadius, mstsskytextureu, mstsskytexturev);
            MSTSSkyDomeTriangleList(0, 0);
            // Cloud dome
            MSTSSkyDomeVertexList((numVertices - 4) / 2, mstsskyRadius - mstscloudDomeRadiusDiff, mstscloudtextureu, mstscloudtexturev);
            MSTSSkyDomeTriangleList((short)((indexCount - 6) / 2), 1);
            // Moon quad
            MoonLists(numVertices - 5, indexCount - 6);//(144, 792);
            // Meshes have now been assembled, so put everything into vertex and index buffers
            InitializeVertexBuffers(renderProcess.GraphicsDevice);
        }
Ejemplo n.º 7
0
        protected virtual Task <RenderProcess> StartProcess(ProcessStartInfo info, CancellationToken ct)
        {
            return(Task.Run(() =>
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                int timeout = 30 * 1000;

                info.WindowStyle = ProcessWindowStyle.Maximized;
                info.CreateNoWindow = true;
                Process targetProcess = Process.Start(info);

                while (targetProcess.MainWindowHandle == IntPtr.Zero)
                {
                    if (ct.IsCancellationRequested)
                    {
                        targetProcess.Kill();
                    }
                    ct.ThrowIfCancellationRequested();
                    Thread.Sleep(10);
                    int pid = targetProcess.Id;
                    targetProcess.Dispose();
                    //mainWindowHandle不会变,重新获取
                    targetProcess = Process.GetProcessById(pid);

                    if (sw.ElapsedMilliseconds > timeout)
                    {
                        sw.Stop();
                        break;
                    }
                }

                RenderProcess result = new RenderProcess()
                {
                    PId = targetProcess.Id,
                    HostHandle = targetProcess.MainWindowHandle,
                    ReceiveMouseEventHandle = targetProcess.MainWindowHandle
                };
                //壁纸引擎关闭后,关闭渲染进程
                _pj.AddProcess(targetProcess);
                targetProcess.Dispose();
                return result;
            }));
        }
Ejemplo n.º 8
0
        public void SetRemoteBrowser(CfrBrowser remoteBrowser, RenderProcess remoteProcess)
        {
            this.remoteBrowser    = remoteBrowser;
            this.remoteProcess    = remoteProcess;
            remoteProcess.OnExit += new Action <RenderProcess>(remoteProcess_OnExit);
            var h = RemoteBrowserCreated;

            if (h != null)
            {
                var e = new RemoteBrowserCreatedEventArgs(remoteBrowser);
                if (RemoteCallbacksWillInvoke && InvokeRequired)
                {
                    RenderThreadInvoke(() => { h(this, e); });
                }
                else
                {
                    h(this, e);
                }
            }
        }
Ejemplo n.º 9
0
 public void SetRemoteBrowser(CfrBrowser remoteBrowser, RenderProcess remoteProcess)
 {
     ((IChromiumWebBrowser)browser).SetRemoteBrowser(remoteBrowser, remoteProcess);
 }
Ejemplo n.º 10
0
 public void RemoteProcessExited(RenderProcess process)
 {
     ((IChromiumWebBrowser)browser).RemoteProcessExited(process);
 }
Ejemplo n.º 11
0
        public LightConePrimitive(LightViewer lightViewer, RenderProcess renderProcess, Light light)
            : base(light)
        {
            Debug.Assert(light.Type == LightType.Cone, "LightConePrimitive is only for LightType.Cone lights.");

            if (VertexDeclaration == null)
            {
                VertexDeclaration = new VertexDeclaration(renderProcess.GraphicsDevice, LightConeVertex.VertexElements);
            }
            if (VertexBuffer == null)
            {
                var vertexData = new LightConeVertex[(CircleSegments + 2) * StateCount];
                SetUpTransitions((state, stateIndex1, stateIndex2) =>
                {
                    var state1 = Light.States[stateIndex1];
                    var state2 = Light.States[stateIndex2];

#if DEBUG_LIGHT_TRANSITIONS
                    Console.WriteLine("    Transition {0} is from state {1} to state {2} over {3:F1}s", state, stateIndex1, stateIndex2, state1.Duration);
#endif

                    Vector3 position1, position2, direction1, direction2;
                    float angle1, angle2, radius1, radius2, distance1, distance2;
                    Vector4 color1, color2;
                    LightViewer.CalculateLightCone(state1, out position1, out direction1, out angle1, out radius1, out distance1, out color1);
                    LightViewer.CalculateLightCone(state2, out position2, out direction2, out angle2, out radius2, out distance2, out color2);
                    var direction1Right = Vector3.Cross(direction1, Vector3.UnitY);
                    var direction1Up    = Vector3.Cross(direction1Right, direction1);
                    var direction2Right = Vector3.Cross(direction2, Vector3.UnitY);
                    var direction2Up    = Vector3.Cross(direction2Right, direction2);

                    for (var i = 0; i < CircleSegments; i++)
                    {
                        var a1 = MathHelper.TwoPi * i / CircleSegments;
                        var a2 = MathHelper.TwoPi * (i + 1) / CircleSegments;
                        var v1 = position1 + direction1 * distance1 + direction1Right * (float)(radius1 * Math.Cos(a1)) + direction1Up * (float)(radius1 * Math.Sin(a1));
                        var v2 = position2 + direction2 * distance2 + direction2Right * (float)(radius2 * Math.Cos(a2)) + direction2Up * (float)(radius2 * Math.Sin(a2));
                        vertexData[(CircleSegments + 2) * state + i] = new LightConeVertex(v1, v2, color1, color2);
                    }
                    vertexData[(CircleSegments + 2) * state + CircleSegments + 0] = new LightConeVertex(position1, position2, color1, color2);
                    vertexData[(CircleSegments + 2) * state + CircleSegments + 1] = new LightConeVertex(new Vector3(position1.X, position1.Y, position1.Z - distance1), new Vector3(position2.X, position2.Y, position2.Z - distance2), color1, color2);
                });
                VertexBuffer = new VertexBuffer(renderProcess.GraphicsDevice, typeof(LightConeVertex), vertexData.Length, BufferUsage.WriteOnly);
                VertexBuffer.SetData(vertexData);
            }
            if (IndexBuffer == null)
            {
                var indexData = new short[6 * CircleSegments];
                for (var i = 0; i < CircleSegments; i++)
                {
                    var i2 = (i + 1) % CircleSegments;
                    indexData[6 * i + 0] = (short)(CircleSegments + 0);
                    indexData[6 * i + 1] = (short)i2;
                    indexData[6 * i + 2] = (short)i;
                    indexData[6 * i + 3] = (short)i;
                    indexData[6 * i + 4] = (short)i2;
                    indexData[6 * i + 5] = (short)(CircleSegments + 1);
                }
                IndexBuffer = new IndexBuffer(renderProcess.GraphicsDevice, typeof(short), indexData.Length, BufferUsage.WriteOnly);
                IndexBuffer.SetData(indexData);
            }

            UpdateState(lightViewer);
        }
 /// <summary>
 /// Cancel ongoing render
 /// </summary>
 public void Cancel()
 {
     RenderProcess?.Cancel();
 }