SimpleOpenNI Use PointClouds From Kinect To Vec3D of Toxiclibs

edited April 2015 in Kinect

Hi everyone!

I have a problem. I am tring to use the pointclouds from kinect, by SimpleopenNI library, to Vec3D array of toxiclibs. The problem is that :
PVector[] realWorldMap = kinect.depthMapRealWorld();
for store all points on an array, it does not work with:
Vec3D[] realWorldMap = kinect.depthMapRealWorld();

And I can not translate from PVector to Vec3D... Any suggest?


  • edited April 2015

    Although I don't have Toxic library installed here, I believe a Vec3D is almost the same as a PVector.
    That is, they have in common these 3 float properties: x, y & z.
    So in case I'm not wrong about it, it's just a matter of passing those 3 values to a new Vec3D.

    // simpleopenni-use-pointclouds-from-kinect-to-vec3d-of-toxiclibs
    static final Vec3D PVecToVec3D(PVector p) {
      return new Vec3D(p.x, p.y, p.z);
    static final Vec3D[] PVecToVec3D(PVector... p) {
      Vec3D[] v = new Vec3D[p.length];
      for (int i = p.length; i-- != 0; v[i] = PVecToVec3D(p[i]));
      return v;

    Here's a simple working test:

    Vec3D[] toxVecs;
    void setup() {
      PVector[] pVecs = new PVector[3];
      for (int i = 0; i != pVecs.length; pVecs[i++] = PVector.random3D(this));
      toxVecs = PVecToVec3D(pVecs);
  • Thank you @GoToLoop !

    I was looking for a for use directly toxiclibs with simpleopenni libraries, but your way is interesting and helpful too! I tested your code and it look like a good and fast way. I will implement it on the kinect code and I will update how it will work.

Sign In or Register to comment.