I have a problem locating on the canvas a large point cloud file (.txt / .xyz) that I have created with Meshlab.
I’ve tried to translate the coordinates numerous times with the translate() function but not only I can’t seem to center the point cloud but also I’m unable to find it on the screen.
I think you need to translate to width/2 height/2 then scale it down … a lot! Mind you, that depends if the values are around zero. What’s the minimum and maximum values for each dimension?
width/2, height/2 translation doesn’t work. I mean I can see a tiny point cloud (I have scaled down to .001) but I have to rotate the camera (PeasyCam) with the mouse and it’s very far.
You could try translating by the negative of the min value in each direction? You could then scale it based on the ratio of width to the difference of max and min.
The translate() coordinates are the negative means of each column.
However, applying that exact translation to an .obj built from the very same vertices doesn’t put that object at the center. It appears on the canvas, but far from the camera and at a different angle. Very strange.
Logic would have it that scale() goes after translate(), as you’re suggesting, but for some reason it’s the exact opposite that works here. Don’t know why.
I prefer putting the negative mean because it makes possible to rotate the point cloud around its centroid.
Yes, but I’d be tempted to do those in two steps, at least at first. Get your points normalized to the window (translate then scale), then move it to the centre. By the way, are you using PeasyCam all the time? Have you tried without just in case?
Just noticed your translate line above has a positive z translation - is that intended?!
Yes, the translate line has a positive z translation and it works fine this way.
Yes, I’m using PeasyCam and your suggestion is relevant, I’ll try adjusting the coordinates without the library first.
Simply because it didn’t work. Negatively translating all the axes makes the object totally disappear from screen. With or without peasycam, before or after scaling…
I’ll stick with the dubious workaround aforementioned: scaling first and translating by negative means.