This site requires JavaScript, please enable it in your browser!
Greenfoot back
B00bietrap
B00bietrap wrote ...

2011/6/22

Scenario outside Greenfoot

B00bietrap B00bietrap

2011/6/22

#
Hello I'm actually working with the Microsoft Kinect Camera. I got the example Programm to work in Greenfoot. Now I wanted to ask if it is possible to run the Scenario outside of Greenfoot. Maybe a Mainclass with a Frame or something? I tried it and got only a bunch of NullPointerException^^ I need to get it to run in Netbeans since I have there the NoDave Java programm to work with SPS systems and bunch of other stuff. greets B00bietrap
nccb nccb

2011/6/22

#
There is an option in Greenfoot to export to a standalone application, which allows you to run your scenario in a fairly minimal window. But I think what you're asking is to run the Kinect parts completely outside Greenfoot in a different Java project. This should work fine; nothing in the Java parts of the Greenfoot-Kinect interface are Java specific (you'll still need to run the Greenfoot-Kinect server application alongside your other project). You just need to take the four Kinect classes (KinectClient, Joint, UserData, Point3D) to a new project, and create and update the KinectClient as KinectWorld does: create a KinectClient, and call kinect.update() each frame (after checking kinect.isConnected()). If that doesn't work, please post the exceptions you're getting here and I'll see if I can help. Although, obviously by then it's only tangentially related to Greenfoot...
B00bietrap B00bietrap

2011/6/22

#
Lemme see.... I'm not sure how to get something visible. :S I made a file KinectWorld. There i make: KinectClient kinect = new KinectClient(); in main method so i can cal anywhere .isConnected and .update Do I have to create a Frame or something to add the visualisation somehow?
B00bietrap B00bietrap

2011/6/22

#
I have atm something like this (It might be totally wrong): I have actually no idea where to get and where to set the "UserImg" ..... Tried Frame and Applet so far.....
import greenfoot.GreenfootImage;
import java.awt.Frame;

/**
 *
 * @author siegt5
 */
public class KinectWorld extends Frame {

    KinectClient kinect = new KinectClient();
    public void init()
    {
        setLayout(null);
        setSize(800, 800);
        setVisible(true);   
    }

    public KinectWorld()
    {
     init();
    }

    public void Update()
    {
        if(kinect.isConnected() == true)
        {
         kinect.update();
        }  
    }

    public static void main(String[] args)
    {
        new KinectWorld();
    }
}
Edit: Actually I just wand somehow the same view Like in Greenfoot.... but I guess I'm too stupid for that atm... Made now A Class with a Panel... Mainclass that shows my Panel.. which is empty... did draw a rectangle to check if it's working at all :p .. it does^^ How I get the Thumbnail or the UserImage which are GreenfootImages into my Panel? Then I see if it I am really connected with the Kinect Cam. I think with that Program I could now get infos from the "UserData" class and draw with them something on my Panel... Or am I totally wrong again?
    import greenfoot.GreenfootImage;
    import java.awt.Frame;

    /**
     *
     * @author siegt5
     */
    public class KinectWorld extends Frame {

        KinectClient kinect = new KinectClient();
        KinectPanel panel = new KinectPanel();
        public void init()
        {
            setLayout(null);
            setSize(800, 800);
            setVisible(true);
            panel.setBounds(0, 0, 600, 600);
            add(panel);
        }

        public KinectWorld()
        {
         init();
         Update();
        }

        public void Update()
        {
            while (true)
            {
            if(kinect.isConnected() == true)
            {
             kinect.update();
             panel.repaint();
            }
            }
        }

        public static void main(String[] args)
        {
            new KinectWorld();
        }
    }  
Edit: I did look a bit through the exampel. I see how it's communicating and hoe to get positions of a hand or so... I just don't get it in a Window to see anything^^ I try atm to work on the Original KinectWorld class.... did insert a main methode into it and made a instance of itself and started act(); just getting NullPointerException ..... blargh xD
mik mik

2011/6/22

#
Since it seems that you don't want to do this in Greenfoot, but entirely outside, a Greenfoot forum might not be the best place to ask for advice. I'd suggest that you find a Kinect development forum - you might get further there.
B00bietrap B00bietrap

2011/6/23

#
It's more or less just a experiment for this Kinect. the minigames i have in greenfoot and it's fine there. I just tried to expand the kinect with all my other stuff in Netbeans. And it's not toally out of greenfoot, still using the same classes system and library. I just try to run it without an additional software this time.
You need to login to post a reply.