本文整理汇总了C++中BoundBox类的典型用法代码示例。如果您正苦于以下问题:C++ BoundBox类的具体用法?C++ BoundBox怎么用?C++ BoundBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BoundBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LeafNode
BVHNode *BVHBuild::create_object_leaf_nodes(const BVHReference *ref, int start, int num)
{
if(num == 0) {
BoundBox bounds = BoundBox::empty;
return new LeafNode(bounds, 0, 0, 0);
}
else if(num == 1) {
if(start == prim_index.size()) {
assert(params.use_spatial_split);
prim_segment.push_back(ref->prim_segment());
prim_index.push_back(ref->prim_index());
prim_object.push_back(ref->prim_object());
}
else {
prim_segment[start] = ref->prim_segment();
prim_index[start] = ref->prim_index();
prim_object[start] = ref->prim_object();
}
uint visibility = objects[ref->prim_object()]->visibility;
return new LeafNode(ref->bounds(), visibility, start, start+1);
}
else {
int mid = num/2;
BVHNode *leaf0 = create_object_leaf_nodes(ref, start, mid);
BVHNode *leaf1 = create_object_leaf_nodes(ref+mid, start+mid, num-mid);
BoundBox bounds = BoundBox::empty;
bounds.grow(leaf0->m_bounds);
bounds.grow(leaf1->m_bounds);
return new InnerNode(bounds, leaf0, leaf1);
}
}
示例2: XAxis
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pRender -
//-----------------------------------------------------------------------------
void CGizmo::Render(CRender3D *pRender)
{
Vector XAxis( m_Position[0] + m_fAxisLength, m_Position[1], m_Position[2] );
Vector YAxis( m_Position[0], m_Position[1] + m_fAxisLength, m_Position[2] );
Vector ZAxis( m_Position[0], m_Position[1], m_Position[2] + m_fAxisLength );
static BoundBox UniformScaleBox;
Vector Mins;
Vector Maxs;
Mins[0] = m_Position[0] - m_fAxisLength * 0.1;
Mins[1] = m_Position[1] - m_fAxisLength * 0.1;
Mins[2] = m_Position[2] - m_fAxisLength * 0.1;
Maxs[0] = m_Position[0] + m_fAxisLength * 0.1;
Maxs[1] = m_Position[1] + m_fAxisLength * 0.1;
Maxs[2] = m_Position[2] + m_fAxisLength * 0.1;
UniformScaleBox.ResetBounds();
UniformScaleBox.UpdateBounds(Mins, Maxs);
pRender->BeginRenderHitTarget(this, GIZMO_HANDLE_UNIFORM_SCALE);
//pRender->RenderBox(Mins, Maxs, BoxType_Solid, 200, 200, 200);
pRender->EndRenderHitTarget();
pRender->SetRenderMode( RENDER_MODE_TEXTURED );
DrawGizmoAxis(pRender, m_Position, XAxis, 255, 0, 0, GIZMO_AXIS_X);
DrawGizmoAxis(pRender, m_Position, YAxis, 0, 255, 0, GIZMO_AXIS_Y);
DrawGizmoAxis(pRender, m_Position, ZAxis, 0, 0, 255, GIZMO_AXIS_Z);
pRender->SetRenderMode( RENDER_MODE_DEFAULT );
}
示例3: split_triangle_primitive
void BVHSpatialSplit::split_triangle_primitive(const Mesh *mesh,
const Transform *tfm,
int prim_index,
int dim,
float pos,
BoundBox& left_bounds,
BoundBox& right_bounds)
{
const int *inds = mesh->triangles[prim_index].v;
const float3 *verts = &mesh->verts[0];
float3 v1 = tfm ? transform_point(tfm, verts[inds[2]]) : verts[inds[2]];
for(int i = 0; i < 3; i++) {
float3 v0 = v1;
int vindex = inds[i];
v1 = tfm ? transform_point(tfm, verts[vindex]) : verts[vindex];
float v0p = v0[dim];
float v1p = v1[dim];
/* insert vertex to the boxes it belongs to. */
if(v0p <= pos)
left_bounds.grow(v0);
if(v0p >= pos)
right_bounds.grow(v0);
/* edge intersects the plane => insert intersection to both boxes. */
if((v0p < pos && v1p > pos) || (v0p > pos && v1p < pos)) {
float3 t = lerp(v0, v1, clamp((pos - v0p) / (v1p - v0p), 0.0f, 1.0f));
left_bounds.grow(t);
right_bounds.grow(t);
}
}
}
示例4: bound
BoundBox BicubicPatch::bound()
{
BoundBox bbox = BoundBox::empty;
for (int i = 0; i < 16; i++)
bbox.grow(hull[i]);
return bbox;
}
示例5: bound
BoundBox LinearTrianglePatch::bound()
{
BoundBox bbox;
for(int i = 0; i < 3; i++)
bbox.grow(hull[i]);
return bbox;
}
示例6: create_leaf_node
BVHNode* BVHBuild::create_leaf_node(const BVHRange& range)
{
vector<int>& p_segment = prim_segment;
vector<int>& p_index = prim_index;
vector<int>& p_object = prim_object;
BoundBox bounds = BoundBox::empty;
int num = 0, ob_num = 0;
uint visibility = 0;
for(int i = 0; i < range.size(); i++) {
BVHReference& ref = references[range.start() + i];
if(ref.prim_index() != -1) {
if(range.start() + num == prim_index.size()) {
assert(params.use_spatial_split);
p_segment.push_back(ref.prim_segment());
p_index.push_back(ref.prim_index());
p_object.push_back(ref.prim_object());
}
else {
p_segment[range.start() + num] = ref.prim_segment();
p_index[range.start() + num] = ref.prim_index();
p_object[range.start() + num] = ref.prim_object();
}
bounds.grow(ref.bounds());
visibility |= objects[ref.prim_object()]->visibility;
num++;
}
else {
if(ob_num < i)
references[range.start() + ob_num] = ref;
ob_num++;
}
}
BVHNode *leaf = NULL;
if(num > 0) {
leaf = new LeafNode(bounds, visibility, range.start(), range.start() + num);
if(num == range.size())
return leaf;
}
/* while there may be multiple triangles in a leaf, for object primitives
* we want there to be the only one, so we keep splitting */
const BVHReference *ref = (ob_num)? &references[range.start()]: NULL;
BVHNode *oleaf = create_object_leaf_nodes(ref, range.start() + num, ob_num);
if(leaf)
return new InnerNode(range.bounds(), leaf, oleaf);
else
return oleaf;
}
示例7: foreach
void BVHBuild::add_references(BVHRange& root)
{
/* reserve space for references */
size_t num_alloc_references = 0;
foreach(Object *ob, objects) {
if(params.top_level) {
if(!ob->mesh->is_instanced()) {
num_alloc_references += ob->mesh->triangles.size();
num_alloc_references += count_curve_segments(ob->mesh);
}
else
num_alloc_references++;
}
else {
num_alloc_references += ob->mesh->triangles.size();
num_alloc_references += count_curve_segments(ob->mesh);
}
}
references.reserve(num_alloc_references);
/* add references from objects */
BoundBox bounds = BoundBox::empty, center = BoundBox::empty;
int i = 0;
foreach(Object *ob, objects) {
if(params.top_level) {
if(!ob->mesh->is_instanced())
add_reference_mesh(bounds, center, ob->mesh, i);
else
add_reference_object(bounds, center, ob, i);
}
else
add_reference_mesh(bounds, center, ob->mesh, i);
i++;
if(progress.get_cancel()) return;
}
/* happens mostly on empty meshes */
if(!bounds.valid())
bounds.grow(make_float3(0.0f, 0.0f, 0.0f));
root = BVHRange(bounds, center, 0, references.size());
}
示例8: viewplane_bounds_get
BoundBox Camera::viewplane_bounds_get()
{
/* TODO(sergey): This is all rather stupid, but is there a way to perform
* checks we need in a more clear and smart fasion?
*/
BoundBox bounds = BoundBox::empty;
if(type == CAMERA_PANORAMA) {
bounds.grow(make_float3(cameratoworld.w.x,
cameratoworld.w.y,
cameratoworld.w.z));
}
else {
bounds.grow(transform_raster_to_world(0.0f, 0.0f));
bounds.grow(transform_raster_to_world(0.0f, (float)height));
bounds.grow(transform_raster_to_world((float)width, (float)height));
bounds.grow(transform_raster_to_world((float)width, 0.0f));
if(type == CAMERA_PERSPECTIVE) {
/* Center point has the most distance in local Z axis,
* use it to construct bounding box/
*/
bounds.grow(transform_raster_to_world(0.5f*width, 0.5f*height));
}
}
return bounds;
}
示例9: boundBox
void FlightPointList::boundBox(BoundBox &bbox)
{
uint index;
for(index=0; index<size(); index++)
{
bbox.setMinMax(m_flightPointList[index]->pos());
}
}
示例10: assert
SPtr<ModelRecord> BoundBox_Loader::loadModel(WorldEntity *we, const std::string &model_id, varconf::Config &model_config) {
assert (we);
SPtr<ModelRecord> model_record = ModelLoader::loadModel(we, model_id, model_config);
BoundBox *model = new BoundBox();
WFMath::AxisBox<3> bbox = we->hasBBox() ? (we->getBBox()) : (WFMath::AxisBox<3>(WFMath::Point<3>(0.0f,0.0f,0.0f), WFMath::Point<3>(1.0f,1.0f,1.0f)));
std::string texture = we->type();
bool wrap = false; //default to false
// Check whether we specify texture wrapping
if (model_config.findItem(model_id, KEY_texture)) {
texture = (std::string)model_config.getItem(model_id, KEY_texture);
}
// Get texture name
if (model_config.findItem(model_id, KEY_wrap_texture)) {
wrap = (bool)model_config.getItem(model_id, KEY_wrap_texture);
}
// Initialise model
if (model->init(bbox, texture, wrap)) {
std::cerr<< "BoundBoxLoader: Error initialising model" << std::endl;
delete model;
return SPtr<ModelRecord>();
}
bool use_stencil = RenderSystem::getInstance().getState(RenderSystem::RENDER_STENCIL) && model_record->outline;
StaticObjectList &sol = model->getStaticObjects();
StaticObjectList::iterator I = sol.begin();
while (I != sol.end()) {
(*I)->setState(model_record->state);
(*I)->setSelectState(model_record->select_state);
(*I)->setUseStencil(use_stencil);
++I;
}
model_record->model = SPtr<Model>(model);
return model_record;
}
示例11: GetGlobalBox
//Determine the global assembly box
ErrorCode ParallelMergeMesh::GetGlobalBox(double *gbox)
{
ErrorCode rval;
/*Get Bounding Box*/
BoundBox box;
if(mySkinEnts[0].size() != 0){
rval = box.update(*myMB, mySkinEnts[0]);MB_CHK_ERR(rval);
}
//Invert the max
box.bMax *= -1;
/*Communicate to all processors*/
MPI_Allreduce(&box, gbox, 6, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
/*Assemble Global Bounding Box*/
//Flip the max back
for(int i=3; i<6; i++){
gbox[i] *= -1;
}
return MB_SUCCESS;
}
示例12: split_curve_primitive
void BVHSpatialSplit::split_curve_primitive(const Mesh *mesh,
const Transform *tfm,
int prim_index,
int segment_index,
int dim,
float pos,
BoundBox& left_bounds,
BoundBox& right_bounds)
{
/* curve split: NOTE - Currently ignores curve width and needs to be fixed.*/
const int k0 = mesh->curves[prim_index].first_key + segment_index;
const int k1 = k0 + 1;
const float4& key0 = mesh->curve_keys[k0];
const float4& key1 = mesh->curve_keys[k1];
float3 v0 = float4_to_float3(key0);
float3 v1 = float4_to_float3(key1);
if(tfm != NULL) {
v0 = transform_point(tfm, v0);
v1 = transform_point(tfm, v1);
}
float v0p = v0[dim];
float v1p = v1[dim];
/* insert vertex to the boxes it belongs to. */
if(v0p <= pos)
left_bounds.grow(v0);
if(v0p >= pos)
right_bounds.grow(v0);
if(v1p <= pos)
left_bounds.grow(v1);
if(v1p >= pos)
right_bounds.grow(v1);
/* edge intersects the plane => insert intersection to both boxes. */
if((v0p < pos && v1p > pos) || (v0p > pos && v1p < pos)) {
float3 t = lerp(v0, v1, clamp((pos - v0p) / (v1p - v0p), 0.0f, 1.0f));
left_bounds.grow(t);
right_bounds.grow(t);
}
}
示例13: PRIMITIVE_UNPACK_SEGMENT
void BVH4::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
{
if(leaf) {
int4 *data = &pack.leaf_nodes[idx];
int4 c = data[0];
/* Refit leaf node. */
for(int prim = c.x; prim < c.y; prim++) {
int pidx = pack.prim_index[prim];
int tob = pack.prim_object[prim];
Object *ob = objects[tob];
if(pidx == -1) {
/* Object instance. */
bbox.grow(ob->bounds);
}
else {
/* Primitives. */
const Mesh *mesh = ob->mesh;
if(pack.prim_type[prim] & PRIMITIVE_ALL_CURVE) {
/* Curves. */
int str_offset = (params.top_level)? mesh->curve_offset: 0;
Mesh::Curve curve = mesh->get_curve(pidx - str_offset);
int k = PRIMITIVE_UNPACK_SEGMENT(pack.prim_type[prim]);
curve.bounds_grow(k, &mesh->curve_keys[0], &mesh->curve_radius[0], bbox);
visibility |= PATH_RAY_CURVE;
/* Motion curves. */
if(mesh->use_motion_blur) {
Attribute *attr = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
if(attr) {
size_t mesh_size = mesh->curve_keys.size();
size_t steps = mesh->motion_steps - 1;
float3 *key_steps = attr->data_float3();
for(size_t i = 0; i < steps; i++)
curve.bounds_grow(k, key_steps + i*mesh_size, &mesh->curve_radius[0], bbox);
}
}
}
else {
/* Triangles. */
int tri_offset = (params.top_level)? mesh->tri_offset: 0;
Mesh::Triangle triangle = mesh->get_triangle(pidx - tri_offset);
const float3 *vpos = &mesh->verts[0];
triangle.bounds_grow(vpos, bbox);
/* Motion triangles. */
if(mesh->use_motion_blur) {
Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
if(attr) {
size_t mesh_size = mesh->verts.size();
size_t steps = mesh->motion_steps - 1;
float3 *vert_steps = attr->data_float3();
for(size_t i = 0; i < steps; i++)
triangle.bounds_grow(vert_steps + i*mesh_size, bbox);
}
}
}
}
visibility |= ob->visibility_for_tracing();
}
/* TODO(sergey): This is actually a copy of pack_leaf(),
* but this chunk of code only knows actual data and has
* no idea about BVHNode.
*
* Would be nice to de-duplicate code, but trying to make
* making code more general ends up in much nastier code
* in my opinion so far.
*
* Same applies to the inner nodes case below.
*/
float4 leaf_data[BVH_QNODE_LEAF_SIZE];
leaf_data[0].x = __int_as_float(c.x);
leaf_data[0].y = __int_as_float(c.y);
leaf_data[0].z = __uint_as_float(visibility);
leaf_data[0].w = __uint_as_float(c.w);
memcpy(&pack.leaf_nodes[idx], leaf_data, sizeof(float4)*BVH_QNODE_LEAF_SIZE);
}
else {
int4 *data = &pack.nodes[idx];
bool is_unaligned = (data[0].x & PATH_RAY_NODE_UNALIGNED) != 0;
int4 c;
if(is_unaligned) {
c = data[13];
}
else {
c = data[7];
}
/* Refit inner node, set bbox from children. */
BoundBox child_bbox[4] = {BoundBox::empty,
BoundBox::empty,
BoundBox::empty,
BoundBox::empty};
//.........这里部分代码省略.........
示例14: BoundBox
BoundBox(const BoundBox<THEIR_PRECISION>& src)
: minpoint(src.min_point())
, maxpoint(src.max_point())
{ }
示例15:
/**
* These add the given point to this bbox - they
* offset each corner by this point. Usful for calculating
* the location of a box in a higher scope, or for moving
* it around as part of a calculation
*
* Naturally, the {+,-} don't modify and the {+,-}= do.
*/
BoundBox operator+ (const point_type& rhs) const {
BoundBox result = *this;
result.offset(rhs);
return result;
}