RMShader issue when passing array as param

Help
2009-05-04
2013-03-24
  • Fabio Piparo
    Fabio Piparo
    2009-05-04

    Hi!
    First of all thanks for the great job you guys have done with putting up such a huuuuuge piece of kit.

    I'm having some issues with RMShader. My situation is this. I have a .sl with this definition:

    <code>
    surface
    st05(
    float barHeight[1024] = { 0 };
    )
    </code>

    The problem I'm having here is that I'm not able to pass the right type of data from the RMShader class. I keep getting a different type of errors.
    In my .py file I tried generating an ndarray, a list, a tuple, a string, and I tried to pass these to my parameter without any luck. The errors that I get are mostly two.

    <code>
      File "/Library/Python/2.5/site-packages/cgkit/rmshader.py", line 347, in declare
        pdefault = eval("%s(%s)"%(pytype, repr(self.undeclared[pname])))
      File "<string>", line 1, in <module>
    TypeError: float() argument must be a string or a number
    </code>

    This happens when I pass a tuple a list or a string.

    <code>
      File "/Library/Python/2.5/site-packages/cgkit/rmshader.py", line 347, in declare
        pdefault = eval("%s(%s)"%(pytype, repr(self.undeclared[pname])))
      File "<string>", line 1
        float(array([ 1.00655671,  0.99376101,  0.95286341, ...,  0.10930373,
                                                            ^
    SyntaxError: invalid syntax
    </code>
    And this happens when I pass a numpy array to it.

    I would like to know what and how should I pass to the parameter in order to get it to work.

    Fabio.

     
    • Matthias Baas
      Matthias Baas
      2009-05-06

      I had a quick look at the code and noticed that there is actually no array support at all yet! Thanks for reminding me, I totally forgot about that one, sorry.
      I'll look into it during the next couple of days.

      Cheers,

      - Matthias -

       
    • Matthias Baas
      Matthias Baas
      2009-05-09

      After having a closer look, it turned out that the situation actually wasn't that bad. Support for arrays was already in there but there was a genuine bug/oversight which meant passing array values via the constructor didn't work.
      I have just committed a fix for this (rev312).

      If you are not in a position to upgrade from svn, there is actually a workaround for the problem. It should work when you set the value outside the constructor after the RMShader object has been created.

      Let me know if this fixes your problem.

      Cheers,

      - Matthias -

       
    • Fabio Piparo
      Fabio Piparo
      2009-05-12

      I managed to solve the issue by assigning the value after the constructor as you suggested. Thanks for your help.
      Fabio.