I had the idea that certain UI components of my project could 'fly away' when I decided to move to another screen. Sure, I could just send them along a straight +X or +Y line until they disappeared from the screen, but I thought that it would be very nice looking to have them follow a flight plan that was described by a curve - maybe even a random curve - but a curve anyway.
So, I've started educating myself about OpenGL and calculating and drawing Bezier curves. Here is the entirety of my code - it is pretty straightforward and will run easily (just a TForm, with a client-aligned TPanel and a TTimer). This code calculates a curve via four control points and is able to display it on the screen - as well as displaying each point on the curve and the control points connected via a thin red line.
What I'm curious about is the code at lines 137 and 148 - the lines that use glEvalCoord1f to apparently draw out a GL_POINT (or a part of a LINE_LOOP) by referencing some values it seems to have pre-calculated with the call to glMap1f earlier - or is calculating on the fly.
While calculating my curve, I would prefer to be able pre-calculate and store the X, Y and Z of each point on the curve in an array - so I can look them up later - glEvalCoord1f is obviously pulling out the correct details - but 1) I don't really know where it is getting them from and 2) I don't know if I can access them in code so I can use glVertex3f to display things.
Is there a way of 1) setting up my control points, 2) setting a number of segments (level of detail), 3) calculating the curve according to the control points and number of segments (level of detail) I want and 4) storing the values of each point on the curve in X, Y and Z format in an array, so that I can then 5) reference them so my moving objects can follow some kind of flight plan?
glEvalCoord1f is great in that it obviously returns or uses some form of X, Y and Z values for the LINE_LOOP and GL_POINTs loop it is being used in - but it is not a function, so I don't know how to get my X, Y and Z values from it... does that make sense?
Registriert: Sa Jan 01, 2005 17:11 Beiträge: 2067
Programmiersprache: C++
Casteljau:
b_k^n (x) := x_k, k = 0,..., n;
b_k^(j+1) (x) := u_o(x|I) b_k^j (x) + u_1(x|I) b_(k+1)^j (x), k = 0,..., n - j - 1;
where u_0 and u_1 are "baryzentrische Koordinaten" which meens:
u_0(x|I) := (t_1 - x) / (t_1 - t_0)
and
u_1(x|I) := (x - t_0) / (t_1 - t_0)
where t_0 and t_1 are the points at the border of the interval I.
b_0^n(x) is the value of the bezier curve at point x.
Mitglieder in diesem Forum: 0 Mitglieder und 13 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.