Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Gradient - InitRenderStruct

    PYTHON Development
    0
    21
    14.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 21/02/2012 at 09:56, xxxxxxxx wrote:

      Hi Lennart,
      here's the code:

      import c4d
      from c4d import utils
      import c4d.modules.mograph as mograph
      from c4d.modules import render

      def main() :
          ColorOverLife = op[c4d.ID_USERDATA,2] # gradient user data
          irs=render.InitRenderStruct()
          ColorOverLife.InitRender(irs)
          
          tp = doc.GetParticleSystem()
          
          md = mograph.GeGetMoData(op)
          if not md: return False

      Color=md.GetArray(c4d.MODATA_COLOR)
          cnt=md.GetCount()

      for i in range (0, cnt) :
              life = tp.Life(i)
              lifeTime = life.Get()
              age = tp.Age(i)
              ageTime = age.Get()

      Color _= c4d.Vector(ColorOverLife.CalcGradientPixel(ageTime/lifeTime))
              
          ColorOverLife.FreeRender()
          md.SetArray(c4d.MODATA_COLOR, Color, True)

      I hope you can help me with the trasparency over life...
      Make good use of it. 😉

      Cheers

      Luther

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 21/02/2012 at 17:24, xxxxxxxx wrote:

        Thanks for the added lines, yeah I run into the same issue how to run several channels
        in my short test. Hopefully Sebastian can add some info if possible.
        I'd love to get this working but are tied 24/7 till the beginning of March.

        Cheers
        Lennart

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 23/02/2012 at 15:27, xxxxxxxx wrote:

          I fail to see how to do this by code only (different gradients for different channels,
          like Color, luminance and alpha i.e). It would be absolutely fantastic to get
          a StormTracer behavior for geometric clones.
          It is still a huge step forward to have your gradient for lets say Luminance
          and then do the standard workaround of using two copies of the material
          one with opaque alpha and the other with full alpha and animate the texture
          tag between them and still get a different color gradient independent of alpha.

          Any input from anyone that might shed some light on this would be fantastic.

          Cheers
          Lennart

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 25/02/2012 at 09:47, xxxxxxxx wrote:

            Hi Lennart,
            I think I have the solution: just create a Black/White ColorOverLife Gradient and than apply a Colorizer channel (luminance Imput)  to modify the gradient.
            It was so simple :nerd: Let me know if that works for you.

            Cheers
            Luther

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 25/02/2012 at 17:04, xxxxxxxx wrote:

              Yup, seems to work pretty well.

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 26/02/2012 at 09:29, xxxxxxxx wrote:

                Would it be possible for one of you guys to post a file of this?

                md.SetArray(c4d.MODATA_COLOR, Color, True) is producing this error: "InvalidObject Length".
                And I can't figure out what I'm doing wrong.

                Thanks,
                -ScottA

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 26/02/2012 at 10:16, xxxxxxxx wrote:

                  I was wondering about this, too. The code Luther posted can't be correct. I guess it should be something like Color _= ColorOverLife.CalcGradientPixel(ageTime/lifeTime).

                  Cheers,
                  Niklas

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 26/02/2012 at 12:03, xxxxxxxx wrote:

                    Just add the index in the for loop result (I think its just a typo by Luther)
                    and it's all dandy.

                      
                    Color[i] = c4d.Vector(ColorOverLife.CalcGradientPixel(ageTime/lifeTime))   
                    
                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 26/02/2012 at 13:01, xxxxxxxx wrote:

                      My guess was right then, ha. Btw, enclosing the call to c4d.Gradient.CalcGradientPixel with c4d.Vector() is not necessary. Cheers, Niklas

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 26/02/2012 at 13:05, xxxxxxxx wrote:

                        Thanks.
                        Got it working now. But having trouble with the luminance part.

                        I assume what you're doing is adding a material to the cloner. Then adding a colorizer to the luminance channel in that material. Then changing the colors for the knots in the colorizer to Black & white to gradually make the particle objects invisible?

                        If that's what you're doing. I'm having a very tough time with that. Because the luminance seems to not fall off from the first knot's color. No matter how I set up the colorizer's knots.

                        -ScottA

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 26/02/2012 at 15:31, xxxxxxxx wrote:

                          You make a userdata color gradient, black to white.
                          Thats the base for the code. Then adding a material with Mograph Color shader
                          for alpha and luminance channel on the cloner.
                          In the luminance channel you add the colorizer on the mo color shader.

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 26/02/2012 at 16:23, xxxxxxxx wrote:

                            Oh. You're using a Mograph color shader.
                            Now I've got it all working

                            Thanks for the explanation.

                            -ScottA

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 27/02/2012 at 01:21, xxxxxxxx wrote:

                              Hi Guys,
                              heres my sample project:
                              ColorOverLife001-1.c4d

                              I hope it's useful to someone.

                              Cheers

                              Luther

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post