View Full Version : Pulsating Objects

02-19-2002, 12:33 PM
What is a simple function to make an object pulsate?

02-19-2002, 12:38 PM
what about glscale?
just a guess

02-19-2002, 12:47 PM
yes, glScale will work. But i was told to use a sine function to implement the pulsating. That is where i am lost

02-19-2002, 01:04 PM
Using a sine wave would be a good solution. You could have the size of your object 'pulsate' between big and small by doing something like:

int size = originalsize+sin(2*PI*curtime/frequency)*amplitude;

where curtime is a variable that is increased every frame. the other variables can just be constants that you think look good. Also you could do something similar to this that affects the alpha value and enable blending so that when the object gets smaller it fades for example

02-19-2002, 01:11 PM
Hey thanks, I actually just figured out something like that. A little lost on the fading bit though. It sounds cool. Could you explain that some more? Thanx

02-19-2002, 02:04 PM
the sine function returns values between -1 and 1
so you do not add the original size and do not multiply by amplitude but therefor map the values to 0 to 1 (only for the color not for your scaling)
and this value is set to the alpha value using glcolor4f

did i get it right tempocrew?