public override void update(float time) { if (this.m_bDirty) { for (int i = 0; i < this.m_sGridSize.x + 1; i++) { for (int j = 0; j < this.m_sGridSize.y + 1; j++) { ccVertex3F _ccVertex3F = base.originalVertex(new ccGridSize(i, j)); CCPoint cCPoint = new CCPoint(this.m_positionInPixels.x - (new CCPoint(_ccVertex3F.x, _ccVertex3F.y)).x, this.m_positionInPixels.y - (new CCPoint(_ccVertex3F.x, _ccVertex3F.y)).y); float mFRadius = CCPointExtension.ccpLength(cCPoint); if (mFRadius < this.m_fRadius) { mFRadius = this.m_fRadius - mFRadius; float single = mFRadius / this.m_fRadius; if (single == 0f) { single = 0.001f; } float single1 = (float)Math.Log((double)single) * this.m_fLensEffect; float single2 = (float)Math.Exp((double)single1) * this.m_fRadius; if (Math.Sqrt((double)(cCPoint.x * cCPoint.x + cCPoint.y * cCPoint.y)) > 0) { cCPoint = CCPointExtension.ccpNormalize(cCPoint); CCPoint cCPoint1 = CCPointExtension.ccpMult(cCPoint, single2); ccVertex3F _ccVertex3F1 = _ccVertex3F; _ccVertex3F1.z = _ccVertex3F1.z + CCPointExtension.ccpLength(cCPoint1) * this.m_fLensEffect; } } base.setVertex(new ccGridSize(i, j), _ccVertex3F); } } this.m_bDirty = false; } }
protected override void updateColor() { base.updateColor(); float single = CCPointExtension.ccpLength(this.m_AlongVector); if (single == 0f) { return; } double num = Math.Sqrt(2); CCPoint cCPoint = new CCPoint(this.m_AlongVector.x / single, this.m_AlongVector.y / single); if (this.m_bCompressedInterpolation) { float single1 = 1f / (Math.Abs(cCPoint.x) + Math.Abs(cCPoint.y)); cCPoint = CCPointExtension.ccpMult(cCPoint, single1 * (float)num); } float mCOpacity = (float)this.m_cOpacity / 255f; ccColor4B _ccColor4B = new ccColor4B() { r = this.m_tColor.r, g = this.m_tColor.g, b = this.m_tColor.b, a = (byte)((float)this.m_cStartOpacity * mCOpacity) }; ccColor4B _ccColor4B1 = _ccColor4B; ccColor4B _ccColor4B2 = new ccColor4B() { r = this.m_endColor.r, g = this.m_endColor.g, b = this.m_endColor.b, a = (byte)((float)this.m_cEndOpacity * mCOpacity) }; ccColor4B _ccColor4B3 = _ccColor4B2; this.m_pSquareColors[0].r = (byte)((double)_ccColor4B3.r + (double)(_ccColor4B1.r - _ccColor4B3.r) * ((num + (double)cCPoint.x + (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[0].g = (byte)((double)_ccColor4B3.g + (double)(_ccColor4B1.g - _ccColor4B3.g) * ((num + (double)cCPoint.x + (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[0].b = (byte)((double)_ccColor4B3.b + (double)(_ccColor4B1.b - _ccColor4B3.b) * ((num + (double)cCPoint.x + (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[0].a = (byte)((double)_ccColor4B3.a + (double)(_ccColor4B1.a - _ccColor4B3.a) * ((num + (double)cCPoint.x + (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[1].r = (byte)((double)_ccColor4B3.r + (double)(_ccColor4B1.r - _ccColor4B3.r) * ((num - (double)cCPoint.x + (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[1].g = (byte)((double)_ccColor4B3.g + (double)(_ccColor4B1.g - _ccColor4B3.g) * ((num - (double)cCPoint.x + (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[1].b = (byte)((double)_ccColor4B3.b + (double)(_ccColor4B1.b - _ccColor4B3.b) * ((num - (double)cCPoint.x + (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[1].a = (byte)((double)_ccColor4B3.a + (double)(_ccColor4B1.a - _ccColor4B3.a) * ((num - (double)cCPoint.x + (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[2].r = (byte)((double)_ccColor4B3.r + (double)(_ccColor4B1.r - _ccColor4B3.r) * ((num + (double)cCPoint.x - (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[2].g = (byte)((double)_ccColor4B3.g + (double)(_ccColor4B1.g - _ccColor4B3.g) * ((num + (double)cCPoint.x - (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[2].b = (byte)((double)_ccColor4B3.b + (double)(_ccColor4B1.b - _ccColor4B3.b) * ((num + (double)cCPoint.x - (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[2].a = (byte)((double)_ccColor4B3.a + (double)(_ccColor4B1.a - _ccColor4B3.a) * ((num + (double)cCPoint.x - (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[3].r = (byte)((double)_ccColor4B3.r + (double)(_ccColor4B1.r - _ccColor4B3.r) * ((num - (double)cCPoint.x - (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[3].g = (byte)((double)_ccColor4B3.g + (double)(_ccColor4B1.g - _ccColor4B3.g) * ((num - (double)cCPoint.x - (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[3].b = (byte)((double)_ccColor4B3.b + (double)(_ccColor4B1.b - _ccColor4B3.b) * ((num - (double)cCPoint.x - (double)cCPoint.y) / (2 * num))); this.m_pSquareColors[3].a = (byte)((double)_ccColor4B3.a + (double)(_ccColor4B1.a - _ccColor4B3.a) * ((num - (double)cCPoint.x - (double)cCPoint.y) / (2 * num))); this.vertices[0].Color = new Microsoft.Xna.Framework.Color((int)this.m_pSquareColors[0].r, (int)this.m_pSquareColors[0].g, (int)this.m_pSquareColors[0].b, (int)this.m_pSquareColors[0].a); this.vertices[1].Color = new Microsoft.Xna.Framework.Color((int)this.m_pSquareColors[1].r, (int)this.m_pSquareColors[1].g, (int)this.m_pSquareColors[1].b, (int)this.m_pSquareColors[1].a); this.vertices[2].Color = new Microsoft.Xna.Framework.Color((int)this.m_pSquareColors[2].r, (int)this.m_pSquareColors[2].g, (int)this.m_pSquareColors[2].b, (int)this.m_pSquareColors[2].a); this.vertices[3].Color = new Microsoft.Xna.Framework.Color((int)this.m_pSquareColors[3].r, (int)this.m_pSquareColors[3].g, (int)this.m_pSquareColors[3].b, (int)this.m_pSquareColors[3].a); }
public override void Update(float time) { if (m_bDirty) { int i, j; for (i = 0; i < m_sGridSize.x + 1; ++i) { for (j = 0; j < m_sGridSize.y + 1; ++j) { ccVertex3F v = originalVertex(new ccGridSize(i, j)); CCPoint vect = new CCPoint(m_positionInPixels.X - new CCPoint(v.x, v.y).X, m_positionInPixels.Y - new CCPoint(v.x, v.y).Y); float r = CCPointExtension.ccpLength(vect); if (r < m_fRadius) { r = m_fRadius - r; float pre_log = r / m_fRadius; if (pre_log == 0) { pre_log = 0.001f; } float l = (float)Math.Log(pre_log) * m_fLensEffect; float new_r = (float)Math.Exp(l) * m_fRadius; if (Math.Sqrt((vect.X * vect.X + vect.Y * vect.Y)) > 0) { vect = CCPointExtension.ccpNormalize(vect); CCPoint new_vect = CCPointExtension.ccpMult(vect, new_r);; v.z += CCPointExtension.ccpLength(new_vect) * m_fLensEffect; } } setVertex(new ccGridSize(i, j), v); } } m_bDirty = false; } }
protected override void updateColor() { base.updateColor(); float h = CCPointExtension.ccpLength(m_AlongVector); if (h == 0) { return; } double c = Math.Sqrt(2.0); CCPoint u = new CCPoint(m_AlongVector.X / h, m_AlongVector.Y / h); // Compressed Interpolation mode if (m_bCompressedInterpolation) { float h2 = 1 / (Math.Abs(u.X) + Math.Abs(u.Y)); u = CCPointExtension.ccpMult(u, h2 * (float)c); } float opacityf = (float)m_cOpacity / 255.0f; ccColor4B S = new ccColor4B { r = m_tColor.r, g = m_tColor.g, b = m_tColor.b, a = (byte)(m_cStartOpacity * opacityf) }; ccColor4B E = new ccColor4B { r = m_endColor.r, g = m_endColor.g, b = m_endColor.b, a = (byte)(m_cEndOpacity * opacityf) }; // (-1, -1) m_pSquareColors[0].r = (byte)(E.r + (S.r - E.r) * ((c + u.X + u.Y) / (2.0f * c))); m_pSquareColors[0].g = (byte)(E.g + (S.g - E.g) * ((c + u.X + u.Y) / (2.0f * c))); m_pSquareColors[0].b = (byte)(E.b + (S.b - E.b) * ((c + u.X + u.Y) / (2.0f * c))); m_pSquareColors[0].a = (byte)(E.a + (S.a - E.a) * ((c + u.X + u.Y) / (2.0f * c))); // (1, -1) m_pSquareColors[1].r = (byte)(E.r + (S.r - E.r) * ((c - u.X + u.Y) / (2.0f * c))); m_pSquareColors[1].g = (byte)(E.g + (S.g - E.g) * ((c - u.X + u.Y) / (2.0f * c))); m_pSquareColors[1].b = (byte)(E.b + (S.b - E.b) * ((c - u.X + u.Y) / (2.0f * c))); m_pSquareColors[1].a = (byte)(E.a + (S.a - E.a) * ((c - u.X + u.Y) / (2.0f * c))); // (-1, 1) m_pSquareColors[2].r = (byte)(E.r + (S.r - E.r) * ((c + u.X - u.Y) / (2.0f * c))); m_pSquareColors[2].g = (byte)(E.g + (S.g - E.g) * ((c + u.X - u.Y) / (2.0f * c))); m_pSquareColors[2].b = (byte)(E.b + (S.b - E.b) * ((c + u.X - u.Y) / (2.0f * c))); m_pSquareColors[2].a = (byte)(E.a + (S.a - E.a) * ((c + u.X - u.Y) / (2.0f * c))); // (1, 1) m_pSquareColors[3].r = (byte)(E.r + (S.r - E.r) * ((c - u.X - u.Y) / (2.0f * c))); m_pSquareColors[3].g = (byte)(E.g + (S.g - E.g) * ((c - u.X - u.Y) / (2.0f * c))); m_pSquareColors[3].b = (byte)(E.b + (S.b - E.b) * ((c - u.X - u.Y) / (2.0f * c))); m_pSquareColors[3].a = (byte)(E.a + (S.a - E.a) * ((c - u.X - u.Y) / (2.0f * c))); vertices[0].Color = new Color(m_pSquareColors[0].r, m_pSquareColors[0].g, m_pSquareColors[0].b, m_pSquareColors[0].a); vertices[1].Color = new Color(m_pSquareColors[1].r, m_pSquareColors[1].g, m_pSquareColors[1].b, m_pSquareColors[1].a); vertices[2].Color = new Color(m_pSquareColors[2].r, m_pSquareColors[2].g, m_pSquareColors[2].b, m_pSquareColors[2].a); vertices[3].Color = new Color(m_pSquareColors[3].r, m_pSquareColors[3].g, m_pSquareColors[3].b, m_pSquareColors[3].a); }
public static float ccpDistance(CCPoint v1, CCPoint v2) { return(CCPointExtension.ccpLength(CCPointExtension.ccpSub(v1, v2))); }
public static CCPoint ccpNormalize(CCPoint v) { return(CCPointExtension.ccpMult(v, 1f / CCPointExtension.ccpLength(v))); }