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


C++ aabb类代码示例

本文整理汇总了C++中aabb的典型用法代码示例。如果您正苦于以下问题:C++ aabb类的具体用法?C++ aabb怎么用?C++ aabb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: IntersectBox

bool Sphere::IntersectBox( aabb& a_Box )
{
	float dmin = 0;
	vector3 v1 = a_Box.GetPos(), v2 = a_Box.GetPos() + a_Box.GetSize();
	if (m_Centre.x < v1.x) 
	{
		dmin = dmin + (m_Centre.x - v1.x) * (m_Centre.x - v1.x);
	}
	else if (m_Centre.x > v2.x)
	{
		dmin = dmin + (m_Centre.x - v2.x) * (m_Centre.x - v2.x);
	}
	if (m_Centre.y < v1.y)
	{
		dmin = dmin + (m_Centre.y - v1.y) * (m_Centre.y - v1.y);
	}
	else if (m_Centre.y > v2.y)
	{
		dmin = dmin + (m_Centre.y - v2.y) * (m_Centre.y - v2.y);
	}
	if (m_Centre.z < v1.z)
	{
		dmin = dmin + (m_Centre.z - v1.z) * (m_Centre.z - v1.z);
	}
	else if (m_Centre.z > v2.z)
	{
		dmin = dmin + (m_Centre.z - v2.z) * (m_Centre.z - v2.z);
	}
	return (dmin <= m_SqRadius);
}
开发者ID:markrosoft,项目名称:se-195-project-ray-tracer,代码行数:30,代码来源:scene.cpp

示例2: caculateCost

float KDTree::caculateCost(SplitNode *split,aabb &frontBox, aabb &backBox)
{
	float frontArea = 2 * (frontBox.w()*frontBox.d() + frontBox.w()*frontBox.h() + frontBox.d()*frontBox.h());
	float backArea = 2 * (backBox.w()*backBox.d() + backBox.w()*backBox.h() +backBox.d()*backBox.h());

	return frontArea * split->nlcount+ backArea * split->nrcount;
}
开发者ID:pythonxy,项目名称:Computer-Graphics,代码行数:7,代码来源:kdtree.cpp

示例3: view_all

void camera::view_all(aabb const& box, vec3 const& up)
{
    float diagonal = length(box.size());
    float r = diagonal * 0.5f;

    vec3 eye = box.center() + vec3(0, 0, r + r / std::atan(fovy_));

    look_at(eye, box.center(), up);
}
开发者ID:cstollw,项目名称:visionaray,代码行数:9,代码来源:camera.cpp

示例4: get_sah_cost

/* get cost of sah(surface area heuristic) method for certain plane */
double get_sah_cost(double plane, aabb &voxel, int num_left, int num_right) 
{
	aabb voxel_left, voxel_right;
	voxel.split_aabb(dim, plane, voxel_left, voxel_right);
	double sa_left = voxel_left.get_surface_area();
	double sa_right = voxel_right.get_surface_area();
	double sa_union = voxel.get_surface_area();

	return get_cost(sa_left / sa_union, sa_right / sa_union, num_left, num_right);
}
开发者ID:chongkong,项目名称:raytrace,代码行数:11,代码来源:kdtree.cpp

示例5: IntersectBox

bool PlanePrim::IntersectBox( aabb& a_Box )
{
	vector3 v[2];
	v[0] = a_Box.GetPos(), v[1] = a_Box.GetPos() + a_Box.GetSize();
	int side1, side2 = 0, i = 0;
	for ( side1 = 0, side2 = 0, i = 0; i < 8; i++ )
	{
		vector3 p( v[i & 1].x, v[(i >> 1) & 1].y, v[(i >> 2) & 1].z );
		if ((DOT( p, m_Plane.N ) + m_Plane.D) < 0) side1++; else side2++;
	}
	if ((side1 == 0) || (side2 == 0)) return false; else return true;
}
开发者ID:getack,项目名称:COS785_Assignments,代码行数:12,代码来源:scene.cpp

示例6: vec3

bool sphere::bounding_box(float t0, float t1, aabb& _aabb)
{
    vec3 _min = center - vec3(radius, radius, radius);
    vec3 _max = center + vec3(radius, radius, radius);

    _aabb.init(_min, _max);

    return true;
}
开发者ID:nakdai,项目名称:samples,代码行数:9,代码来源:sphere.cpp

示例7:

aap::aap(const aabb &total)
{
	VEC3F center = total.center();
	char xyz = 2;

	if (total.width() >= total.height() && total.width() >= total.depth()) {
		xyz = 0;
	} else
	if (total.height() >= total.width() && total.height() >= total.depth()) {
		xyz = 1;
	}

	this->xyz = xyz;
	this->p = center[xyz];
}
开发者ID:yunteng,项目名称:CubicaPlus,代码行数:15,代码来源:aap.cpp

示例8: getLocalBounds

void Trigger::getLocalBounds( aabb& out ) const
{
	if ( triggerModel )
	{
		triggerModel->getBounds( out );
	}
	else
	{
		out.fromHalfSize( 4.f );
	}
}
开发者ID:OnlyTheGhosts,项目名称:OWEngine,代码行数:11,代码来源:Trigger.cpp

示例9: IsAABBInsideSphere

bool IsAABBInsideSphere( const aabb& bb, const vec3_c& sphereCenter, float sphereRadius )
{
	float radSq = Square( sphereRadius );
	for ( u32 i = 0; i < 8; i++ )
	{
		vec3_c p = bb.getPoint( i );
		if ( p.distSQ( sphereCenter ) > radSq )
			return false;
	}
	return true;
}
开发者ID:OnlyTheGhosts,项目名称:OWEngine,代码行数:11,代码来源:rf_shadowVolume.cpp

示例10: line_aabb

const collision line_aabb(const line &a, const aabb &b)
{
	collision r;
	r.result = false;
	
	for (int i = 0; i < 4; ++i)
	{
		r.result = r.result || line_line(a, b.edge(i)).result;
	}

	return r;
}
开发者ID:Zac-King,项目名称:GameAI,代码行数:12,代码来源:shapes.cpp

示例11: GetBoxVertex

void KDTree::GetBoxVertex(aabb box, Point3 *Pos)
{
	Point3 start;
	Point3 end;
	for(int i = 0; i< 3; i++)
	{
		start.cell[i] = box.GetPos().cell[i];
		end.cell[i] = box.GetPos().cell[i] + box.GetSize().cell[i];
	}

	Pos[0].set(start);
	Pos[6].set(end);

	Pos[1].set(Point3(end.x,start.y,start.z));
	Pos[2].set(Point3(end.x,start.y,end.z));
	Pos[3].set(Point3(start.x,start.y,end.z));

	Pos[4].set(Point3(start.x,end.y,start.z));
	Pos[5].set(Point3(end.x,end.y,start.z));
	Pos[7].set(Point3(start.x,end.y,end.z));
}
开发者ID:pythonxy,项目名称:Computer-Graphics,代码行数:21,代码来源:kdtree.cpp

示例12: aabb_aabb

const collision aabb_aabb(const aabb &a, const aabb &b)
{
	collision r;
	debug("AABB AABB : only result, no normal data", false);

	r.result = 
	!(a.max().x < a.min().x ||
	b.max().x < a.min().x ||
	a.max().y < a.min().y ||
	b.max().y < a.min().y);

	return r;
}
开发者ID:Zac-King,项目名称:GameAI,代码行数:13,代码来源:shapes.cpp

示例13: Optimize

void KDTree::Optimize(KDTreeNode* R,Side s,aabb AABB)
{
	if(!R) return;
	while(R->Type != LEFT)
	{
		if(s-2*R->m_Axis>=0&&s-2*R->m_Axis<=1)
		{
			if(s%2==0)
				R = R->m_rchild;
			else 
				R = R->m_lchild;

		}

		else if(R->m_Split >=AABB.GetPos().cell[R->m_Axis]+AABB.GetSize().cell[R->m_Axis])
			R = R->m_lchild;

		else if(R->m_Split <= AABB.GetPos().cell[R->m_Axis])
			R = R->m_rchild;

		else
			break;
	}
}
开发者ID:pythonxy,项目名称:Computer-Graphics,代码行数:24,代码来源:kdtree.cpp

示例14: get_best_plane

/* build kd-tree */
kdtree::kdtree(aabb &voxel, vector<primitive*> &pris, int depth, kdtree* parent)
{
	parent_kdtree = parent;
	left_kdtree = right_kdtree = NULL;
	bbox = voxel;

	/* end criteria; make this leaf */
	if (depth > maximum_depth || pris.size() < 1)
	{
		primitives = pris;
	}

	/* general case: determine whether and how to devide current voxel */
	else
	{
		double cost_asleaf = cost_i * pris.size();	
		cost_min = 1E100;							

		for (dim = 0; dim < 3; dim++)
		{
			get_best_plane(pris, voxel);
		}

		/* internal node; divide further */
		if (cost_min < cost_asleaf)
		{
			vector<primitive*> left_pris, right_pris;
			classify_primitives(pris, best_plane, left_pris, right_pris);

			aabb left_voxel, right_voxel;
			voxel.split_aabb(best_dim, best_plane, left_voxel, right_voxel);

			left_kdtree = new kdtree(left_voxel, left_pris, depth + 1, this);
			right_kdtree = new kdtree(right_voxel, right_pris, depth + 1, this);
		}

		/* leaf; division end */
		else							
		{
			primitives = pris;
		}
	}
}
开发者ID:chongkong,项目名称:raytrace,代码行数:44,代码来源:kdtree.cpp

示例15: calcDepthRange

void calcDepthRange(mat4 const& pr, mat4 const& mv,
                    aabb const& bbox, float& minval, float& maxval)
{
    vec3 center = vec4( mv * vec4(bbox.center(), 1.0f) ).xyz();
    vec3 min    = vec4( mv * vec4(bbox.min, 1.0f) ).xyz();
    vec3 max    = vec4( mv * vec4(bbox.max, 1.0f) ).xyz();

    float radius = length(max - min) * 0.5f;

    // Depth buffer of ibrPlanes
    vec3 scal(center);
    scal = normalize(scal) * radius;
    min = center - scal;
    max = center + scal;

    vec4 min4 = pr * vec4(min, 1.f);
    vec4 max4 = pr * vec4(max, 1.f);

    min = min4.xyz() / min4.w;
    max = max4.xyz() / max4.w;

    minval = (min.z+1.f) * 0.5f;
    maxval = (max.z+1.f) * 0.5f;
}
开发者ID:aumuell,项目名称:deskvox,代码行数:24,代码来源:vvibr.cpp


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