arialy-mocap

I wanted to have decorate to bodies through this mocap project. Both figures would be created by cubes. Figure A would be the light source, mostly dark since the inner light would cast a shadow on the visible parts of its cubes, and figure B would be lit only by figure A’s light. I liked the irony of the light source being dark, and the figure without its own light being bright.

 

arialymocapgif

screen-shot-2016-11-17-at-6-32-22-pm

mocapscreenvideo

 

https://github.com/acdaly/60-212/tree/master/brekel_mocap


import java.util.List;

 

class PBvh
{
BvhParser parser;

PBvh(String[] data) {
parser = new BvhParser();
parser.init();
parser.parse( data );
}

void update( int ms ) {
parser.moveMsTo( ms );//30-sec loop
parser.update();
}

//------------------------------------------------
void draw() {
// Previous method of drawing, provided by Rhizomatiks/Perfume

fill(color(255));
for ( BvhBone b : parser.getBones()) {
pushMatrix();
translate(b.absPos.x, b.absPos.y, b.absPos.z);
ellipse(0, 0, 2, 2);
popMatrix();
if (!b.hasChildren()) {
pushMatrix();
translate( b.absEndPos.x, b.absEndPos.y, b.absEndPos.z);
ellipse(0, 0, 10, 10);
popMatrix();
}
}
}

//------------------------------------------------
// Alternate method of drawing, added by Golan

void drawBones(int light) {
//noFill();
stroke(255);
strokeWeight(1);

List<BvhBone> theBvhBones = parser.getBones();
int nBones = theBvhBones.size(); // How many bones are there?
BvhBone cBone = theBvhBones.get(1);
PVector boneCoordc = cBone.absPos;
float x2 = boneCoordc.x; // Get the (x,y,z) values
float y2 = boneCoordc.y; // of its start point
float z2 = boneCoordc.z;
/*
BvhBone bBone = theBvhBones.get(16);
PVector boneCoordb = bBone.absPos;
float x3 = boneCoordb.x; // Get the (x,y,z) values
float y3 = boneCoordb.y; // of its start point
float z3 = boneCoordb.z;
line(x2, y2, z2, x3, y3, z3);
*/
BvhBone dBone = theBvhBones.get(0); // Get the i'th bone
println(dBone.getName());
PVector boneCoordx = dBone.absPos; // Get its start point
float xl = boneCoordx.x; // Get the (x,y,z) values
float yl = boneCoordx.y; // of its start point
float zl = boneCoordx.z;
//LIGHT SOURCE


if (light == 1) {
pointLight(255, 255, 225, xl, yl - 60, zl);
}
for (int i=0; i<nBones; i++) { // Loop over all the bones
BvhBone aBone = theBvhBones.get(i); // Get the i'th bone

PVector boneCoord0 = aBone.absPos; // Get its start point
float x0 = boneCoord0.x; // Get the (x,y,z) values
float y0 = boneCoord0.y; // of its start point
float z0 = boneCoord0.z;
String boneName = aBone.getName();

if (aBone.hasChildren()) {
stroke(255);

// If this bone has children,
// draw a line from this bone to each of its children
List<BvhBone> childBvhBones = aBone.getChildren();
int nChildren = childBvhBones.size();
for (int j=0; j<nChildren; j++) {
BvhBone aChildBone = childBvhBones.get(j);
String childName = aChildBone.getName();

PVector boneCoord1 = aChildBone.absPos;

float x1 = boneCoord1.x;
float y1 = boneCoord1.y;
float z1 = boneCoord1.z;
//for (
int cubeNum = 10;
float deltaZ = (z1 - z0)/cubeNum;
float deltaY = (y1 - y0)/cubeNum;
float deltaX = (x1 - x0)/cubeNum;

float maxDelta = max(deltaZ, deltaY, deltaX);
for (int c = 0; c < cubeNum; c++) {
pushMatrix();
noStroke();
translate( x0 + deltaX*c + random(-5, 5), y0+ deltaY*c+ random(-10, 10), z0+ deltaZ*c+ random(-5, 5));
//translate(x0 + deltaX*c, y0+ deltaY*c, z0+ deltaZ*c);
box(random(2, 5));
popMatrix();
}

//line(x0, y0, z0, x1, y1, z1);
}
} else {
// Otherwise, if this bone has no children (it's a terminus)
// then draw it differently.
stroke(255);
PVector boneCoord1 = aBone.absEndPos; // Get its start point
float x1 = boneCoord1.x;
float y1 = boneCoord1.y;
float z1 = boneCoord1.z;

//line(x0, y0, z0, x1, y1, z1);
boneName = aBone.getName();

if (boneName.equals("Head")) {
if (light == 1) {
noStroke();

//stroke(255, 50);
pushMatrix();
translate(x1+random(-5,5), y1+random(-5,5), z1+random(-5,5));
box(8);
popMatrix();
} else {
noStroke();
shininess(1.0);
pushMatrix();
translate(x1+random(-5,5), y1+random(-5,5), z1+random(-5,5));
box(8);
popMatrix();
}
}
}
}
}
}