本文整理汇总了C++中FPoint::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ FPoint::Length方法的具体用法?C++ FPoint::Length怎么用?C++ FPoint::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPoint
的用法示例。
在下文中一共展示了FPoint::Length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawAbsolute
void ReceiverEffect::DrawAbsolute()
{
float alpha = 1.f;
FPoint pos;
FPoint scale(1.0f, 1.f);
float angle = 0.0f;
if(_state == RE_JUMP)
{
float t = _time;
pos = GameSettings::ToScreenPos(_posStartOnField);
pos += math::lerp(FPoint(0.f, 0.f), JUMP_POS, math::ease(t, 0.9f, 0.1f));
scale = math::lerp(FPoint(1.f, 1.f), FPoint(_jumpScale, _jumpScale), t);
}
else if(_state == RE_STAY)
{
scale = FPoint(_jumpScale, _jumpScale);
pos = GameSettings::ToScreenPos(_posStartOnField + JUMP_POS);
}
else if(_state == RE_FLY)
{
float t = math::ease(math::clamp(0.f, 1.f, (_time-0.2f)/0.8f), 0.4f, 0.1f);
//float t = math::clamp(0.f, 1.f, (_time-0.2f)/0.8f);
pos = _spline.getGlobalFrame(t);
//pos.y += 150.f*math::clamp(0.f, 1.f, _time/0.5f)*math::clamp(0.f, 1.f, 1 - (_time - 0.4f)/0.6f);
scale = math::lerp(FPoint(_jumpScale, _jumpScale), _finishScaleCrystal, t);
scale.y *= 1 - 0.3f*sinf(math::clamp(0.f, 1.f, _time/0.4f)*math::PI*1.5f);
//angle = _angleSpline.getGlobalFrame(t);
//angle = math::lerp(0.f, angle, t/0.3f);
//angle = math::lerp(angle, 0.f, (t - 0.7f)/0.3f);
FPoint dir = _spline.getGlobalFrame(1.f) - pos;
if(dir.Length() > 0)
{
angle = (dir.GetAngle()*180.f/math::PI - 90.f)*math::clamp(0.f, 1.f, (_time- 0.f)/0.2f);
_lastAngle = angle;
}
alpha = math::clamp(0.f, 1.f, 1 - (t - 0.95f)/0.05f);
}
else if(_state == RE_HIDE)
{
pos = _spline.getGlobalFrame(1.f);
scale = _finishScaleCrystal;
scale.y *= 1.3f;
angle = _lastAngle;
alpha = 0.f; // math::clamp(0.f, 1.f, math::cos(math::clamp(0.f, 1.f, _time*4.f)*math::PI*0.5f));
}
//else if(_state == RE_WAIT)
//{
// pos = _spline.getGlobalFrame(1.f);
// alpha = math::clamp(0.f, 1.f, math::cos(_time*math::PI*0.5f));
// scale = _finishScaleCrystal;
// angle = _lastAngle;
//}
else if(_state == RE_FINISH)
{
pos = _spline.getGlobalFrame(1.f);
alpha = 0.f;
scale = _finishScaleCrystal;
scale.y *= 1.3f;
angle = _lastAngle;
}
if(_flyEffect)
{
_flyEffect->SetPos(pos);
}
_effCont.Draw();
Render::device.PushMatrix();
Render::device.MatrixTranslate(pos);
Render::device.MatrixTranslate(-CRYSTAL_POS_ANIM_ON_SQUARE + CRYSTAL_SCALE_CENTER);
Render::device.MatrixRotate(math::Vector3::UnitZ, angle);
Render::device.MatrixTranslate(CRYSTAL_POS_ANIM_ON_SQUARE - CRYSTAL_SCALE_CENTER);
Render::device.PushMatrix();
Render::device.MatrixScale(scale.x, scale.y, 1.0f);
_effContInner.Draw();
Render::BeginAlphaMul(alpha);
Render::device.MatrixTranslate(-CRYSTAL_POS_ANIM_ON_SQUARE);
_crystalAnim->Draw();
Render::EndAlphaMul();
Render::device.PopMatrix();
Render::device.PopMatrix();
}
示例2: DrawStripe
void Render::DrawStripe(const QVector<FPoint> &dots, GLTexture2D *texture, float y1, float y2, float x1, float stepX, int startI, int endI, VertexBuffer *vb)
{
assert(dots.size() >= 2);
VertexBuffer quad;
quad.Resize(4, 6);
quad.VertUV(2).y = quad.VertUV(3).y = y1;
quad.VertUV(1).y = quad.VertUV(0).y = y2;
FPoint f;
FPoint n;
float lenX = x1;
float h2 = fabs(y2 - y1) / 2 * texture->Height();
for (int i = startI; i < endI - 1; ++i)
{
f.x = dots[i].y - dots[i + 1].y;
f.y = dots[i + 1].x - dots[i].x;
f *= h2 / f.Length();
if ((i + 2) < static_cast<int>(dots.size()))
{
n.x = dots[i + 1].y - dots[i + 2].y;
n.y = dots[i + 2].x - dots[i + 1].x;
n *= h2 / n.Length();
}
else
{
n = f;
}
quad.VertUV(3).x = quad.VertUV(0).x = lenX;
lenX += stepX;
quad.VertUV(2).x = quad.VertUV(1).x = lenX;
quad.VertXY(0).x = dots[i].x + f.x;
quad.VertXY(0).y = dots[i].y + f.y;
quad.VertXY(1).x = dots[i + 1].x + n.x;
quad.VertXY(1).y = dots[i + 1].y + n.y;
quad.VertXY(2).x = dots[i + 1].x - n.x;
quad.VertXY(2).y = dots[i + 1].y - n.y;
quad.VertXY(3).x = dots[i].x - f.x;
quad.VertXY(3).y = dots[i].y - f.y;
if (vb == NULL)
{
quad.Draw();
}
else
{
if (_slowUnion)
{
vb->Union(quad);
}
else
{
vb->Add(quad);
}
}
}
}