Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Ian Ross has just released a book on Anim8or. It's perect for a beginner and a good reference for experienced users. It contains detailed chapters on every aspect, with many examples. Get your own copy here: "Anim8or Tutorial Book"

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.

Topics - Trevor

Pages: [1]
1
ASL Scripts / Fast 3D Export (Beta) 0625
« on: May 10, 2020, 12:13:00 pm »
Here is an export plugin for Fast3D at source level.


Debug mode is enabled

ver 20200625 (Beta)
 
 
 
  Features:
  • Duplicate Vertex removal
  • Triangle Sorting
  • Flat Shading
  • Smooth Shading (Lighting only, An8 does not support Vertex Shading)
  • Lighting
  • Fog (Disables Vertex Alpha as N64 places Distance on Vertex Alpha)
  • Texture Mapping
  • Environment Mapping
  • Bounding Box 
  • Bounding Volume Radius - Nothing Output Yet
  • Binary Seperating Plane (Partial Support with Tree traversal)
  • Groups and full hiearchy. Usefull for animation or part culling.   [/color]

 
  Supports:
  • Fast3D (16 vertex cache)(Default)
  • 4Tri   (GE/PD Fast3D Extension) 
  • F3DEX  (32 Vertex Cache, 2Triangles)
  • F3DEX2 (32 Vertex Cache, 2Triangles)   

  WishList:
  Portals (use mesh name "PortalA-B")
  Animations - Translate/Rotate
                        Needs flag IsAnimate else Pre-Calc matrix
                        using $point = $transformMat.Project($point);
 
 
 
 
  Attributes (Case in-sensitive):
    uCode    - Define EITHER a String Attribute with name "uCode" with:
                                             OR
                            Define an Attribute of ANY type with name:
                              Fast3D (default)
                              F3DEX
                              F3DEX2
 
    4 Triangles Extension - Define an Attribute of ANY type with name "TRI4_Ext"
 
    Vertex Cache Override - Define an Integer with name "VtxCacheOvr" (Not Recomended)
 
    Integer Vertices         - Define a Boolean with name "IntVtx" (Default False)
 
    Optimization Level    - Define an Integer with name "Optimize"
                                       0 None
                                       1 Sort Triangles           
                                       2 Trim Duplicate Vertices  (Default)
                                       3 Trim Vertices Aggressive (Not Recomended)
                                                   Ignore ST and RGBA, Force Integer Vertices
 
    Lighting              - Define a Boolean with name "G_LIGHTING" (Default false)
 
    Fog                      - Define a Boolean with name "G_FOG" (Default True)
 
    Auto Sun (Static      - Define a Point with name "AutoSun" (Default False)
          Vertex Shading)  X = Direction(0-360) (North = 0, East = 90 etc)
                                       Y = Azimuth (0-90) where 0 is the Horizon
 
Code: [Select]
  *   Ortho View
 *               90 Y+. Azimuth
 *                   /|\
 *                 .``|``
 *                '   |
 *               -    |
 *              .     |
 *                    |  S  180
 *             E 90   |  /
 *                 '-.|/`
 *           -      /` ```--..
 *           .    /`          ``--..     .
 *         0 .  /`                  ``--:.`.
 *           ./`                       :----' X+ W 270
 *       |'-.`
 *    Z+ ````` N 0
 
  Light direction is "Source" of light
    eg: The sun is in the south (180) at 45 High
 
 
 
 


Result C attached as txt

H
Code: [Select]

/*
* Export object "object01"
*
* Do not edit this file. It was automatically generated
* with Anim8or 1.01 Build 1.01.1378+
* from File "test.an8"
* Using uCode Fast3D
*/

#define G_CC_PASS1 0, 0, 0, 0, 0, 0, 0, 0
#define G_CC_PRIMSHADE PRIMITIVE, 0, SHADE, 0, 0, 0, 0, 1
#define G_CC_PRIMSHADEA PRIMITIVE, 0, SHADE, 0, 0, 0, 0, SHADE
#define G_CC_PRIMSHADEFA PRIMITIVE, 0, SHADE, 0, 0, 0, 0, PRIMITIVE
#define G_CC_SHADE2 PRIMITIVE, 0, SHADE, 0, 0, 0, 0, 1
#define G_CC_SHADE2A PRIMITIVE, 0, SHADE, 0, 0, 0, 0, SHADE
#define G_CC_SHADE2FA PRIMITIVE, 0, SHADE, 0, 0, 0, 0, PRIMITIVE
#define G_CC_MODRGB COMBINED, 0, SHADE, 0, 0, 0, 0, 1
#define G_CC_MODRGBA  COMBINED, 0, SHADE, 0, 0, 0, 0, SHADE
#define G_CC_MODRGBFA COMBINED, 0, SHADE, 0, 0, 0, 0, PRIMITIVE

#define LoadTextureBlock(ltbTextureName, ltbTextureImageFormat, ltbBitDepth, isDetail, width,    \
                         height, pal, cms, cmt, masks, maskt, shifts, shiftt)                    \
                                                                                                 \
        gsDPSetTextureImage(ltbTextureImageFormat, ltbBitDepth##_LOAD_BLOCK, 1, ltbTextureName), \
        gsDPSetTile(ltbTextureImageFormat, ltbBitDepth##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE,        \
                    0 , cmt, maskt,    shiftt, cms, masks, shifts),                              \
        gsDPLoadSync(),                                                                          \
        gsDPLoadBlock(G_TX_LOADTILE, 0, 0,                                                       \
                    (((width)*(height) + ltbBitDepth##_INCR) >> ltbBitDepth##_SHIFT)-1,          \
                    CALC_DXT(width, ltbBitDepth##_BYTES)),                                       \
        gsDPPipeSync(),                                                                          \
        gsDPSetTile(ltbTextureImageFormat, ltbBitDepth,                                          \
                    ((((width) * ltbBitDepth##_LINE_BYTES)+7)>>3), 0,                            \
                    G_TX_RENDERTILE+isDetail, pal, cmt, maskt, shiftt, cms, masks, shifts),      \
        gsDPSetTileltbBitDepthe(G_TX_RENDERTILE+isDetail, 0, 0,                                  \
                    ((width)-1) << G_TEXTURE_IMAGE_FRAC,                                         \
                    ((height)-1) << G_TEXTURE_IMAGE_FRAC)                                       

#define LoadMipMapTile(tmemoffset, rtile, ltbTextureImageFormat, ltbBitDepth, width,             \
                       height, pal, cms, cmt, masks, maskt, shifts, shiftt)                      \
        gsDPSetTile(ltbTextureImageFormat, ltbBitDepth,                                          \
                    ((((width) * ltbBitDepth##_LINE_BYTES)+7)>>3), tmemoffset,                   \
                    rtile, pal, cmt, maskt, shiftt, cms, masks, shifts),                         \
        gsDPSetTileltbBitDepthe(rtile, 0, 0,                                                     \
                    ((width)-1) << G_TEXTURE_IMAGE_FRAC,                                         \
                    ((height)-1) << G_TEXTURE_IMAGE_FRAC)                                       

/* Define Textures */

/*
 * Texture image format :
 *     G_IM_FMT_RGBA(RGBA format)
 *     G_IM_FMT_YUV (YUV format)
 *     G_IM_FMT_CI  (CI format)
 *     G_IM_FMT_IA  (IA format)
 *     G_IM_FMT_I   (I format)
 * Bit Depth :
 *     G_IM_SIZ_8b  (8 bits / texel)
 *     G_IM_SIZ_16b (16 bits / texel)
 *     G_IM_SIZ_32b (32 bits / texel)
 * S T Flags :
 *     G_TX_MIRROR  (enable mirror operations)
 *     G_TX_NOMIRROR(disable mirror operations)
 *     G_TX_WRAP    (enable wrap operations)
 *     G_TX_CLAMP   (enable clamp operations)
 */

/* Assign the corect values for brickdetail4colour Including any Mip-Map Tiles at end. */
#define BRICKDETAIL4COLOUR_Width  32
#define BRICKDETAIL4COLOUR_Height 32
#define BRICKDETAIL4COLOUR_MaskS  Log(BRICKDETAIL4COLOUR_Width) / Log(2)
#define BRICKDETAIL4COLOUR_MaskT  Log(BRICKDETAIL4COLOUR_Height) / Log(2)
#define BRICKDETAIL4COLOUR_DL \
    gsDPPipeSync(),                                                                                                  \
    LoadTextureBlock(&brickdetail4colour,                                                                                            \
                     G_IM_FMT_RGBA, G_IM_SIZ_32b, FALSE, /* Format, BitDepth, isDetail */                            \
                     BRICKDETAIL4COLOUR_Width, BRICKDETAIL4COLOUR_Height, 0,      /* Width, Height, PaletteID   */                                   \
                     S Flags, T Flags,            /* Clamp/Wrap/Mirror          */                                   \
                     BRICKDETAIL4COLOUR_MaskS, BRICKDETAIL4COLOUR_MaskT,          /* Pow 2 Bounds for flag, eg  use 5 for a 32x32 texture (5^2=32) */\
                     ShiftS, ShiftT),             /* Use G_TX_NOLOD             */                                   \
    LoadMipMapTile(0, 0,                          /* TMEM Offset, TileNumber    */                                   \
                     G_IM_FMT_RGBA, G_IM_SIZ_32b, /* Format, BitDepth           */                                   \
                     BRICKDETAIL4COLOUR_Width, BRICKDETAIL4COLOUR_Height, 0,      /* Width, Height, PaletteID   */                                   \
                     S Flags, T Flags,            /* Clamp/Wrap/Mirror          */                                   \
                     BRICKDETAIL4COLOUR_MaskS, BRICKDETAIL4COLOUR_MaskT,          /* Pow 2 Bounds for flag, eg  use 5 for a 32x32 texture (5^2=32) */\
                     ShiftS, ShiftT),             /* Use G_TX_NOLOD             */                                   \
  /* (From here, do LoadMipMapTile for each subsequent tile, eg a 32x32 usually has 6 tiles (0-5))                 */\


Trev

Edit 21:34, Added more draw commands
Edit 02:36, Added Triangle sorting, Auto Sun Baking, some other flags.
Edit 02:08, Added 4Tri and fixed VtxCache to batch by TnL changes and uCode limits (16/32 counts)
Edit 01:17, Added Tree traversal, Bounding boxes and named BSP support

2
Ongoing Anim8or Development / ASL issues
« on: May 05, 2020, 09:46:24 pm »
ASL Bugs and Feature requests as of Build 1379

Nested If statements cannot return to caller, an8 hangs, turns white, titlebar states (Not Responding) and console stops output.
Code: [Select]
// Return True if Vertex Exists, Save NewID Mapping to $gVtxIDMap
int $VertexExists(point3 $xyz, string $uv, point3 $rgb, int $a)
{
int $i, $r;

for ($i = 0; $i < $gXYZs.size; $i++)
{
$DebugPrint(PrintToString("Compare to %d", $i));
// cant do && "Illegal Type arg"
if (($xyz.x == $gXYZs[$i].x) && ($xyz.y == $gXYZs[$i].y) && ($xyz.z == $gXYZs[$i].z))
{
if ($uv == $gSTs[$i])
{
if (($rgb.x == $gRGBs[$i].x) && ($rgb.y == $gRGBs[$i].y) && ($rgb.z == $gRGBs[$i].z))
{
if ($a == $gAs[$i])
{
$gVtxIDMap[$gVtxIDMap.size - 1] = $i;
//return true;
$r = 1; //BUG cannot return from here, this makes script wasteful
}
}
}
}
}
return $r;
}

Attributes cannot return NULL...
workaround: Use a global Attribute and use Push/Size = 0
Code: [Select]
//return $gCurObject.GetAttribute($i);
$gLookupAttributeUcase.push($gCurObject.GetAttribute($i));
return;
}
}
//return NULL;
$gLookupAttributeUcase.size = 0;
}


As Documented already Recursion is not supported, however it would be good to support for parsing trees.
Code: [Select]
void $ParseChildren(shape $Shape)
{
...
$DebugPrint("Parsing Children " + $Shape.name);

if ($Shape.GetKind() == SHAPE_KIND_GROUP)
{
//Recursion Not Supported
$ConsolePrint("Groups are not supported\n");
//$ParseChildren($Shape);
}
...
}


I also put together some functions for people to use but hope for native support for them instead.
Code: [Select]
// Returns Index to start of $Contains if within $Base.
// Returns False if $Base does not contain $Contains
int $StringContains(string $Base, string $Contains)
{
int $i, $r;
string $Comparitor;
//$DebugPrint(PrintToString("looking for %s in %s", $Contains, $Base));
for ($i = 0; $i < max(0,($Base.length - $Contains.length)); $i++)
{
$Comparitor = $Base.SubString($i, ($i + ($Contains.length-1)));
$DebugPrint(PrintToString("contains %s at %d", $Comparitor, $i));
if ($Comparitor == $Contains)
{
$r = $i +1;
break;
}
}
//$DebugPrint(PrintToString("returning %d", $r));

return $r;
}

// Split String $Base anywhere $Split occurs
// Returns Array (via $gSplit) of Strings
int $StringSplit(string $Base, string $Split)
{
int $r, $Start, $End;
$gSplit.size = 0;
while (1)//$StringContains($Base.SubString($Start, $Base.length), $Split))
{
$End = $StringContains($Base.SubString($Start, $Base.length), $Split);

if (!$End)
{
//$r = 0;
$DebugPrint($Base.SubString($Start, $Base.length));
$gSplit.push($Base.SubString($Start, $Base.length));
break;
}
$r++;

$DebugPrint($Base.SubString($Start, $End - 1 - $Split.length));
$gSplit.push($Base.SubString($Start, $End - 1 - $Split.length));
$Start = $Start + ($End-1) + ($Split.length);
}
$DebugPrint(PrintToString("Split legnth %d, contains %s", $gSplit.size, $gSplit[$gSplit.size-1]));
return $r;
}

// Returns String from Array (via $gSplit) of Strings
string $StringJoin()
{
int $i;
string $t;

for($i=0; $i< $gSplit.size; $i++)
{
$t = $t + $gSplit[$i];
}
$gSplit.size = 0;
return $t;
}

// Returns String as UPPER CASE
string $StringToUpper(string $str)
{
int $i, $t;
for ($i = 0; $i < $str.length; $i++)
{
$t = $str.GetChar($i);
if (($t >= 97) && ($t <= 122))
{
$t = $t - 32;
$str = $str.SetChar($t, $i);
}
}
return $str;
}

// Looks up Attribute by Name (Case-insensitive)
void $LookupAttribute(string $str, int $CaseCompare)
{
int $i, $r;
attribute $temp;
if (!$CaseCompare)
{
$str = $StringToUpper($str);
}

$DebugPrint("Looking up Attribute " + $str);

for ($i = 0; $i < $gCurObject.GetNumAttributes(); $i++)
{
$temp = $gCurObject.GetAttribute($i);
if (($StringToUpper($temp.GetName()) == $str) && (!$CaseCompare || ($temp.GetName() == $str)))
{
//return $gCurObject.GetAttribute($i);
$DebugPrint("Found Attribute " + $str);
$gLookupAttribute.push($temp);
$r = true;
break;
}
}
if ($r) return;
//return NULL;
$gLookupAttribute.size = 0;
}

// Convert quaternion to xyz (PYR)
point3 $QuaternionToPYR(quaternion $q) {
point3 $angles;
float $sin_cos, $cos_cos;

// pitch (x-axis rotation)
$sin_cos = 2 * ($q.w * $q.x + $q.y * $q.z);
$cos_cos = 1 - 2 * ($q.x * $q.x + $q.y * $q.y);
$angles.x = atan2($sin_cos, $cos_cos);

// yaw (y-axis rotation)
$sin_cos = 2 * ($q.w * $q.y - $q.z * $q.x);
if (abs($sin_cos) >= 1)
{
$angles.y = clamp($sin_cos, -PI / 2, PI / 2); // use 90 degrees if out of range
}
else
{
$angles.y = asin($sin_cos);
}

// role (z-axis rotation)
$sin_cos = 2 * ($q.w * $q.z + $q.x * $q.y);
$cos_cos = 1 - 2 * ($q.y * $q.y + $q.z * $q.z);
$angles.z = atan2($sin_cos, $cos_cos);

return $angles;
}

// Returns the integral value that is nearest to val, with halfway cases rounded away from zero.
int $round(float $val)
{
if ($val >= 0)
{
if (fract($val) >= 0.5)
{
return ceil($val);
}
else
{
return floor($val);
}
}
if (fract($val) > -0.5)
{
return ceil($val);
}
//else
return floor($val);
}

//Cast To Integer
int $int(float $val)
{
return $val;
}

//Cast to Float
float $float(int $val)
{
return $val;
}


I also took the documentation and put it in a h file for use in VS.
I shifted the comments round so it works with Intellisense and word completion as you type.

Which reminds me, any chance of ignoring #include "a8s.h" and then including other script files?
Also #if(0) #endif would be good to block certain code blocks from functioning

Many Thanks
Trev[/code]

3
Finished Works and Works in Progress / Diffuse Inter-Reflection Test
« on: October 23, 2017, 11:18:14 am »
I was in the process of making a lighting tutorial for PerfectGold when I wanted some comparison shots from An8.
Ive mentioned in the past about ART needing Diffuse Inter-Reflection and ToneMapper but I simulated it with Glossyreflector.

My material settings are crazy
Ambient 0
Diffuse 20 + texture
Specular 0.95 + Texture
Roughness 0

Setting specular to 1 means diffuse doesn't work

Scene Lighting set to 1 for exterior, 4 for interior

Im quite sure these would be much better (not to mention easier to set up) if an8 suported it as a checkbox
Also note that Ambient Occlude is NOT on, AmbOcc is a simplified DIR.

The results

4
Ongoing Anim8or Development / Problem with Local Lights
« on: March 03, 2015, 07:34:26 am »
well, they just dont give any light. Everything is black unless an infinit or spot light is added.

This is in raytracing mode, not scanline.

Oh... Odd... now Im testing its working again... ok... so, it must be the polycount that makes it fail.
Both previous times I tried I had high polycounts and they refused to light anything. I ckecked the face-oriantation but that didnt help.

OHHH! I found the bug.

Local Lights only work in camera mode.

Just going to test that in a new project by adding just 1 light.
Ok, definatly confirmed, local lights only work in camera, not ortho or perspective.

Trev

Pages: [1]