Jump to content
  • Advertisement
Sign in to follow this  
Juliean

OpenGL How to draw [these kind of] splines?

This topic is 1673 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites

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.

Edited by Juliean

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!