POV-Ray : Newsgroups : povray.newusers : While in while: help me, please! : Re: While in while: help me, please! Server Time
14 May 2024 09:26:45 EDT (-0400)
  Re: While in while: help me, please!  
From: Jeff Reifel
Date: 19 Jan 2014 12:05:00
Message: <web.52dc04c19cd0892411fab0250@news.povray.org>
"LanuHum" <Lan### [at] yandexru> wrote:
> Hi!
> Sorry!
> Again it is impossible to me :(
> It is necessary to create object from the array
>
> File 'HairSystem.inc' line 54: Parse error:
> Expected 'numeric expression', array identifier found instead
> Fatal error in parser: Cannot parse input
> Render failed
>
> #declare ArrayHairSystem = array[4] {
> spline { cubic_spline
> 0/9 <1.104,-0.535,-0.7421>
> 1/9 <1.358,-0.4768,-0.8438>
> 2/9 <1.626,-0.3345,-0.922>
> 3/9 <1.939,-0.1466,-0.9378>
> 4/9 <2.328,0.04195,-0.8999>
> 5/9 <2.732,0.1853,-0.8488>
> 6/9 <3.079,0.2744,-0.8224>
> 7/9 <3.371,0.3472,-0.8292>
> 8/9 <3.616,0.4306,-0.8473>
> },
> spline { cubic_spline
> 0/9 <1.281,-0.6221,-0.5943>
> 1/9 <1.531,-0.6057,-0.8389>
> 2/9 <1.761,-0.4055,-1.027>
> 3/9 <2.022,-0.1217,-1.065>
> 4/9 <2.371,0.1307,-0.9738>
> 5/9 <2.757,0.2744,-0.8509>
> 6/9 <3.1,0.3207,-0.7875>
> 7/9 <3.387,0.3535,-0.8038>
> 8/9 <3.616,0.4306,-0.8473>
> },
> spline { cubic_spline
> 0/9 <1.091,-0.6223,-0.6592>
> 1/9 <1.357,-0.5827,-0.841>
> 2/9 <1.618,-0.4031,-0.9808>
> 3/9 <1.915,-0.1566,-1.009>
> 4/9 <2.296,0.07255,-0.9414>
> 5/9 <2.704,0.2209,-0.85>
> 6/9 <3.062,0.2908,-0.8028>
> 7/9 <3.366,0.346,-0.815>
> 8/9 <3.616,0.4306,-0.8473>
> },
> spline { cubic_spline
> 0/9 <1.107,-0.5015,-0.7747>
> 1/9 <1.356,-0.4359,-0.8449>
> 2/9 <1.627,-0.3081,-0.8988>
> 3/9 <1.946,-0.1432,-0.9097>
> 4/9 <2.339,0.02948,-0.8836>
> 5/9 <2.742,0.171,-0.8484>
> 6/9 <3.084,0.2678,-0.8302>
> 7/9 <3.372,0.3476,-0.8348>
> 8/9 <3.616,0.4306,-0.8473>
> },
> }
> #declare HairSegment =
> sphere {0,0.1 translate z*0.125}
>
> #declare HairStep = 1;
> #declare Hair =
> union {
>     #declare I = 0;
>     #while (I < ArrayHairSystem)
>         union {
>             #declare ctr = 0;
>             #while (ctr < 1)
>                 object { HairSegment texture{pigment{rgb 1}}rotate z*0
>                         translate ArrayHairSystem[I] (ctr)}
>             #declare ctr = ctr + 0.00025;
>             #end
> #local I = I + HairStep
> #end
> }}
>
> Thanks!

ArrayHairSystem is your array not the size of your array. In your while loop you
need to step through your array one spline at a time.
 Try This
#declare ArrayHairSystem = array[4] {
spline { cubic_spline
0/9 <1.104,-0.535,-0.7421>
1/9 <1.358,-0.4768,-0.8438>
2/9 <1.626,-0.3345,-0.922>
3/9 <1.939,-0.1466,-0.9378>
4/9 <2.328,0.04195,-0.8999>
5/9 <2.732,0.1853,-0.8488>
6/9 <3.079,0.2744,-0.8224>
7/9 <3.371,0.3472,-0.8292>
8/9 <3.616,0.4306,-0.8473>
},
spline { cubic_spline
0/9 <1.281,-0.6221,-0.5943>
1/9 <1.531,-0.6057,-0.8389>
2/9 <1.761,-0.4055,-1.027>
3/9 <2.022,-0.1217,-1.065>
4/9 <2.371,0.1307,-0.9738>
5/9 <2.757,0.2744,-0.8509>
6/9 <3.1,0.3207,-0.7875>
7/9 <3.387,0.3535,-0.8038>
8/9 <3.616,0.4306,-0.8473>
},
spline { cubic_spline
0/9 <1.091,-0.6223,-0.6592>
1/9 <1.357,-0.5827,-0.841>
2/9 <1.618,-0.4031,-0.9808>
3/9 <1.915,-0.1566,-1.009>
4/9 <2.296,0.07255,-0.9414>
5/9 <2.704,0.2209,-0.85>
6/9 <3.062,0.2908,-0.8028>
7/9 <3.366,0.346,-0.815>
8/9 <3.616,0.4306,-0.8473>
},
spline { cubic_spline
0/9 <1.107,-0.5015,-0.7747>
1/9 <1.356,-0.4359,-0.8449>
2/9 <1.627,-0.3081,-0.8988>
3/9 <1.946,-0.1432,-0.9097>
4/9 <2.339,0.02948,-0.8836>
5/9 <2.742,0.171,-0.8484>
6/9 <3.084,0.2678,-0.8302>
7/9 <3.372,0.3476,-0.8348>
8/9 <3.616,0.4306,-0.8473>
},
}
#declare HairSegment =
sphere {0,0.01 }

#declare HairStep = 1;
#declare Hair =
union {
    #declare I = 0;
    #while (I < 4) //!!!!!!!!/4 splines in your array!!!!!!!!!!
        union {
            #declare ctr = 0;
            #while (ctr < 1)
                object { HairSegment texture{pigment{rgb 1}}
                        translate ArrayHairSystem[I](ctr)}
            #declare ctr = ctr + 0.0025;
            #end }
#local I = I + HairStep ;
#end }
object{Hair}
camera{ location -z*2 look_at x*3}
light_source{-z*99 rgb 1}
background{rgb z}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.