Your SlideShare is downloading. ×
  • Like
Greenfoot & Kinect (Parte 3)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Greenfoot & Kinect (Parte 3)

  • 712 views
Published

Programando el Kinect con Greenfoot, parte 3. …

Programando el Kinect con Greenfoot, parte 3.
Clase de Proyecto de Diseño de Videojuegos @ ITESM SLP

Published in Education , Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
712
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
11
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Programando elKinect con Greenfoot (3) Eduardo H. Calvillo Gámez
  • 2. Calibrando Usuarios Clase UserData  Métodos  isTracking();  Booleano, nos indica si esta haciendo “tracking” pues ya termino de calibrar.  isCalibrating();  Booleano, nos indica si esta calibrando. Clase KinectWorld  getAllUsers();  Arreglo de UserData, todos los usuarios frente al Kinect.
  • 3. Ejemplo:Instrucciones.java Método act() & addedToWorld(…)
  • 4. //Método act()KinectWorld world = (KinectWorld)getWorld(); boolean trackingAny = false; boolean calibratingAny = false; UserData[] us = world.getAllUsers(); for (UserData u : us) { trackingAny = trackingAny || u.isTracking(); calibratingAny = calibratingAny || u.isCalibrating(); } if (us.length > 0 && !trackingAny && ! calibratingAny) { setImage(begin); } else if (us.length > 0 && !trackingAny && calibratingAny) { setImage(calibrating); } else { setImage(blank); } }
  • 5. protected void addedToWorld(World world) { begin = new GreenfootImage("begin.png"); begin.scale(world.getWidth(), world.getHeight()); calibrating = new GreenfootImage("calibrating.png"); calibrating.scale(world.getWidth(), world.getHeight()); blank = new GreenfootImage(1, 1); setImage(blank); }
  • 6. Usuarios Clase UserData  drawStickFigure(…)  drawStickFigure(getBackground(), 60);  getJoint Clase Joint  Constantes para cada parte del cuerpo getJoint(Joint.LEFT_HAND) nos regresa la parte que indicamos (objeto de tipo Joint)
  • 7. Ejemplo Para checar si alguien levanto la mano izquierda  u.getJoint(Joint.LEFT_HAND).getY() < u.getJoint(Joint.HEAD).getY()
  • 8. EjemploDibujando con la mano derecha
  • 9. import greenfoot.*;public class Brocha extends Actor{ public Brocha(int width, int height) { setImage(new GreenfootImage(width, height)); getImage().setColor(java.awt.Color.GREEN); } public void act() { PaintWorld world = (PaintWorld)getWorld(); UserData[] users = world.getTrackedUsers(); for (UserData user : users) { Joint rightHand = user.getJoint(Joint.RIGHT_HAND); getImage().fillOval(rightHand.getX(), rightHand.getY(), 20, 20); if (user.getJoint(Joint.LEFT_HAND).getY() < user.getJoint(Joint.HEAD).getY()) { getImage().clear(); } } }}
  • 10. Ejemplo PintarMundo
  • 11. public class PintarMundo extends KinectWorld{ private static final int THUMBNAIL_WIDTH = 80; private static final int THUMBNAIL_HEIGHT = 60; … public PintarMundo() { super(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, 1.0, false); final int width = getWidth(); final int height = getHeight(); addObject(new Brocha(width, height), width/2, height/2); addObject(new Instructiones(), width/2, height/2); addObject(new Foto(), width - THUMBNAIL_WIDTH/2, height -THUMBNAIL_HEIGHT/2); Label instr = new Label(”Usa la mano derecha para pintar, la izquierdapara borrar", 20); addObject(instr, instr.getImage().getWidth() /2, getBackground().getHeight() - (instr.getImage().getHeight() / 2)); }
  • 12. public void act() { super.act(); if (!isConnected()) return; UserData[] us = getTrackedUsers(); getBackground().setColor(java.awt.Color.WHITE); getBackground().fill(); for (UserData u: us) { //Draws their stick figure: u.drawStickFigure(getBackground(), 60);}