Emitter position
3 posters
Emitter position
I have an emitter and it changes its position. I do it with this code:
But the position is not the same as object. What am I doing wrong?
Cheers.
- Code:
_SIO2emitter1->pos->x = _Object->pos->x;
_SIO2emitter1->pos->y = _Object->pos->y;
_SIO2emitter1->pos->z = _Object->pos->z;
_SIO2emitter1->_SIO2particlecreation = particle_creation;
sio2EmitterBindMatrix(_SIO2emitter1);
sio2EmitterPlay( _SIO2emitter1 );
But the position is not the same as object. What am I doing wrong?
Cheers.
Re: Emitter position
What values do you get when you print to console?
printf()
Best,
-j
printf()
Best,
-j
meteors- Posts : 241
Join date : 2008-11-08
Location : Sunny Florida
Re: Emitter position
If I reset and setup the particles with this code:
The printed text is:
Particle text printed in particle creation. The emitter is not shown (or at least I donīt see it, perhaps itīs out of the screen)
If I do not reset and setup the particles:
As the particle and object position are equal, the problem is not with the particle or emitter position. The only thing I think now is emitters have a different coordinate system and thatīs because I donīt see it.
More info: Thereīs one emitter and after half a second of play, itīs particle creation callback funtion is set to null (thatīs a way to stop emitter but render the created and still not dead particles, I think the sio2EmitterPause should do that). This emitter is an explosion so when the object is eliminated (previous code) I reset the callback function with _SIO2emitter1->_SIO2particlecreation = particle_creation, delete the object and restart the timer for the half second.
Cheers.
- Code:
sio2EmitterResetParticles(_SIO2emitter1);
printf("Object: %f, %f, %f\n", _Object->pos->x, _Object->pos->y, _Object->pos->z);
memcpy( _SIO2emitter1->pos, _Object->pos, 12 );
sio2EmitterBindMatrix(_SIO2emitter1);
sio2EmitterSetupParticles(_SIO2emitter1);
_SIO2emitter1->_SIO2particlecreation = particle_creation;
sio2EmitterPlay( _SIO2emitter1 );
sio2TimerPlay(_SIO2timer1);
The printed text is:
- Code:
Object: 1.594214, 8.439402, 2.857523
Particle: 1.594214, 8.439402, 2.857523
Particle: 1.594214, 8.439402, 2.857523
.
.
.
Particle text printed in particle creation. The emitter is not shown (or at least I donīt see it, perhaps itīs out of the screen)
If I do not reset and setup the particles:
- Code:
//sio2EmitterResetParticles(_SIO2emitter1);
printf("Object: %f, %f, %f\n", _Object->pos->x, _Object->pos->y, _Object->pos->z);
memcpy( _SIO2emitter1->pos, _Object->pos, 12 );
sio2EmitterBindMatrix(_SIO2emitter1);
//sio2EmitterSetupParticles(_SIO2emitter1);
_SIO2emitter1->_SIO2particlecreation = particle_creation;
sio2EmitterPlay( _SIO2emitter1 );
sio2TimerPlay(_SIO2timer1);
- Code:
Object: -1.434598, 10.548120, -2.418906
Particle: -1.434598, 10.548120, -2.418906
Particle: -1.434598, 10.548120, -2.418906
.
.
.
As the particle and object position are equal, the problem is not with the particle or emitter position. The only thing I think now is emitters have a different coordinate system and thatīs because I donīt see it.
More info: Thereīs one emitter and after half a second of play, itīs particle creation callback funtion is set to null (thatīs a way to stop emitter but render the created and still not dead particles, I think the sio2EmitterPause should do that). This emitter is an explosion so when the object is eliminated (previous code) I reset the callback function with _SIO2emitter1->_SIO2particlecreation = particle_creation, delete the object and restart the timer for the half second.
Cheers.
Re: Emitter position
just set the particle position to zero.
the particle position is a relative number to the emitter
the particle position is a relative number to the emitter
sw- Posts : 73
Join date : 2008-10-12
Re: Emitter position
ummm, I may be wrong but I think particles has its own position. Look for example at this piece of code in particle_creation in example 12:
And if youīre right and the particle position is relative to emitter position, when I set the particle creation callback function, the particles are created using the new position of the emitter and I should be created in the right position.
Cheers.
- Code:
// Sparkle
case 4:
{
_SIO2particle->col->x = sio2Randomf() + 0.15f;
_SIO2particle->col->y = sio2Randomf() + 0.15f;
_SIO2particle->col->z = sio2Randomf() + 0.15f;
memcpy( _SIO2particle->pos, _SIO2emitter->pos, 12 );
_SIO2particle->lifetime = MAX_LIFETIME;
_SIO2particle->speed = (float)sio2Randomui( (unsigned int)MAX_SPEED ) / 100.0f;
_SIO2particle->size = (float)sio2Randomui( 16 );
_SIO2particle->angle = (float)sio2Randomui( 360 );
break;
}
And if youīre right and the particle position is relative to emitter position, when I set the particle creation callback function, the particles are created using the new position of the emitter and I should be created in the right position.
Cheers.
Re: Emitter position
In SIO2EmitterRender, the particle position is extracted directly from _SIO2emitter, not taking itīs position as a relative:
- Code:
glVertexPointer( 3, GL_FLOAT, 0, _SIO2emitter->_SIO2particle[ i ]->pos );
Re: Emitter position
iphoniac wrote:I donīt see the fun in it...
- Code:
// Sparkle
case 4:
{
_SIO2particle->col->x = sio2Randomf() + 0.15f;
_SIO2particle->col->y = sio2Randomf() + 0.15f;
_SIO2particle->col->z = sio2Randomf() + 0.15f;
///memcpy( _SIO2particle->pos, _SIO2emitter->pos, 12 );
_SIO2particle->pos->x = 0.0f;
_SIO2particle->pos->y = 0.0f;
_SIO2particle->pos->z = 0.0f;
_SIO2particle->lifetime = MAX_LIFETIME;
_SIO2particle->speed = (float)sio2Randomui( (unsigned int)MAX_SPEED ) / 100.0f;
_SIO2particle->size = (float)sio2Randomui( 16 );
_SIO2particle->angle = (float)sio2Randomui( 360 );
break;
}
sw- Posts : 73
Join date : 2008-10-12
Similar topics
» Emitter positions
» Stopping emitter after 1 'cycle'
» Problems with the emitter tutorial
» Placing particles emitter in front of camera
» Resetting object position
» Stopping emitter after 1 'cycle'
» Problems with the emitter tutorial
» Placing particles emitter in front of camera
» Resetting object position
Permissions in this forum:
You cannot reply to topics in this forum