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.

Author Topic: The Plane Primitive  (Read 5765 times)

flametiger74

  • Full Member
  • ***
  • Posts: 152
    • View Profile
The Plane Primitive
« 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);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]
« Last Edit: January 31, 2008, 02:18:41 am by flametiger74 »
Logged

BOB_I_Ts

  • Full Member
  • ***
  • Posts: 155
    • View Profile
    • Anim8rOrg
Re: The Plane Primitive
« Reply #1 on: January 31, 2008, 02:30:37 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
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
« Last Edit: January 31, 2008, 02:36:44 am by BOB_I_Ts »
Logged

flametiger74

  • Full Member
  • ***
  • Posts: 152
    • View Profile
Re: The Plane Primitive
« Reply #2 on: January 31, 2008, 03:28:27 am »

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

vobla

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: The Plane Primitive
« Reply #3 on: January 31, 2008, 12:28:02 pm »

#parameter("side", float, 10.0, 0.001, 99999, scale);I'm guessing this is the parameter
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).

#return($plane);
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.

shape $plane;
point3 $p;
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 :)

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));

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 ;)
Logged