Page 1 of 1
How to change the color of a point with code?
Posted: Thu Jul 22, 2021 8:53 am
by xiaolu
hi there,
I want to change the color of a point with code.
For example, I want to change the 10th point in the point cloud to red.
thanks~
Re: How to change the color of a point with code?
Posted: Sun Jul 25, 2021 10:23 pm
by DA523
1- Use text editor or LibreOffice Calc to add 255 in front of your red points and 0 for others
2- Save as csv or txt
3- Open by CC as in pic below
However may be there is beter way directly by CC ?
Remarks:
1- You can ignore label during importing points
2- You can put labels in group to show or hide
3- You can change opacity of label to 0
4- To change points size use properties not (+- ) it is sometimes does not work
.
- 12.png (48.57 KiB) Viewed 2326 times
.
- 123.png (66.49 KiB) Viewed 2326 times
.
- 33.png (93.25 KiB) Viewed 2326 times
.
.
.
Re: How to change the color of a point with code?
Posted: Mon Jul 26, 2021 7:07 am
by xiaolu
Thank you for your reply.
But this method doesn't quite work for me.
What I need is a point cloud already loaded and then change the color of one of its points.
But still, thank you very much.
I found a function
Code: Select all
void ccPointCloud::setPointColor(unsigned pointIndex, const ccColor::Rgba& col)
{
assert(m_rgbaColors && pointIndex < m_rgbaColors->currentSize());
m_rgbaColors->setValue(pointIndex, col);
//We must update the VBOs
colorsHaveChanged();
}
This is how I use it (pc1 is the point cloud already loaded into the dbtree)
Code: Select all
pc1->setPointColor(10, ccColor::red);
But it reports an error.
Code: Select all
Assertion `m_rgbaColors && pointIndex < m_rgbaColors->currentSize()' failed.
Aborted (core dumped)
Re: How to change the color of a point with code?
Posted: Mon Jul 26, 2021 8:06 am
by xiaolu
I found my own way
need to set a base color first.
Then change the color of the 10th point
Code: Select all
pc1->setPointColor(10, ccColor::red);
Then
Success