public void Multiply(EPointF pnt) { x *= pnt.X; y *= pnt.Y; width *= pnt.X; height *= pnt.Y; }
public ArrayList GetSpritesUnderLoc(EPointF a_pnt, int a_nMaxNumSprites) { ArrayList aSprites = new ArrayList(); SortedList plSprites = new SortedList(); int n = 0; GetVisibleOffspringZSorted(ref plSprites, ref n); for (int i = plSprites.Count - 1; i >= 0; i--) { Sprite sp = (Sprite)plSprites.GetByIndex(i); EPointF pntSprite = sp.ConvRootLocToParentLoc(a_pnt); if (sp.Rect == null) { continue; } if (sp.Rect.Contains(pntSprite)) { aSprites.Add(sp); if (aSprites.Count == a_nMaxNumSprites) { break; } } } return(aSprites); }
private void MoveToCoordinate() { string s = tbCoordinate.Text; s = s.Trim(); s = System.Text.RegularExpressions.Regex.Replace(s, @"[^0-9^;^.^-]", ""); string[] ss = s.Split(";".ToCharArray(), 2); //System.Globalization.NumberFormatInfo fi = new System.Globalization.NumberFormatInfo(); //fi.CurrencyDecimalSeparator = "."; EPointF pnt = new EPointF(); if (ss.GetLength(0) > 0) { pnt.X = Convert.ToSingle(ss[0]); } if (ss.GetLength(0) > 1) { pnt.Y = Convert.ToSingle(ss[1]); } tbCoordinate.Text = pnt.X.ToString() + ";" + pnt.Y.ToString(); Send(pnt); }
public bool CheckChildrenMouse(MouseEventArgs e, EPointF a_pntLocalLoc, bool a_bButtonAction, bool a_bDown) { bool bContinueChecking = true; m_bLooping = true; a_pntLocalLoc = this.ConvParentLocToSrcLoc(a_pntLocalLoc); for (int i = this._slChildrenLocZSorted.Count - 1; i >= 0; i--) { Sprite sp = (Sprite)this._slChildrenLocZSorted.GetByIndex(i); // foreach (DataRowView row in m_dvChildrenLocZInverseSorted) //m_dvChildrenLocZInverseSorted m_dvChildrenLocZSorted // { // Sprite sp = ((Sprite)m_plChildrenByHash[(int)row["Hash"]]); if (sp.ChildCount > 0) { bContinueChecking = sp.CheckChildrenMouse(e, a_pntLocalLoc, a_bButtonAction, a_bDown); } if (bContinueChecking && sp.MouseActive) { bContinueChecking = sp.CheckMouse(e, a_pntLocalLoc, a_bButtonAction, a_bDown); } if (!bContinueChecking) { break; } } m_bLooping = false; return(bContinueChecking); }
public TestCircle() { m_pntVel = new EPointF(0,0); m_pntThrust = new EPoint(0,0); aKeysPressedX = new ArrayList(); aKeysPressedY = new ArrayList(); Bitmap bmp = new Bitmap(40,40, PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(bmp); g.FillEllipse(new SolidBrush(Color.Red), 0,0,40,40); g.Dispose(); MemberSpriteBitmap mb = new MemberSpriteBitmap(bmp); mb.CenterRegPoint(); Member = mb; m_aLines = new ArrayList(); for (int i = 0; i < 1; i++) { TestLine line = new TestLine(m_endogine); line.SetLine(new EPointF((i)*150,0), new EPointF((i+1)*150,150)); m_aLines.Add(line); } LocZ = 10; Loc = new EPointF(171,171); m_endogine.KeyEvent+=new KeyEventHandler(m_endogine_KeyEvent); }
public void ExpandSpecial(EPointF pnt) { this.Left = pnt.X < this.Left?pnt.X:this.Left; this.Top = pnt.Y < this.Top?pnt.Y:this.Top; this.Right = pnt.X > this.Right?pnt.X:this.Right; this.Bottom = pnt.Y > this.Bottom?pnt.Y:this.Bottom; }
private MeterBar Create1DMeter(EPointF ptLoc, string prop, float max) { MeterBar bar = new MeterBar(); bar.Rect = new ERectangleF(ptLoc.X, ptLoc.Y, 100, 8); bar.MaxValue = max; bar.SetAutoFetch(this._car, prop); return bar; }
public Quad(EPointF p1, EPointF p2, EPointF p3, EPointF p4) { this._points = new EPointF[4]; this._points[0] = p1; this._points[1] = p2; this._points[2] = p3; this._points[3] = p4; }
public static EPointF FromLengthAndAngle(float a_fLength, float a_fAngle) { EPointF pnt = new EPointF(0, -1); pnt.Angle = a_fAngle; pnt.Length = a_fLength; return(pnt); }
public EPointF ConvRootLocToParentLoc(EPointF a_pnt) { if (Parent != null) { a_pnt = Parent.ConvRootLocToSrcLoc(a_pnt); } return(a_pnt); }
public EPointF ConvParentLocToRootLoc(EPointF a_pntLoc) { if (m_spParent == null) { return(a_pntLoc); } return(m_spParent.ConvParentLocToRootLoc(m_spParent.ConvSrcLocToParentLoc(a_pntLoc))); }
public JogShuttle() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); m_pntFactor = new EPointF(1,1); m_pntWrappedAdd = new EPoint(); m_pntActiveAxes = new EPoint(1,1); FixLayout(); }
public JogShuttle() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); m_pntFactor = new EPointF(1, 1); m_pntWrappedAdd = new EPoint(); m_pntActiveAxes = new EPoint(1, 1); FixLayout(); }
public EPointF ConvRootLocToSrcLoc(EPointF a_pnt) { //convert a loc in root (normally stage) space to source space. //One calculation per link can make it slow in deep trees. if (Parent != null) { a_pnt = Parent.ConvRootLocToSrcLoc(a_pnt); } return(ConvParentLocToSrcLoc(a_pnt)); }
public EPointF ConvParentLocToDrawLoc(EPointF a_pntLoc, Sprite a_spDraw) { if (m_spParent == null || (m_spParent != null && m_spParent == a_spDraw)) { return(a_pntLoc); } a_pntLoc = m_spParent.ConvSrcLocToParentLoc(a_pntLoc); return(m_spParent.ConvParentLocToDrawLoc(a_pntLoc, a_spDraw)); }
public EPointF MapPointFromRectAToRectB(EPointF a_pnt, ERectangleF a_rctA, ERectangleF a_rctB) { EPointF pntNew = new EPointF(a_pnt.X - a_rctA.Left, a_pnt.Y - a_rctA.Top); pntNew.X /= a_rctA.Width; pntNew.Y /= a_rctA.Height; pntNew.X = pntNew.X * a_rctB.Width + a_rctB.Left; pntNew.Y = pntNew.Y * a_rctB.Height + a_rctB.Top; return(pntNew); }
//ParentLoc = point relative to the output rect (Rect) - source loc after move/scale/rotate public EPointF ConvSrcLocToParentLoc(EPointF a_pntLoc) { //if (Member==null) // return a_pntLoc; // PointF pntFract = new PointF(a_pntLoc.X/m_mb.Size.Width, a_pntLoc.Y/m_mb.Size.Height); EPointF pntFract = new EPointF(a_pntLoc.X / SourceRect.Width, a_pntLoc.Y / SourceRect.Height); pntFract.X = pntFract.X * m_rctDstParent.Width + m_rctDstParent.Left; pntFract.Y = pntFract.Y * m_rctDstParent.Height + m_rctDstParent.Top; return(pntFract); }
private void PlayerBall_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t) { if (t == Sprite.MouseEventType.Down) { forceMarker.Visible = true; } else if (t == Sprite.MouseEventType.StillDown) { MemberSpriteBitmap mb = forceMarker.Member; if (mb!=null) mb.Dispose(); //this.MouseDownLoc.X, this.MouseDownLoc.Y ERectangleF rctLine = ERectangleF.FromLTRB(this.Loc.X, this.Loc.Y, this.MouseLastLoc.X, this.MouseLastLoc.Y); forceVector = rctLine.Size; if (rctLine.Width != 0 && rctLine.Height != 0) { Bitmap bmp = new Bitmap((int)Math.Abs(rctLine.Width)+1, (int)Math.Abs(rctLine.Height)+1, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(bmp); ERectangleF rctOrigo = rctLine.Copy(); rctOrigo.MakeTopLeftAtOrigo(); Pen pen = new Pen(Color.Red, 2); g.DrawLine(pen, rctOrigo.X, rctOrigo.Y, rctOrigo.X+rctOrigo.Width, rctOrigo.Y+rctOrigo.Height); g.Dispose(); EPointF locOffset = new EPointF(); if (rctOrigo.Width < 0) locOffset.X = rctOrigo.Width; if (rctOrigo.Height < 0) locOffset.Y = rctOrigo.Height; mb = new MemberSpriteBitmap(bmp); forceMarker.Member = mb; forceMarker.Loc = this.Loc + locOffset; } else forceMarker.Member = null; } else if (t == Sprite.MouseEventType.UpOutside || t == Sprite.MouseEventType.Click) { this.Velocity = forceVector*-0.1f; forceMarker.Visible = false; MemberSpriteBitmap mb = forceMarker.Member; if (mb!=null) { forceMarker.Member = null; mb.Dispose(); } } }
public ValueEdit() { InitializeComponent(); m_pntDefault = new EPointF(); m_pntStart = new EPointF(); m_pntCurrent = new EPointF(); jsShuttle.StartTimer(); jsShuttle.Factor = new EPointF(0.1f,0.1f); }
public ValueEdit() { InitializeComponent(); m_pntDefault = new EPointF(); m_pntStart = new EPointF(); m_pntCurrent = new EPointF(); jsShuttle.StartTimer(); jsShuttle.Factor = new EPointF(0.1f, 0.1f); }
private void Send(EPointF pnt) { m_pntCurrent = pnt; lblCurrent.Text = pnt.X.ToString("#0.0") + "; " + pnt.Y.ToString("#0.0"); if (ValueChanged != null) { ValueChanged(this, pnt); } }
/// <summary> /// Transforms a point in a rectangle to where it would be in the quad /// </summary> /// <param name="pnt"></param> /// <param name="rect"></param> /// <returns></returns> public EPointF MapFromRect(EPointF pnt, ERectangleF rect) { EPointF fract = pnt / rect.Size; EPointF pntTopOfQuadAtX = (this._points[1] - this._points[0])*fract.X + this._points[0]; EPointF pntBottomOfQuadAtX = (this._points[2] - this._points[3]) * fract.X + this._points[3]; EPointF inQuad = (pntBottomOfQuadAtX - pntTopOfQuadAtX) * fract.Y + pntTopOfQuadAtX; return inQuad; //pntFract = point(float(a_pnt[1])/a_rct.width, float(a_pnt[2])/a_rct.height) //pntTopOfQuadAtX = (a_aQuad[2]-a_aQuad[1])*pntFract[1]+a_aQuad[1] //pntBottomOfQuadAtX = (a_aQuad[3]-a_aQuad[4])*pntFract[1]+a_aQuad[4] //return (pntBottomOfQuadAtX-pntTopOfQuadAtX)*pntFract[2] + pntTopOfQuadAtX }
private void Init(bool bAutoSetParent) { m_aChildrenToRemove = new ArrayList(); m_plChildrenByHash = new Hashtable(); this._slChildrenLocZSorted = new SortedFloatList(); m_sID = ""; m_nInk = (int)RasterOps.ROPs.Copy; m_nBlend = 255; m_matrix = new Matrix4(); m_vPivot = new Vector3(); m_fLocZ = 0.0f; m_pntLoc = new EPointF(0.0f, 0.0f); m_pntScale = new EPointF(1.0f, 1.0f); m_pntRegPoint = new EPoint(0, 0); m_rctSrcClip = new ERectangle(0, 0, 1, 1); m_clr = Color.White; m_rctDstParent = new ERectangleF(0, 0, 0, 0); m_aBehaviors = new ArrayList(); m_nMemberAnimFrame = 0; m_dtChildren = new DataTable(); m_dtChildren.Columns.Add("Name", typeof(System.String)); m_dtChildren.Columns.Add("LocZ", typeof(System.Double)); m_dtChildren.Columns.Add("Hash", typeof(System.Int32)); m_pntMouseDown = new EPoint(); m_pntMouseLast = new EPoint(); _pntMouse = new EPoint(); if (bAutoSetParent && m_endogine != null && m_endogine.Stage != null) { Parent = m_endogine.Stage.DefaultParent; } m_renderStrategy = m_endogine.Stage.CreateRenderStrategy(); m_renderStrategy.SetEndogine(m_endogine); m_renderStrategy.SetSprite(this); m_renderStrategy.Init(); //TODO: make this optional (takes some resources) Sprite[] lcs = new Sprite[1]; lcs[0] = this; EH.Instance.LatestCreatedSprites = lcs; }
public PlayerShot(EPointF pntStart) { this.Velocity = new EPointF(0,-4); this.Loc = pntStart; string anim = "PlayerShot"; if (!EH.Instance.CastLib.FrameSets.Exists(anim)) PicRef.CreatePicRefs("SpaceInv\\PlayerShot", 2, 2); Endogine.Animation.BhAnimator an = new Endogine.Animation.BhAnimator(this, anim); this.Color = GameMain.Instance.m_clrOffwhite; //TODO: never disposed properly }
public ERectangleF CalcRectInDrawTarget() { // ERectangleF rctTmp = m_rctDstParent.Copy(); // if (Member != null && Member.GotAnimation) // rctTmp.Offset(Member.GetOffsetForFrame(this.MemberAnimationFrame).ToEPointF()*-1); //TODO: check if anything was invalidated since last frame - if not, use a cached value instead of re-calculating. EPointF pnt1 = ConvParentLocToDrawLoc(m_rctDstParent.Location, m_spDrawTarget); EPointF pnt2 = ConvParentLocToDrawLoc(m_rctDstParent.BottomRight, m_spDrawTarget); return(new ERectangleF(pnt1.X, pnt1.Y, pnt2.X - pnt1.X, pnt2.Y - pnt1.Y)); }
/// <summary> /// Transforms a point in a rectangle to where it would be in the quad /// </summary> /// <param name="pnt"></param> /// <param name="rect"></param> /// <returns></returns> public EPointF MapFromRect(EPointF pnt, ERectangleF rect) { EPointF fract = pnt / rect.Size; EPointF pntTopOfQuadAtX = (this._points[1] - this._points[0]) * fract.X + this._points[0]; EPointF pntBottomOfQuadAtX = (this._points[2] - this._points[3]) * fract.X + this._points[3]; EPointF inQuad = (pntBottomOfQuadAtX - pntTopOfQuadAtX) * fract.Y + pntTopOfQuadAtX; return(inQuad); //pntFract = point(float(a_pnt[1])/a_rct.width, float(a_pnt[2])/a_rct.height) //pntTopOfQuadAtX = (a_aQuad[2]-a_aQuad[1])*pntFract[1]+a_aQuad[1] //pntBottomOfQuadAtX = (a_aQuad[3]-a_aQuad[4])*pntFract[1]+a_aQuad[4] //return (pntBottomOfQuadAtX-pntTopOfQuadAtX)*pntFract[2] + pntTopOfQuadAtX }
public override void EnterFrame() { this._frameNum++; float f = (float)Math.Sin((float)this._frameNum/7f); EPointF ptNew = EPointF.FromLengthAndAngle(50, f*0.5f); ptNew.Y*=0.2f; if (this._ptOffset == null) this._ptOffset = ptNew; EPointF ptDiff = ptNew - this._ptOffset; this._ptOffset = ptNew; this.Parent.Loc+=ptDiff; }
public void OnMouseDown(object sender, MouseEventArgs e) { EPointF pntMouse = new EPointF(e.X, e.Y); //MessageBox.Show(this.m_formMdiParent, "Aloha!"); //MessageBox.Show(this.m_formMdiParent.ActiveMdiChild, "Aloha!"); if (m_bSendMouseEventsToSprites || true) //TODO: .... { Stage.RootSprite.CheckChildrenMouse(e, pntMouse, true, true); //else //{ //select a sprite on stage: if (e.Button == MouseButtons.Right || (e.Button == MouseButtons.Left && System.Windows.Forms.Control.ModifierKeys == Keys.Control)) { int nNumSprites = -1; if (e.Button == MouseButtons.Left) { nNumSprites = 1; } m_aSpritesInContextMenu = Stage.RootSprite.GetSpritesUnderLoc(pntMouse, nNumSprites); if (m_aSpritesInContextMenu.Count > 1 || (m_aSpritesInContextMenu.Count == 1 && e.Button == MouseButtons.Right)) { System.Windows.Forms.ContextMenu cxmn = new ContextMenu(); foreach (Sprite sp in m_aSpritesInContextMenu) { cxmn.MenuItems.Add(sp.GetSceneGraphName()); cxmn.MenuItems[cxmn.MenuItems.Count - 1].Click += new EventHandler(ContextMenu_Click); } cxmn.MenuItems.Add("-"); cxmn.MenuItems.Add("Exit edit mode"); cxmn.Show(this.Stage.RenderControl, new Point(e.X, e.Y)); } else if (m_aSpritesInContextMenu.Count == 1) { m_sceneGraphViewer.SelectedSprite = (Sprite)m_aSpritesInContextMenu[0]; } } } m_pntMouseLoc.X = e.X; m_pntMouseLoc.Y = e.Y; m_bMouseDown = true; if (MouseButtonEvent != null) { MouseButtonEvent(sender, e, true); } }
public override void Move(EPointF a_pnt) { base.Move (a_pnt); if (this.m_bExploding) { this.Dispose(); } if (this.Animator != null) { this.Animator.Animator.StepSize = 1; this.Animator.Animator.Step(); this.Animator.Animator.StepSize = 0; } }
protected override void OnMouse(MouseEventArgs e, MouseEventType t) { if (t == MouseEventType.Down) this.Color = Color.FromArgb(this.Color.R, this.Color.G, 0); else if (t == MouseEventType.Up || t == MouseEventType.UpOutside || t == MouseEventType.Click) this.Color = Color.FromArgb(this.Color.R, this.Color.G, 255); else if (t == MouseEventType.Enter) this.Color = Color.FromArgb(0, this.Color.G, this.Color.B); else if (t == MouseEventType.Leave) this.Color = Color.FromArgb(255, this.Color.G, this.Color.B); else if (t == MouseEventType.StillDown) { Scaling = new EPointF(1.0f+0.005f*e.X, 1); Loc = new EPointF(e.X, e.Y); Blend = (int)(100*e.X*1.0/100); } }
public void SetLine(EPointF a_pnt1, EPointF a_pnt2) { m_rct = ERectangleF.FromLTRB(a_pnt1.X, a_pnt1.Y, a_pnt2.X, a_pnt2.Y); if (Member!=null) Member.Dispose(); Loc = m_rct.Location; Bitmap bmp = new Bitmap((int)Math.Abs(m_rct.Width),(int)Math.Abs(m_rct.Height), PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(bmp); //Point pnt1 = a_pnt1; //if (a_pnt1.Y <= a_pnt2.Y && a_pnt1.X <= a_pnt2.X) g.DrawLine(new Pen(Color.White, 1), new Point(0,0), new Point((int)m_rct.Width, (int)m_rct.Height)); g.Dispose(); MemberSpriteBitmap mb = new MemberSpriteBitmap(bmp); Member = mb; }
public override void EnterFrame() { if (m_nExplodeCnt > 0) { } else { EPointF pntMove = new EPointF(); if (this.m_keys.GetKeyActive("left")) pntMove.X = -2; else if (this.m_keys.GetKeyActive("right")) pntMove.X = 2; this.Move(pntMove); } base.EnterFrame (); }
public void WrapPointInside(EPointF pnt) { if (pnt.X < this.Left) { pnt.X = this.Right - (this.Left - pnt.X); } else if (pnt.X > this.Right) { pnt.X = this.Left + (pnt.X - this.Right); } if (pnt.Y < this.Top) { pnt.Y = this.Bottom - (this.Top - pnt.Y); } else if (pnt.Y > this.Bottom) { pnt.Y = this.Top + (pnt.Y - this.Bottom); } }
public virtual Interactor.Base CreateInteractor(TrackPlayer tp, ChannelMessage cm) { EPointF ptLoc = new EPointF(); int note = cm.Data1; int strength = cm.Data2; int duration = 10; Interactor.Base interactor = null; LocSetter.Base locSetter = null; Endogine.Node node = this._trackSettings[tp.Track.Name]; if (node != null) { if (node["Interactor"]!=null) { string sType = "MusicGame.Midi.Interactor."+node["Interactor"].Text; Type type = Type.GetType(sType); System.Reflection.ConstructorInfo cons = type.GetConstructor(new Type[]{}); interactor = (Interactor.Base)cons.Invoke(new object[]{}); } if (node["LocSetter"]!=null) { string sType = "MusicGame.Midi.LocSetter." + node["LocSetter"].Text; Type type = Type.GetType(sType); System.Reflection.ConstructorInfo cons = type.GetConstructor(new Type[]{}); locSetter = (LocSetter.Base)cons.Invoke(new object[]{}); } } if (interactor==null) interactor = new Interactor.Default(); // if (locSetter==null) // locSetter = new LocSetter.Default(); interactor.Prepare(tp.Track.Name, cm.MidiChannel, this._readAheadMsecs, note, strength, duration, ptLoc); if (locSetter!=null) locSetter.Parent = interactor; this._spritesToStart.Add(interactor); return interactor; }
public override void EnterFrame() { base.EnterFrame(); bool bCollided = false; m_pntVel.X = m_pntThrust.X*3; //m_pntVel.X = -4; m_pntVel.Y = m_pntThrust.Y*3; //m_pntVel.Y = -4; EPointF pntCollision; EPointF pntCircleAtCollision; EPointF pntNormal = new EPointF(0,0); for (int i = 0; i < m_aLines.Count; i++) { TestLine line = (TestLine)m_aLines[i]; if (Endogine.Collision.Collision.CalcCircleLineCollision(Loc, SourceRect.Width/2, m_pntVel, line.m_rct, out pntCollision, out pntCircleAtCollision)) { //pntCollision, out pntCircleAtCollision EPointF pntDiff = new EPointF(pntCircleAtCollision.X-pntCollision.X, pntCircleAtCollision.Y-pntCollision.Y); SpriteOneFrame sp = new SpriteOneFrame(m_endogine); sp.MemberName = "Cross"; sp.Loc = pntCollision; sp.LocZ = 11; sp = new SpriteOneFrame(m_endogine); sp.MemberName = "Cross"; sp.Loc = pntCircleAtCollision; sp.LocZ = 11; sp.Color = Color.Green; double dAngle = Math.Atan2(pntDiff.X, -pntDiff.Y); float fDist = 1; Loc = new EPointF(fDist*(float)Math.Sin(dAngle)+pntCircleAtCollision.X, -fDist*(float)Math.Cos(dAngle)+pntCircleAtCollision.Y); bCollided = true; } } if (!bCollided) Move(m_pntVel); }
public Ball(int a_nType, PlayArea a_playArea) { Parent = a_playArea; m_playArea = a_playArea; string sClr = ""; switch (a_nType) { case 0: sClr = "Red"; break; case 1: sClr = "Green"; break; case 2: sClr = "Blue"; break; case 3: sClr = "Yellow"; break; case 4: sClr = "Purple"; break; case 5: sClr = "White"; break; case 6: sClr = "Black"; break; case 7: sClr = "Orange"; break; } BallType = a_nType; MemberName = "Ball"+sClr; this.CenterRegPoint(); m_pntVel = new EPointF(0,0); }
// private Sound m_sndStep1; // private Sound m_sndStep2; public InvadersGrid() { this.SourceRect = new ERectangle(0,0,1,1); this._invaders = new List<Invader>(); int nColumns = 11; int nRows = 5; //nColumns = 0; //nRows = 0; this._columnSortedInvaders = new SortedList<int, SortedList<int, Invader>>(); for (int i = 0; i < nColumns; i++) this._columnSortedInvaders.Add(i, new SortedList<int, Invader>()); for (int y = 0; y < nRows; y++) { string anim = "Invader03"; if (y >= 3) anim = "Invader01"; else if (y>=1) anim = "Invader02"; for (int x = 0; x<nColumns; x++) { Invader invader = new Invader(); invader.SetGraphics(anim); invader.Loc = new EPointF((x-1)*32,(y-1)*32) + new EPointF(185,124); invader.Parent = this; this._invaders.Add(invader); this._columnSortedInvaders[x].Add(y, invader); } } this.m_pntMovement = new EPointF(4,0); }
public DrumForm() { if (Endogine.Audio.SoundManager.DefaultSoundManager == null) { throw new Exception("No sound system .dll found!"); } this.Rect = new ERectangleF(0,0,600,150); this.m_pntGridCellSize = new EPoint(35,40); this.m_pntGridStart = new EPointF(10,50); this.MouseActive = true; this.m_tracks = new Track[2]; string[] aSounds = new string[]{"drumsnare.wav", "drumbass.wav"}; for (int nChannel = 0; nChannel < aSounds.Length; nChannel++) { Track track = new Track(aSounds[nChannel], m_nNumNotes, this.m_pntGridCellSize); track.Parent = this; track.Loc = new EPointF(0,nChannel*this.m_pntGridCellSize.Y)+m_pntGridStart; this.m_tracks[nChannel] = track; //track.Visible=false; } this.m_tracks[0].LoadPattern(new int[]{0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0}); this.m_tracks[1].LoadPattern(new int[]{1,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0}); this.m_spPlaybackHead = new Sprite(); this.m_spPlaybackHead.MemberName = "Cross"; this.m_spPlaybackHead.CenterRegPoint(); this.m_spPlaybackHead.Parent = this; this.m_spPlaybackHead.Loc = m_pntGridStart; this.m_timer = new Timer(new TimerCallback(this.Tick), null, 0, 125); this._listener = new Endogine.Audio.Listener(); this._pk = new PlayKeyboard(); }
public override void EnterFrame() { float f = (float)Math.Sin((double)this.FramesAlive*0.5f); float factor = 1f-(float)this.FramesAlive/70; EPointF ptNew = new EPointF(0,this._intensity*f*factor*20); if (this._ptOffset==null) this._ptOffset = ptNew; EPointF ptDiff = ptNew-this._ptOffset; this._ptOffset = ptNew; this.Parent.Loc+=ptDiff; //this.Parent.Rotation = f*(float)Math.PI*intensity; //EH.Put(this.Rotation.ToString()); base.EnterFrame (); if (factor <= 0) { //this.Parent.Rotation = 0; this.Dispose(); } }
public void GetMouseCheckOrder(EPointF a_pntLocalLoc, ArrayList sprites) { a_pntLocalLoc = this.ConvParentLocToSrcLoc(a_pntLocalLoc); for (int i = this._slChildrenLocZSorted.Count - 1; i >= 0; i--) { Sprite sp = (Sprite)this._slChildrenLocZSorted.GetByIndex(i); //foreach (DataRowView row in m_dvChildrenLocZInverseSorted) //{ // Sprite sp = ((Sprite)m_plChildrenByHash[(int)row["Hash"]]); if (sp.ChildCount > 0) { sp.GetMouseCheckOrder(a_pntLocalLoc, sprites); } if (sp.MouseActive) { if (sp.Rect.Contains(a_pntLocalLoc)) { sprites.Add(sp); } } } }
public void MakePointInside(EPointF pnt) { if (pnt.X < this.Left) { pnt.X = this.Left; } else if (pnt.X > this.Right) { pnt.X = this.Right; } if (pnt.Y < this.Top) { pnt.Y = this.Top; } else if (pnt.Y > this.Bottom) { pnt.Y = this.Bottom; } //pnt.X = Math.Max(pnt.X, x); //pnt.X = Math.Min(pnt.X, Right); //pnt.Y = Math.Max(pnt.Y, y); //pnt.Y = Math.Min(pnt.Y, Bottom); }
/// <summary> /// Transforms a point in the quad to where it would be if the quad was stretched out to a rectangle /// </summary> /// <param name="pnt"></param> /// <param name="rect"></param> /// <returns></returns> public EPointF MapToRect(EPointF pnt, ERectangleF rect) { //--Courtesy of NoiseCrime float x = pnt.X; float y = pnt.Y; float af = this._points[0].X - this._points[1].X - this._points[3].X + this._points[2].X; float bf = this._points[1].X - this._points[0].X; float cf = this._points[3].X - this._points[0].X; float df = this._points[0].X; float ef = this._points[0].Y - this._points[1].Y - this._points[3].Y + this._points[2].Y; float ff = this._points[1].Y - this._points[0].Y; float gf = this._points[3].Y - this._points[0].Y; float hf = this._points[0].Y; float A = af * ff - bf * ef; float B = ef * x - af * y + af * hf - df * ef + cf * ff - bf * gf; float C = gf * x - cf * y + cf * hf - df * gf; float D = af * gf - cf * ef; float u, v; float tmpBResult = 0; if (Math.Abs(A) > 0.00001f) { tmpBResult = (B * B) - (4f * A * C); if (tmpBResult < 0) return null; tmpBResult = (float)Math.Sqrt(tmpBResult); u = (-B - tmpBResult) / (2f * A); float u2 = 0; // If our u is outside our range. if ((u < 0) || (u > 1)) u2 = (-B + tmpBResult) / (2f * A); // If u2 is in the correct range, use u2 if ((u2 >= 0) && (u2 <= 1)) u = u2; else //pick whichever is closest to range (0...1) if (Math.Abs(u2 - 0.5f) < Math.Abs(u - 0.5f)) u = u2; } else { if ((int)Math.Round(B) != 0) u = -C / B; else u = 0; //return null; //!!@ "Error Quad mapping U = 0") } if (Math.Abs(D) > 0.00001f) { float temp = af * u + cf; v = -1f; if ((temp > 0.00001f) || (temp < -0.00001f)) v = (x - bf * u - df) / temp; else v = 0; //return null; // v = 0 -- !!@ "Error Quad mapping V = 0 if ((v < 0) || (v > 1)) { float E = ef * x - af * y + af * hf - df * ef - cf * ff + bf * gf; float F = ff * x - bf * y + bf * hf - df * ff; float tmpEResult = E * E - 4f * D * F; if (tmpBResult < 0) //TODO: he meant tmpEResult, no? return null; tmpBResult = (float)Math.Sqrt(tmpBResult); //TODO: he meant tmpEResult, no? // If our result is going to be outside our rect, use the alternative value for the quadratic equation. v = (-E + tmpEResult) / (2f * D); if ((v < 0) || (v > 1)) { float v2 = (-E - tmpEResult) / (2f * D); // If v2 is in the correct range, use u2 if ((v2 >= 0) && (v2 <= 1)) v = v2; else // pick whichever is closest to range (0...1) if (Math.Abs(v2 - 0.5f) < Math.Abs(v - 0.5f)) v = v2; } } } else { float E = ef * x - af * y + af * hf - df * ef - cf * ff + bf * gf; float F = ff * x - bf * y + bf * hf - df * ff; if ((int)Math.Round(E) != 0) v = -F / E; else return null; //Error Quad mapping VE= 0") } //--JB 041001: float pToh = u * rect.Width + rect.X; //-rect.X + prect[1] + 0.0) --+ 0.5 float pTov = v * rect.Height + rect.Y; //-prect[2] + prect[2] + 0.0) --+ 0.5 return new EPointF(pToh, pTov); }
/// <summary> /// Transforms a point in the quad to where it would be if the quad was stretched out to a rectangle /// </summary> /// <param name="pnt"></param> /// <param name="rect"></param> /// <returns></returns> public EPointF MapToRect(EPointF pnt, ERectangleF rect) { //--Courtesy of NoiseCrime float x = pnt.X; float y = pnt.Y; float af = this._points[0].X - this._points[1].X - this._points[3].X + this._points[2].X; float bf = this._points[1].X - this._points[0].X; float cf = this._points[3].X - this._points[0].X; float df = this._points[0].X; float ef = this._points[0].Y - this._points[1].Y - this._points[3].Y + this._points[2].Y; float ff = this._points[1].Y - this._points[0].Y; float gf = this._points[3].Y - this._points[0].Y; float hf = this._points[0].Y; float A = af * ff - bf * ef; float B = ef * x - af * y + af * hf - df * ef + cf * ff - bf * gf; float C = gf * x - cf * y + cf * hf - df * gf; float D = af * gf - cf * ef; float u, v; float tmpBResult = 0; if (Math.Abs(A) > 0.00001f) { tmpBResult = (B * B) - (4f * A * C); if (tmpBResult < 0) { return(null); } tmpBResult = (float)Math.Sqrt(tmpBResult); u = (-B - tmpBResult) / (2f * A); float u2 = 0; // If our u is outside our range. if ((u < 0) || (u > 1)) { u2 = (-B + tmpBResult) / (2f * A); } // If u2 is in the correct range, use u2 if ((u2 >= 0) && (u2 <= 1)) { u = u2; } else //pick whichever is closest to range (0...1) if (Math.Abs(u2 - 0.5f) < Math.Abs(u - 0.5f)) { u = u2; } } else { if ((int)Math.Round(B) != 0) { u = -C / B; } else { u = 0; //return null; //!!@ "Error Quad mapping U = 0") } } if (Math.Abs(D) > 0.00001f) { float temp = af * u + cf; v = -1f; if ((temp > 0.00001f) || (temp < -0.00001f)) { v = (x - bf * u - df) / temp; } else { v = 0; //return null; // v = 0 -- !!@ "Error Quad mapping V = 0 } if ((v < 0) || (v > 1)) { float E = ef * x - af * y + af * hf - df * ef - cf * ff + bf * gf; float F = ff * x - bf * y + bf * hf - df * ff; float tmpEResult = E * E - 4f * D * F; if (tmpBResult < 0) //TODO: he meant tmpEResult, no? { return(null); } tmpBResult = (float)Math.Sqrt(tmpBResult); //TODO: he meant tmpEResult, no? // If our result is going to be outside our rect, use the alternative value for the quadratic equation. v = (-E + tmpEResult) / (2f * D); if ((v < 0) || (v > 1)) { float v2 = (-E - tmpEResult) / (2f * D); // If v2 is in the correct range, use u2 if ((v2 >= 0) && (v2 <= 1)) { v = v2; } else // pick whichever is closest to range (0...1) if (Math.Abs(v2 - 0.5f) < Math.Abs(v - 0.5f)) { v = v2; } } } } else { float E = ef * x - af * y + af * hf - df * ef - cf * ff + bf * gf; float F = ff * x - bf * y + bf * hf - df * ff; if ((int)Math.Round(E) != 0) { v = -F / E; } else { return(null); //Error Quad mapping VE= 0") } } //--JB 041001: float pToh = u * rect.Width + rect.X; //-rect.X + prect[1] + 0.0) --+ 0.5 float pTov = v * rect.Height + rect.Y; //-prect[2] + prect[2] + 0.0) --+ 0.5 return(new EPointF(pToh, pTov)); }
public Quad(EPointF[] points) { this._points = points; }
protected override void EnterFrame() { EPointF pnt = new EPointF( (float)Math.Sin(this.pntLocSpeed.X*m_nCnt), (float)Math.Sin(this.pntLocSpeed.Y*m_nCnt)) * this.pntLocAmount; m_sp.Loc+=pnt-this.pntOffset; this.pntOffset = pnt; m_sp.Rotation = (float)Math.Sin(fRotationSpeed*m_nCnt)*fRotationAmount; m_nCnt++; base.EnterFrame(); }
private void m_frame_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t) { if (t == Sprite.MouseEventType.StillDown) { EPointF pntDiff = new EPointF(e.X-m_frame.MouseLastLoc.X, e.Y-m_frame.MouseLastLoc.Y); this.Parent.Move(pntDiff); } }
public EPointF GetGfxLocFromGridLoc(EPointF a_pnt) { return new EPointF( (a_pnt.X)*BallDiameter/2, (a_pnt.Y)*BallDiameter/2*HeightProportion); }
private void DoPhysics(float msecsPassed) { float timeDelta = msecsPassed / 1000; if (this._inputSteerAngle != 0) { int i = 0; } float sn = (float)Math.Sin(this._angle); float cs = (float)Math.Cos(this._angle); //SAE convention: x is to the front of the car, y is to the right, z is down //transform velocity in world reference frame to velocity in car reference frame localVel.X = cs * this._velocity.Y + sn * this._velocity.X; localVel.Y = -sn * this._velocity.Y + cs * this._velocity.X; //Lateral force on wheels //Resulting velocity of the wheels as result of the yaw rate of the car body //v = yawrate * r where r is distance of wheel to CG (approx. half wheel base) //yawrate (ang.velocity) must be in rad/s float yawspeed = this._carType.Wheelbase * 0.5f * this._angularVelocity; float rot_angle = 0; if (localVel.X == 0) //TODO: fix singularity rot_angle = 0; else rot_angle = (float)Math.Atan2(yawspeed, localVel.X); //localVel.X, yawspeed); //Calculate the side slip angle of the car (a.k.a. beta) float sideslip = 0; if (localVel.X == 0) //TODO: fix singularity sideslip = 0; else sideslip = (float)Math.Atan2(localVel.Y, localVel.X); //localVel.X, localVel.Y); //Calculate slip angles for front and rear wheels (a.k.a. alpha) slipanglefront = sideslip + rot_angle - this._inputSteerAngle * Math.Sign(localVel.X); slipanglerear = sideslip - rot_angle; //weight per axle = half car mass times 1G (=9.8m/s^2) float weight = this._carType.Mass * 9.8f * 0.5f; //lateral force on front wheels = (Ca * slip angle) capped to friction circle * load EPointF flatf = new EPointF(); flatf.Y = this._environment.CornerStiffnessF * slipanglefront; flatf.Y = Math.Min(this._environment.MaxGrip, flatf.Y); flatf.Y = Math.Max(-this._environment.MaxGrip, flatf.Y); flatf.Y *= weight; if (this._useFrontSlip) flatf.Y *= 0.5f; //lateral force on rear wheels EPointF flatr = new EPointF(); flatr.Y = this._environment.CornerStiffnessR * slipanglerear; flatr.Y = Math.Min(this._environment.MaxGrip, flatr.Y); flatr.Y = Math.Max(-this._environment.MaxGrip, flatr.Y); flatr.Y *= weight; if (this._useRearSlip) flatr.Y *= 0.5f; //longitudinal force on rear wheels - very simple traction model EPointF ftraction = new EPointF(); ftraction.X = 100f * (this._inputThrottle - this._inputBrake * Math.Sign(localVel.X)); if (this._useRearSlip) ftraction.X *= 0.5f; // Forces and torque on body //drag and rolling resistance EPointF pntAbs = new EPointF(Math.Abs(localVel.X), Math.Abs(localVel.Y)); EPointF resistance = (localVel * this._environment.Resistance + localVel * pntAbs * this._environment.Drag) * -1; //resistance.x = -(RESISTANCE * velocity.x + DRAG * velocity.x * ABS(velocity.x)); //resistance.y = -(RESISTANCE * velocity.y + DRAG * velocity.y * ABS(velocity.y)); //sum forces force = new EPointF(); force.X = ftraction.X + (float)Math.Sin(this._inputSteerAngle) * flatf.X + flatr.X + resistance.X; force.Y = ftraction.Y + (float)Math.Cos(this._inputSteerAngle) * flatf.Y + flatr.Y + resistance.Y; ////JB: mechanical friction and cylinders //force.X += -1000*localVel.X; //torque on body from lateral forces float torque = this._carType.CenterOfMassToFront * flatf.Y - this._carType.CenterOfMassToRear * flatr.Y; // Acceleration //Newton F = m.a, therefore a = F/m localAcceleration = force / this._carType.Mass; float angular_acceleration = torque / this._carType.Inertia; // Velocity and position //transform acceleration from car reference frame to world reference frame acceleration = new EPointF( cs * localAcceleration.Y + sn * localAcceleration.X, -sn * localAcceleration.Y + cs * localAcceleration.X); //velocity is integrated acceleration this._velocity += acceleration * timeDelta; //position is integrated velocity this.Loc += this._velocity * timeDelta*20; // Angular velocity and heading //integrate angular acceleration to get angular velocity this._angularVelocity += angular_acceleration * timeDelta; //integrate angular velocity to get angular orientation this._angle += this._angularVelocity * timeDelta; }
public override void EnterFrame() { float minStep = (float)Math.PI / 32; if (this._keys.GetKeyActive("right")) this._inputSteerAngle = Math.Max(this._inputSteerAngle - minStep, -(float)Math.PI / 4); if (this._keys.GetKeyActive("left")) this._inputSteerAngle = Math.Min(this._inputSteerAngle + minStep, (float)Math.PI / 4); if (this._inputSteerAngle > 0) { this._inputSteerAngle -= minStep / 4; if (this._inputSteerAngle < 0) this._inputSteerAngle = 0; } else if (this._inputSteerAngle < 0) { this._inputSteerAngle += minStep / 4; if (this._inputSteerAngle > 0) this._inputSteerAngle = 0; } if (this._keys.GetKeyActive("up")) { this._targetSpeed += 1; this._inputThrottle = Math.Min(this._inputThrottle + 10, 100f); } else if (this._keys.GetKeyActive("down")) { this._targetSpeed -= 1; this._inputThrottle = Math.Max(this._inputThrottle - 10, -60f); } else { if (localVel.X > 0) { if (localVel.X > 0.5f) { this._inputThrottle = -25; } else if (this._inputThrottle == 0) this._velocity = new EPointF(); } } //if (this.Velocity.Length < this._targetSpeed) // this._inputThrottle = 30; //else if (this.Velocity.Length > this._targetSpeed) // this._inputThrottle = -30; if (this._inputThrottle > 0) this._inputThrottle -= 5; else if (this._inputThrottle < 0) this._inputThrottle += 5; if (this._keys.GetKeyActive("action")) { this._inputBrake = 100; this._inputThrottle = 0; } else this._inputBrake = 0; if (this._lastFrameTicks > 0) { int timeDelta = (int)(DateTime.Now.Ticks - this._lastFrameTicks); if (timeDelta > 0) //this.DoPhysics(10); this.DoPhysics(timeDelta / 10000); } this._lastFrameTicks = DateTime.Now.Ticks; this.Rotation = -this._angle; ERectangleF rct = new ERectangleF(new EPointF(), EH.Instance.Stage.ControlSize.ToEPointF()); EPointF loc = this.Loc.Copy(); rct.WrapPointInside(loc); this.Loc = loc; base.EnterFrame(); }
public EPointF GetGridLocFromGfxLoc(EPointF a_pnt) { return new EPointF(a_pnt.X*2/BallDiameter, a_pnt.Y/BallDiameter*2/HeightProportion); //return new Point((int)(a_pnt.X*2/BallDiameter), (int)Math.Round((a_pnt.Y/BallDiameter*2/HeightProportion))); }
public Camera() { this.SourceRect = Parent.SourceRect.Copy(); this.Rect = Parent.Rect.Copy(); m_pntLocInternal = new EPointF(); }
public void InitWithValue(EPointF pnt) { DefaultValue = pnt; StartValue = pnt; CurrentValue = pnt; }
public override void Start() { Random rnd = new Random(); this.Interactor.Loc = new EPointF(rnd.Next(100), rnd.Next(100)) + new EPointF(300,300); this._locOrg = this.Interactor.Loc.Copy(); }
public override bool Equals(object obj) { EPointF pnt = (EPointF)obj; return(pnt.X == x && pnt.Y == y); }
public EPoint RoundToClosestGridLoc(EPointF a_pntLoc) { int y = (int)Math.Round(a_pntLoc.Y); float x = a_pntLoc.X/2 + (y%(2+CeilingNumStepsDown))*0.5f; x = (int)Math.Round(x)*2 - (y % (2+CeilingNumStepsDown)); if (x < 0) x = 0; else if (x >= GridSize.Width) x = GridSize.Width-1-y%2; return new EPoint((int)x, y); }
public ParallaxLayer() { m_pntScrollFactor = new EPointF(1, 1); this.SourceRect = new ERectangle(0, 0, 1, 1); this.Rect = new ERectangleF(0, 0, 1, 1); }
public ParallaxLayer() { m_pntScrollFactor = new EPointF(1,1); this.SourceRect = new ERectangle(0,0,1,1); this.Rect = new ERectangleF(0,0,1,1); }
public override void SubDraw() { ERectangleF rctDraw = m_sp.CalcRectInDrawTarget(); //TODO: if same rect as last time, use a cached matrix instead of re-calculating all this. // if (m_sp.Picture != null) // { // ERectangleF x = rctDraw.Copy(); // x.Intersect(new ERectangleF(0,0,600,600)); // if (!x.IsEmpty && !x.IsNegative) // { // x.Width+=1; // } // } Matrix QuadMatrix = Matrix.Scaling(rctDraw.Width, rctDraw.Height, 1); EPointF pntRegOff = m_sp.RegPoint.ToEPointF() / new EPointF(m_sp.SourceRect.Width, m_sp.SourceRect.Height) * new EPointF(rctDraw.Width, rctDraw.Height); QuadMatrix.Multiply(Matrix.Translation(-pntRegOff.X, pntRegOff.Y, 0)); QuadMatrix.Multiply(Matrix.RotationZ(-m_sp.Rotation)); QuadMatrix.Multiply(Matrix.Translation(pntRegOff.X, -pntRegOff.Y, 0)); EPointF pntLoc = new EPointF(rctDraw.X - device.Viewport.Width / 2, rctDraw.Y - device.Viewport.Height / 2); QuadMatrix.Multiply(Matrix.Translation(pntLoc.X, -pntLoc.Y, 0f)); Stage3D stage = ((Stage3D)EH.Instance.Stage); stage.ZCurrent += stage.ZStep; QuadMatrix.M43 = 10000f - stage.ZCurrent - 1; //QuadMatrix.M43 = 10000f-m_sp.LocZ-1; // if (this.m_sp.Parent.Name == "Bar" && (this.m_sp.Name == "2;1" || this.m_sp.Name == "2;2")) // { // this.m_sp.CalcInParent(); // m_sp.CalcRectInDrawTarget(); // float x = rctDraw.Bottom; // x++; // } device.Material = m_mtrl; //TODO: (in controlling mechanism:) render order by RenderStates somehow? I hear that state changes are expensive switch (m_sp.Ink) { case RasterOps.ROPs.Copy: if (this.m_sp.Member.GotAlpha || true) //this.m_mtrl.Diffuse.A != 255) { device.RenderState.AlphaBlendEnable = true; device.RenderState.SourceBlend = Blend.SourceAlpha; device.RenderState.DestinationBlend = Blend.InvSourceAlpha; if (this.m_mtrl.Diffuse.A != 255) { device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse; device.TextureState[0].AlphaOperation = TextureOperation.Modulate; device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse; device.TextureState[0].ColorOperation = TextureOperation.Modulate; device.TextureState[1].AlphaOperation = TextureOperation.Disable; device.TextureState[1].ColorOperation = TextureOperation.Disable; } } else { device.RenderState.AlphaBlendEnable = false; } break; case RasterOps.ROPs.AddPin: device.RenderState.AlphaBlendEnable = true; device.RenderState.DestinationBlend = Blend.InvSourceColor; device.RenderState.SourceBlend = Blend.One; break; case RasterOps.ROPs.Multiply: //multiply? device.RenderState.AlphaBlendEnable = true; device.RenderState.BlendOperation = BlendOperation.Min; //device.RenderState.SourceBlend = Blend.DestinationColor same? break; case RasterOps.ROPs.BgTransparent: device.RenderState.AlphaBlendEnable = true; device.RenderState.SourceBlend = Blend.SourceAlpha; device.RenderState.DestinationBlend = Blend.InvSourceAlpha; // if (m_sp.Blend!=255) // { // device.RenderState.BlendFactor = Color.FromArgb(0, m_sp.Blend, m_sp.Blend,m_sp.Blend);//m_sp.Blend, m_sp.Blend, m_sp.Blend); // device.RenderState.AlphaSourceBlend = Blend.BlendFactor; // } break; case RasterOps.ROPs.Lightest: //lightest? device.RenderState.AlphaBlendEnable = true; device.RenderState.BlendOperation = BlendOperation.Max; break; case RasterOps.ROPs.SubtractPin: //OK device.RenderState.AlphaBlendEnable = true; device.RenderState.SourceBlend = Blend.Zero; device.RenderState.DestinationBlend = Blend.InvSourceColor; break; case RasterOps.ROPs.Difference: //Hmm.. device.RenderState.AlphaBlendEnable = true; device.RenderState.SourceBlend = Blend.InvDestinationColor; device.RenderState.DestinationBlend = Blend.InvSourceColor; break; case RasterOps.ROPs.D3DTest1: //Director blend ink (by sprite's Blend value) device.RenderState.AlphaBlendEnable = true; device.RenderState.BlendFactor = Color.FromArgb(0, m_sp.Blend, m_sp.Blend, m_sp.Blend); //m_sp.Blend, m_sp.Blend, m_sp.Blend); device.RenderState.SourceBlend = Blend.BlendFactor; device.RenderState.DestinationBlend = Blend.InvBlendFactor; break; case RasterOps.ROPs.D3DTest2: //Alpha channel blending device.RenderState.AlphaBlendEnable = true; device.RenderState.BlendFactor = Color.FromArgb(0, m_sp.Blend, m_sp.Blend, m_sp.Blend); device.RenderState.SourceBlend = Blend.SourceAlpha; device.RenderState.DestinationBlend = Blend.InvSourceAlpha; break; case RasterOps.ROPs.D3DTest3: //don't understand this one... device.RenderState.AlphaBlendEnable = true; device.RenderState.SourceBlend = Blend.InvSourceColor; break; case RasterOps.ROPs.D3DTest4: //device.RenderState.AlphaTestEnable = false; //device.RenderState.ReferenceAlpha = 0x01; //device.RenderState.AlphaFunction = Compare.GreaterEqual; device.RenderState.AlphaBlendEnable = true; //device.RenderState.BlendFactor = Color.FromArgb(m_sp.Blend, 255,255,255);//m_sp.Blend, m_sp.Blend, m_sp.Blend); device.RenderState.BlendFactor = Color.FromArgb(0, m_sp.Blend, m_sp.Blend, m_sp.Blend); //m_sp.Blend, m_sp.Blend, m_sp.Blend); //device.RenderState.AlphaSourceBlend = Blend.BlendFactor; //device.RenderState.AlphaDestinationBlend = Blend.BlendFactor; device.RenderState.SourceBlend = Blend.BlendFactor; device.RenderState.DestinationBlend = Blend.InvBlendFactor; //device.RenderState.Ambient = System.Drawing.Color.FromArgb(0, 255, 255, 255); //m_mtrl.Ambient = m_mtrl.Diffuse = Color.FromArgb(10, m_mtrl.Diffuse.R, m_mtrl.Diffuse.G, m_mtrl.Diffuse.B); //device.RenderState.BlendFactor = Color.FromArgb(10, 127, 127, 127); //device.RenderState.DiffuseMaterialSource = ColorSource.Material; //device.RenderState.BlendOperation = BlendOperation.Add; //device.SetTextureStageState(0, TextureStageStates.AlphaArgument0, 100f); //device.Material = m_mtrl; //device.SetRenderState(RenderStates.DestinationBlend, 4); //device.RenderState.SourceBlend = Blend.BothSourceAlpha; //let's though key only? //device.RenderState.DestinationBlend = Blend.SourceColor; //some transparency in grayish areas? //device.RenderState.BlendOperation = BlendOperation.Subtract; ?? //device.RenderState.BlendOperation = BlendOperation.Add; //device.SetRenderState(RenderStates.BlendFactor, 0.5f); //device.RenderState.SourceBlend = Blend.SourceAlpha; //device.RenderState.DestinationBlend = Blend.InvSourceAlpha; //device.RenderState.BlendFactor = Color.FromArgb(127, 127, 127, 127); //device.RenderState.BlendFactor = Color.FromArgb(127, 255, 255, 255); //m_mtrl.Diffuse = Color.FromArgb(127, m_mtrl.Diffuse.R, m_mtrl.Diffuse.G, m_mtrl.Diffuse.B); //device.SetTextureStageState(0, TextureStageStates.AlphaArgument1, 100f); break; //http://www.two-kings.de/tutorials/d3d.html //disappeared?? // http://www.toymaker.info/Games/html/render_states.html } device.SetTexture(0, m_sp.Member.Texture); device.SamplerState[0].MagFilter = this.m_sp.TextureMagFilter; device.SamplerState[0].MinFilter = this.m_sp.TextureMinFilter; device.SetStreamSource(0, vertexBuffer, 0); device.VertexFormat = customVertexFlags; device.SetTransform(TransformType.View, QuadMatrix); device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, numVerts - 2); }
private void jsShuttle_DraggingEvent(object sender, Endogine.EPointF pntDelta) { EPointF pnt = jsShuttle.GetDelta(); Send(m_pntCurrent + pnt); }