Merge pull request #1984 from billy1380/master

CCLens3d can be concave
This commit is contained in:
minggo 2013-02-21 18:08:47 -08:00
commit 33b857c3f7
2 changed files with 7 additions and 2 deletions

View File

@ -367,6 +367,7 @@ bool CCLens3D::initWithDuration(float duration, const CCSize& gridSize, const CC
setPosition(position);
m_fRadius = radius;
m_fLensEffect = 0.7f;
m_bConcave = false;
m_bDirty = true;
return true;
@ -438,7 +439,7 @@ void CCLens3D::update(float time)
{
vect = ccpNormalize(vect);
CCPoint new_vect = ccpMult(vect, new_r);
v.z += ccpLength(new_vect) * m_fLensEffect;
v.z += (m_bConcave ? -1.0f : 1.0f) * ccpLength(new_vect) * m_fLensEffect;
}
}

View File

@ -96,7 +96,9 @@ public:
inline float getLensEffect(void) { return m_fLensEffect; }
/** Set lens center position */
inline void setLensEffect(float fLensEffect) { m_fLensEffect = fLensEffect; }
/** Set whether lens is concave */
inline void setConcave(bool bConcave) { m_bConcave = bConcave; }
inline const CCPoint& getPosition(void) { return m_position; }
void setPosition(const CCPoint& position);
@ -114,6 +116,8 @@ protected:
float m_fRadius;
/** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */
float m_fLensEffect;
/** lens is concave. (true = concave, false = convex) default is convex i.e. false */
bool m_bConcave;
bool m_bDirty;
};