|
|
Setting a particles position directly?
#415090
01/13/13 18:56
01/13/13 18:56
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
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:
PARTICLE** PList;
int FirstPIndex = 0;
the particle function to initialize itself
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 :|
for(i = 0; i < FirstPIndex; i++)
{
(PList[FirstPIndex]).x = 0;
(PList[FirstPIndex]).y = 300;
(PList[FirstPIndex]).z = 0;
}
Someone has an idea?
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Setting a particles position directly?
[Re: Ayumi]
#415094
01/13/13 19:39
01/13/13 19:39
|
Joined: Oct 2009
Posts: 149 Germany
muffel
Member
|
Member
Joined: Oct 2009
Posts: 149
Germany
|
Flüchtigkeits Fehler. Schau dir die Indizes mal an. So sollte es aussehen
for(i = 0; i < FirstPIndex; i++)
{
(PList[i]).x = 0;
(PList[i]).y = 300;
(PList[i]).z = 0;
}
muffel
|
|
|
Re: Setting a particles position directly?
[Re: muffel]
#415104
01/13/13 21:11
01/13/13 21:11
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
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  EDIT: okay that worked for some reason:
LP = PList[i];
LP.x = (GPosition[i]).x*40;
LP.y = (GPosition[i]).z*40;
LP.z = (GPosition[i]).y*40;
Last edited by Rackscha; 01/13/13 21:20.
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Setting a particles position directly?
[Re: Rackscha]
#415115
01/14/13 00:14
01/14/13 00:14
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
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?
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Setting a particles position directly?
[Re: Uhrwerk]
#415130
01/14/13 10:10
01/14/13 10:10
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
The worked for "some reason" has the open question in my mind: what is the difference between: and
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?
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Setting a particles position directly?
[Re: Rackscha]
#415133
01/14/13 10:47
01/14/13 10:47
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
The first doesnt work(but no exception/error), but the second works. Can someone explain this behaviour to me? This is called Lite-C  I ran into this problem also and i hate it... try with (List[Index])->x and a tip from my side: #define PRAGMA_POINTER
|
|
|
|