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


C++ MyObject::addPoly方法代码示例

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


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

示例1: placeSidePolygon

void PicDisp::placeSidePolygon(MyObject& obj, int b, bool is1, int x, int y) const
{
    static Vec3 pnti1[4], pnti2[4], pntiA[4], pntiB[4], pntiC[4], pntiD[4];

    Vec3 shpp[4];
    TexAnchor ancs1[4], ancs2[4], baseancf[4], baseancs[4], ancsR1[4], ancsR2[4], ancsR3[4], ancsR4[4];
    int i;

    double bx, by, rbx, rby; // makers of texture coordinates.. fronts and side-patches

    rbx = bx = double(x)/5.0;
    rby = by = double(y)/5.0;

/*	const PicGroupDef *mygrp = m_pdef->mygrp();
    if (mygrp->drawtype == DRAW_TEXTURE_IMAGE)
    {
        rbx = 0.0; rby = 0.0; // side patches of this has their own coordinates
    }
*/

    baseancf[0] = TexAnchor(bx, by);
    baseancf[1] = TexAnchor(bx + 0.2, by);
    baseancf[2] = TexAnchor(bx + 0.2, by + 0.2);
    baseancf[3] = TexAnchor(bx, by + 0.2);
    
    baseancs[0] = TexAnchor(rbx, rby);
    baseancs[1] = TexAnchor(rbx + 0.2, rby);
    baseancs[2] = TexAnchor(rbx + 0.2, rby + 0.2);
    baseancs[3] = TexAnchor(rbx, rby + 0.2);

/*	if (mygrp->drawtype == DRAW_TEXTURE_IMAGE)
    { // rescale it since the texture is a big one
        double xfact = mygrp->sideTex->img.width(), yfact = mygrp->sideTex->img.height();
        for(i = 0; i < 4; ++i) // pntn == 4
        {
            baseancs[i].x += ((double)(mygrp->sideTexX) / xfact);
            baseancs[i].y += ((double)(mygrp->sideTexY) / yfact);
        }
    }
*/
    Texture *tex = nullptr; //m_pdef->tex;

    ancs1[0] = baseancf[0]; ancs2[0] = baseancf[3]; 
    ancs1[1] = baseancf[1]; ancs2[1] = baseancf[2]; 
    ancs1[2] = baseancf[2]; ancs2[2] = baseancf[1];
    ancs1[3] = baseancf[3]; ancs2[3] = baseancf[0];

    shpp[0] = Vec3(x, y, 0); 	 shpp[1] = Vec3(x+1, y, 0);
    shpp[2] = Vec3(x+1, y+1, 0); shpp[3] = Vec3(x, y+1, 0);
    PlaceInto(4, shpp, pnti1, pnti2, PLACE_NORM);

    if (is1)
    { // polys that make the flat surface.
        obj.addPoly(pnti1, ancs1, nullptr); //if its an out of place, it's textured
        obj.addPoly(pnti2, ancs2, tex);
    }

    /////////////////////// side patches //////////////////
    if (b < 0)
        return; // enough of this shananigan, we're not on the sides.

    if (false) //mygrp->drawtype == DRAW_TEXTURE_IMAGE)
    {
        for (i = 0; i < 4; ++i)
        {
            ancsR1[half_orient_data[3][i]] = baseancs[i];
            ancsR2[half_orient_data[3][i]] = baseancs[i];

            ancsR3[half_orient_data[0][i]] = baseancs[i];
            ancsR4[half_orient_data[1][i]] = baseancs[i];
        }
    }
    else
    {  // randomly turned...
        for(i = 0; i < 4; ++i)
        {
            ancsR3[i] = ancsR1[i] = baseancs[3-i];
            ancsR4[i] = ancsR2[i] = baseancs[i];
        }
    }

    shpp[0] = Vec3(x, y, 0);   shpp[1] = Vec3(x, y, 1);
    shpp[2] = Vec3(x+1, y, 1); shpp[3] = Vec3(x+1, y, 0);
    PlaceInto(4, shpp, pntiA, pntiB, PLACE_X);

    shpp[0] = Vec3(x, y, 0);   shpp[1] = Vec3(x, y+1, 0);
    shpp[2] = Vec3(x, y+1, 1); shpp[3] = Vec3(x, y, 1);
    PlaceInto(4, shpp, pntiC, pntiD, PLACE_Y);

    int polyf = 0;
    if (is1)
    {
        if (build[b].corner)
            polyf |= build[b].pold.in1 | build[b].pold.in0;
        else
            polyf |= build[b].pold.in1;
        
        int prevb = (b == 0)?15:(b - 1), nextb = b + 1;

        if (uncub(build[prevb].pnt.x, build[prevb].pnt.y) != is1)
//.........这里部分代码省略.........
开发者ID:shooshx,项目名称:happysolver,代码行数:101,代码来源:PicPainter.cpp


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