Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Probably everyone is familiar with all kinds of visual node based programming tools like HLSL editor in Visual Studio 2011 or UDK engine Kismet/Material editors. My point of interest are the connectors between the nodes. Basically those are implementation of Bezier Curve algorithms. Those are not hard to put into code.

How I make each connector line bend into right direction and with the right angle when it is being connected between two points not laying on the same line?

share|improve this question
1  
I guess that question is better suited for stackoverflow –  bummzack Jan 9 '12 at 10:04
    
Yeah ,I think I will post it there.Tnx. –  Michael IV Jan 9 '12 at 10:07

2 Answers 2

up vote 6 down vote accepted

Start with something simple. Use cubic bezier curves (2 control points), with the control points directly pointing out from the control nodes by some fixed distance. That should be good enough.

share|improve this answer
3  
You can also use cubic Hermite splines, where you directly specify the endpoints and the tangent vector at each endpoint. (They are mathematically equivalent to Bezier curves with the control points placed as you described.) –  Nathan Reed Jan 9 '12 at 17:26
    
@NathanReed Doesn't the Hermite spline run through the control points? That would make it actually less suited imho. –  bummzack Jan 9 '12 at 21:10
2  
@bummzack A Hermite spline has two endpoints (which it touches) and lets you directly specify the tangent vectors at those endpoints. A Bezier spline likewise has two endpoints, but shapes the curve by using two additional control points that it doesn't necessarily touch. You might be thinking of Catmull-Rom splines, which do run through all their control points (and are internally a set of Hermite splines with the tangents calculated based on neighboring control points). –  Nathan Reed Jan 9 '12 at 21:28
1  
I am using Flash Player API .It has got a built in cubic bezier.So to construct one is not a problem.The problem is to adjust its curve when you actually manipulate only the end point of the connector.Think of it this way:The start point of the connector line is connected to a node at x:100,y:100 .The endpoint is connected to the next node at the point x:500,y:400 so as you can imagine the curve should adjust itself to a sinusoidal bent for this position.Yeah I can think about all kind of trig solutions but I thought may be anybody knows some specific API that supplies all this . –  Michael IV Jan 10 '12 at 7:34

I would personnaly use a cosinus. Why bother with a complicated and costly bezier curve ?

share|improve this answer
1  
If the connectors are always horizontal, then a scaled cosine curve would actually be a pretty good and simple solution if the connections always go from the right side of the left node to the left side of the right node. Trouble is, often times you will drag nodes around so that this is not the case. –  Nathan Reed Jan 9 '12 at 18:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.