Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 10/24/26 01:54
Tradestation missing in table of contents
by AndrewAMD. 10/23/26 14:35
No connection to MT4
by JeyKey II. 10/22/26 15:33
Zorro tutorial ideas?
by mistery. 10/21/26 05:28
Avoid "log\ - delete old files" message
by Martin_HH. 10/20/26 07:23
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (TipmyPip), 7,671 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
JimSimons, julienp, julienper, KelleyAbbey, Yopachi
19246 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Beziers #341935
09/22/10 01:48
09/22/10 01:48
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline OP
Expert
Joozey  Offline OP
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
I made a little module for creating bezier paths. The conventions of programming I use may be a littlebit unfamiliar/obscure to you. I'm not going to change that tongue.

Quote:
BEZIERPATH_Create( void *function, var precision )
Creates a new bezier path. function will be called when the path is drawn, and a VECTOR* is given through for you to do something with (like a draw_line function). var point and var part are also given to function, which are the bezierpoint number and segment number (relative to the bezierpoint) resp.
precision gives the precision of the path drawn (e.g. amount of segments between two points) in the form of (1/precision).

BEZIERPATH_Add( BEZIERPATH *bp, VECTOR *pos, VECTOR *outgoing, VECTOR *incomming )
Adds a new bezierpoint to bezierpath bp. The point has position pos, an outgoing and an incomming control point (both relative to its position).

BEZIERPATH_Draw( BEZIERPATH *bp )
Draws the bezierpath bp (and calls the function given in BEZIERPATH_Create [precision*total_bezierpoints] times)


About beziers:
Beziers are curved lines from A to B, angling towards a set of control points. I chosed 2 control points per curve in this module, but I might update it to a user defined amount.
Read more about it here: http://en.wikipedia.org/wiki/B%C3%A9zier_curve

It is handy to draw nice curved paths, splines, anticipate autopilot direction of your spaceship and many other things. I'm sure you see the possibilities laugh. Beware though that because I use vector functions, which are fueled by "var" elements, the precision is not very well. At 0.01 precision (100 segments between A and B ) you can clearly see rounding errors. I tried floats but that just makes your CPU go nuts tongue. Any suggestions are welcome.





Download code here

Let me know if it is easy to use, or things are confusing somewhere.

Regards,
Joozey


Last edited by Joozey; 09/22/10 01:59.

Click and join the 3dgs irc community!
Room: #3dgs
Re: Beziers [Re: Joozey] #341962
09/22/10 09:53
09/22/10 09:53
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
Puppeteer Offline
Expert
Puppeteer  Offline
Expert

Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
Naice work!

But i would rather render them on a bitmap (maybe with floats). so the beziers dont have to be calculated in every frame. It depends kinda on how someone is going to use them.


Formally known as Omega
Avatar randomness by Quadraxas & Blade
http://omegapuppeteer.mybrute.com
Re: Beziers [Re: Puppeteer] #341998
09/22/10 15:22
09/22/10 15:22
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Joozey, you rock! Thanks for this :-)

Re: Beziers [Re: HeelX] #342002
09/22/10 16:00
09/22/10 16:00
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline OP
Expert
Joozey  Offline OP
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
@puppeteer: you could render the vectors simply in an array and use them from there all the time laugh. I should add a function to update and remove a bezier, rather than just add one. But you can do that too, it's not too hard laugh.

@heelx: Thank you laugh


Click and join the 3dgs irc community!
Room: #3dgs

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1