FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Emitter position

3 posters

Go down

Emitter position Empty Emitter position

Post  iphoniac Tue Jan 13, 2009 3:58 pm

I have an emitter and it changes its position. I do it with this code:

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.

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Emitter position Empty Re: Emitter position

Post  meteors Tue Jan 13, 2009 5:04 pm

What values do you get when you print to console?

printf()





Best,
-j
meteors
meteors

Posts : 241
Join date : 2008-11-08
Location : Sunny Florida

Back to top Go down

Emitter position Empty Re: Emitter position

Post  sw Tue Jan 13, 2009 9:33 pm

you need to adjust the _particle position . Very Happy Very Happy
sw
sw

Posts : 73
Join date : 2008-10-12

Back to top Go down

Emitter position Empty Re: Emitter position

Post  iphoniac Wed Jan 14, 2009 3:44 am

If I reset and setup the particles with this code:
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);
The result is:
Code:

Object: -1.434598, 10.548120, -2.418906
Particle: -1.434598, 10.548120, -2.418906
Particle: -1.434598, 10.548120, -2.418906
.
.
.
I see the emitter but not in the position it should be (the _object position). If I let the emitter position to be (0,0,0) the emitter is shown in the correct position with both pieces of code.

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.

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Emitter position Empty Re: Emitter position

Post  sw Wed Jan 14, 2009 4:30 am

just set the particle position to zero.
the particle position is a relative number to the emitter
sw
sw

Posts : 73
Join date : 2008-10-12

Back to top Go down

Emitter position Empty Re: Emitter position

Post  iphoniac Wed Jan 14, 2009 4:51 am

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:
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;
      }
The particle pos is copied from the emitter position.

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.

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Emitter position Empty Re: Emitter position

Post  iphoniac Wed Jan 14, 2009 6:39 am

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

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Emitter position Empty Re: Emitter position

Post  sw Wed Jan 14, 2009 8:48 pm

Very Happy Laughing
sw
sw

Posts : 73
Join date : 2008-10-12

Back to top Go down

Emitter position Empty Re: Emitter position

Post  iphoniac Thu Jan 15, 2009 3:44 am

I donīt see the fun in it...

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Emitter position Empty Re: Emitter position

Post  sw Thu Jan 15, 2009 9:42 pm

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
sw

Posts : 73
Join date : 2008-10-12

Back to top Go down

Emitter position Empty Re: Emitter position

Post  iphoniac Sun Jan 18, 2009 11:56 am

Holy sh!t, you were right. Embarassed Embarassed Embarassed Embarassed Embarassed Embarassed Embarassed Embarassed Embarassed Embarassed

My apologies Neutral

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Emitter position Empty Re: Emitter position

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum