DirectX9 - 3d object translating with sine wave pattern ...
-
does anyone know how to get an object moving along the path of a sine wave? I've got my object translating across the screen with simple matrix multiplication in DX9 but I can't figure out the sine wave path. anyone have any ideas?
Move the world matrix of that object according to the sine wave. The position of the matrix is a vector with 3 components, so create a function that returns a "sine wave" vector by giving the relative or absolute time (depends on your timing model) as function parameter and add the result vector's components to the position values of the world matrix. How such a function should look like is quite easy. I think you want to use the y-axis as magnitude of the wave. So: y = sin("angular velocity" * t); Then you have to define a movement vector for spreading directon of the wave (let's call it v). x = v.x * t; z = v.z * t; I hope that helps... Regards, Alex Don't try it, just do it! ;-)
-
Move the world matrix of that object according to the sine wave. The position of the matrix is a vector with 3 components, so create a function that returns a "sine wave" vector by giving the relative or absolute time (depends on your timing model) as function parameter and add the result vector's components to the position values of the world matrix. How such a function should look like is quite easy. I think you want to use the y-axis as magnitude of the wave. So: y = sin("angular velocity" * t); Then you have to define a movement vector for spreading directon of the wave (let's call it v). x = v.x * t; z = v.z * t; I hope that helps... Regards, Alex Don't try it, just do it! ;-)
-
Move the world matrix of that object according to the sine wave. The position of the matrix is a vector with 3 components, so create a function that returns a "sine wave" vector by giving the relative or absolute time (depends on your timing model) as function parameter and add the result vector's components to the position values of the world matrix. How such a function should look like is quite easy. I think you want to use the y-axis as magnitude of the wave. So: y = sin("angular velocity" * t); Then you have to define a movement vector for spreading directon of the wave (let's call it v). x = v.x * t; z = v.z * t; I hope that helps... Regards, Alex Don't try it, just do it! ;-)
I guess I don't fully understand. I've got my timer around my render function so it only renders if the time is more than a certain value. What exactly do you mean give the relative or absolute time to the "sine wave" function? Also what would I use to calculate my angular velocity and my movement vector? I think I'm starting to understand, thanks a lot for you help. j