Exemplo n.º 1
0
            public Pass(Pass copyFrom, BatchInfo inputOverride)
            {
                this.input          = inputOverride;
                this.output         = copyFrom.output;
                this.clearColor     = copyFrom.clearColor;
                this.clearDepth     = copyFrom.clearDepth;
                this.clearFlags     = copyFrom.clearFlags;
                this.matrixMode     = copyFrom.matrixMode;
                this.visibilityMask = copyFrom.visibilityMask;

                this.MakeAvailable();
            }
Exemplo n.º 2
0
        /// <summary>
        /// Renders a scene from the perspective of a single, pre-configured drawing device.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="drawDevice"></param>
        /// <param name="viewportRect"></param>
        /// <param name="imageSize"></param>
        /// <param name="outputTargetRect"></param>
        public void RenderPointOfView(Scene scene, DrawDevice drawDevice, Rect viewportRect, Vector2 imageSize)
        {
            // Memorize projection matrix settings, so the drawing device can be properly reset later
            RenderMatrix oldDeviceMatrix     = drawDevice.RenderMode;
            Vector2      oldDeviceTargetSize = drawDevice.TargetSize;

            try
            {
                this.OnRenderPointOfView(scene, drawDevice, viewportRect, imageSize);
            }
            catch (Exception e)
            {
                Console.WriteLine("There was an error while {0} was rendering a point of view in {1}: {2}", this, scene, /*LogFormat.Exception(*/ e /*)*/);
            }

            // Reset matrices for projection calculations to their previous state
            drawDevice.RenderMode = oldDeviceMatrix;
            drawDevice.TargetSize = oldDeviceTargetSize;
            drawDevice.UpdateMatrices();
        }
Exemplo n.º 3
0
			public Pass(Pass copyFrom, BatchInfo inputOverride)
			{
				this.input = inputOverride;
				this.output = copyFrom.output;
				this.clearColor = copyFrom.clearColor;
				this.clearDepth = copyFrom.clearDepth;
				this.clearFlags = copyFrom.clearFlags;
				this.matrixMode = copyFrom.matrixMode;
				this.visibilityMask = copyFrom.visibilityMask;

				this.MakeAvailable();
			}
Exemplo n.º 4
0
        public void Update(GameTime p_gameTime)
        {
            m_renderList.Clear();
            m_boneTransforms.Clear();

            m_elapsedTime += p_gameTime.ElapsedGameTime.Milliseconds;
            if (m_elapsedTime > m_current.Length)
            {
                if (AnimationEnded != null)
                {
                    AnimationEnded();
                }
                if (m_current.Looping)
                {
                    m_elapsedTime -= m_current.Length;
                }
                else
                {
                    m_elapsedTime = m_current.Length;
                }
            }

            int l_frame = 0;

            for (int l_i = 0; (l_i < m_current.MainLine.Count); l_i++)
            {
                if (m_elapsedTime >= m_current.MainLine[l_i].Time)
                {
                    l_frame = l_i;
                }
            }

            Vector2     l_flip     = new Vector2(m_flipX ? -1.0f : 1.0f, m_flipY ? -1.0f : 1.0f);
            MainlineKey l_mainline = m_current.MainLine[l_frame];

            for (int l_i = 0; l_i < l_mainline.Body.Count; l_i++)
            {
                TimelineKey l_key = m_current.TimeLines[l_mainline.Body[l_i].Timeline].Keys[l_mainline.Body[l_i].Key];
                // check if file for this object is missing, and if so skip calculating transforms
                if (m_rect[l_key.Folder][l_key.File].Width == 0)
                {
                    continue;
                }

                RenderMatrix l_render = new RenderMatrix(ApplyBoneTransforms(l_mainline, l_mainline.Body[l_i]));

                FindMapChar(l_key.Folder, l_key.File, out l_render.Folder, out l_render.File);
                if (l_render.Folder == -1 || l_render.File == -1)
                {
                    continue;
                }

                l_render.Location = Location + Vector2.Multiply(l_render.Location, l_flip);

                if (m_flipX)
                {
                    l_render.Effects |= SpriteEffects.FlipHorizontally;
                    l_render.Pivot.X  = m_rect[l_key.Folder][l_render.File].Width - l_render.Pivot.X;
                }

                if (m_flipY)
                {
                    l_render.Effects |= SpriteEffects.FlipVertically;
                    l_render.Pivot.Y  = m_rect[l_key.Folder][l_render.File].Height - l_render.Pivot.Y;
                }

                if (m_flipX != m_flipY)
                {
                    l_render.Rotation *= -1.0f;
                }

                l_render.ZOrder = l_mainline.Body[l_i].ZOrder;

                m_renderList.Add(l_render);
            }
        }
Exemplo n.º 5
0
        public virtual void Update(GameTime p_gameTime)
        {
            m_renderList.Clear();
            m_boneTransforms.Clear();

            m_elapsedTime += p_gameTime.ElapsedGameTime.Milliseconds;
            if (m_elapsedTime > m_current.Length)
            {
                // pitää ottaa talteen että nähdään vaihtaako eventti animaatiota
                Animation current = m_current;
                if (AnimationEnded != null)
                {
                    AnimationEnded(m_current);
                }
                // jos animaatioi vaihtui niin alotetaan taas aika nollasta
                if (!Equals(current, m_current))
                {
                    m_elapsedTime = 0;
                }
                else if (m_current.Looping)
                {
                    m_elapsedTime -= m_current.Length;
                }
                else
                {
                    m_elapsedTime = m_current.Length;
                }
            }

            int l_frame = 0;

            for (int l_i = 0; (l_i < m_current.MainLine.Count); l_i++)
            {
                if (m_elapsedTime >= m_current.MainLine[l_i].Time)
                {
                    l_frame = l_i;
                }
            }

            Vector2     l_flip     = new Vector2(m_flipX ? -1.0f : 1.0f, m_flipY ? -1.0f : 1.0f);
            MainlineKey l_mainline = m_current.MainLine[l_frame];

            for (int l_i = 0; l_i < l_mainline.Body.Count; l_i++)
            {
                TimelineKey l_key = m_current.TimeLines[l_mainline.Body[l_i].Timeline].Keys[l_mainline.Body[l_i].Key];
                // check if file for this object is missing, and if so skip calculating transforms
                if (m_rect[l_key.Folder][l_key.File].Width == 0)
                {
                    continue;
                }

                RenderMatrix l_render = new RenderMatrix(ApplyBoneTransforms(l_mainline, l_mainline.Body[l_i]));

                l_render.File   = l_key.File;
                l_render.Folder = l_key.Folder;

                l_render.Location = Location + Vector2.Multiply(l_render.Location, l_flip);

                if (m_flipX)
                {
                    l_render.Effects |= SpriteEffects.FlipHorizontally;
                    l_render.Pivot.X  = m_rect[l_key.Folder][l_render.File].Width - l_render.Pivot.X;
                }

                if (m_flipY)
                {
                    l_render.Effects |= SpriteEffects.FlipVertically;
                    l_render.Pivot.Y  = m_rect[l_key.Folder][l_render.File].Height - l_render.Pivot.Y;
                }

                if (m_flipX != m_flipY)
                {
                    l_render.Rotation *= -1.0f;
                }

                l_render.ZOrder = l_mainline.Body[l_i].ZOrder;

                m_renderList.Add(l_render);
            }
        }