Skip to main content
GameDev.net gamedev.net
🔒 Locked

Drawing curve in directX

Started by transcendent_one May 3, 2005 at 2:41 AM 4 replies 9.2k views
Original Post
transcendent_one
transcendent_one
Hi. Does anyone know how to render curve in directx? I know that i have to use spline interpolation or something similar, but the problem is that i dont know if there are any simple solutions in directx. I have managed to find functions like D3DXVec3CatmullRom(...) but i dont really understand how it works. Please help. Thanks
dave
dave
What is this curve for? If its a simple circle or oval you are after it is easier. Also is this needed in 2D or 3D space?

ace
darookie
darookie
D3DXVec3CatmullRom is a very handy function. You just pass in the control points of your curve and it calculates interpolated intermediate points for you.

You can use a line-strip to render the output (no matter whether it's 2D or 3D).

If you need more info, just ask.

Regards,
Pat
transcendent_one
transcendent_one
Well, the task is a bit hard. I have to draw a set of isolines (curves) onto the screen by given points. Everything will be in 2d space, but i will have to represent z value by drawing these curves.
My other question would be: i pass four points to D3DXVec3CatmullRom, but i get only one point back, so how can i draw (sorry, my english is shit :)) more realistic curves, i mean how can i get more points? Do i have to call it recursively to obtain requred number of points, or there is other solutions?
Are there any better interpolation functions in DX?
Evil Steve
Evil Steve
Quote:
Original post by transcendent_one
My other question would be: i pass four points to D3DXVec3CatmullRom, but i get only one point back, so how can i draw (sorry, my english is shit :)) more realistic curves, i mean how can i get more points? Do i have to call it recursively to obtain requred number of points, or there is other solutions?
Yup, you call it repeatedly. The last paremter s is the weighting factor. You call the function as many times as you want, passing a larger s each time. For example, you could call it 5 times with s = 0.0f, 0.25f, 0.5f, 0.75f and 1.0f to give you 5 points along the curve.

From the DX9 docs:
Quote:
Given four points (p1, p2, p3, p4), find a function Q(s) such that:

Q(s) is a cubic function.
Q(s) interpolates between p2 and p3 as s ranges from 0 to 1.
Q(s) is parallel to the line joining p1 to p3 when s is 0.
Q(s) is parallel to the line joining p2 to p4 when s is 1.


Edit: This might help:
Catmull Rom
The red lines are immaginary, the black line is the generated spline. I'm not entirely sure that I've got that right, someone feel free to correct me if I'm wrong.
transcendent_one
transcendent_one
Thanks guys. There's one more question, are there any directx online tutorials or samples how to implement curve drawing? I tried to google but coulndt find anythig useful.

Thanks again.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.