PDA

View Full Version : Spline Editor



chronozphere
11-04-2011, 06:50 AM
Hey guys,

It's been a while since I last worked on a Pascal project, but it's about time I start something new again. This project involves building a WYSIWYG spline editor that I will use for TubeRunner (Which I really hope to finish in October this year). Features include:

> WYSIWYG editing by dragging handles (done)
> Move/Zoom camera with mouse (done)
> Switch between views (top/side/front)... yes It's a 3D spline. :D
> Click on spline to create a new anchor
> Manual editing of coordinates & tangents
> Load/Save the spline to an XML

Screenshot:

http://img847.imageshack.us/img847/6941/splineeditor1.th.jpg (http://img847.imageshack.us/i/splineeditor1.jpg/)

This is my first project done in Lazarus (It won't work on Delphi). I must say that I'm really impressed with Lazarus, allthough there are some small points where delphi still excells.

The good thing is that this program is a general purpose spline editor, so anyone can use it. Therefore I will donate the source to the community under some very non-restrictive license. :)

I did most of the work yesterday and I made a lot of progress. I will probably finish it in 2 weeks.

paul_nicholls
11-04-2011, 12:21 PM
Looking good mate :)

cheers,
Paul

User137
11-04-2011, 03:28 PM
Looks nice. My personal favorite though are splines that go through the points, using next ones in the route as control points. It's propably called Catmull-rom.

And there it was: http://www.pascalgamedevelopment.com/showthread.php?4621-Bezier-curves&p=38234&viewfull=1#post38234

http://img512.imageshack.us/img512/3514/catmull2kp4.jpg

chronozphere
11-04-2011, 03:34 PM
Yes I know how to draw those too. This program will be use Bezier-splines because I found them to be most effective for tunnels used in race-games. Feel free to extend the program to support Catmull-Rom splines, once I have published the source. ;)

code_glitch
11-04-2011, 06:59 PM
Nice indeed, I may even in fact have a use for this one, and that isn't something I can say about most of the stuff on my HDD, or even in my life. Sweet. It saves into XML right? Any chance of CSV? With my coming up with a XML parsing system almost from the ground up I'm trying to avoid it like the plague for now :D

chronozphere
11-04-2011, 09:00 PM
It doesn't do much yet, but I'm planning on XML import/export. I keep the export functionality separated from the rest of my code, so you can easily add CSV support yourself. ;)

You can now drag a "handle" to the side of the screen and it will start scrolling in that direction. Very handy when working on large splines with loads of detail.

Update: Just made the entire view menu functional. You can switch between XY, YX and XZ view-planes, zoom in/out, show/hide the tangents and reset the camera of the viewport. :) If I can keep going at this rate, I will be done next weekend.

code_glitch
11-04-2011, 10:08 PM
Holidays are great for that: work work work work work! Loving it so far... About 1400 lines down, an estimated 2500 more to go. At this rate, I can have 1 or 2 days for school work and still have 4-5 days R&R, so its looking good. Hate weeks for that because once you finish school, do work, chill for 5 mins, play some black ops and etc, you only end up with enough time to open up your IDE, check out where you were and close it again :D

I assume its all based on the bezier curve am I right? Although the GUI might not be exactly my area of interest, the algorithm and implementation would definitely be handy, an porting required to get it over to OpenGL or is it written in OGL from the start?

cheers,
code_glitch

chronozphere
12-04-2011, 06:45 AM
I separated the spline from the rendering part (like everyone else should do!), so you can fetch my spline class and just get a list of line segments out of that. I also have other spline code for different kinds such as Catmull-rom and Hermite splines, if you're interested. I won't use them in the editor though. :)

WILL
15-04-2011, 07:17 PM
Nice! Glad to see you working on your engine/designer again. ;)

chronozphere
22-04-2011, 10:46 PM
Things have taken slightly longer than I expected, but still... new update. :)

As said, the view menu is fully functional. You can also use the list of anchors to quickly select an anchor and see it's properties. Also, the red plus-signs allow you to insert new spline-anchors to make more complex splines, like this one. ;)

http://img692.imageshack.us/img692/7291/splineeditor2.jpg

The main things that I still need to do are: import/export functionality, add upvector support, make those properties work (bottom-left) and fix a bunch of small buggies.

paul_nicholls
23-04-2011, 12:07 AM
Nice! Looking good chief :)

cheers,
Paul

chronozphere
25-04-2011, 09:44 PM
Just did a little work on this one again. :) Manual editing (entering coordinates) of anchor positions and tangents is now possible. I will release the whole thing once I've made the export/import functionality work.

I'm stuck with one problem though. I want to support "upvectors". These are vectors that show which direction is "up", if you were to travel along the spline. This vector will always be perpedicular to the spline, and can therefore be described by an angle (with respect to the Y axis, which conventionally points to the sky of the world). But how can I design an interface for editing this angle for each anchor?

One thing I will do is let the user enter this angle manually. It would be good to have some WYSIWYG-way of editing this. However, I feel that this may become rather awkward if not done right. If I were to create a new handle for this, it would be constrained to rotate around the spline and have a fixed length. I'm not sure what to do here.

I'll probably leave it out in the first version (or give some visual feedback at best). Still, any ideas about this are appreciated!

chronozphere
27-04-2011, 09:45 PM
Ok, getting closer and closer... My program now produces this:



<?xml version="1.0"?>
<Spline Closed="True">
<Anchor ID="0">
<Position x="-20,000" y="0,000" z="-20,000"/>
<Tangent x="15,000" y="0,000" z="-15,000"/>
<Upvector x="0,000" y="0,000" z="1,000"/>
</Anchor>
<Anchor ID="1">
<Position x="30,000" y="-3,000" z="-25,000"/>
<Tangent x="15,000" y="0,000" z="5,000"/>
<Upvector x="0,000" y="0,000" z="1,000"/>
</Anchor>
etc....
</Spline>


Working with XML in Lazarus is suprisingly easy. :D

Update: Almost done with this project. Loading/Saving splines is now possible. I only have to work out the "upvector" thingy and then I can release it. :)

paul_nicholls
27-04-2011, 10:25 PM
Looking good bro :)

cheers,
Paul

chronozphere
07-05-2011, 01:09 PM
Little update here. :)

First of all, I've managed to make this work on Ubuntu. YEAH Lazarus rocks! :D

I also made those upvectors work. They can only be manipulated by changing the edit boxes at the left (So no WYSIWYG because that was too hard). Finally, Each anchor has it's own string, that is exported to XML aswell, so you can add your own data there.

It will be ready for release soon. ;) Just needs some polish and a proper license.

chronozphere
30-05-2011, 07:15 PM
I want to release this on Github, but I've been fighting with SSH, TortoiseGit and msysGit for over an hour and a I can't get them to play ball together nicely. :(

Update: Finally managed to do it. If anyone is interested at the source, fetch it here:

https://github.com/chronozphere/spline_editor

And please don't be shy and give GIT a try yourself ;)

Hope my work will be of use to anyone else. :)

paul_nicholls
30-05-2011, 10:14 PM
Nice! Great job Nathan :)

cheers,
Paul

paul_nicholls
07-11-2011, 06:01 AM
Hey Nathan :)
I was curious as to whether you have done any updates to this project lately? :)

Ignoring any updates, I was just thinking that I could use it to create some spline objects for a game...so I might give it a whirl ;)

cheers,
Paul

chronozphere
13-11-2011, 08:24 PM
Well, the source is still up there, so please go ahead and try if the program works for you. if you have any problems/questions, don't hesitate to ask me about them. ;)

This project was more or less finished, so no more updates. Anyone who needs this in the future can derive his/her own version, but please let me know about them. :)

paul_nicholls
13-11-2011, 09:50 PM
No worries Nathan :)
I will give it a go...

cheers,
Paul