Setting a particles position directly?

Posted By: Rackscha

Setting a particles position directly? - 01/13/13 18:56

Hi,
currently i need to set a particles position directly.
For this purpose, i save all particles in a list to access them.
(these particles are never deleted)

the global vars:
Code:
PARTICLE** PList;
int FirstPIndex = 0;



the particle function to initialize itself
Code:
function PInit(PARTICLE* p)
{
	PList[FirstPIndex] = p;
	FirstPIndex++;
	p.size = 16;
	p.lifespan = 100;
	set(p, MOVE | BRIGHT | TRANSLUCENT);
}



this should store the particles BUT when i loop through the registered range(0 to FirstPIndex-1) to manipulate the positions, nothing happens to them :|

Code:
for(i = 0; i < FirstPIndex; i++)
		{
			(PList[FirstPIndex]).x = 0;
			(PList[FirstPIndex]).y = 300;
			(PList[FirstPIndex]).z = 0;
		}



Someone has an idea?
Posted By: muffel

Re: Setting a particles position directly? - 01/13/13 19:39

Flüchtigkeits Fehler. Schau dir die Indizes mal an.
So sollte es aussehen
Click to reveal..

Code:
for(i = 0; i < FirstPIndex; i++)
		{
			(PList[i]).x = 0;
			(PList[i]).y = 300;
			(PList[i]).z = 0;
		}


muffel
Posted By: Rackscha

Re: Setting a particles position directly? - 01/13/13 21:11

ou...shame on me^^

But something is still wrong:

even after correcting, the particles do not changes their position according to the set values.

For testing purpose, i changed the list to store entities instead of Particles(and added entities) but they didnt change either. So something is still wrong o.O

And something that bothers me:
it seems a particle MUST have a function. The above particle function executes itself each frame(which leads to an array overflow). So i added a dummy event which just sets lifespan to 100.

Isnt it possible to just create undead particles without a function? thats currecntly up to 5k unecessary call stuff per frame frown

EDIT: okay that worked for some reason:

Code:
LP = PList[i];
			LP.x =  (GPosition[i]).x*40;	
			LP.y = (GPosition[i]).z*40;
			LP.z = (GPosition[i]).y*40;

Posted By: Uhrwerk

Re: Setting a particles position directly? - 01/14/13 00:14

Of course you can use particles without functions. You can either pass NULL to effect or use a function in effect to initialize the particles and the manually set p->event to NULL.

Why "for some reason"? Is there anything unclear?
Posted By: Rackscha

Re: Setting a particles position directly? - 01/14/13 10:10

The worked for "some reason" has the open question in my mind:

what is the difference between:

Code:
(List[Index]).x = 5;



and

Code:
LP = LIst[Index];
LP.x = 5;



The first doesnt work(but no exception/error), but the second works. Can someone explain this behaviour to me?
Posted By: MasterQ32

Re: Setting a particles position directly? - 01/14/13 10:47

Originally Posted By: Rackscha
The first doesnt work(but no exception/error), but the second works. Can someone explain this behaviour to me?

This is called Lite-C grin
I ran into this problem also and i hate it...

try with
(List[Index])->x

and a tip from my side:
#define PRAGMA_POINTER
© 2024 lite-C Forums