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


C++ BBox::center方法代码示例

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


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

示例1: read_patches

void read_patches(const char* filename, vector<BezierPatch>& patches, bool flip_surface)
{
    vector<int> indices;
    vector<vec3> points;
    FILE* file = fopen(filename, "r");    

    if (!file) {
        cerr << "Can't open " << filename << endl;
        exit(1);
    }

    int np, nv;
    int r = fscanf(file, "%i\n", &np);
    indices.resize(np * 16);
    for (int i = 0; i < np; ++i) {
        int *p = &(indices[i*16]);
        if (!flip_surface) {
            r = fscanf(file, "%i, %i, %i, %i,",  p+ 0, p+ 1, p+ 2, p+ 3);
            r = fscanf(file, "%i, %i, %i, %i,",  p+ 4, p+ 5, p+ 6, p+ 7);
            r = fscanf(file, "%i, %i, %i, %i,",  p+ 8, p+ 9, p+10, p+11);
            r = fscanf(file, "%i, %i, %i, %i\n", p+12, p+13, p+14, p+15);
        } else {
            r = fscanf(file, "%i, %i, %i, %i,",  p+ 0, p+ 4, p+ 8, p+12);
            r = fscanf(file, "%i, %i, %i, %i,",  p+ 1, p+ 5, p+ 9, p+13);
            r = fscanf(file, "%i, %i, %i, %i,",  p+ 2, p+ 6, p+10, p+14);
            r = fscanf(file, "%i, %i, %i, %i\n", p+ 3, p+ 7, p+11, p+15);
        }
    }

    BBox bbox;

    r= fscanf(file, "%i\n", &nv);
    points.resize(nv);
    for (int i = 0; i < nv; ++i) {
        float x,y,z;
        r= fscanf(file, "%f, %f, %f\n", &x, &y, &z);
        points[i] = vec3(x,y,z);
        bbox.add_point(vec3(x,y,z));
    }

    vec3 center = bbox.center();

    for (int i = 0; i < nv; ++i) {
        points[i] -= center;
    }

    patches.resize(np);

    int k = 0;
    for (int i = 0; i < np; ++i) {
        vec3* ps = patches[i].P[0];

        for (int j = 0; j < 16; ++j) {
            ps[j] = points[indices[k]-1];
            ++k;
        }
    }
}
开发者ID:yzhwang,项目名称:micropolis,代码行数:58,代码来源:Patch.cpp

示例2: renderCentered

  void GPUFont::renderCentered(const wchar_t * str,
			       const Nimble::Matrix3 & transform)
  {
    BBox bb;

    cpuFont()->bbox(str, bb);
    Nimble::Vector2 center = bb.center();

    render(str, transform * Nimble::Matrix3::translate2D(-center.x, center.y));
  }
开发者ID:enuuros,项目名称:multitude,代码行数:10,代码来源:GPUFont.cpp

示例3: draw_statbar_with_text

static void draw_statbar_with_text(GameState* gs, const BBox& bbox, int statmin,
		int statmax, Colour statcol, Colour backcol,
		Colour textcol = Colour(0, 0, 0)) {
	draw_statbar(bbox, float(statmin) / statmax, statcol, backcol);

	using namespace ldraw;
	const Font& font = gs->font();
	font.drawf(DrawOptions(CENTER, textcol), bbox.center(), "%d/%d", statmin,
			statmax);
}
开发者ID:yi-juchung,项目名称:lanarts,代码行数:10,代码来源:Sidebar.cpp

示例4: moveDeltaForBounds

 Vec3f Grid::moveDeltaForBounds(const Model::Face& face, const BBox& bounds, const BBox& worldBounds, const Ray& ray, const Vec3f& position) const {
     const Plane dragPlane = Plane::alignedOrthogonalDragPlane(position, face.boundary().normal);
     
     const Vec3f halfSize = bounds.size() * 0.5f;
     float offsetLength = halfSize.dot(dragPlane.normal);
     if (offsetLength < 0.0f)
         offsetLength *= -1.0f;
     const Vec3f offset = dragPlane.normal * offsetLength;
     
     const float dist = dragPlane.intersectWithRay(ray);
     const Vec3f newPos = ray.pointAtDistance(dist);
     Vec3f delta = moveDeltaForPoint(bounds.center(), worldBounds, newPos - (bounds.center() - offset));
     
     Axis::Type a = dragPlane.normal.firstComponent();
     if (dragPlane.normal[a] > 0.0f) delta[a] = position[a] - bounds.min[a];
     else delta[a] = position[a] - bounds.max[a];
     
     return delta;
 }
开发者ID:fluffyfreak,项目名称:TrenchBroom,代码行数:19,代码来源:Grid.cpp

示例5: referencePoint

 Vec3f Grid::referencePoint(const BBox& bounds) {
     return snap(bounds.center());
 }
开发者ID:fluffyfreak,项目名称:TrenchBroom,代码行数:3,代码来源:Grid.cpp


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