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

    Sampling color at vertexes

    SDK Help
    0
    53
    39.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

      On 08/08/2014 at 09:06, xxxxxxxx wrote:

      I don't have the Remo code in my plugin, like you have.
      It is in a separate file that I include at the start of my source code, like this:

      #include "c4d.h"
      #include "c4d_symbols.h"
      #include "tpolypaintfrommaterial.h"
      #include "c4d_helpers.h"
      #include "remo_sampler.h"

      Could it be because of this?

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

        On 08/08/2014 at 09:18, xxxxxxxx wrote:

        Doing some simple detective work I found out that what is causing the crash in SampleColorAtVertices is the line:

        Sampler smpl;

        If I place a return INIT_SAMPLER_RESULT_OK; before this line, no crash occurs.
        If I place a return INIT_SAMPLER_RESULT_OK; after this line, the crash occurs.

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

          On 08/08/2014 at 11:41, xxxxxxxx wrote:

          Hi
          This seems to be a problem in the constructor.
          Sampler::Sampler() { ... }

          But it is imposible to say exactly what causes this crash without knowing what was changed in the code.

          Have you changes something in this code section ?

            
          	AutoAlloc<VolumeData> vd; //Owning ptr 	  
          AutoAlloc<TexData>	 tex; //Owning ptr  
          

          Because this will auto alloc vd and tex.

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

            On 08/08/2014 at 12:03, xxxxxxxx wrote:

            This is what I have:

              
            //=================================================================================================   
            class Sampler   
            //=================================================================================================   
            {   
            public:   
                 Sampler();   
                 ~Sampler();   
                    
                 //init this sampler, always call one of this before everything else.   
                 INIT_SAMPLER_RESULT Init(BaseObject *obj,LONG chnr=CHANNEL_COLOR,Real time=0.0);   
                 INIT_SAMPLER_RESULT Init(BaseMaterial *mat ,LONG chnr,Real time,BaseDocument *doc,BaseObject *op=nullptr);   
                 INIT_SAMPLER_RESULT Init(TextureTag *textag,LONG chnr,Real time,BaseDocument *doc,BaseObject *op=nullptr);   
                    
                 //return true if Init was called before.   
                 inline Bool IsInit(){ return TexInit; };   
                    
                 //return color at UVW coordinates.   
                 Vector     SampleUV(const Vector &uv;, Real time=0.0);   
                    
                 //return color at 3D coordinates p, if shader is not 3D then uv will be used.   
                 Vector     Sample3D(const Vector &pos3d;, const Vector &uv; = Vector(0.0), Real time=0.0);   
                    
                 //return average color of the shader   
                 Vector AverageColor(LONG num_samples = 128);   
                    
                 void Free();   
            private:   
                 BaseShader                *texShader; //NON owning ptr   
                 AutoAlloc<VolumeData> vd; //Owning ptr   
                 AutoAlloc<TexData>      tex; //Owning ptr   
                 RayObject                *rop; //Owning ptr   
                    
                 InitRenderStruct     irs;   
                 ChannelData               cd;   
                    
                 Matrix               omg;   
                 Real               offsetX;   
                 Real               offsetY;   
                 Real               lenX;   
                 Real               lenY;   
                 Bool               TexInit;   
            };   
            
            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 08/08/2014 at 12:06, xxxxxxxx wrote:

              Well then it will be cause by some changes in the constructor.
              Sampler::Sampler()

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

                On 08/08/2014 at 12:15, xxxxxxxx wrote:

                Well, the listing is a bit long. Should I paste it here or should I send it over through e-mail? (if I can, of course... I don't want to be imposing).

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

                  On 08/08/2014 at 12:18, xxxxxxxx wrote:

                  Should I paste it here or should I send it over through e-mail?
                  Of course you can send it over e-mail.
                  Even better just place it on github.com

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

                    On 08/08/2014 at 12:25, xxxxxxxx wrote:

                    Mustn't I have an account in github.com to place something there?
                    And, if I send you the listing over e-mail, can I use the mail I used when I bought some of your plugins? 🙂

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

                      On 08/08/2014 at 13:18, xxxxxxxx wrote:

                      Since you're having so many problems with this. I decided to create a DescriptionToolData plugin myself.
                      I used your Message() code for the getting the object in the linkbox gizmo.
                      And I used the same Sample class code I sent you in my CD plugin.
                      I also used a separate .h file to host that code. Using #include "sampler.h" to point to the code from the plugin's .cpp file

                      It all works fine for me and does not crash at all. I can't undestand why you're having so many problems with it.
                      Would you like me to send you my tool plugin?

                      -ScottA

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

                        On 08/08/2014 at 13:24, xxxxxxxx wrote:

                        Mustn't I have an account in github.com to place something there?
                        I think yes.
                        > And, if I send you the listing over e-mail, can I use the mail I used when I bought some of your plugins? 🙂
                        Or just PM me here, whatever you want 🙂
                        Note: I do not ready my e-mails often. Some times for many days.

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

                          On 08/08/2014 at 13:38, xxxxxxxx wrote:

                          Thank you to both.
                          I will try take a look at Scott plugin and compare it with mine first.
                          I hope I find my mistake (I'm assuming I must be doing something wrong).
                          If I still don't manage to fix it, I will send you my code through PM, Remo.
                          Ok?

                          So, if you don't mind, Scott, I would gladly take a look at your plugin.
                          Same batchannel, same bat-mail 😉

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

                            On 08/08/2014 at 14:57, xxxxxxxx wrote:

                            I'm still cleaning up (it still hanged my code 😞 )
                            In the meanwhile, let me tell you guys one thing that may help pinpoit the problem.
                            Xcode is giving me a warning in the line:

                            GeDynamicArray<Colors> colors(pcnt);

                            The warning is: Template argument uses local type 'Colors'

                            What is this?!?

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

                              On 09/08/2014 at 12:43, xxxxxxxx wrote:

                              Remo, I have sent you an mail (and a movie through wetransfer) to your gmail account.
                              I don't know if it is still active, though.

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