Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ckfg committed Oct 17, 2011
0 parents commit 252160c
Show file tree
Hide file tree
Showing 8 changed files with 35,836 additions and 0 deletions.
121 changes: 121 additions & 0 deletions Data.pde
@@ -0,0 +1,121 @@
///////////////////////////
// DATA CLASS
// Marius Watz - http://workshop.evolutionzone.com

class Data {
ArrayList datalist;
String filename,data[];
int datalineId;

// begin data saving
void beginSave() {
datalist=new ArrayList();
}

void add(String s) {
datalist.add(s);
}

void add(float val) {
datalist.add(""+val);
}

void add(int val) {
datalist.add(""+val);
}

void add(boolean val) {
datalist.add(""+val);
}

void endSave(String _filename) {
filename=_filename;

data=new String[datalist.size()];
data=(String [])datalist.toArray(data);

saveStrings(filename, data);
println("Saved data to '"+filename+
"', "+data.length+" lines.");
}

void load(String _filename) {
filename=_filename;

datalineId=0;
data=loadStrings(filename);
println("Loaded data from '"+filename+
"', "+data.length+" lines.");
}

float readFloat() {
return float(data[datalineId++]);
}

int readInt() {
return int(data[datalineId++]);
}

boolean readBoolean() {
return boolean(data[datalineId++]);
}

String readString() {
return data[datalineId++];
}

// Utility function to auto-increment filenames
// based on filename templates like "name-###.txt"

public String getIncrementalFilename(String templ) {
String s="",prefix,suffix,padstr,numstr;
int index=0,first,last,count;
File f;
boolean ok;

first=templ.indexOf('#');
last=templ.lastIndexOf('#');
count=last-first+1;

if( (first!=-1)&& (last-first>0)) {
prefix=templ.substring(0, first);
suffix=templ.substring(last+1);

// Comment out if you want to use absolute paths
// or if you're not using this inside PApplet
if(sketchPath!=null) prefix=savePath(prefix);

index=0;
ok=false;

do {
padstr="";
numstr=""+index;
for(int i=0; i< count-numstr.length(); i++) padstr+="0";
s=prefix+padstr+numstr+suffix;

f=new File(s);
ok=!f.exists();
index++;

// Provide a panic button. If index > 10000 chances are it's an
// invalid filename.
if(index>10000) ok=true;

}
while(!ok);

// Panic button - comment out if you know what you're doing
if(index> 10000) {
println("getIncrementalFilename thinks there is a problem - "+
"Is there more than 10000 files already in the sequence "+
" or is the filename invalid?");
println("Returning "+prefix+"ERR"+suffix);
return prefix+"ERR"+suffix;
}
}

return s;
}

}
81 changes: 81 additions & 0 deletions FlaePin.pde
@@ -0,0 +1,81 @@
import proxml.*;

Data data;

int sW = 720;
int sH = 405;
int fps = 24;

proxml.XMLElement keyFrameList;
XMLInOut xmlIO;
boolean loaded = false;

String[] oscNames = {
"r_hand","r_elbow","r_shoulder", "l_hand","l_elbow","l_shoulder","head"
};

int[] pinNums = {
1,2,3,4,5,6,7
};

float posX,posY,posZ;


void setup() {
//size(sW,sH);
//frameRate(fps);

xmlIO = new XMLInOut(this);
try {
xmlIO.loadElement("mocapData.xml"); //loads the XML
}
catch(Exception e) {
//if loading failed
println("Loading Failed");
}

data = new Data();
data.beginSave();
data.add("Adobe After Effects 8.0 Keyframe Data");
data.add("\r");
data.add("\t"+"Units Per Second"+"\t"+fps);
data.add("\t"+"Source Width"+"\t"+"100");
data.add("\t"+"Source Height"+"\t"+"100");
data.add("\t"+"Source Pixel Aspect Ratio"+"\t"+"1");
data.add("\t"+"Comp Pixel Aspect Ratio"+"\t"+"1");
}

void xmlEvent(proxml.XMLElement element) {
//this function is ccalled by default when an XML object is loaded
keyFrameList = element;
//parseXML(); //appelle la fonction qui analyse le fichier XML
loaded = true;
}

void draw() {
if(loaded) {

for(int j=0;j<oscNames.length;j++){
data.add("\r");
data.add("Effects" + "\t" + "Puppet #2" + "\t" + "arap #3" + "\t" + "Mesh" + "\t" + "Mesh #1" + "\t" + "Deform" + "\t" + "Pin #" + pinNums[j] + "\t" + "Position");
data.add("\t" + "Frame" + "\t" + "X pixels" + "\t" + "Y pixels");
for(int i=0;i<keyFrameList.countChildren();i++) { // i=1 because 0 is the frame number
data.add("\t" + i
+ "\t" + (sW * float(keyFrameList.getChild(i).getChild(j+1).getChild(0).getChild(0).toString()))
+ "\t" + (sH * float(keyFrameList.getChild(i).getChild(j+1).getChild(1).getChild(0).toString()))); //gets to the child we need //gets to the child we need
}
}


data.add("\r");
data.add("\r");
data.add("End of Keyframe Data");
data.endSave(
data.getIncrementalFilename(
sketchPath("save"+
java.io.File.separator+
"data ####.txt")));
exit();
}
}

Binary file added data/.DS_Store
Binary file not shown.

0 comments on commit 252160c

Please sign in to comment.