I have to admit my c++ is rather weak. I managed to do like below.
ccHighlightCloud .h
Code: Select all
#include<ccPointCloud.h>
class ccHighlightCloud : public ccPointCloud
{
public:
ccHighlightCloud();
ccBBox getOwnBB(bool withGLFeatures/*=false*/);
};
ccHighlightCloud.cpp
Code: Select all
#include "ccHighlightCloud.h"
ccHighlightCloud::ccHighlightCloud()
{
}
ccBBox ccHighlightCloud::getOwnBB(bool withGLFeatures/*=false*/)
{
ccBBox box;
const CCVector3* point = getPoint(0);
if (!point) return box;
box = ccBBox(CCVector3(point->x - 1, point->y - 1, point->z - 1), CCVector3(point->x + 1, point->y + 1, point->z + 1));
if (size())
{
getBoundingBox(box.minCorner(), box.maxCorner());
box.setValidity(true);
}
return box;
}
I created a cloud, added it to DbTree(is it required?) and invoked the below code hoping my above adventure would yield something.
Code: Select all
ccPointCloud* tempCloud = createTempCloud(Pglobal);
m_app->addToDB(tempCloud);
ccHighlightCloud* highCloud = static_cast<ccHighlightCloud*>(tempCloud);
ccHObject* pointObj = highCloud->getChild(pointIndex);
m_app->setSelectedInDB(pointObj, true);
When i debugged, this is giving false to the below code..Is there something that I have done horribly wrong here?
Code: Select all
void MainWindow::setSelectedInDB(ccHObject* obj, bool selected)
{
if (obj && m_ccRoot) //this is giving false :(