当前位置: 首页>>代码示例>>C++>>正文


C++ FTPoint::Normalise方法代码示例

本文整理汇总了C++中FTPoint::Normalise方法的典型用法代码示例。如果您正苦于以下问题:C++ FTPoint::Normalise方法的具体用法?C++ FTPoint::Normalise怎么用?C++ FTPoint::Normalise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FTPoint的用法示例。


在下文中一共展示了FTPoint::Normalise方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RenderSide

void FTExtrudeGlyphImpl::RenderSide()
{
    int contourFlag = vectoriser->ContourFlag();
    //LOG_INFO("RenderSide %d", contourFlag);
    GLfloat colors[4];
    for(size_t c = 0; c < vectoriser->ContourCount(); ++c)
    {
        const FTContour* contour = vectoriser->Contour(c);
        size_t n = contour->PointCount();

        if(n < 2)
        {
            continue;
        }

        glGetFloatv(GL_CURRENT_COLOR, colors);
        ftglBegin(GL_QUADS);
        ftglColor4f(colors[0]/2, colors[1]/2, colors[2]/2, colors[3]/2);
            for(size_t j = 0; j < n; j++ )
            {
                size_t cur = j % n;
                size_t next = (j + 1) % n;
                
                FTPoint frontPt = contour->FrontPoint(cur);
                FTPoint frontPt1 = contour->FrontPoint(next);
                FTPoint backPt = contour->BackPoint(cur);
                FTPoint backPt1 = contour->BackPoint(next);

                FTPoint normal = FTPoint(0.f, 0.f, 1.f) ^ (frontPt - frontPt1);
                if(normal != FTPoint(0.0f, 0.0f, 0.0f))
                {
                    const FTGL_DOUBLE* pD = static_cast<const FTGL_DOUBLE*>(normal.Normalise());
                    glNormal3f( pD[0], pD[1], pD[2]);
                }

                ftglTexCoord2f(frontPt.Xf() / hscale, frontPt.Yf() / vscale);

                if(contourFlag & ft_outline_reverse_fill)
                {
                    ftglVertex3f(backPt.Xf() / 64.0f, backPt.Yf() / 64.0f, 0.0f);
                    ftglVertex3f(frontPt.Xf() / 64.0f, frontPt.Yf() / 64.0f, -depth);
                    ftglVertex3f(frontPt1.Xf() / 64.0f, frontPt1.Yf() / 64.0f, -depth);
                    ftglVertex3f(backPt1.Xf() / 64.0f, backPt1.Yf() / 64.0f, 0.0f);
                }
                else
                {
                    ftglVertex3f(backPt.Xf() / 64.0f, backPt.Yf() / 64.0f, -depth);
                    ftglVertex3f(frontPt.Xf() / 64.0f, frontPt.Yf() / 64.0f, 0.0f);
                    ftglVertex3f(frontPt1.Xf() / 64.0f, frontPt1.Yf() / 64.0f, 0.f);
                    ftglVertex3f(backPt1.Xf() / 64.0f, backPt1.Yf() / 64.0f, -depth);
                }
            }
        ftglEnd();
    }
}
开发者ID:JackFan-Z,项目名称:ftgles,代码行数:55,代码来源:FTExtrudeGlyph.cpp

示例2: RenderSide

void FTExtrudeGlyphImpl::RenderSide()
{
    int contourFlag = vectoriser->ContourFlag();

    for(size_t c = 0; c < vectoriser->ContourCount(); ++c)
    {
        const FTContour* contour = vectoriser->Contour(c);
        size_t n = contour->PointCount();

        if(n < 2)
        {
            continue;
        }

        glBegin(GL_QUAD_STRIP);
            for(size_t j = 0; j <= n; ++j)
            {
                size_t cur = (j == n) ? 0 : j;
                size_t next = (cur == n - 1) ? 0 : cur + 1;

                const FTPoint& frontPt = contour->FrontPoint(cur);
                const FTPoint& nextPt = contour->FrontPoint(next);
                const FTPoint& backPt = contour->BackPoint(cur);

                FTPoint normal = FTPoint(0.f, 0.f, 1.f) ^ (frontPt - nextPt);
                if(normal != FTPoint(0.0f, 0.0f, 0.0f))
                {
                    glNormal3dv(static_cast<const FTGL_DOUBLE*>(normal.Normalise()));
                }

                glTexCoord2f(frontPt.Xf() / hscale, frontPt.Yf() / vscale);

                if(contourFlag & ft_outline_reverse_fill)
                {
                    glVertex3f(backPt.Xf() / 64.0f, backPt.Yf() / 64.0f, 0.0f);
                    glVertex3f(frontPt.Xf() / 64.0f, frontPt.Yf() / 64.0f, -depth);
                }
                else
                {
                    glVertex3f(backPt.Xf() / 64.0f, backPt.Yf() / 64.0f, -depth);
                    glVertex3f(frontPt.Xf() / 64.0f, frontPt.Yf() / 64.0f, 0.0f);
                }
            }
        glEnd();
    }
}
开发者ID:ethicalfive,项目名称:critterding,代码行数:46,代码来源:FTExtrudeGlyph.cpp


注:本文中的FTPoint::Normalise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。