![]() |
problem with arranging values of an array |
Post Reply
|
| Author | |||
ello
Member
Joined: 2005 Feb 04 Location: Germany Online Status: Offline Posts: 382 |
Post Options
Quote Reply
Topic: problem with arranging values of an arrayPosted: 2010 Mar 06 at 1:13pm |
||
|
User Information: Cinema 4D Version: r11Platform: 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...
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 |
|||
![]() |
|||
ello
Member
Joined: 2005 Feb 04 Location: Germany Online Status: Offline Posts: 382 |
Post Options
Quote Reply
Posted: 2010 Mar 08 at 12:27pm |
||
|
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 |
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 08 at 10:58pm |
||
|
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 |
|||
![]() |
|||
ello
Member
Joined: 2005 Feb 04 Location: Germany Online Status: Offline Posts: 382 |
Post Options
Quote Reply
Posted: 2010 Mar 08 at 11:18pm |
||
|
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 :) |
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 08 at 11:42pm |
||
|
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? |
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 09 at 12:03am |
||
|
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++) 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. Edited by MWittav - 2010 Mar 09 at 12:05am |
|||
![]() |
|||
ello
Member
Joined: 2005 Feb 04 Location: Germany Online Status: Offline Posts: 382 |
Post Options
Quote Reply
Posted: 2010 Mar 09 at 4:20am |
||
|
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?? |
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 09 at 6:35am |
||
|
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
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.
Edited by MWittav - 2010 Mar 09 at 6:39am |
|||
![]() |
|||
ello
Member
Joined: 2005 Feb 04 Location: Germany Online Status: Offline Posts: 382 |
Post Options
Quote Reply
Posted: 2010 Mar 09 at 7:10am |
||
|
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?
|
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 09 at 8:34am |
||
|
I don't have my Compiler handy right now, so I might be a bit off, but when saying
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,
should work. Also, when working on a new particle, you might need to do something like a
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 :-) |
|||
![]() |
|||
ello
Member
Joined: 2005 Feb 04 Location: Germany Online Status: Offline Posts: 382 |
Post Options
Quote Reply
Posted: 2010 Mar 09 at 11:22am |
||
|
the mission is to create a trail (spline) for each particle.
trying to push a new GeDynamicArray<Vector> gives me an error message:
maybe this whole approach wrong? but how else would such stuff work? Edited by ello - 2010 Mar 10 at 1:57am |
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 09 at 1:44pm |
||
|
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
(I'd say the ()'s should do it) |
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 09 at 10:57pm |
||
|
Hm, no sorry, the approach with
Thus, you could use
Then you don't need the
Edited by MWittav - 2010 Mar 09 at 11:02pm |
|||
![]() |
|||
ello
Member
Joined: 2005 Feb 04 Location: Germany Online Status: Offline Posts: 382 |
Post Options
Quote Reply
Posted: 2010 Mar 10 at 12:08am |
||
|
thank for pointing out GeAutoDynamicArray.. can you show me how to put a vector into it?
using
thank you very much for your help Edited by ello - 2010 Mar 10 at 12:08am |
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 10 at 1:04am |
||
|
You just do
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.
|
|||
![]() |
|||
ello
Member
Joined: 2005 Feb 04 Location: Germany Online Status: Offline Posts: 382 |
Post Options
Quote Reply
Posted: 2010 Mar 10 at 1:56am |
||
|
hm, still the same error..
what does this mean?? |
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 10 at 2:35am |
||
|
Please send the exact code from your testobj.cpp, line 15 (& neccessary declarations).
Can it be that you did
Because he complains that he got a vector where he expects a GeDynamicArray...
|
|||
![]() |
|||
ello
Member
Joined: 2005 Feb 04 Location: Germany Online Status: Offline Posts: 382 |
Post Options
Quote Reply
Posted: 2010 Mar 10 at 3:41am |
||
|
line15:
error comes only when i try this:
|
|||
![]() |
|||
MWittav
Member
Joined: 2010 Feb 16 Location: Germany Online Status: Offline Posts: 21 |
Post Options
Quote Reply
Posted: 2010 Mar 16 at 10:03am |
||
|
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:
Thanks Mike Edited by MWittav - 2010 Mar 16 at 10:06am |
|||
![]() |
|||
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |