本文整理汇总了C++中BBox::add_point方法的典型用法代码示例。如果您正苦于以下问题:C++ BBox::add_point方法的具体用法?C++ BBox::add_point怎么用?C++ BBox::add_point使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBox
的用法示例。
在下文中一共展示了BBox::add_point方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calc_bbox
void calc_bbox(const BezierPatch& patch, BBox& box) {
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
box.add_point(patch.P[i][j]);
}
}
}
示例2: 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;
}
}
}
示例3: maximum
void Reyes::BoundNSplitGLCPU::bound_patch_range (const PatchRange& r, const BezierPatch& p,
const mat4& mv, const mat4& mvp,
BBox& box, float& vlen, float& hlen)
{
const size_t RES = 3;
//vec2 pp[RES][RES];
vec3 ps[RES][RES];
vec3 pos;
box.clear();
for (size_t iu = 0; iu < RES; ++iu) {
for (size_t iv = 0; iv < RES; ++iv) {
float v = r.range.min.x + (r.range.max.x - r.range.min.x) * iu * (1.0f / (RES-1));
float u = r.range.min.y + (r.range.max.y - r.range.min.y) * iv * (1.0f / (RES-1));
eval_patch(p, u, v, pos);
vec3 pt = vec3(mv * vec4(pos,1));
box.add_point(pt);
// pp[iu][iv] = project(mvp * vec4(pos,1));
ps[iu][iv] = pt;
}
}
vlen = 0;
hlen = 0;
for (size_t i = 0; i < RES; ++i) {
float h = 0, v = 0;
for (size_t j = 0; j < RES-1; ++j) {
// v += glm::distance(pp[j][i], pp[j+1][i]);
// h += glm::distance(pp[i][j], pp[i][j+1]);
v += glm::distance(ps[j][i], ps[j+1][i]);
h += glm::distance(ps[i][j], ps[i][j+1]);
}
vlen = maximum(v, vlen);
hlen = maximum(h, hlen);
}
}