Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


How to draw [these kind of] splines?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Juliean   GDNet+   -  Reputation: 2695

Like
0Likes
Like

Posted 16 May 2014 - 10:18 AM

Hello,

 

I'm implementing visual scripting similar to what Unreal realizes in their blueprints to my engine. Now I'm wondering, how do you render those kind of connection-splines in DX/OpenGL?

 

2435-rocket_spawner_blueprint.png

As you can see in this screenshot, they behave quite... special... and appear totally smooth here. I suppose that did use something other than pure DX/OGL, but does somebody know a formular for generating enough controller-points between two points p1 and p2 so I can render such a smooth line in that fashion using line rendering?



Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 5714

Like
2Likes
Like

Posted 16 May 2014 - 11:06 AM

To my eye it looks like most of the curves could be done using Bezier curves. E.g., for horizontal: (screen coord) control points p1 = p0 + (scale,0), p2 = p3 + (-scale,0), where p0 and p3 are the screen coord start/end points. It's been a few years since I've done it, but, if you're working in Windows, you can grab the window HDC and use GDI with PolyBezier. "scale" would be proportional to delta-x.


Edited by Buckeye, 16 May 2014 - 11:08 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#3 eppo   Crossbones+   -  Reputation: 2546

Like
2Likes
Like

Posted 16 May 2014 - 12:01 PM

I suspect you'll be able to draw such a spline as a Hermite curve using only an outgoing and an incoming set of positions and (flat/horizontal) tangents.

 

You can use the Hermite routines that come with the D3DX-library.

 

http://msdn.microsoft.com/en-us/library/windows/desktop/bb204998(v=vs.85).aspx

 

Or you can use the cubic equations mentioned there directly.



#4 Juliean   GDNet+   -  Reputation: 2695

Like
2Likes
Like

Posted 17 May 2014 - 05:30 AM

Thanks,

 

I managed to get a generic b-spline algorithmn that I further found to running using the control points you mentioned, though I had to use delta-x/2 to get the desired result. I'm simply drawing the lines in DX/GL for now, since my whole gui is rendered with those, it fit better than using GDI. Now all I've got to do is adding support for drawing thicker lines, but I already got an basic idea how to do this, so not a problem.

Attached Thumbnails

  • EventsSplines.png

Edited by Juliean, 17 May 2014 - 05:31 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS