Exemple #1
0
void ccSubMesh::refreshBB()
{
	m_bBox.clear();
	
	for (unsigned i=0; i<size(); ++i)
	{
		CCLib::GenericTriangle* tri = _getTriangle(i);
		m_bBox.add(*tri->_getA());
		m_bBox.add(*tri->_getB());
		m_bBox.add(*tri->_getC());
	}

	notifyGeometryUpdate();
}
Exemple #2
0
void ccSubMesh::refreshBB()
{
	m_bBox.clear();
	
	for (unsigned i=0; i<size(); ++i)
	{
		CCLib::GenericTriangle* tri = _getTriangle(i);
		m_bBox.add(*tri->_getA());
		m_bBox.add(*tri->_getB());
		m_bBox.add(*tri->_getC());
	}

	updateModificationTime();
}
Exemple #3
0
void ccGenericMesh::computeInterpolationWeights(unsigned triIndex, const CCVector3& P, CCVector3d& weights) const
{
	CCLib::GenericTriangle* tri = const_cast<ccGenericMesh*>(this)->_getTriangle(triIndex);
	const CCVector3 *A = tri->_getA();
	const CCVector3 *B = tri->_getB();
	const CCVector3 *C = tri->_getC();

	//barcyentric intepolation weights
	weights.x = sqrt(((P-*B).cross(*C-*B)).norm2d())/*/2*/;
	weights.y = sqrt(((P-*C).cross(*A-*C)).norm2d())/*/2*/;
	weights.z = sqrt(((P-*A).cross(*B-*A)).norm2d())/*/2*/;

	//normalize weights
	double sum = weights.x + weights.y + weights.z;
	weights /= sum;
}
void ccCameraParamEditDlg::processPickedItem(int entityID, unsigned itemIndex, int x, int y)
{
	if (!m_associatedWin)
		return;

	ccHObject* obj = 0;
	ccHObject* db = m_associatedWin->getSceneDB();
	if (db)
		obj = db->find(entityID);
	if (obj)
	{
		CCVector3 P;
		if (obj->isKindOf(CC_TYPES::POINT_CLOUD))
		{
			ccGenericPointCloud* cloud = ccHObjectCaster::ToGenericPointCloud(obj);
			if (!cloud)
			{
				assert(false);
				return;
			}
			P = *cloud->getPoint(itemIndex);
		}
		else if (obj->isKindOf(CC_TYPES::MESH))
		{
			ccGenericMesh* mesh = ccHObjectCaster::ToGenericMesh(obj);
			if (!mesh)
			{
				assert(false);
				return;
			}
			CCLib::GenericTriangle* tri = mesh->_getTriangle(itemIndex);
			P = m_associatedWin->backprojectPointOnTriangle(CCVector2i(x,y),*tri->_getA(),*tri->_getB(),*tri->_getC());
		}
		else
		{
			//unhandled entity
			assert(false);
			return;
		}

		m_associatedWin->setPivotPoint(CCVector3d::fromArray(P.u));
		m_associatedWin->redraw();
	}

	m_associatedWin->setPickingMode(ccGLWindow::DEFAULT_PICKING);
	disconnect(m_associatedWin, SIGNAL(itemPicked(int, unsigned, int, int)), this, SLOT(processPickedItem(int, unsigned, int, int)));
}