Anim8or Community

General Category => ASL Scripts => Topic started by: BOB_I_Ts on March 22, 2010, 03:10:12 pm

Title: assistant~script reverse normals !
Post by: BOB_I_Ts on March 22, 2010, 03:10:12 pm
i made mini script to help reduce amount of time to put coordinates into a8s script it works perfect for the task it was indented but the vertexn  output has the sequence in reverse so faces on the generate data are flipped around the wrong way?

here is the assistant script originaly based from looking at the code in Steves obj export script
Code: [Select]
/* assistant script v0.02 ~ object mesh wirecage must match to work on final a8s*/
#plugin("object", "export", "a8s quicky", ".txt");
#file($output, "text");
file $output;
int $result;

object $curObject;
shape $shape;
meshdata $mdata,$mdat1,$mdat2;
int $numPoints,$numfaces,$numsides;
int $totalP,$totaln;
int $ii,$jj;
int $tshape;
point3 $point,$m1,$m2,$m1f,$m2f;
float4x4 $transp;
string $aname,$bname,$cname;

/*(search mesh by name temp code) */

$aname = "cage";
$bname = "morph1";
$cname = "morph2";

for $tshape = 0 to 2 do {
if ($tshape == 0 ) {
$shape = project.curObject.LookupShape($aname);
if ($tshape == 1 ) {
$shape = project.curObject.LookupShape($bname);
if ($tshape == 2 ) {
$shape = project.curObject.LookupShape($cname);

$curObject = project.curObject; /*access the active object mode !*/
$output.print("#object \"%s\":\n",$; /*this line not needed in final script*/
$mdata = $shape.GetMeshData(); /*shape load the data*/
$transp = $shape.GetGlobalTransform(); /*transp search the data matrix !*/
$numPoints = $mdata.GetNumPoints(); /*counts the points*/

for $ii = 0 to $numPoints - 1 do {
$point = $mdata.GetPoint($ii);
$point = $transp.Project($point);
$output.print("$p.x = %.6g ; $p.y = %.6g ; $p.z = %.6g ; $index[",$point);
$output.print("%d", $ii);
$output.print("] = $face.AddPoint($p); \n");

$numfaces = $mdata.GetNumFaces();

for $ii = 0 to $numfaces - 1 do {
$numsides = $mdata.GetNumSides($ii);
for $jj =  0 to $numsides -1 step 1 do {
$output.print("%d",$mdata.GetFacePointIndex($ii,$jj) );
$output.print("$face.CloseFace(); \n");


current planning v0.3

~ reminder find out how to get script to print font (") to files
~ add a8s parameters to exported file

goal = (cage coordinate) +/- (morph cordinate) * by  100 = #parameter 

~finding the morph should go somthing like !
if ($point.x > $m1.x ) {
$m1f = $point.x - $m1.x;

if ($point.x < $m1.x ) {
$m1f = $point.x - $m1.x;


edit: haven't had time to play with scripts have an abandoned siberian husky pup which isnt  house trained yet keeping me on constantly on my toes ...much more difficult than a german shepherd to house train :'(
Title: Re: assistant~script reverse normals !
Post by: Kubajzz on March 22, 2010, 05:44:05 pm
Interesting script BOB_I_Ts!

If the normals are reversed, you need to reverse the order of vertices in each face. Change the loop where you are calling "VertexN" to make it go the opposite way, that should fix the problem...

I guess you are going to use this script for your generic head script... Good luck with that, I'd love to see it finished.
Title: Re: assistant~script reverse normals !
Post by: BOB_I_Ts on March 22, 2010, 09:59:42 pm
Duh slaps head so obvious.

"for $jj =  0 to $numsides -1 step 1 do {---}" thanks for reminder it will certainly  reduce the mountain of cords 630 point3 coords :-\

asl doesnt search morph data that im aware of so id need to probably separate morphs into mesh of same curobject then rename them so script can search and compare them (after all the point index should still be identical !) then tweak exporter with something like
if point3 > do morph value - parent value */which should return morph coordinate !
then if point3 < do parent value - morph value
then == skip print  $ii = $ii + 1
... anim8or asl will practically write script for me i hope .... john connar shouldn't be worried about sky net he should worry about asl.