示例#1
0
// gets called at every program start and when a new file is opened in the viewer
void AbstractNavigation::sceneChanged(Group * scene)
{
    AxisAlignedBoundingBox bb = scene->boundingBox();

    m_BBRadius = bb.radius();

    m_frontView = glm::lookAt(bb.center() + glm::vec3(0.f, 0.f, bb.radius()*2.5), bb.center(), glm::vec3(0.f, 1.f, 0.f));
    setFromMatrix(topRightView());
    updateCamera();
}
示例#2
0
void LightSourcePass::sceneChanged(Group * scene)
{
    if(m_scene)
        m_lightcam->remove(m_scene);
    m_lightcam->append(scene);

    AxisAlignedBoundingBox bb = scene->boundingBox();
    m_lightcam->setView(glm::lookAt(glm::vec3(4.0f, 5.5f, 6.0f) + bb.center(),
                                    bb.center(), glm::vec3(0.0f,1.0f,0.0f)));
    m_scene = scene;
}
示例#3
0
	IntersectionTest::Result IntersectionTest::plane_aabb(const Vec4f &plane, const AxisAlignedBoundingBox &aabb)
	{
		Vec3f center = aabb.center();
		Vec3f extents = aabb.extents();
		float e = extents.x * std::abs(plane.x) + extents.y * std::abs(plane.y) + extents.z * std::abs(plane.z);
		float s = center.x * plane.x + center.y * plane.y + center.z * plane.z + plane.w;
		if (s - e > 0)
			return inside;
		else if (s + e < 0)
			return outside;
		else
			return intersecting;
	}
示例#4
0
	IntersectionTest::OverlapResult IntersectionTest::ray_aabb(const Vec3f &ray_start, const Vec3f &ray_end, const AxisAlignedBoundingBox &aabb)
	{
		Vec3f c = (ray_start + ray_end) * 0.5f;
		Vec3f w = ray_end - c;
		Vec3f h = aabb.extents();

		c -= aabb.center();

		Vec3f v(std::abs(w.x), std::abs(w.y), std::abs(w.z));

		if (std::abs(c.x) > v.x + h.x || std::abs(c.y) > v.y + h.y || std::abs(c.z) > v.z + h.z)
			return disjoint;

		if (std::abs(c.y * w.z - c.z * w.y) > h.y * v.z + h.z * v.y ||
			std::abs(c.x * w.z - c.z * w.x) > h.x * v.z + h.z * v.x ||
			std::abs(c.x * w.y - c.y * w.x) > h.x * v.y + h.y * v.x)
			return disjoint;

		return overlap;
	}
 void TextEngineRenderer::DrawAxisAlignedBoundingBox(AxisAlignedBoundingBox aabb) {
   DrawRectangle(aabb.center(), aabb.extent());
 }