Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

An update to Anim8or, v1.00b, is available with a few bug fixes. Get your copy HERE. See the "ReadMe" file for details.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - CobraSpectre

Pages: [1] 2 3
1
ASL Scripts / Updated Mirroring Script
« on: September 29, 2008, 05:12:56 am »
New version info:

Instead of using the mesh's name, select the mesh to mirror before running the script.

You can choose to mirror the X, Y, or Z axis. It defaults to X automatically. For Y and Z, create a string attribute named "Mirror" with a value of "Y" or "Z".

Code: [Select]
#command("object");

/* X, Y, Z axis mesh mirror, USE AT YOUR OWN RISK */

shape $S, $NewS, $AS[0], $AS2[0];
attribute $Attr, $AxisAttr;
int $i, $j;
point3 $pointedit;
quaternion $rotation;
string $AxisStr;

project.curObject.GetShapes($AS);

for $i = $AS.size-1 to 0 step -1 do {
  if ($AS[$i].Selected == 1)
    $AS2.push($AS.pop());
  else
    $AS.pop();
}

if ($AS2.size == 1)
  $S = $AS2[0];

if ($S.Selected == 1) {

$Attr = project.curObject.LookupAttribute("STOP");

/* create a copy */
$NewS = mesh();


while ($Attr == NULL) {

  $NewS.Open();

  /* copy the points and faces */
  for $i = 0 to $NewS.GetNumPoints()-1 do {
    $NewS.SetPointSelected($i, true);
  }
  $NewS.DeleteSelectedPoints();

  $AxisAttr = project.curObject.LookupAttribute("Mirror");
  $AxisStr = $AxisAttr.GetStringValue();

  if ($AxisStr != "Y" && $AxisStr != "Z") { /* X axis mirror is default behavior */
    /* correct orientaton for X*/
    $rotation = $S.orientation;
    $rotation.y = -$rotation.y;
    $rotation.z = -$rotation.z;
    $NewS.orientation = $rotation;

    for $i = 0 to $S.GetNumPoints()-1 do {
      $pointedit = $S.GetPoint($i);
      $pointedit.x = -$pointedit.x; /* mirror around X axis */
      $NewS.AddPoint($pointedit);
    }
  }

  if ($AxisStr == "Y") {
    /* correct orientaton for Y*/
    $rotation = $S.orientation;
    $rotation.x = -$rotation.x;
    $rotation.z = -$rotation.z;
    $NewS.orientation = $rotation;

    for $i = 0 to $S.GetNumPoints()-1 do {
      $pointedit = $S.GetPoint($i);
      $pointedit.y = -$pointedit.y; /* mirror around Y axis */
      $NewS.AddPoint($pointedit);
    }
  }

  if ($AxisStr == "Z") {
    /* correct orientaton for Z*/
    $rotation = $S.orientation;
    $rotation.x = -$rotation.x;
    $rotation.y = -$rotation.y;
    $NewS.orientation = $rotation;

    for $i = 0 to $S.GetNumPoints()-1 do {
      $pointedit = $S.GetPoint($i);
      $pointedit.z = -$pointedit.z; /* mirror around Z axis */
      $NewS.AddPoint($pointedit);
    }
  }

  for $i = 0 to $S.GetNumFaces()-1 do {
    $NewS.OpenFace(0, 0);
    for $j = 0 to $S.GetNumSides($i)-1 do {
      $NewS.VertexN($S.GetFacePointIndex($i, $S.GetNumSides($i)-1-$j));
    }
    $NewS.CloseFace();
  }

    $NewS.Close();

  /* check for attribute to stop the cycle */
  $Attr = project.curObject.LookupAttribute("STOP");
}
}

2
Anim8or v0.98 Discussion Forum / Re: Bad meshdata from subdivision?
« on: September 26, 2008, 11:50:25 pm »
It appears the meshdata can change while faces are being added.

If you put a refresh() after $NewS.VertexN or $NewS.CloseFace() the display is refreshed after every face is added, which slows it down and you can see what's happening. If a subd's points are moved they begin drawing to produce a messed up mesh or it causes an error.

If $M = $S.GetMeshData() is moved above the while loop, it will draw correctly until the points are moved on a subd. The original mesh is then drawn instead, but does not update point changes.

3
Anim8or v0.98 Discussion Forum / Bad meshdata from subdivision?
« on: September 26, 2008, 07:05:06 am »
I've been working on the mirroring script so that it supports subdivision elements as its source. In order to do this I've changed the code so that it pulls point data from a meshdata and not a shape.

At this point, the script works fine, until it doesn't. When using a subd it will occasionally get an error of "*** Out of bounds memory reference in script ***". Based on the line errors it appears to happen on commands like $M.GetNumSides().

I've never had it fail on a mesh or a mesh > subd > mesh.

The most reliable way to get it to error is to have a subd, select some or all points, then keep moving or rotating them to different positions. Eventually, it causes an error.

Using .97d. Remember, the subd has to be named "mesh01"

Code: [Select]
#command("object");

/* Y axis mesh mirror, USE AT YOUR OWN RISK */

shape $S, $NewS;
meshdata $M;
attribute $Attr;
int $i, $j, $sides;
point3 $pointedit;
quaternion $rotation;

$S = project.curObject.LookupShape("mesh01"); /*get the original shape */

if ($S != NULL) {

$Attr = project.curObject.LookupAttribute("STOP");

/* create a copy */
$NewS = mesh();


while ($Attr == NULL) {

  $M = $S.GetMeshData();

  $NewS.Open();

  /* copy the points and faces */
  for $i = 0 to $NewS.GetNumPoints()-1 do {
    $NewS.SetPointSelected($i, true);
  }
  $NewS.DeleteSelectedPoints();

  /* correct orientaton */
  $rotation = $S.orientation;
  $rotation.y = -$rotation.y;
  $rotation.z = -$rotation.z;
  $NewS.orientation = $rotation;

  for $i = 0 to $M.GetNumPoints()-1 do {
    $pointedit = $M.GetPoint($i);
    $pointedit.x = -$pointedit.x; /* mirror around Y axis, make x points negative */
    $NewS.AddPoint($pointedit);
  }

  for $i = 0 to $M.GetNumFaces()-1 do {
    $sides = $M.GetNumSides($i);
    $NewS.OpenFace(0, 0);
    for $j = 0 to $M.GetNumSides($i)-1 do {
      $NewS.VertexN($M.GetFacePointIndex($i, $sides-1-$j));
    }
    $NewS.CloseFace();
  }

    $NewS.Close();

  /* check for attribute to stop the cycle */
  $Attr = project.curObject.LookupAttribute("STOP");
}

}


4
ASL Scripts / Re: EXPERIMENTAL Mirroring Script
« on: September 24, 2008, 11:12:37 pm »
Oops, fixed now.

5
ASL Scripts / EXPERIMENTAL Mirroring Script
« on: September 24, 2008, 10:37:09 pm »
First, I have to thank Kubajzz for finding this 'feature' in anim8or. The code below is obviously built on his code.

Second, this is still highly experimental, it causes my CPU to go to 100% utilization which may cause problems and random restarts due to heat. Use at your own risk.

Notes:
  • This attempts to create real time mirroring for modeling. A new mesh is created that is mirrored around the X axis. Point edits, and object rotation carry over to the mirrored mesh. Materials work depending on situation, texture coordinates have not been tested.
  • Adding the open and close to the mesh at each cycle prevents RAM use from going out of control while removing the condition to update. RAM and page file may still go up, please monitor them from the Task Manager.
  • It appears to be possible to catch the mesh mid-update and it may not draw correctly. Interface workaround: if you are using the one display or four display pressing "1" or "4" respectively will force anim8or to redraw.
  • Either mesh can be moved without affecting the other. The mirrored mesh can be added to a group without a problem and can be independently rotated.
  • The script looks for a mesh named "mesh01" to mirror.
  • The script exits when there is an attribute named "STOP".
  • Exiting anim8or without stopping the script causes anim8or to quit with an error.
  • When switching to other modes CPU stays at full, CPU drops when a menu is opened.
  • Running this script prevents other scripts from running.

There's still more that can be done to improve the script. I'm hoping Anim8or can improve to make this easier to work with.

Update:
Correct Normals
Code: [Select]
#command("object");

/* X axis mesh mirror, USE AT YOUR OWN RISK */

shape $S, $NewS;
attribute $Attr;
int $i, $j;
point3 $pointedit;
quaternion $rotedit;

$S = project.curObject.LookupShape("mesh01"); /*get the original shape */

if ($S != NULL) {

$Attr = project.curObject.LookupAttribute("STOP");

/* create a copy */
$NewS = mesh();


while ($Attr == NULL) {

  $NewS.Open();

  /* copy the points and faces */
  for $i = 0 to $NewS.GetNumPoints()-1 do {
    $NewS.SetPointSelected($i, true);
  }
  $NewS.DeleteSelectedPoints();

  /* correct orientaton */
  $rotedit = $S.orientation;
  $rotedit.y = -$rotedit.y;
  $rotedit.z = -$rotedit.z;
  $NewS.orientation = $rotedit;

  for $i = 0 to $S.GetNumPoints()-1 do {
    $pointedit = $S.GetPoint($i);
    $pointedit.x = -$pointedit.x; /* mirror around X axis, invert x values*/
    $NewS.AddPoint($pointedit);
  }

  for $i = 0 to $S.GetNumFaces()-1 do {
    $NewS.OpenFace(0, 0);
    for $j = 0 to $S.GetNumSides($i)-1 do {
      $NewS.VertexN($S.GetFacePointIndex($i, $S.GetNumSides($i)-1-$j));
    }
    $NewS.CloseFace();
  }

    $NewS.Close();

  /* check for attribute to stop the cycle */
  $Attr = project.curObject.LookupAttribute("STOP");
}

}

6
ASL Scripts / Re: Real time command scripts
« on: September 22, 2008, 05:18:35 pm »
It's probably not a good idea to use this. Anim8or starts using all the CPU, ram use climbs and page file climbs as well.

7
ASL Scripts / Re: Real time command scripts
« on: September 22, 2008, 05:03:50 pm »
If you change:

Code: [Select]
if ($S.GetNumPoints != $NewS.GetNumPoints)
to

Code: [Select]
if ($S != $NewS)
It updates when you move points. However if I use the cut tool on the shape I get an several errors "SimpleSolid::VertexN: Bad point index" that I have to click through, but then it's okay.

Very cool capability.

8
Anim8or v0.98 Discussion Forum / Re: A list of ideas for anim8or
« on: September 21, 2008, 05:23:10 am »
Bone inserting is something that's been added to Anim8or.

In figure mode it's under Build > Insert Bone.

9
I think what you want is a premultiplied alpha. Currently your edges become a partially transparent combination of the object color and the background color. The premultiplied alpha makes your edges the object color only.

You might be able to try rendering large and resizing. Render without AA at a size that is 2x, 4x, 8x, etc larger than you want. Bring it into a photo editing program like GIMP, delete the background making it transparent. Then resize it down to the correct size.

10
Anim8or v0.98 Discussion Forum / Re: ortho view in scene mode
« on: September 10, 2008, 07:31:53 pm »
It is gone from the view menu, but you can still use it.

Either click on the view descriptor in the top left of the view, "Front", for example, and choose Ortho.

You can also press 9 on the num pad.

11
An object's Pivot is one of the things that is not accessible with scripts. If pivot was scriptable it could be moved for specific rotations.


12
ASL Scripts / Re: New ASL Functions in v0.97b update
« on: June 06, 2008, 02:15:58 am »
Does the console write only work from an export script?

13
Anim8or v0.98 Discussion Forum / Re: v0.97b Preview Ready
« on: June 06, 2008, 02:09:30 am »
Great to see multithreading.

In case of confusion, you don't need multiple cores to use this feature. It lets you do things like minimize and switch windows, then return and see the rendering progress.

14
General Anim8or Forum / GPU Gems available free online
« on: May 14, 2008, 09:32:32 pm »
Nvidia has put GPU Gems online in HTML form. It has lots of great articles about real time graphic programming and techniques.

Read it here

You may also be interested in knowing that Steve contributed chapter 20 Texture Bombing.

15
General Anim8or Forum / An8zip - texture packager for Anim8or
« on: May 08, 2008, 03:43:49 am »
An8zip is a stand alone utility that searches an anim8or file for the images that are used and then packages the anim8or file and images into a zip.

An8zip does not modify or write to the anim8or file, though you should still have a backup. If not all images were found, try resaving the anim8or file in Anim8or.

Download it, try it out, and please report any problems. I've only tested with Windows XP.


Known Issues:

Only the file location saved in the anim8or file is searched.

Images that have the same filename but a different directory are not handled. The image name must be changed.

Directory structure is not preserved.

Windows 95/98/ME may require w9xpopen.exe to run.

Download from Anim8or.org from the attachments of the first post or try this direct link to An8zip_v1.zip

Pages: [1] 2 3