General Category > ASL Scripts

The Plane Primitive

(1/1)

flametiger74:
Hey all
I was trying to figure out a script by Tyson Collins (AKA Null) and I was wondering if someone could explain to me some of the things Here's the script I added some questions which are blue. One last thing where does it say in the script which points are where.

#plugin("object", "mesh", "plane"); I understand this it's the name and type
#parameter("side", float, 10.0, 0.001, 99999, scale);I'm guessing this is the parameter
#return($plane); What does return do and how can it do it if  $plane hasn't been declared
#button(17, 25, 2,
    0x00000000, 0x00000000, 0x0fffffff, 0x00010001,
    0x00010001, 0x00010001, 0x00010001, 0x00010001,
    0x00010001, 0x00010001, 0x00010001, 0x00010001,
    0x00010001, 0x00010001, 0x00010001, 0x00010001,
    0x00010001, 0x00010001, 0x0fffffff, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000);
shape $plane;   It looks like these are all declaring variables but what are they.
int $side,$i;
point3 $p;
$side = parameter("side");

$plane.Open();
$plane.OpenFace(0,4);
Basicly I don't really get what the rest is saying like what's "TextCoord. and all the other stuff
$p.x = -$side;
$p.y = 0;
$p.z = -$side;
$plane.TexCoordN($plane.AddTexCoord((0,1)));
$plane.VertexN($plane.AddPoint($p));

$p.x = $side;
$p.y = 0;
$p.z = -$side;
$plane.TexCoordN($plane.AddTexCoord((1,1)));
$plane.VertexN($plane.AddPoint($p));

$p.x = $side;
$p.y = 0;
$p.z = $side;
$plane.TexCoordN($plane.AddTexCoord((1,0)));
$plane.VertexN($plane.AddPoint($p));

$p.x = -$side;
$p.y = 0;
$p.z = $side;
$plane.TexCoordN($plane.AddTexCoord((0,0)));
$plane.VertexN($plane.AddPoint($p));

$plane.CloseFace();
$plane.Close();

If someone could please help me I would really appreciate it. Thanks[/glow][/shadow]

BOB_I_Ts:

--- Quote from: flametiger74 on January 31, 2008, 01:50:01 am ---Hey all
I was trying to figure out a script by Tyson Collins (AKA Null) and I was wondering if someone could explain to me some of the things Here's the script I added some questions which are blue. One last thing where does it say in the script which points are where.

#plugin("object", "mesh", "plane"); I understand this it's the name and type
#parameter("side", float, 10.0, 0.001, 99999, scale);this parameter are mouse rules for the shape 1st is name for the dialog 2nd parameters is type of counter used 3rd is default/start scale 4th is min scale 5th max scale and last parameter tells animator to scale object
optional 7th can be added to locked to x,y or z scale per viewpoint when using non-unform scale tool by adding for example edit line "scale,scale_y);" at the end
#return($plane); this declares the object
#button(17, 25, 2,
    0x00000000, 0x00000000, 0x0fffffff, 0x00010001,
    0x00010001, 0x00010001, 0x00010001, 0x00010001,
    0x00010001, 0x00010001, 0x00010001, 0x00010001,
    0x00010001, 0x00010001, 0x00010001, 0x00010001,
    0x00010001, 0x00010001, 0x0fffffff, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000);
shape $plane;   these are the elements/counters used in the script
int $side,$i;
point3 $p;
$side = parameter("side");

$plane.Open();
$plane.OpenFace(0,4);
TextCoord are the U,V texture coordinates fixed to the point textcoord must be set before the point is drawn
$p.x = -$side;
$p.y = 0;
$p.z = -$side;
$plane.TexCoordN($plane.AddTexCoord((0,1)));
$plane.VertexN($plane.AddPoint($p));

$p.x = $side;
$p.y = 0;
$p.z = -$side;
$plane.TexCoordN($plane.AddTexCoord((1,1)));
$plane.VertexN($plane.AddPoint($p));

$p.x = $side;
$p.y = 0;
$p.z = $side;
$plane.TexCoordN($plane.AddTexCoord((1,0)));
$plane.VertexN($plane.AddPoint($p));

$p.x = -$side;
$p.y = 0;
$p.z = $side;
$plane.TexCoordN($plane.AddTexCoord((0,0)));
$plane.VertexN($plane.AddPoint($p));

$plane.CloseFace();
$plane.Close();

If someone could please help me I would really appreciate it. Thanks

--- End quote ---
maybe of interest i did shape based from Tysons script uvblock.an8 which shows use of the scale_# parameter were you can change the uv of the block using xy of non-unform scale tool or hold right mouse down to scale shape "z" from front view
Remember to apply a texture to block after  ;D

flametiger74:
Thanks but that dosn't really help me understand parametive scripts

vobla:

--- Quote from: flametiger74 on January 31, 2008, 01:50:01 am ---#parameter("side", float, 10.0, 0.001, 99999, scale);I'm guessing this is the parameter

--- End quote ---
That is correct.
side - param name;
float - type;
10.0 - min value;
0.001 - min step;
99999 - max value;
scale - scale parameter (aparantly non uniform scale wont be available on this obj, couse author use side for width and for length).


--- Quote from: flametiger74 on January 31, 2008, 01:50:01 am ---#return($plane);

--- End quote ---
It's return value. At the end of the script this value wil be passed back to Anim8tor. It's not initialized yet.. Hmm.. My gues, that you pass name of the variable, which you sould initialize later. Other wise "#return(..)" or smthng like that would be normaly at the end of the script.


--- Quote from: flametiger74 on January 31, 2008, 01:50:01 am ---shape $plane;
point3 $p;

--- End quote ---
point3 like shape is a structured type variable type. It has three floating point values. $i has $i.x, $i.y and $i.z (point 3d coordinates).
shape has loc is a point3 type property - it hold the location of the shape. shape also has some methods..

You can read more http://www.anim8or.com/scripts/spec/Anim8or_Scripting_Language.html
veeeerrry useful :)


--- Quote from: flametiger74 on January 31, 2008, 01:50:01 am ---Basicly I don't really get what the rest is saying like what's "TextCoord. and all the other stuff
$p.x = -$side;
$p.y = 0;
$p.z = -$side;
$plane.TexCoordN($plane.AddTexCoord((0,1)));
$plane.VertexN($plane.AddPoint($p));

--- End quote ---

Ok, first three lines set the point $p properties - x, y and z.
$plane wich is the shape type has some methods. I will rewrite last two lines more elegant and explain it step by step:

int $point_index;
shape $plane;
point3 $p;

[..........]

$point_index = $plane.AddTexCoord(0, 1);   // Add new texture coordinates to a point (we get the new point index)..

$plane.TexCoordsN($point_index);   // We use $point_index to actually set the added texture coords. More info for texture coords in general: http://paulyg.f2s.com/uv.htm

$point_index = $plane.AddPoint($p);   // We add point to the plane and get integer value - added point index - as a return value;

$plane.VertexN($point_index);   // Draw the added point.

So, basicly we have to set point parameters and then draw it..


Cheers ;)

Navigation

[0] Message Index

Go to full version