ccPointCloud *pc;
......
pc->setDisplay(m_app->getActiveGLWindow());
pc->addScalarField("DefaultScalarField");
pc->enableScalarField();
// modified here
pc->showSF(true);
pc->setCurrentDisplayedScalarField(0); // After several attempts, must setCurrentDisplayedScalarField.
......
pc->reserve(1); // reserve memory to store a new point.
pc->addPoint(CCVector3(ppoint_data->x, ppoint_data->y, ppoint_data->z)); //ppoint_data is from Lidar
pc->getScalarField(0)->addElement(ppoint_data->reflectivity);// add ScalarValue
pc->getScalarField(0)->computeMinAndMax();