|
|
tommaso wrote:
> con il POVRAY
>
> voglio disegnare un SOLIDO con 8 vertici
> come fare?
>
> NON con la "box" (2 punti opposti) e poi con "scale"
> NON con "union" di 6 polygons
>
> Ma solo introducendo le coordinate di 8 punti generici.
>
> Grazie
>
> Tommaso
>
> Tst### [at] capoleucait
First, povray.programming is really for how to program stuff that make
POV, not how to use POV.
So really your question belongs to the povray.text.scene-file group.
Second, I was challenged by your question and I came up with two ways
to deal with the problem :
one keeps dead straight lines between all corners.
the second tries to make corners as if they were not deformed (right
at the corner) and the rest smoothly deformed.
You can try either my StraighSolid or my TwistedSolid below.
I have done very quick testing so there may be bugs I did not spot (I
did not really check all faces were where they should be), but it
looks OK as it is.
Be warn though that this is made up of bezier patches and they cannot
take part in CSG.
--------8<-------------
#include "colors.inc"
#include "textures.inc"
#macro OneStraightFace (a,b,c,d)
// a = top left
// b = top right
// c = bottom right
// d = bottom left
#local ad=a+(d-a)/3;
#local ab=a+(b-a)/3;
#local ba=b+(a-b)/3;
#local bc=b+(c-b)/3;
#local cb=c+(b-c)/3;
#local cd=c+(d-c)/3;
#local dc=d+(c-d)/3;
#local da=d+(a-d)/3;
#local abd=(a+b+d)/3;
#local bac=(b+a+c)/3;
#local cbd=(c+b+d)/3;
#local dac=(d+a+c)/3;
bicubic_patch
{
type 1
flatness 0
u_steps 4
v_steps 4,
a, ab, ba, b,
ad, abd, bac, bc,
da, dac, cbd, cb,
d, dc, cd, c
}
#end
#macro StraightSolid (a,b,c,d,e,f,g,h)
// a = top left front
// b = top right front
// c = bottom right front
// d = bottom left front
// e = top left back
// f = top right back
// g = bottom right back
// h = bottom left back
OneStraightFace(a,b,c,d) // front
OneStraightFace(b,f,g,c) // right
OneStraightFace(e,f,b,a) // up
OneStraightFace(f,e,h,g) // back
OneStraightFace(e,a,d,h) // left
OneStraightFace(d,c,g,h) // down
#end
#macro FindRightCorner (a, b, c, d, Epsilon, af, ag, ah)
// a = centre corner
// b = edge's one other corner => af in the rightened corner
// c = edge's two other corner => ag in the rightened corner
// d = edge's three other corner => ah in the rightened corner
// Epsilon = tolerance for corner resolution
#local ab = b - a;
#local ac = c - a;
#local ad = d - a;
#local ae = (ab + ac + ad) / 3;
#local eb = ab - ae;
#local ec = ac - ae;
#local ed = ad - ae;
#local Beta = 1;
#local dBeta = 2*Epsilon;
#while (dBeta > Epsilon)
#local Beta = Beta + dBeta * 0.5;
#local af = ae + Beta * eb;
#local Gama = - vdot (ae, af) / vdot (ec, af);
#local ag = ae + Gama * ec;
#local Delta = - vdot (ae, ag) / vdot (ed, ag);
#local ah = ae + Delta * ed;
#local nBeta = - vdot (ae, ah) / vdot (eb, ah);
#local dBeta = nBeta - Beta;
#end
#local af = vnormalize (af) * vlength (ab) / 3;
#local ag = vnormalize (ag) * vlength (ac) / 3;
#local ah = vnormalize (ah) * vlength (ad) / 3;
#end
#macro OneTwistedFace (a,ab,ad, b,ba,bc, c,cb,cd, d,dc,da)
// a = top left
// b = top right
// c = bottom right
// d = bottom left
#local abd=a+ab+ad;
#local bac=b+ba+bc;
#local cbd=c+cb+cd;
#local dac=d+da+dc;
bicubic_patch
{
type 1
flatness 0
u_steps 4
v_steps 4,
a, a+ab, b+ba, b,
a+ad, abd, bac, b+bc,
d+da, dac, cbd, c+cb,
d, d+dc, c+cd, c
}
#end
#macro TwistedSolid (a,b,c,d,e,f,g,h)
// a = top left front
// b = top right front
// c = bottom right front
// d = bottom left front
// e = top left back
// f = top right back
// g = bottom right back
// h = bottom left back
#declare Epsilon = 0.0001;
#declare null = <0,0,0>;
#declare ab = null; #declare ad = null; #declare ae = null;
#declare ba = null; #declare bf = null; #declare bc = null;
#declare cd = null; #declare cb = null; #declare cg = null;
#declare da = null; #declare dc = null; #declare dh = null;
#declare ea = null; #declare eh = null; #declare ef = null;
#declare fb = null; #declare fe = null; #declare fg = null;
#declare gc = null; #declare gf = null; #declare gh = null;
#declare hd = null; #declare hg = null; #declare he = null;
FindRightCorner (a, b, d, e, Epsilon, ab, ad, ae)
FindRightCorner (b, a, f, c, Epsilon, ba, bf, bc)
FindRightCorner (c, d, b, g, Epsilon, cd, cb, cg)
FindRightCorner (d, a, c, h, Epsilon, da, dc, dh)
FindRightCorner (e, a, h, f, Epsilon, ea, eh, ef)
FindRightCorner (f, b, e, g, Epsilon, fb, fe, fg)
FindRightCorner (g, c, f, h, Epsilon, gc, gf, gh)
FindRightCorner (h, d, g, e, Epsilon, hd, hg, he)
OneTwistedFace (a,ab,ad, b,ba,bc, c,cb,cd, d,dc,da) // front
OneTwistedFace (b,bf,bc, f,fb,fg, g,gf,gc, c,cg,cb) // right
OneTwistedFace (e,ef,ea, f,fe,fb, b,bf,ba, a,ab,ae) // up
OneTwistedFace (f,fe,fg, e,ef,eh, h,he,hg, g,gh,gf) // back
OneTwistedFace (e,ea,eh, a,ae,ad, d,da,dh, h,hd,he) // left
OneTwistedFace (d,dc,dh, c,cd,cg, g,gc,gh, h,hg,hd) // down
#end
camera
{
orthographic
location <0, -10, 0>
direction y
up 2*10*z
right 2*10*1.25*x
}
light_source { < 20, -30, 20> 1.5*White }
union
{
TwistedSolid
(<-3,3,-3>,<2,-2,-8>,<2,-9,-6>,<-8,-7,0>,<5,5,3>,<9,0,-3>,<7,-6,0>,<5,-2,5>)
// StraightSolid
(<-3,3,-3>,<2,-2,-8>,<2,-9,-6>,<-8,-7,0>,<5,5,3>,<9,0,-3>,<7,-6,0>,<5,-2,5>)
// try one or the other
// beware, my newswriter may have wrapped the lines,
// you may have to glue them back together.
texture {White_Marble}
}
--------8<-------------
--
ANTI SPAM / ANTI ARROSAGE COMMERCIAL :
To answer me, please take out the Z from my address.
Post a reply to this message
|
|