Maybe it's just a newbie error, but here's the error message I get when I try to load my bvh file with the moD_demo.pde provided by Xer (http://processing.org/discourse/yabb_beta/YaBB.cgi?board=os_libraries_tools;action=display;num=1164867108;start=7#7)
Code:
java.lang.ArrayIndexOutOfBoundsException: 8
at BVH.ImportData(BVH.java:920)
at MotionData.<init>(MotionData.java:30)
at Temporary_9553_4774.setup(Temporary_9553_4774.java:37)
at processing.core.PApplet.handleDisplay(PApplet.java:1384)
at processing.core.PGraphics.requestDisplay(PGraphics.java:690)
at processing.core.PApplet.run(PApplet.java:1556)
at java.lang.Thread.run(Thread.java:613)
java.lang.ArrayIndexOutOfBoundsException: 8
at BVH.ImportData(BVH.java:920)
at MotionData.<init>(MotionData.java:30)
at Temporary_9553_4774.setup(Temporary_9553_4774.java:37)
at processing.core.PApplet.handleDisplay(PApplet.java:1384)
at processing.core.PGraphics.requestDisplay(PGraphics.java:690)
at processing.core.PApplet.run(PApplet.java:1556)
at java.lang.Thread.run(Thread.java:613)
Here's the source code of moD_Demo.pde:
Code:
import processing.opengl.*;
MotionData motion_data; // <==================== Add MoD library
int NumOfSegs;
int NumOfFrames;
int FrameRate;
static final int _W=1; // joint width
static final int _F=100; // joint scaler
static final int _NUM_FILES=1;
static final int _START_FILE=1;
double [][][]p0;
double [][][]p1;
boolean [][]isEP;
int f;
void setup()
{
String []filename=new String [_NUM_FILES];
int i;
// init frame number
f=0;
// set filenames list
//
// I'm not using this loop to load the bvh files.
//
/* for(i=0;i<_NUM_FILES;i++)
{
if((i+_START_FILE)<10)
filename[i]= "//bvh\\motion0"+(i+_START_FILE)+".bvh";
else
filename[i]= "C:\\bvh\\motion"+(i+_START_FILE)+".bvh";
System.out.println(filename[i]);
}*/
//
// Instead I put my url in the first position of the array. Is that what causes
// the error ? Doesn't seem so.
//
filename[0] = "azumi.bvh";
// startup a class
MotionData motion_data = new MotionData(filename);
// get info
NumOfSegs = motion_data.GetNumberOfSegments();
NumOfFrames = motion_data.GetNumberOfFrames();
FrameRate = motion_data.GetFrameRate();
System.out.println("Number of Segments ="+NumOfSegs);
System.out.println("Number of Frames ="+NumOfFrames);
System.out.println("Number of FrameRate ="+FrameRate);
// set frame rate
frameRate(FrameRate);
// setup joint data
p0 = new double [NumOfFrames][NumOfSegs][3];
p1 = new double [NumOfFrames][NumOfSegs][3];
isEP = new boolean [NumOfFrames][NumOfSegs];
for(f=0; f<NumOfFrames; f++)
motion_data.GetFrameObject(p0[f], p1[f], isEP[f], f);
// smooth out the motion
motion_data.FilterObject(p0,p1,NumOfSegs,NumOfFrames);
System.out.println("===========================");
size(1024, 768, OPENGL);
noStroke();
}
void draw()
{
double vx,vy,vz;
translate(width/2, height/2);
// color of joints
fill(0, 0, 0);
background(200);
// render the frame
if(f==NumOfFrames) f=0;
for(int i=0; i<NumOfSegs; i++)
{
beginShape(QUADS);
vx = _F*p0[f][i][0]; vy = _F*p0[f][i][1]-_W; vz = _F*p0[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p0[f][i][0]; vy = _F*p0[f][i][1]+_W; vz = _F*p0[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p1[f][i][0]; vy = _F*p1[f][i][1]+_W; vz = _F*p1[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p1[f][i][0]; vy = _F*p1[f][i][1]-_W; vz = _F*p1[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
endShape();
beginShape(QUADS);
vx = _F*p0[f][i][0]-_W; vy = _F*p0[f][i][1]; vz = _F*p0[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p0[f][i][0]+_W; vy = _F*p0[f][i][1]; vz = _F*p0[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p1[f][i][0]+_W; vy = _F*p1[f][i][1]; vz = _F*p1[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p1[f][i][0]-_W; vy = _F*p1[f][i][1]; vz = _F*p1[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
endShape();
}
// update the next frame number
f++;
}
Finally, here's the bvh file I'm trying to load. It's a pretty long bvh file. http://www.glockenspiel.ca/transfert/azumi.bvh
Also, when I load the pde file, it automatically open an untitled sketch with it. Am I missing some files with it ?
Do you have a working example I could perhaps take a look at ?