示例#1
0
 private void slider_SliderEvent(float fPosition, Endogine.Sprite.MouseEventType t)
 {
     //Dragged the numparticles slider
     if (m_psys==null)
         return;
     m_psys.NumNewParticlesPerFrame = fPosition*2;
 }
示例#2
0
 public void WritePSDRectangle(Endogine.ERectangle rct)
 {
     this.Write((int)rct.Y);
     this.Write((int)rct.X);
     this.Write((int)rct.Bottom);
     this.Write((int)rct.Right);
 }
示例#3
0
 private void sliderSize_SliderEvent(float fPosition, Endogine.Sprite.MouseEventType t)
 {
     //Dragged the particle size slider
     if (m_psys==null)
         return;
     m_psys.SizeFact = fPosition*5;
 }
示例#4
0
 public void SetStartPositionRelativeLoc(Endogine.EPoint loc)
 {
     if (loc == null)
         loc = new Endogine.EPoint(Cursor.Position);
     //TODO: set a prop instead and automatically do this on Show(). But: can't override show, which event is it?
     this.Location = (loc + new Endogine.EPoint(-this.Width / 2, 15)).ToPoint();
     //TODO: if too far to left, right or bottom
 }
示例#5
0
 private void btnChangeSize_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
 {
     //Mouse down on size change button
     if (t == Endogine.Sprite.MouseEventType.Down)
     {
         if (m_psys==null)
             return;
         m_psys.ChangeSizes();
     }
 }
示例#6
0
 public override void Save(string filename, Endogine.ColorEx.Palette palette)
 {
     System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.FileStream(filename, System.IO.FileMode.OpenOrCreate));
     foreach (KeyValuePair<string, ColorEx.ColorBase> kv in palette)
     {
         //Vector4 v = color.VectorRGBA;
         System.Drawing.Color c = kv.Value.ColorRGBA;
         writer.Write((byte)(int)c.R);
         writer.Write((byte)(int)c.G);
         writer.Write((byte)(int)c.B);
     }
 }
示例#7
0
 protected override void OnMouse(System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
 {
     if (t==Endogine.Sprite.MouseEventType.StillDown)
     {
         EPointF pntDiff = new EPointF(e.X-MouseLastLoc.X, e.Y-MouseLastLoc.Y);
         Move(pntDiff);
         //if (!GetConstrainRect().Contains(new Point((int)Loc.X,(int)Loc.Y)))
         //{
         //	Move(new PointF(-pntDiff.X,-pntDiff.Y));
         //}
     }
     base.OnMouse (e, t);
 }
示例#8
0
 public void waitframes(Endogine.Scripting.EScript.Executer exec, int frames)
 {
 }
示例#9
0
 //public override void SetValue(string name, Vector3 val)        { }
 public override void SetValue(string name, Endogine.Vector4 val)
 {
     this._effect.SetValue(name, new Microsoft.DirectX.Vector4(val.X, val.Y, val.Z, val.W));
 }
示例#10
0
 private void valueEditLoc_ValueChanged(object sender, Endogine.EPointF pnt)
 {
     if (m_sp==null)
         return;
     m_sp.Loc = pnt;
 }
示例#11
0
        public static void RenderGradientOnPattern(Endogine.Interpolation.InterpolatorColor interpol, Endogine.BitmapHelpers.Canvas canvas)
        {
            Graphics g = canvas.GetGraphics();
            BackgroundPattern.Fill(g);

            Bitmap bmp = new Bitmap(255, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Endogine.BitmapHelpers.Canvas c2 = Endogine.BitmapHelpers.Canvas.Create(bmp);
            RenderGradient(interpol, c2);
            g.InterpolationMode = InterpolationMode.NearestNeighbor;
            g.DrawImage(bmp, new Rectangle(0, 0, canvas.Width, canvas.Height * 2));
        }
示例#12
0
 public void RenderVivisection(Endogine.Vector3 rotation, float fraction)
 {
 }
 public override void SetPixelDataProvider(Endogine.BitmapHelpers.PixelDataProvider pdp)
 {
 }
示例#14
0
 public void _goto(Endogine.Scripting.EScript.Executer exec, string sMethod)
 {
     //stop script execution and start from the designated method
     //when that method has finished, jump directly to next method in order!
 }
示例#15
0
        public void waitms(Endogine.Scripting.EScript.Executer exec, int ms)
        {
            exec.Paused = true;
            this.m_exec = exec;

            this.m_timer = new System.Timers.Timer(ms);
            this.m_timer.Elapsed+=new System.Timers.ElapsedEventHandler(timer_Elapsed);
            this.m_timer.Start();
        }
示例#16
0
        public override Endogine.BitmapHelpers.PixelDataProvider TransformIntoRenderTarget(Endogine.BitmapHelpers.PixelDataProvider pdp)
        {
            Surface surf = ((PixelDataProvider)pdp).Texture.GetSurfaceLevel(0);
            bool isTarget = ((int)surf.Description.Usage & (int)Usage.RenderTarget) != 0;
            if (isTarget)
                return pdp;

            Surface oldSurfRT = this._device.GetRenderTarget(0);

            PixelDataProvider pdpRT = new PixelDataProvider(pdp.Width, pdp.Height, pdp.BitsPerPixel / 8, this._device, Usage.RenderTarget);
            this.RenderTarget = pdpRT;

            Endogine.SpriteRenderStrategy rs = this.CreateRenderStrategy();
            rs.Init();
            rs.SetPixelDataProvider(pdp);
            ERectangleF rctDrawTarget = new ERectangleF(0,0, pdp.Width, pdp.Height);//-pdp.Width, -pdp.Height, pdp.Width * 2, pdp.Height * 2) * 2;
            //rs.SourceClipRect = sourceClipRect;
            rs.CalcRenderRegion(rctDrawTarget, 0, new EPoint(), new EPoint(pdp.Width, pdp.Height));

            //render:
            this.PreUpdate();
            rs.SubDraw();
            this.EndUpdate();

            //reset renderer and finish up:
            this._device.SetRenderTarget(0, oldSurfRT);
            this.PostUpdate();

            return pdpRT;
        }
示例#17
0
        public override Endogine.BitmapHelpers.PixelDataProvider UglyConvertRenderTargetToReadable(Endogine.BitmapHelpers.PixelDataProvider pdpTarget)
        {
            PixelDataProvider pdp3DTarget = (PixelDataProvider)pdpTarget;

            //http://www.gamedev.net/community/forums/topic.asp?topic_id=388869
            //http://www.gamedev.net/community/forums/topic.asp?topic_id=384658&whichpage=1&
            //http://www.gamedev.net/community/forums/topic.asp?topic_id=388736

            //TODO: EXTREMELY ugly!! First copy to system memory, then back to card!!
            Surface sfSrc = pdp3DTarget.Texture.GetSurfaceLevel(0);

            //this._device.StretchRectangle(sfSrc, new System.Drawing.Rectangle(0,0,pdpTarget.Width,pdpTarget.Height),

            Surface sfDst = this._device.CreateOffscreenPlainSurface(pdp3DTarget.Width, pdp3DTarget.Height,
                pdp3DTarget.SurfaceDescription.Format, Pool.SystemMemory); //Pool.SystemMemory Managed

            this._device.GetRenderTargetData(sfSrc, sfDst);

            //Surface sfDst2 = new Surface(this._device,
            //SurfaceLoader.FromSurface(sfDst2,
            Texture tx = new Texture(this._device, pdp3DTarget.Width, pdp3DTarget.Height, 1, Usage.None, pdp3DTarget.SurfaceDescription.Format, Pool.Managed);
            //this._device.UpdateSurface(sfDst, sf);

            //unsafe
            //{
            //    byte* ptr;
            //    //byte[] array = (byte[])ptr;
            //    Buffer.BlockCopy(ptr, 0, ptr, 0, 20000);
            //}
            PixelDataProvider pdpCP = new PixelDataProvider(sfDst);
            Endogine.BitmapHelpers.Canvas cCP = Endogine.BitmapHelpers.Canvas.Create(pdpCP);
            cCP.Locked = true;

            PixelDataProvider pdp = new PixelDataProvider(tx);
            Endogine.BitmapHelpers.Canvas c1 = Endogine.BitmapHelpers.Canvas.Create(pdp);
            c1.Locked = true;
            for (int y = c1.Height-1; y >= 0; y--)
            {
                for (int x = c1.Width - 1; x >= 0; x--)
                    c1.SetPixel(x, y, cCP.GetPixel(x, y));
            }
            c1.Locked = false;
            cCP.Locked = false;

            //return pdpCP;
            return pdp;
        }
 public override void SetMember(Endogine.ResourceManagement.MemberBase a_mb)
 {
     this.OnCreateVertexBuffer(_vertexBuffer, null);
     this._tx = ((MemberSpriteBitmapRenderStrategy)((MemberSpriteBitmap)a_mb).RenderStrategy).Texture;
     //this._tx = ((MemberSpriteBitmapRenderStrategyA)_sp.Member.RenderStrategy).Texture;
 }
示例#19
0
 public static void RenderGradient(Endogine.Interpolation.InterpolatorColor interpol, Endogine.BitmapHelpers.Canvas canvas)
 {
     canvas.Locked = true;
     for (int x = 0; x < canvas.Width; x++)
     {
         Color clr = interpol.GetValueAtTime((double)x / canvas.Width);
         canvas.SetPixel(x, 0, clr);
     }
     canvas.Locked = false;
 }
 public override void SetPixelDataProvider(Endogine.BitmapHelpers.PixelDataProvider pdp)
 {
     this.OnCreateVertexBuffer(_vertexBuffer, null);
     this._tx = ((PixelDataProvider)pdp).Texture;
 }
示例#21
0
        public static List<PicRef> CreatePicRefs(Endogine.ResourceManagement.MemberBitmapBase mb, int numFramesOnX, int numFramesTotal)
        {
            List<string> animRefs = new List<string>();
            List<PicRef> picRefs = new List<PicRef>();
            int numFramesOnY = numFramesTotal / numFramesOnX;
            EPoint frameSize = new EPoint(mb.Size.X / numFramesOnX, mb.Size.Y / numFramesOnY);
            for (int i = 0; i < numFramesTotal; i++)
            {
                string picRefName = mb.Name + "_" + i;
                int x = i % numFramesOnX;
                int y = i / numFramesOnX;
                PicRef pr = PicRef.Create((MemberSpriteBitmap)mb, picRefName);
                pr.SourceRectangle = new ERectangle(x * frameSize.X, y * frameSize.Y, frameSize.X, frameSize.Y);
                picRefs.Add(pr);
                animRefs.Add(picRefName);
            }

            EH.Instance.CastLib.FrameSets.AddFrameSet(mb.Name, animRefs);

            return picRefs;
        }
示例#22
0
        private void moveSprite_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
        {
            if (t == Endogine.Sprite.MouseEventType.StillDown)
            {
                EPointF pntNow = new EPointF(e.X, e.Y);
                EPointF gridSpacing = new EPointF(30, 30);
                EPointF gridOffset = new EPointF(0, 0);
                if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Control) //Snap to grid
                {
                    pntNow -= _gridOffset.ToEPointF();
                    pntNow /= _gridSpacing.ToEPointF();
                    pntNow = new EPointF((float)Math.Round(pntNow.X), (float)Math.Round(pntNow.Y)) * _gridSpacing.ToEPointF();
                    pntNow += _gridOffset.ToEPointF();
                }
                EPointF pntDiff = pntNow - sender.MouseDownLoc.ToEPointF();

                if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Shift) //Force horizontal/vertical movement
                {
                    if ((pntDiff.Angle > (float)Math.PI/4 && pntDiff.Angle < 3*(float)Math.PI/4) ||
                        (pntDiff.Angle < -(float)Math.PI/4 && pntDiff.Angle > -3*(float)Math.PI/4))
                        pntDiff*=new EPointF(1,0);
                    else
                        pntDiff*=new EPointF(0,1);
                }
                this.m_sp.Loc = pntDiff + this.pntStartMove;
                this.Update();
            }
            else if (t == Endogine.Sprite.MouseEventType.Down)
                this.pntStartMove = this.m_sp.Loc.Copy();
        }
示例#23
0
 private void valueEditScale_ValueChanged(object sender, Endogine.EPointF pnt)
 {
     if (m_sp==null)
         return;
     m_sp.Scaling= pnt;
 }
示例#24
0
        private void pivotSprite_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
        {
            if (t == Endogine.Sprite.MouseEventType.StillDown)
            {
                EH.Put(e.X.ToString() + " " + e.Y.ToString() + this.m_sp.Loc.ToString());
                sender.Loc+= new EPointF(e.X, e.Y) - sender.MouseLastLoc.ToEPointF();

                //TODO: setting the regpoint is not working when scaled.
                if (false)
                {
                    EPoint pntLastRegPoint = this.m_sp.RegPoint.Copy();
                    this.m_sp.RegPoint = (sender.Loc/this.m_sp.Scaling).ToEPoint();
                    this.m_sp.Loc += (this.m_sp.RegPoint-pntLastRegPoint).ToEPointF();
                    this.Update();
                }
            }
        }
示例#25
0
        private void rotateSprite_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
        {
            EPointF pivotLoc = this.m_sp.Loc;
            if (t == Endogine.Sprite.MouseEventType.StillDown)
            {
                EPointF pntNow = new EPointF(e.X, e.Y) - pivotLoc;
                float fAngleDiff = pntNow.Angle - this.pntMouseStartRotate.Angle;
                if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Shift)
                {

                }
                this.m_sp.Rotation = fAngleDiff;
            }
            else if (t == Endogine.Sprite.MouseEventType.Down)
                this.pntMouseStartRotate = new EPointF(e.X, e.Y) - pivotLoc;
        }
示例#26
0
        /// <summary>
        /// Stretching sprite
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="t"></param>
        private void spSquare_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
        {
            if (t == Endogine.Sprite.MouseEventType.StillDown)
            {
                EPoint pntWhichSquare = (EPoint)sender.Tag;
                EPointF pntDiff = new EPointF(e.X, e.Y) - sender.MouseLastLoc.ToEPointF();

                EPointF pntRestrictTo = new EPointF();
                if (pntWhichSquare.Y == 1)
                    pntRestrictTo.X = 1;
                else if (pntWhichSquare.X == 1)
                    pntRestrictTo.Y = 1;
                else
                    pntRestrictTo = new EPointF(1,1);

                EPointF pntMove = pntDiff*pntRestrictTo;
                ERectangleF rct = this.m_sp.Rect.Copy();

                if (pntWhichSquare.X == 0 || pntWhichSquare.Y == 0)
                {
                    if (pntWhichSquare.X == 0 && pntWhichSquare.Y == 2)
                    {
                        rct.X+=pntMove.X;
                        rct.Width-=pntMove.X;
                        rct.Height+=pntMove.Y;
                    }
                    else if (pntWhichSquare.X == 2 && pntWhichSquare.Y == 0)
                    {
                        rct.Y+=pntMove.Y;
                        rct.Height-=pntMove.Y;
                        rct.Width+=pntMove.X;
                    }
                    else
                    {
                        rct.Location+=pntMove;
                        rct.Size-=pntMove;
                    }
                }
                else
                    rct.Size+=pntMove;

                this.m_sp.Rect = rct;

                this.Update();
            }
        }
示例#27
0
 public override void SetValue(string name, Endogine.BitmapHelpers.PixelDataProvider val)
 {
     this._effect.SetValue(name, ((PixelDataProvider)val).Texture);
 }
示例#28
0
        private void sp_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
        {
            if (t == Endogine.Sprite.MouseEventType.Down)
            {

            }
            else if (t == Endogine.Sprite.MouseEventType.StillDown)
            {
                EPoint pntAxis = (EPoint)sender.Tag;
                EPointF pntDiff = new EPointF(e.X, e.Y) - sender.MouseLastLoc.ToEPointF();
                this.m_sp.Move(pntDiff*pntAxis);
            }
        }
示例#29
0
 public override void Save(string filename, Endogine.ColorEx.Palette palette)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#30
0
 public void waitframe(Endogine.Scripting.EScript.Executer exec)
 {
 }