Solved Armorstand and kinect

Discussion in 'Spigot Plugin Development' started by coco_gigpn, Jan 14, 2019.

  1. I remember this old video of sethbling

    And I still don’t understand how he did it, so impressive...

    I don’t understand what’s the bridge between reading user movement and sending informations to a server.

    So first step, read movement with kinect api and a custom java software. convert kinect movement into Euler angle
    And then send information to the server.
    How could we send euler angle to the server ?

    I am very curious thanks in advance !
     
  2. A java plugin is a java program. As such, you can just make another thread in your plugin running a listener of some sort, like a local HttpServer I believe would work? You could send the information with sockets from your other program, and in your plugin's thread, call Bukkit.getScheduler().runTask().
    I haven't done this myself before, but here's a stackoverflow page about it: https://stackoverflow.com/questions/5052102/communication-between-local-jvms
    I hope this helps!
     
    • Like Like x 1
  3. You can use sockets to send the info maybe?
     
    • Useful Useful x 1
  4. md_5

    Administrator Developer

    Just plug the kinect into your server (which is likely his desktop PC) and then use something like https://research.dwi.ufl.edu/ufdw/j4k/ in your plugin.
    Nothing fancy needed.


    Obviously if you are hosting a dedicated server elsewhere then you'll need to do what is said above, but I somehow don't think that's the point of this demo :)
     
    • Agree Agree x 1
    • Friendly Friendly x 1
  5. Thank you very much for your help !
    I gonna try with my kinect
    I hope I will not have issue with Mac OS and this kinect.
     
  6. No that's just silly, there have never ever been issues with Microsoft products working with MacOS. They don't even have a competing operating system that may insentivize them to limit support.
     
    #6 GreatThane, Jan 14, 2019
    Last edited: Jan 14, 2019
    • Optimistic Optimistic x 1
  7. I tried with mac os mojave, almost impossible xD
     
    • Funny Funny x 1
  8. Soooo I was able to use the kinect with my windows computer and load this lib:
    This is great, everything is working. However I really don't know how to rotate and move the armorstand with this api.
    This is the skeleton class:
    https://hastebin.com/ujewopular.cpp

    I tested some code, I got some random positions values:
    Code (Text):
        private float previousX, previousY,previousZ = 0F;
        public void moveArmorstand(Skeleton skeleton) {
            float headx = skeleton.get3DJointX(Skeleton.HEAD);
            float heady = skeleton.get3DJointY(Skeleton.HEAD);
            float headz = skeleton.get3DJointZ(Skeleton.HEAD);
           
            if(headx == previousX || heady == previousY || headz == previousZ) {
                return;
            }
           
            this.previousX = headx;
            this.previousY = heady;
            this.previousZ = headz;
           
            if(headx == 0 || heady == 0 || headz == 0)
                return;
           
           
            System.out.println("x: " + headx + " y: "+ heady + " z: " + headz);
        }
     
    But I really can't figure out how to convert this with euler angle and so on

    I could use that, for example getHeadTransform(double[] ect...) but I don't know what to use for the parameters.
    Code (Text):

        /*The following methods compute the orientations and transformations
          of various body parts, which may be used for human-computer interaction.*/
        public double getBodyOrientation();
        public double[] getTorsoOrientation();
        public double[] getRelativeNUICoords();
        public double getTorsoTransform(double[] transf, double[] inv_transf);
        public double getHeadTransform(double[] transf, double[] inv_transf);
        public double getFixHeadTransform(double[] transf, double[] inv_transf);
        public double getShoulderTransform(double[] transf, double[] inv_transf);
        public double getBetweenHandsTransform(double[] transf, double[] inv_transf);
        public double getRightThighTransform(double[] transf, double[] inv_transf);
        public double getLeftThighTransform(double[] transf, double[] inv_transf);
        public double getRightLegTransform(double[] transf, double[] inv_transf);
        public double getLeftLegTransform(double[] transf, double[] inv_transf);
        public double getRightArmTransform(double[] transf, double[] inv_transf);
        public double getLeftArmTransform(double[] transf, double[] inv_transf);
        public double getRightForearmTransform(double[] transf, double[] inv_transf);
        public double getLeftForearmTransform(double[] transf, double[] inv_transf);    
     
  9. well it looks like j4k is open source, so in intellij you can look through the methods yourself by just doing File -> New -> Project from Version Control -> Git -> "https://research.dwi.ufl.edu/git/ufdw"
     
  10. #10 coco_gigpn, Jan 14, 2019
    Last edited: Jan 14, 2019
  11. Oh well dang aren't I the fool lol
    These variable names are atrocious for source code...
    Considering the name "transf," I'd try passing in some empty arrays, and have a program write the returned value of one of your appendages to the screen to see if when you spin around your arm / head, it displays any meaningful information (such as sticking your hand up outputting 360 or 2π)
     
  12. This is because I used fernflower via intellij xD
    I see what you want to do but I think there is nothing in this api to get angle (radian or degree) I need to calcul...
     
  13. It'd be a pain, but you could always write your own API by looking at the source of the source?
     
  14. What if using the three points of #getJoint creates a new EulerAngle? (new EulerAngle(headx, heady, headz) what would be the result?
     
  15. I will try tomorrow, but I don't think this is radian angle xD
     
  16. You can use Math#toRadians
     
  17. No I mean this is just a position x,y,z
    and I tried to move my head left right, up and down but the values did not change
     
    #17 coco_gigpn, Jan 15, 2019 at 12:08 AM
    Last edited: Jan 15, 2019 at 12:15 AM
  18. Based on what? The current position of the "image"? Maybe you can get the angle getting the shoulder and hand coords and calculate it yourself
     
  19. Maybe your kinect doesn't read your head?
     
  20. You are probably right
    i saw the skeleton's moving ;)

    Okay after some hours of thinking, I need first to define some vectors:

    calcul of the head euler angle:
    spine Vector (spine base - spine mid) and head vector (neck - head).

    Those points are available with the api ! and that's why sethbling draws points with different colors I think
    [​IMG]

    After all vectors calculated, I need to get the euler angle between 2 vectors ;) and that's it

    EDIT:
    Only 1 vector is needed to determine yaw and pitch :)
     
    #20 coco_gigpn, Jan 15, 2019 at 12:40 PM
    Last edited: Jan 15, 2019 at 5:17 PM

Share This Page