Donnerstag, 29. Oktober 2015

Interactive Art - Homework 7


Optitrack Motion Capture Sensor
http://www.optitrack.com/















The Optitrack Sensors capture motions. This can be an interesting feature for several projects. Unfortuantelly the sensors are not affordable for every students:
The price starts with about 500 USD for the Flex Series.


The results are outstanding if there the technical expertise is provided.


Here is an example video where Optitrack Sensors come to use.

The sensors track the points on the subjects face. On software-side this points are converted into a 3d model to which an animated texture is applied.

This model is projected back on the face. While moving the head in a certain direction, the 3d shape begins to change and so does the projection back onto the face.

The effect is really cool and has some kind of augmented reality feeling!






MyvIdea:

Glasses that project 3d objects into real environment. If you wear these glasses there is made a 2d projection on each of the two glasses which appears in 3d.

An example how it works:

If you see a cube, normally the images a human sees are 2-dimensional. The only thing that creates depth and lets images we see look 3-dimensional is the fact, that we see an object from two sides actually, because we have two eyes, which are not at the same point.

Spoken in mathematical formulars: If you have 2 points (our eyes) and an angle (errated by our brain of a comparison of the images of the object we see from two sides) of a triangle you can errate the distance to the third point  (the object we actually see) of the triangle.
































So we see two images of maybe an objects like this cube from two positions.

The depth or in this case 3d look is created by our brain which combines this two images.
What finally is created is a 3d image of the scene.






What basicially the glass is projecting an 3d objects on each of the two glasses. 

-The angle and size of each projection of the object defines its distance to the viewer. Bigger angle = its nearer
-The position on the glasses defines its angle to the viewer

On this way, if the viever wears the glasses he will see 3d objects in real space. They will look like if they were part of the real world








Samstag, 24. Oktober 2015

Interactive Art - Homework 6

A simple concept of a help/support button. If someone presses the button somewhere else (maybe at a security office etc) an alarm light blinks.

The power circuit:



int led1 = 7; 
int led2 = 6; 
int led3 = 5; 
int tick = 0;
int inputPin = 13;   

void setup() 
{
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(inputPin, INPUT);    
}

void loop()
{
  if (digitalRead(inputPin) == HIGH) 
  {         
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW); 
    digitalWrite(led3, LOW); 
  } 
  else 
  {
    blinks();
  }
}

void blinks()
{

  digitalWrite(led1, HIGH);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  delay(50);
  digitalWrite(led1, LOW);
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
  delay(50);
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
  delay(50);
}

Freitag, 16. Oktober 2015

Interactive Art - Homework 5



Song: Boys Noize - Alarm
Please download video. Youtube muted the sound because of coypright reasons.



int led1  = 13;
int led2  = 12;
int led3  = 11;
int led10 = 7;
int led9  = 6;
int led8  = 5;
boolean led8on  = false;
boolean led10on = false;

boolean led1on = true;
boolean led2on = false;
boolean led3on = false;

int tick0 = 0;
int tick1 = 0;
int tick2 = 0;

void setup() 
{
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led10, OUTPUT);
  pinMode(led9, OUTPUT);
  pinMode(led8, OUTPUT); 
  Serial.begin(9600);
  Serial.println("Programm startet...");
}

void loop() 
{
   if(millis() ==  15000)
   {
       digitalWrite(led1,HIGH);
       digitalWrite(led2,HIGH);
       digitalWrite(led3,HIGH);
       digitalWrite(led8,HIGH);
       digitalWrite(led9,HIGH);
       digitalWrite(led10,HIGH);
   }
   if(millis() == 16000)
   {
       digitalWrite(led1,LOW);
       digitalWrite(led2,LOW);
       digitalWrite(led3,LOW);
       digitalWrite(led8,LOW);
       digitalWrite(led9,LOW);
       digitalWrite(led10,LOW);
   }
   if(millis() < 15000 || millis() > 16000)music();
}

void music()
{


  if( millis() - tick2 > 200 )
  {
    if( led1on == true )
    {
      led1on = false;
      led2on = true;
      tick2 = millis(); 
    }
    else if( led2on == true )
    {
      led2on = false;     
      led3on = true;   
      tick2 = millis(); 
    }   
    else if( led3on == true )
    {
      led1on = true;     
      led3on = false;   
      tick2 = millis()-100; 
    }       
    
  }
  if( led1on == true)
  {
    digitalWrite(led3,LOW);     
    digitalWrite(led1,HIGH);
  }
  else if( led2on == true)
  {
    digitalWrite(led1,LOW);  
    digitalWrite(led2,HIGH);  
  }
  else if( led3on == true)
  {
    digitalWrite(led2,LOW);  
    digitalWrite(led3,HIGH);  
  }




  
  if( millis() - tick0 > 200 )
  {
    if( led8on == true )
    {
      led8on = false;
    }
    else
    {
      led8on = true;   
    }   
    tick0 = millis();  
  }
  if( led8on == true)
  {
    digitalWrite(led8,HIGH);
  }
  else
  {
    digitalWrite(led8,LOW);  
  }



  
  if(millis() >  16000)
  {
    if( millis() - tick1 > 600 )
    {
      if( led10on == true )
      {
        led10on = false;
      }
      else
      {
        led10on = true;   
      }   
      tick1 = millis();  
    }
    if( led10on == true)
    {
      digitalWrite(led9,LOW);
      digitalWrite(led10,HIGH);
    }
    else
    {
      digitalWrite(led10,LOW);  
      digitalWrite(led9,HIGH);    
    } 
  }
}






Samstag, 10. Oktober 2015

Interactive Art Homework - Week 4

A pattern in my daily life (or atleast on weekendss...)



Code uses images. So a download is necessary:
Download me!


































class Button
{
  int     sizeX;
  int     sizeY;
  int     posX;
  int     posY;
  String  text;
  String  toolTip;
  int     colorR;
  int     colorG;
  int     colorB;
  int     colorA;
  boolean border = true;
  
  private Button(int posX, int posY, int sizeX, int sizeY, String text, String toolTip)
  {
    this.posX    = posX;
    this.posY    = posY;
    this.sizeX   = sizeX;
    this.sizeY   = sizeY;
    this.text    = text;
    this.toolTip = toolTip;
    colorR       = 0;
    colorG       = 0; 
    colorB       = 0;      
    colorA       = 255;
  }
  
  // Zeichnet den Button
  
  private void drawButton()
  {
    pushStyle();
    noSmooth();
    fill(colorR, colorG, colorB, colorA);
    if (!border)
    {
      noStroke();
    }
    rect(posX, posY, sizeX, sizeY);
    fill(255,255,255);
    textSize(12);
    textAlign(CENTER);
    text(text, posX + sizeX / 2, posY + sizeY / 1.4);    
    popStyle();
  }
  
  // Prüft ob die Maus über dem Button ist.
  
  private boolean isCollission()
  {
    
    if ((mouseX > posX && mouseX < posX + sizeX) && (mouseY > posY && mouseY < posY + sizeY))
    {
      return true;
    }
    else
    {
      return false;
    }
  }
}

class Ingredient
{
  
  String item;
  color  colour;
  
  public Ingredient(String item)
  {
    this.item = item;
    updateColour();
  }
  
  void updateColour()
  {
    if(item == "empty")colour = color(255,255,255,0); 
    if(item == "Wodka")colour = color(255,255,255,40);        
    if(item == "Bacardi")colour = color(255,255,255,40);      
    if(item == "Whiskey")colour = color(79,57,31,200);
    if(item == "Sprite")colour = color(255,255,255,40);
    if(item == "Coke")colour = color(48,0,5,230);
    if(item == "Blue Curacao")colour = color(0,0,255,90);
    if(item == "Maracuja Juice")colour = color(223,241,76,240);
    if(item == "Energy")colour = color(254,255,210,240);  
  }
}


Button[]     buttons;  
Ingredient[] mixture;
int          ingredientsAdded;
color        currentColor;
PImage       cocktail, straw, swirl;

void setup()
{
  size(800, 600);

  buttons = new Button [8];
  buttons[0] = new Button(20, 30, 100, 20, "Wodka", "Add Wodka");  
  buttons[1] = new Button(20, 60, 100, 20, "Bacardi", "Add Bacardi");  
  buttons[2] = new Button(20, 90, 100, 20, "Whiskey", "Add Whiskey");  
  buttons[3] = new Button(20, 120, 100, 20, "Sprite", "Add Sprite");    
  buttons[4] = new Button(20, 150, 100, 20, "Coke", "Add Coke");  
  buttons[5] = new Button(20, 180, 100, 20, "Blue Curacao", "Add Blue Curacao");  
  buttons[6] = new Button(20, 210, 100, 20, "Maracuja Juice", "Add Maracuja");  
  buttons[7] = new Button(20, 240, 100, 20, "Energy", "Add Energy");  

  mixture = new Ingredient[10];
  for (int i = 0; i < mixture.length; i++)
  {
    mixture[i] = new Ingredient("empty");
  }
  ingredientsAdded = 0;
  currentColor = color(127,127,127,0);
  cocktail = loadImage("cocktail.png");
  straw    = loadImage("straw.png");  
  swirl    = loadImage("straw.png");  
}


void draw()
{
  background(45);
  drawGUI();
}

void drawGUI()
{
  for(int i = 0; i < buttons.length; i++)
  {
    buttons[i].drawButton();
    if(buttons[i].isCollission())
    {
      giveToolTip(i);
    }
  }
  
  for(int i = 0; i < mixture.length; i++)
  {
    if(mixture[i].item != "empty")
    {
      pushStyle();
      noStroke();
      fill(mixture[i].colour);
      rect(350,400 - i * 20,100,20);
      fill(255,255,255,255);      
      text(mixture[i].item, 480,400 - i * 20 + 15);
      popStyle();
    }
  }
  image(cocktail, 320, 189); 
 
  if(ingredientsAdded == 10)
  {
    image(straw, 320, 66);
  }  
}

void mouseReleased()
{
  for(int i = 0; i < buttons.length; i++)
  {
    if(buttons[i].isCollission())
    {
      addIngredient(buttons[i].text);
    }
  }
}

void addIngredient(String ingredient)
{
  if(ingredientsAdded <10)
  {
    mixture[ingredientsAdded].item = ingredient;
    mixture[ingredientsAdded].updateColour();
    //updateAllColours();
    ingredientsAdded++;
  }
}

void updateAllColours()
{
  if(ingredientsAdded == 0)
  {
    currentColor = color(mixture[ingredientsAdded].colour);
  }
  else
  {
    currentColor = lerpColor(currentColor, mixture[ingredientsAdded].colour, 0.3);
  }
  
  
  for(int i = 0; i < mixture.length; i++)
  {
    if(mixture[i].item != "empty")
    {
      mixture[i].colour = currentColor;
    }
  }  
}

private void giveToolTip(int i)
{
    int toolTipPanelSizeX = floor(textWidth(buttons[i].toolTip));  
    int toolTipVerticalDistance = 0;
    
    pushStyle();
    noSmooth();

    if(mouseY < 300)
    {
      toolTipVerticalDistance = 20;
    }
    else
    {
      toolTipVerticalDistance = -20;
    }
    if(buttons[i].posX < 400)
    {
      fill(0,0,0, 150);      
      rect(mouseX , mouseY - 5, + toolTipPanelSizeX + 10, toolTipVerticalDistance);     
      textAlign(LEFT);
      fill(255,255,255);
      textSize(12); 
      text(buttons[i].toolTip, mouseX +5 , mouseY + toolTipVerticalDistance / 2 );      
    }
    if(buttons[i].posX >= 400)
    {
      fill(0,0,0, 150);     
      rect(mouseX , mouseY - 5, - toolTipPanelSizeX - 10, toolTipVerticalDistance);      
      textAlign(RIGHT);
      fill(255,255,255);
      textSize(12);
      text(buttons[i].toolTip, mouseX - 5, mouseY + toolTipVerticalDistance / 2 );      
    }
    popStyle();  
}