problem with arranging values of an array



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

    On 06/03/2010 at 13:13, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   r11 
    Platform:      
    Language(s) :     C++  ;

    ---------
    Hi there,

    i am missing the idea how to read out an array in the right order. this is my code where i put coordinates into an array and how i take them to build points of a spline. i just dont get the final idea how to read out the values properly so they build up correct trails of the particles...

      
                   for (int i = 0; i<particleCount;i++)   
                   {   
                        const Particle *particle = particleObject->GetParticleR(particleTag, i);   
                        if (particle->bits&(PARTICLE_VISIBLE|PARTICLE_ALIVE))   
                        {   
                             punkte.Push(particle->off);   
                        }   
                   }   
                   padr = splineResult->GetPointW();   
      
                   for (int j=0;j<punkte.GetCount();j++)   
                   {   
    //i know that my fault is in this part   
                        if (j<splineResult->GetPointCount())   
                             padr[j] = punkte[j];   
                   }   
    

    here is a screenshot. its looking nice, but obviously not the way i want it to look :)

    i hope someone can give me a hint how to adress the array properly here..

    thanks in advance
    cheers,
    ello



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

    On 08/03/2010 at 12:27, xxxxxxxx wrote:

    Anyone?? I still dont have an idea how to calculate the number of the correct entry in the array. i guess i need to step thru the array by somewhat combination of the framenumber and the number of current particles, but how to do this i dont have any meanings...

    cheers,
    ello



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

    On 08/03/2010 at 22:58, xxxxxxxx wrote:

    Hm, what is it you want to do? I'm a bit irritated by you saying you need the framenumber...
    Do you want to track one specific particle over time, or do you want one spline interconnecting all current particles (then I don't see where you would need the framenumber)?
    Your code looks like you are trying to interconnect all currently visible/alive particles, and it seems like it is more or less working, at least I can see indentations yielding towards the particles. Perhaps a bit tweeking of the spline's interpolation mode is neccessary?

    Cheers
    Mike



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

    On 08/03/2010 at 23:18, xxxxxxxx wrote:

    no, i want to create a spline that shows the particle trails..
    the positions are all there, i just need to connect them properly, and thats where my brain simply shuts down :)



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

    On 08/03/2010 at 23:42, xxxxxxxx wrote:

    So you just want to track one single particle?
    But your first loop iterates through all particles from one emitter.

    particleObject->GetParticleR(particleTag, i)
    

    gives you particle i, not particle x's position at a certain time. Thus, you end up connecting all particles of the selected emitter.
    To track one particle, you'd need to follow this one through time.
    Or do I mis-interpret you?



  • 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.

    _



  • 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??



  • 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.
     
     
     
     
    _



  • 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?



  • 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 :-)



  • 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?



  • 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)



  • 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.



  • 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



  • 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.



  • 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??



  • 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...



  • 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);   
    


  • 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


Log in to reply