|
![](/i/fill.gif) |
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmail com> wrote:
>
> Have a look at the code below.
>
> Tor Olav
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
>
> #version 3.6;
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
>
> #declare PatchesInWidth = 2;
> #declare PatchesInHeight = 2;
>
> #declare PatchPoints =
> array[PatchesInHeight][PatchesInWidth][4][4] {
> {
> {
> { < 0, 0, 0>, < 1, 0, 0>, < 2, 0, 0>, < 3, 0, 0> },
> { < 0, 0, 1>, < 1, 1, 1>, < 2, 1, 1>, < 3, 0, 1> },
> { < 0, 0, 2>, < 1, 1, 2>, < 2, 1, 2>, < 3, 0, 2> },
> { < 0, 0, 3>, < 1, 0, 3>, < 2, 0, 3>, < 3, 0, 3> }
> },
> {
> { < 3, 0, 0>, < 4, 0, 0>, < 5, 0, 0>, < 6, 0, 0> },
> { < 3, 0, 1>, < 4, -1, 1>, < 5, -1, 1>, < 6, 0, 1> },
> { < 3, 0, 2>, < 4, -1, 2>, < 5, -1, 2>, < 6, 0, 2> },
> { < 3, 0, 3>, < 4, 0, 3>, < 5, 0, 3>, < 6, 0, 3> }
> }
> },
> {
> {
> { < 0, 0, 3>, < 1, 0, 3>, < 2, 0, 3>, < 3, 0, 3> },
> { < 0, 0, 4>, < 1, -1, 4>, < 2, -1, 4>, < 3, 0, 4> },
> { < 0, 0, 5>, < 1, -1, 5>, < 2, -1, 5>, < 3, 0, 5> },
> { < 0, 0, 6>, < 1, 0, 6>, < 2, 0, 6>, < 3, 0, 6> }
> },
> {
> { < 3, 0, 3>, < 4, 0, 3>, < 5, 0, 3>, < 6, 0, 3> },
> { < 3, 0, 4>, < 4, 1, 4>, < 5, 1, 4>, < 6, 0, 4> },
> { < 3, 0, 5>, < 4, 1, 5>, < 5, 1, 5>, < 6, 0, 5> },
> { < 3, 0, 6>, < 4, 0, 6>, < 5, 0, 6>, < 6, 0, 6> }
> }
> }
> }
>
>
>
> #declare PatchTextures =
>
> array[PatchesInHeight][PatchesInWidth] {
> {
>
> texture {
> pigment {
> checker
> color rgbf <1.0, 1.0, 1.0, 0.6>
> color rgbf <0.0, 0.0, 0.0, 0.6>
>
> }
> },
> texture {
> pigment {
> checker
> color rgbf <0.7, 0.0, 0.0, 0.6>
> color rgbf <1.0, 1.0, 1.0, 0.6>
> }
> }
> },
> {
> texture {
> pigment {
> checker
> color rgbf <0.0, 0.7, 0.0, 0.6>
> color rgbf <1.0, 1.0, 1.0, 0.6>
> }
> },
> texture {
> pigment {
> checker
> color rgbf <1.0, 1.0, 1.0, 0.6>
> color rgbf <0.0, 0.0, 0.7, 0.6>
> }
> }
> }
> }
>
> #declare CntH = 0;
> #while (CntH < PatchesInHeight)
> #declare CntW = 0;
> #while (CntW < PatchesInWidth)
>
> bicubic_patch {
> type 1
> flatness 0.001
> u_steps 4
> v_steps 4
> uv_vectors
> <0, 0>
> <1, 0>
> <1, 1>
> <0, 1>
>
> #declare I = 0;
> #while (I < 4)
> #declare J = 0;
> #while (J < 4)
> PatchPoints[CntH][CntW][I][J]
> #declare J = J + 1;
> #end // while
> #declare I = I + 1;
> #end // while
>
> uv_mapping
> texture {
> PatchTextures[CntH][CntW]
> scale 1/3
> }
> }
>
> #declare CntW = CntW + 1;
> #end // while
> #declare CntH = CntH + 1;
> #end // while
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
>
> background {
> color rgb 0.5*<1, 1, 1>
> }
>
> camera {
> location <3, 6, -3>
> look_at <3, 0, 3>
> }
>
> light_source {
> 500*<1, 1, -1>
> color rgb <1, 1, 1>
> shadowless
> }
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
That's great! Took me a while to understand the nested loops though.
Thank you very much.
The other reason I posted was to ask if there was a way to reduce the process of
creating the vectors for the patches to a while loop or nested loops.
Call me lazy, but I'm always looking for shorter/easier ways to do things. :)
D103
Post a reply to this message
|
![](/i/fill.gif) |