コード例 #1
0
GLC_BoundingBox GLC_StructOccurence::boundingBox() const
{
	GLC_BoundingBox boundingBox;

	if (NULL != m_pWorldHandle)
	{
		if (has3DViewInstance())
		{
			Q_ASSERT(m_pWorldHandle->collection()->contains(id()));
			boundingBox= m_pWorldHandle->collection()->instanceHandle(id())->boundingBox();
		}
		else
		{
			if (hasChild())
			{
				QList<GLC_StructOccurence*> childrenList= children();
				const int size= childrenList.size();

				for (int i= 0; i < size; ++i)
				{
					boundingBox.combine(childrenList.at(i)->boundingBox());
				}
			}
		}
	}

	return boundingBox;
}
コード例 #2
0
ファイル: glc_3drep.cpp プロジェクト: c3d/tao-object-loader
// Return the 3DRep bounding Box
GLC_BoundingBox GLC_3DRep::boundingBox() const
{
	GLC_BoundingBox resultBox;
	const int size= m_pGeomList->size();
	for (int i= 0; i < size; ++i)
	{
		resultBox.combine(m_pGeomList->at(i)->boundingBox());
	}
	return resultBox;
}
コード例 #3
0
void GLC_Viewport::reframe(const GLC_BoundingBox& box)
{
	Q_ASSERT(!box.isEmpty());

	// Center view on the BoundingBox
	const GLC_Vector3d deltaVector(box.center() - m_pViewCam->target());
	m_pViewCam->translate(deltaVector);

	double cameraCover= box.boundingSphereRadius() * 2.0;

	// Compute Camera distance
	const double distance = cameraCover / m_ViewTangent;

	// Update Camera position
	m_pViewCam->setDistEyeTarget(distance);
}
コード例 #4
0
ファイル: glc_octreenode.cpp プロジェクト: 01iv3r/OpenPilot
void GLC_OctreeNode::addInstance(GLC_3DViewInstance* pInstance, int depth)
{
    m_Empty= false;
    const GLC_BoundingBox instanceBox= pInstance->boundingBox();
    // Check if the instance's bounding box intersect this node bounding box
    if (!instanceBox.isEmpty() && intersect(instanceBox))
    {
        if (0 == depth)
        {
            m_3DViewInstanceSet.insert(pInstance);
        }
        else
        {
            if (m_Children.isEmpty())
            {
                // Create children
                addChildren();
            }
            QVector<bool> childIntersect(8);
            bool allIntersect= true;
            bool currentIntersect= false;
            for (int i= 0; i < 8; ++i)
            {
                currentIntersect= m_Children.at(i)->intersect(instanceBox);
                allIntersect= allIntersect && currentIntersect;
                childIntersect[i]= currentIntersect;
            }
            if (allIntersect)
            {
                m_3DViewInstanceSet.insert(pInstance);
            }
            else
            {
                for (int i= 0; i < 8; ++i)
                {
                    if (childIntersect[i])
                    {
                        m_Children[i]->addInstance(pInstance, depth - 1);
                    }
                }
            }
        }

    }
}
コード例 #5
0
GLC_BoundingBox GLC_3DViewCollection::boundingBox(bool allObject)
{
	GLC_BoundingBox boundingBox;
	// Check if the bounding box have to be updated
	if (!m_3DViewInstanceHash.isEmpty())
	{
		ViewInstancesHash::iterator iEntry= m_3DViewInstanceHash.begin();
	    while (iEntry != m_3DViewInstanceHash.constEnd())
	    {
	        if(allObject || iEntry.value().isVisible() == m_IsInShowSate)
	        {
	        	// Combine Collection BoundingBox with element Bounding Box
	        	boundingBox.combine(iEntry.value().boundingBox());
	        }
	        ++iEntry;
	    }
	}
	return boundingBox;
}
コード例 #6
0
ファイル: glc_viewport.cpp プロジェクト: JasonWinston/GLC_lib
GLC_Camera GLC_Viewport::reframedCamera(const GLC_BoundingBox &box, double coverFactor) const
{
    Q_ASSERT(!box.isEmpty());
    GLC_Camera subject(*m_pViewCam);

    // Center view on the BoundingBox
    const GLC_Vector3d deltaVector(box.center() - m_pViewCam->target());
    subject.translate(deltaVector);

    if (coverFactor > 0.0) {
        double cameraCover= box.boundingSphereRadius() * coverFactor;

        // Compute Camera distance
        const double distance = cameraCover / m_ViewTangent;

        // Update Camera position
        subject.setDistEyeTarget(distance);
    }

    return subject;
}
コード例 #7
0
ファイル: glc_factory.cpp プロジェクト: JasonWinston/GLC_lib
GLC_3DViewInstance GLC_Factory::createBox(const GLC_BoundingBox& boundingBox) const
{
	const double lx= boundingBox.upperCorner().x() - boundingBox.lowerCorner().x();
	const double ly= boundingBox.upperCorner().y() - boundingBox.lowerCorner().y();
	const double lz= boundingBox.upperCorner().z() - boundingBox.lowerCorner().z();
	GLC_Box* pBox= new GLC_Box(lx, ly, lz);
	GLC_3DViewInstance newBox(pBox);
	newBox.translate(boundingBox.center().x(), boundingBox.center().y()
					, boundingBox.center().z());
	return newBox;
}
コード例 #8
0
void GLC_Viewport::setDistMinAndMax(const GLC_BoundingBox& bBox)
{
	if(!bBox.isEmpty())
	{
		// The scene is not empty
		GLC_Matrix4x4 matComp(m_pViewCam->modelViewMatrix());

		// The bounding Box in Camera coordinate
		GLC_BoundingBox boundingBox(bBox);
		boundingBox.transform(matComp);

		// Increase size of the bounding box
		const double increaseFactor= 1.1;
		// Convert box distance in sphere distance
		const double center= fabs(boundingBox.center().z());
		const double radius= boundingBox.boundingSphereRadius();
		const double min= center - radius * increaseFactor;
		const double max= center + radius * increaseFactor;

		GLC_Point3d camEye(m_pViewCam->eye());
		camEye= matComp * camEye;

		if (min > 0.0)
		{
			// Outside bounding Sphere
			m_dDistanceMini= min;
			m_DistanceMax= max;
			//qDebug() << "distmin" << m_dCamDistMin;
			//qDebug() << "distmax" << m_dCamDistMax;
		}
		else
		{
			// Inside bounding Sphere
			m_dDistanceMini= qMin(0.01 * radius, m_pViewCam->distEyeTarget() / 4.0);
			m_DistanceMax= max;
			//qDebug() << "inside distmin" << m_dCamDistMin;
			//qDebug() << "inside distmax" << m_dCamDistMax;
		}
	}
	else
	{
		// The scene is empty
		m_dDistanceMini= m_pViewCam->distEyeTarget() / 2.0;
		m_DistanceMax= m_pViewCam->distEyeTarget();
	}

	// Update OpenGL projection matrix
	updateProjectionMat();
}