Hello, I have to do a work for my college that I had to travel a camera between 4 points using a spline curve(GLM_GTX_spline), but I dont know where to start, I search in the internet for the theory but I didnt found anything useful…

Can someone help me? Just to put me in the way…

I already found this function to calculate the curve: genType catmullRom (genType const &v1, genType const &v2, genType const &v3, genType const &v4, typename genType::value_type const &s), but I dont know the last parameter neither the return.

If you know the points on the spline then you can move towards those points. I did an XNA example in 2D where sprites followed splines. If the closest point on the track is your target, you can move to the next point on the track once you arrive at the target. The next point becomes your new target.

[QUOTE=matheusweber;1282477]Hello, I have to do a work for my college that I had to travel a camera between 4 points using a spline curve(GLM_GTX_spline), but I dont know where to start
[/QUOTE]

Do you just want to move the camera along the curve while its direction remains fixed, or do you want the camera to rotate to follow the direction of the curve (so that the camera is always moving “forward” based upon the view direction).

If it’s the latter, you need to calculate derivatives, either analytically or by evaluating the curve at similar values of the parameter, i.e. s and s+ds where ds is much less than 1. You can then use the two points as the eye and center parameters to glm::lookAt().

Do you have a fixed “up” direction, or should the view rotate according to the curvature? If it’s the latter, you also need an approximate second derivative. This can be found analytically or by using three equally-spaced points, with the up vector given by f(s-ds)+f(s+ds)-2*f(s). Note that if the curvature is zero (i.e. if a curve segment is a straight line, or at an inflection point), then the up vector is undefined.

You also need to consider speed. If the curves have second-order continuity, then each segment corresponds to the same time interval. Otherwise, you need to define the parameter s as an affine function of time, s=s0*(1-t)+s1*t where s0 and s1 are chosen to avoid instantaneous changes in speed at the boundaries between segments.