Advertisement Jump to content
Sign in to follow this  
FiberCore

How to build a smart bezier curve?

This topic is 1734 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

I want to build a smart bezier curve like this. There are 100 targets (grid) in the map. I know the source point (Rocket), and the target point (Grid). How to calculate two control points to build a beautiful bezier curve which can not across the blue map?

 

bzH.png

Share this post


Link to post
Share on other sites
Advertisement

I want to build a smart bezier curve like this. There are 100 targets (grid) in the map. I know the source point (Rocket), and the target point (Grid). How to calculate two control points to build a beautiful bezier curve which can not across the blue map?


"a beautiful bezier curve which" what?

Share this post


Link to post
Share on other sites

If you know it will only ever be 100 targets and the position of the source is constant, it might be easiest to just generate all 100 of them manually.

 

If you need to come up with an algorithmic solution you would probably want to base it on whatever is aesthetically pleasing to you, and that is going to take a lot of work. 

Share this post


Link to post
Share on other sites

A variation of frobs idea:

Perhaps you can hard code the edge cases, and dynamically generate the easy cases where the ship/target are not near the edges?

 

You might also consider not using a curve, maybe doing it via physics?  A steering system that considers the edges as something to avoid would do their best to not touch them.  Though you do run into a problem where the object might not always make it perfectly to the point.  (Which you can kind of fake if you really need it.)

 

How are you determining the curve?  If you have points you know you want the thing to pass through, you could try catmull-rom, and then it's pretty easy to ensure that the catmull-rom control points are clamped to be inside the blue rectangle, which would mostly get you the curve you want.  (Not perfect, you'd still run into cases where you might go outside)

 

Another thing you might want to do, is instead of using some sort of parameterized curve, use a Dubin's Curve instead, and adjust start angle or the min radius as necessary so that the curve doesn't go outside the bounds. 

Share this post


Link to post
Share on other sites

I am not quite sure I am following what you are asking here. You know two points. And you need two control points... I got that.

 

Why not just use the two points you have to form the two control points? If you are attempting to calculate trajectory, that is actually all you need unless your physics engine is some odd design.

 

If you mean, you do not want it to cross the map, I assume the grid, then you will want to use an invisible anchor that will collide with the grid, which effectively will cause the bezzier to adjust it's shape.

 

If you follow this idea, you will need to adjust it slightly so that the bezzier doesn't take such a large curve as well.

Edited by Tangletail

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!