Blender Live Shapes (018; 06.09.2009; blender, processing)
Blender Live Shape 1.0 from MyInventions on Vimeo.
Blender Live Shape (BLS) - Blender 3D object with real-time displacement modifier (similar to normal map) based on live grayscale video from webcam.
How it works?
Practice
This concept files are full open:
You could comment at BlenderNation:
Processing source code:
import processing.serial.*; import processing.video.*; Serial myPort; Capture webcam; int liczbaPikseli; color Kolor; int A, R, G, B, Y, j=1; String name; int t, T; void setup() { size(200, 150); println(Serial.list()); myPort = new Serial(this,"COM10", 9600); webcam = new Capture(this, width, height, 10); //framerate:10 liczbaPikseli = webcam.width*webcam.height; //webcam.settings(); } void draw(){ if (webcam.available() == true){ webcam.read(); set(0, 0, webcam); loadPixels(); for (int i=0; i < liczbaPikseli; i++){ Kolor = pixels[i]; R = (Kolor >> 16) & 0xFF; G = (Kolor >> 8) & 0xFF; B = Kolor & 0xFF; Y=int(0.3*R+0.59*G+0.11*B); A = 255 << 24; R = Y << 16; G = Y << 8; B=Y; pixels[i]=A|R|G|B; } updatePixels(); name=str(j)+".png"; saveFrame(name); myPort.write(char(j)); j++; if (j==6){ //T=millis()-t; //println(5000.0/T); //print real frame rate //t=millis(); j=1; } } }
Blender python API script:
import Blender from Blender import Image from Blender import Texture from Blender import Material from Blender import Object from Blender import Window from Blender import Modifier from Blender import Scene import serial myPort = serial.Serial('COM11', 9600) texture=Texture.Get('Textura') texture.setType('Image') scene=Scene.getCurrent() plane=Object.Get('Plane') modifier=plane.modifiers[0] myPort.flushInput() for i in range(1, 301): y = ord(myPort.read(size=1)) name=str(y)+".png" image=Image.Load(name) texture.image=image modifier[Modifier.Settings.TEXTURE] = texture Window.EditMode(1) Window.EditMode(0) Window.Redraw()
Blender Game Engine python script:
import Blender from Blender import Image from Blender import Texture from Blender import Material from Blender import Object from Blender import Window from Blender import Modifier from Blender import Scene import serial myPort = serial.Serial('COM11', 9600) texture=Texture.Get('Textura') texture.setType('Image') scene=Scene.getCurrent() plane=Object.Get('Plane') modifier=plane.modifiers[0] y = ord(myPort.read(size=1)) name=str(y)+".png" image=Image.Load(name) texture.image=image modifier[Modifier.Settings.TEXTURE] = texture controller = GameLogic.getCurrentController() obj = controller.owner mesh = obj.meshes[0] obj.replaceMesh(mesh)