28th January 2012 18:41 UTC
How to create a polygon and its normal?
How to create a polygon with Superscope and its normal vector?
Thanks in advance.
Archive: How to create a polygon and its normal?
patipano
28th January 2012 18:41 UTC
How to create a polygon and its normal?
How to create a polygon with Superscope and its normal vector?
Thanks in advance.
Warrior of the Light
2nd February 2012 22:31 UTC
there's a list of tutorials here. I suggest you read through PAK-9's one
QOAL
2nd February 2012 23:18 UTC
I'd probably recommend using the triangle APE, if you want nice filled polys, rather than a superscope. (Not that I can remember how to use that ape)
patipano
3rd February 2012 06:23 UTC
The PAK-9's Tutorial didn't show me how to create polygon with Triangle(Render) :(.
Warrior of the Light
3rd February 2012 13:36 UTC
I never really used it myself but it's basically a SSC with 3 X's and 3 Y's instead of one I think.
patipano
3rd February 2012 15:38 UTC
Thank you everyone! i got it! (using SSC) :D
Any example code for solid pentagon (SSC)?
Warrior of the Light
3rd February 2012 16:45 UTC
solids are not possible since there only is a line. There are tricks though.
The most commonly used is 'zigzagging' This is the code for a square, do your best to turn this into a pentagon:
init:
n=h
point:
linesize=2;
sw=bnot(sw);
x=sw*1-0.5;
y=i*1-0.5
patipano
10th February 2012 18:14 UTC
Is this okay for pentagon?
"la" is amount of layer(density)
Init:
la=7;n=la*6;a=72/360*2*$pi;asp=h/w;
x0=1;x1=cos(a);x2=cos(2*a);x3=x2;x4=x1;
y0=0;y1=-sin(a);y2=-sin(2*a);y3=-y2;y4=-y1;
Frame:
p=0;c=0;
Point:
x=(equal(p,0)*x0+equal(p,1)*x1+equal(p,2)*x2+equal(p,3)*x3+equal(p,4)*x4+equal(p,5)*x0);
y=(equal(p,0)*y0+equal(p,1)*y1+equal(p,2)*y2+equal(p,3)*y3+equal(p,4)*y4+equal(p,5)*y0);
sc=1-floor(c/6)*(1/la);
sc=if(below(sc,0),0,sc);
skip=if(equal(p%6,0),1,0);
x=x*asp*sc;
y=y*sc;
p=(p+1)%6;c=c+1;
Warrior of the Light
10th February 2012 22:36 UTC
Looks great! the code you managed to create is more advanced than I had expected.
I would increase la to (for instance) w*0.5 and make the linewidth 2 or 3.
some optimization tips:
You could remove the if() statement for skip; skip=equal(p%6,0); will work too.
The extra line for sc is not needed. Simply use sc=max(1-floor(c/6)*(1/la),0); instead.
patipano
11th February 2012 05:41 UTC
Oh thank you for cleaning my code! :up: i have to learn lots about minimizing the code.
What's the difference between longer code and shorter code? only FPS rate?
Warrior of the Light
11th February 2012 13:14 UTC
Yes. the CPU always runs at 100% with AVS and both reading the code and rendering the image is done by the processor. So the less code it has to read, the faster the image is rendered. Especially in the Point box because it is calculated for every point of the scope over and over again.
For this example it isn't really important but once your preset starts 'growing' you can see the framerate dropping fast.
patipano
12th February 2012 07:22 UTC
Why this scope is so mess? I just added some 3D rotation to my pentagon.
Point:
x1=(equal(p,0)*x0+equal(p,1)*x1+equal(p,2)*x2+equal(p,3)*x3+equal(p,4)*x4+equal(p,5)*x0);
y1=(equal(p,0)*y0+equal(p,1)*y1+equal(p,2)*y2+equal(p,3)*y3+equal(p,4)*y4+equal(p,5)*y0);
//Additional
z1=0
y2=y1*xc-z1*xs;z2=y1*xs+z1*xc;
x2=z2*ys+x1*yc;z3=z2*yc-x1*ys;
x3=x2*zc-y2*zs;y3=y2*zc+x2*zs;
//End of additional
sc=1-floor(c/6)*(1/la);
skip=equal(p%6,0);
//Additional
z=1/(z3+1);
x=x3*asp*sc*z;
y=y3*sc*z;
//End of additional
p=(p+1)%6;c=c+1;
Warrior of the Light
12th February 2012 15:25 UTC
you forgot a ; after z1=0
patipano
12th February 2012 16:19 UTC
It also messy. It isn't 3D pentagon :cry:
Grandchild
13th February 2012 22:00 UTC
Small triangle tutorial
I really suggest you spend your time learning how to use Triangle. It's just that much more clean than approximating stuff with zig-zagging them in an SSC.
That being said, here's a few pointers to get you going with your pentagon:
First you have to ask, How can a <enter your shape here> be created with triangles? In the case of a pentagon that's pretty easy once you draw a pentagon on paper:
http://s15.postimage.org/d8jevke6v/p...2triangles.png
Blue numbers identify triangles and red numbers identify vertices (corners).
So you are going to have 3 triangles.
So in your Init box goes
n = 3;
crcl5th = 2*$PI/5; // precalculate the step size around a circle
size = 1;
point1x = sin(crcl5th*0)*size; point1y = cos(crcl5th*0)*size;
point2x = sin(crcl5th*1)*size; point2y = cos(crcl5th*1)*size;
point3x = sin(crcl5th*2)*size; point3y = cos(crcl5th*2)*size;
point4x = sin(crcl5th*3)*size; point4y = cos(crcl5th*3)*size;
point5x = sin(crcl5th*4)*size; point5y = cos(crcl5th*4)*size;
// x coordinate ------------- y coordinate ------------- z coordinate
// triangle 1
assign(megabuf(00),point1x);assign(megabuf(01),point1y);assign(megabuf(02),0);
assign(megabuf(03),point4x);assign(megabuf(04),point4y);assign(megabuf(05),0);
assign(megabuf(06),point5x);assign(megabuf(07),point5y);assign(megabuf(08),0);
// triangle 2
assign(megabuf(09),point1x);assign(megabuf(10),point1y);assign(megabuf(11),0);
assign(megabuf(12),point4x);assign(megabuf(13),point4y);assign(megabuf(14),0);
assign(megabuf(15),point3x);assign(megabuf(16),point3y);assign(megabuf(17),0);
// triangle 3
assign(megabuf(18),point1x);assign(megabuf(19),point1y);assign(megabuf(20),0);
assign(megabuf(21),point2x);assign(megabuf(22),point2y);assign(megabuf(23),0);
assign(megabuf(24),point3x);assign(megabuf(25),point3y);assign(megabuf(26),0);
x1 = someval; y1 = someval;
x2 = someval; y2 = someval;
x3 = someval; y3 = someval;
red1 = redval;
blue1 = blueval;
green1 = greenval;
counter = 0;
x1 = megabuf(counter); y1 = megabuf(counter+1); // you can add z1/2/3 here if needed
x2 = megabuf(counter+3); y2 = megabuf(counter+4);
x3 = megabuf(counter+6); y3 = megabuf(counter+7);
counter = counter+9;
patipano
14th February 2012 07:30 UTC
Wow, lots of coding but I'd have to check it out! Thanks :up:
patipano
15th February 2012 18:07 UTC
I think this triangle coding is harder than using SSC to coloring from center (gradient).
Any idea for coloring (from center with Triangle)?
Fork me on GitHub