Alright, so I decided to flesh out some of the other viewer elements first.
Firstly, I added .a8s embedded support. What this does is embed the contents of a .a8s file directly within the post with syntax highlighting.
I also added the asl tags so that you can embed ASL just by copying and pasting into those tags. The syntax would be
[asl title="optional"]ASL Script[/asl]
If a title isn't given, "ASL Snippet" is used instead. Please note that the syntax highlighter isn't very mature yet, and will be fleshed out over time.
Finally, I added options for the video attachments. You can now set to enable/disable the controls, autoplay, or loop.
Related to that, I'm replacing "an8={}" for the more universal "options={}". Please use that instead (first post will be updated to reflect this).
Examples.a8s Attachment:
[attach]1[/attach]
ASL code snippet:
[asl]ASL Text (not shown in full here)[/asl]
ASL Snippet
/**
* @author Randall Bezant (aka Raxx)
* @attribution "Fast, Minimum Storage Ray/Triangle Intersection" by Tomas Moller and Ben Trumbore:
* http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf
*
* @param <point3> $v0, $v1, $v2 - The three points of the colliding triangle in clockwise direction
* @param <point3> $rSource - Ray source point
* @param <point3> $rDir - Ray Direction
*
* @return point2 - If collision, returns the length along the ray direction (known as t),
* and collided indicator of 1 for a value of (1, t). Otherwise returns (0, 0). If t is negative,
* that means it collided in the opposite direction of the specified ray direction, behind the
* ray source.
*
* Single-sided ray/triangle intersection method. To get the point of intersection on the triangle,
* use this formula:
*
* pI = p + t*d
*
* pI: Point of intersection (point3)
* p: Ray source (point3)
* t: length along ray (float)
* d: Ray direction (point3)
*
*/
point2 $rayTriangleIntersect (point3 $V0, point3 $V1, point3 $V2, point3 $rSource, point3 $rDir)
{
// Determinant
point3 $pvec, $tvec, $qvec, $edge1, $edge2;
float $determinant, $triangleV, $triangleU;
$edge1 = $V1 - $V0;
$edge2 = $V2 - $V0;
$pvec = cross($rDir, $edge2);
$determinant = dot($edge1, $pvec);
if ($determinant < 0.000001)
return (0,0);
$tvec = $rSource - $V0;
$triangleU = dot($tvec, $pvec);
if($triangleU < 0.0 || $triangleU > $determinant)
return (0,0);
$qvec = cross($tvec, $edge1);
$triangleV = dot($rDir, $qvec);
if ($triangleV < 0.0 || $triangleU + $triangleV > $determinant)
return (0,0);
return (1, dot($edge2, $qvec) / $determinant);
}