Dryden

03 March 2009, 04:47 PM

Hi,

I'm working since few weeks on a custom exporter to a real time engine.

I can export mesh, textures without issue. But about animation I still have trouble.

The following code show the matrix creation (performed for each bones), so I guess I'm gonna have issue with parenting animation.

If u have any idea about how to deal with... (translation matrix is the only one who works actually)

string $return = "";

//Gathering data from current bones

// Gathering data from world space for translation, to try to go trought the parent inherit translation

float $t[] = `xform -q -ws -t $bonesName`;

float $s[] = `getAttr ($bonesName+".s")`;

float $r[] = `getAttr ($bonesName+".r")`;

//Initialize matrices

matrix $translate [4][4];

matrix $scale [4][4];

matrix $rotateX [4][4];

matrix $rotateY [4][4];

matrix $rotateZ [4][4];

matrix $multi [4][4];

//Fill Matrices

$scale = <<$s[0],0,0,0; 0,$s[1],0,0; 0,0,$s[2],0; 0,0,0,1>>;

$translate = <<1,0,0,0; 0,1,0,0; 0,0,1,0; $t[0],$t[1],$t[2],1>>;

$rotateX = <<1,0,0,0; 0,`cos $r[0]`,`sin $r[0]`,0; 0,-(`sin $r[0]`),`cos $r[0]`,0; 0,0,0,1>>;

$rotateY = <<`cos $r[1]`,0,-(`sin $r[1]`),0; 0,1,0,0; `sin $r[1]`,0,`cos $r[1]`,0; 0,0,0,1>>;

$rotateZ = <<`cos $r[2]`,`sin $r[2]`,0,0; -(`sin $r[2]`),`cos $r[2]`,0,0; 0,0,1,0; 0,0,0,1>>;

//Combine them.

$multi = $scale * $rotateX * $rotateY * $rotateZ * $translate; // ????

for($i=0;$i<4;$i++)

{

for($j=0;$j<4;$j++)

{

if(($i == 3) && ($j == 3))

{

$return += "M"+($i+1)+"."+($j+1)+":"+$multi[$i][$j];

}else{

$return += "M"+($i+1)+"."+($j+1)+":"+$multi[$i][$j]+",";

}

}

}

I'm working since few weeks on a custom exporter to a real time engine.

I can export mesh, textures without issue. But about animation I still have trouble.

The following code show the matrix creation (performed for each bones), so I guess I'm gonna have issue with parenting animation.

If u have any idea about how to deal with... (translation matrix is the only one who works actually)

string $return = "";

//Gathering data from current bones

// Gathering data from world space for translation, to try to go trought the parent inherit translation

float $t[] = `xform -q -ws -t $bonesName`;

float $s[] = `getAttr ($bonesName+".s")`;

float $r[] = `getAttr ($bonesName+".r")`;

//Initialize matrices

matrix $translate [4][4];

matrix $scale [4][4];

matrix $rotateX [4][4];

matrix $rotateY [4][4];

matrix $rotateZ [4][4];

matrix $multi [4][4];

//Fill Matrices

$scale = <<$s[0],0,0,0; 0,$s[1],0,0; 0,0,$s[2],0; 0,0,0,1>>;

$translate = <<1,0,0,0; 0,1,0,0; 0,0,1,0; $t[0],$t[1],$t[2],1>>;

$rotateX = <<1,0,0,0; 0,`cos $r[0]`,`sin $r[0]`,0; 0,-(`sin $r[0]`),`cos $r[0]`,0; 0,0,0,1>>;

$rotateY = <<`cos $r[1]`,0,-(`sin $r[1]`),0; 0,1,0,0; `sin $r[1]`,0,`cos $r[1]`,0; 0,0,0,1>>;

$rotateZ = <<`cos $r[2]`,`sin $r[2]`,0,0; -(`sin $r[2]`),`cos $r[2]`,0,0; 0,0,1,0; 0,0,0,1>>;

//Combine them.

$multi = $scale * $rotateX * $rotateY * $rotateZ * $translate; // ????

for($i=0;$i<4;$i++)

{

for($j=0;$j<4;$j++)

{

if(($i == 3) && ($j == 3))

{

$return += "M"+($i+1)+"."+($j+1)+":"+$multi[$i][$j];

}else{

$return += "M"+($i+1)+"."+($j+1)+":"+$multi[$i][$j]+",";

}

}

}