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

    problem with arranging values of an array

    SDK Help
    0
    19
    1.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 09/03/2010 at 00:03, xxxxxxxx wrote:

      I think I now understand your code, what you want to do and why it ends up like this:
      You probably have an outer loop that iterates over time.
      You want to have one spline per particle that trajects it's course, but with the code above you end up having one spline per timeframe, connecting all the particles at that time.

      In the loop, you would need an array of splines (one for each particle), and instead of adding all points to a single spline, you would do something like this in the i loop:

       for (int i = 0; i<particleCount;i++)  
        
                   {  
        
                        const Particle \*particle = particleObject->GetParticleR(particleTag, i);  
        
                        if (particle->bits&(PARTICLE_VISIBLE|PARTICLE_ALIVE))  
        
                        {  
        
                             \*\* add point particle->off to the end of spline _ _i  
        
                         }  
        
                   }  
      __
      

      _But this way, all your splines would "start" at the same time, since they don't have a time information along with them. Depends on what you're using them for whether that's what you want.

      _

      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 09/03/2010 at 04:20, xxxxxxxx wrote:

        How can i create an array of an array?
        say i have this:
        GeDynamicArray <Vector>tPos;
        and now i want to create an array which itself consists out of it?

        or is there a way to create two-dimensional dynamic arrays? so that i can use myArray[x][y] ??

        or am i totally on the planks and it would be better to check what exactly HyperFiles are and if those can help me in this task??

        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 09/03/2010 at 06:35, xxxxxxxx wrote:

          Well, if you want to do it with a dynamic array, how about an array of dynamic arrays, something like
           GeDynamicArray<GeDynamicArray<Vector>>tposarr;
          then with

          tposarr _[i][j]
          

          you should be able to address spline i's element no j.  _
          _ 
          Whereas I would probably just create an array of pointers to splines, add alle the points to the splines, and then add the splines to the scene. By using pointers, you don't have to worry about handing ownership of the splines over to cinema 4d when adding them to the scene.
           
           
           
           
          _

          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 09/03/2010 at 07:10, xxxxxxxx wrote:

            thank you for pointing that one 🙂 one question remains for me. how do i use push with this? as i did it up to now, using push increased the count of the one-dimensonal array, but what will happen now?

            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 09/03/2010 at 08:34, xxxxxxxx wrote:

              I don't have my Compiler handy right now, so I might be a bit off, but when saying

              tposarr[i]
              

              what you are dealing with is a the array i, and you should be able to deal with it as though it were a normal array.
              Thus,

              tposarr[i].Push(..)
              

              should work.

              Also, when working on a new particle, you might need to do something like a

              tposarr.push(new GeDynamicArray<Vector>)
              

              to append a new array to your array of arrays 🙂

              But bear in mind the following: If a particle's life is only starting in frame 100, then the spline will (with your above code) have the value of frame 100 at position 0, frame 101 at position 1 etc., so whatever you want to do with the splines will not preserve the time. If you want for example to have an object follow the spline, you might need to keep book about each particle's lifespan.

              So, depending on what you want to do, it might be a more interesting alternative to look at animation tracks instead of splines. Depends on your mission 🙂

              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 09/03/2010 at 11:22, xxxxxxxx wrote:

                the mission is to create a trail (spline) for each particle.
                trying to push a new GeDynamicArray<Vector> gives me an error message:

                c4dplugin_test\plugins est\source\etracer.cpp(130) : error C2275: 'GeDynamicArray<TYPE>': Ungültige Verwendung dieses Typs als Ausdruck
                        with
                        [
                            TYPE=Vector
                        ]

                maybe this whole approach wrong? but how else would such stuff work?

                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 09/03/2010 at 13:44, xxxxxxxx wrote:

                  Well, if you just want the trail, without regards to thetimeline, then this should do it, even though it's probably not the most efficient algorithm, depending on how many particles you want to deal with.

                  As I mentioned I don't have my compiler at hand at the moment, so perhaps someone could check this. I think it should be something like

                  tposarr.push(new GeDynamicArray<Vector>())
                  

                  (I'd say the ()'s should do it)

                  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 09/03/2010 at 22:57, xxxxxxxx wrote:

                    Hm, no sorry, the approach with

                    new 
                    

                    was wrong since we're not talking pointers here. But I just saw the GeAutoDynamicArray. It will automatically create new entries on the fly as needed.
                    Thus, you could use

                    GeAutoDynamicArray<GeDynamicArray<Vector>> tposarr
                    

                    Then you don't need the

                    tposarr.push(..)
                    

                    at all.

                    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 10/03/2010 at 00:08, xxxxxxxx wrote:

                      thank for pointing out GeAutoDynamicArray.. can you show me how to put a vector into it?

                      using

                      tposarr[i][j] = particle->off;
                      

                      results in a bunch of errors so i think this is the wrong method..

                      thank you very much for your help

                      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 10/03/2010 at 01:04, xxxxxxxx wrote:

                        You just do

                        tposarr[i].Push(particle->off);
                        

                        Only the Array containing the Arrays needs to be GeAutoDynamicArray, the Arrays it carries are still of type GeDynamicArray, since there may be "holes" in it (for example if a particle doesn't start in frame 0, but only in frame 100.
                        Example: Particle 100 starts it's lifetime at frame 200.
                        If you'd use GeAutoDynamicArray, you would end up with
                        tposarr[100][200] containing the first coordinate, but tposarr[100][0] up to tposarr[100][199] would all be zeroes, which you don't want.
                         
                        By using the above method, tposarr[100][0] would contain the first position of the particle (at frame 200), tposarr[100][1] the second position at frame 201, ...
                        I suppose that's what you want.

                        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 10/03/2010 at 01:56, xxxxxxxx wrote:

                          hm, still the same error..

                          1>c4d_plugin\resource\_api\ge_dynamicarray.h(470) : error C2440: '=': 'Vector *const *' kann nicht in 'GeDynamicArray<TYPE> *' konvertiert werden
                          1>        with
                          1>        [
                          1>            TYPE=Vector
                          1>        ]
                          1>        Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat.
                          1>        c4d_plugin\resource\_api\ge_dynamicarray.h(449) : Bei der Kompilierung der Klassen-template der Bool GeDynamicArray<TYPE>::ReScope(VLONG)-Memberfunktion
                          1>        with
                          1>        [
                          1>            TYPE=GeDynamicArray<Vector>
                          1>        ]
                          1>        c4d_plugin\resource\_api\ge_dynamicarray.h(986) : Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "GeDynamicArray<TYPE>".
                          1>        with
                          1>        [
                          1>            TYPE=GeDynamicArray<Vector>
                          1>        ]
                          1>        c4d_plugin\plugins est\source estobj.cpp(15) : Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "GeAutoDynamicArray<TYPE>".
                          1>        with
                          1>        [
                          1>            TYPE=GeDynamicArray<Vector>
                          1>        ]

                          what does this mean??

                          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 10/03/2010 at 02:35, xxxxxxxx wrote:

                            Please send the exact code from your testobj.cpp, line 15 (& neccessary declarations).
                             Can it be that you did

                            tposarr.push(..)
                            

                            instead of

                            tposarr[i].push(..)
                            

                            ?
                            Because he complains that he got a vector where he expects a GeDynamicArray...

                            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 10/03/2010 at 03:41, xxxxxxxx wrote:

                              line15:

                                
                              GeAutoDynamicArray<GeDynamicArray<Vector>> tposarr;   
                              

                              error comes only when i try this:

                                
                              tposarr[frameNum].Push(source->GetParticleR(pt,i)->off);   
                              
                              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 16/03/2010 at 10:03, xxxxxxxx wrote:

                                Ok, I get the same errors with 11.5 SDK.
                                It comes grom GeAutoDynamicArray's ReScope.
                                It also comes when I substitute GeAutoDynamicArray with GeDynamicArray and use a manual ReSize() before trying to access an element.
                                Seems like a Ge(Auto)DynamicArray doesn't like to resize itself when it carries other Ge(Auto)DynamicArrays.
                                @Matthias , do you see this as an error in the SDK?
                                Or can you recommend an alternative?
                                I myself would go STL or a manually administrated Array of pointers to GeDynamicArrays, but perhaps you can recommend ello something that requires less manual handling?

                                Here's a minimal code snippet to reproduce the compiler errors:

                                    GeAutoDynamicArray<GeDynamicArray<Vector>> tposarr;  
                                  Vector vec;  
                                  tposarr[0].Push(vec);
                                

                                Thanks
                                Mike

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