Page 1 of 1

Creating a track renderer/editor in HTML/JS

PostPosted: Mon May 22, 2017 1:05 am
by josepedrodias
I got really frustrated with the existing editor (bundled with torcs, in Java).

Ended up wanting to create a better one.
So far I managed to render tracks to canvas. They're mostly correct but due to what I presume are rounding or interpolation errors, they don't quite close right.
Starting to sketch the editor itself but that's 10% at most.

Wanted to say hello and let you know about my little effort and gather any feedback - do you find this relevant? Am I missing a much better editor? Is this the better way to reach the developers? Cheers!

current demo (focus on the viewer for now, ignore the editor for the time being, just started the GUI forms): ... index.html

source code:

P.S. - testing in Chrome with some ES5/6 features wo/ babel. May break on some browsers.

Re: Creating a track renderer/editor in HTML/JS

PostPosted: Wed May 24, 2017 7:25 pm
by madbad
Hi Josep,
really interesting project.
We really need a better editor, and I think web technologies are perfect for this kind of work.

I've tried, in a similar way, to to render track maps on canvas with javascript and I found similar issues: with some track the start and end did not align preperly (honestly I didn't put much effort in my attempt)



Re: Creating a track renderer/editor in HTML/JS

PostPosted: Thu May 25, 2017 1:55 am
by josepedrodias
The editor is taking shape: ... almela.xml

It would be great if anyone with knowledge on the implementation internals to take a look at my interpretation on the curve segments, both in abstract: ...

and on code: ... le.js#L101

I'll eventually take a look at the tooling source code myself but it will take me much longer to figure it out without guidance.

Re: Creating a track renderer/editor in HTML/JS

PostPosted: Sun Jun 11, 2017 11:19 am
by simon-2

i guess you are struggling with the clothoid segments (rStart ≠ rEnd)?
i also had this problem when implementing a "split segment" function to the old (java) editor; but solved it *. You need to "copy" the original algorithm for creating curves from the SD sources (or from the java editor). There is one (or two?) loops run before creation of the final segment to sum up lengths and/or angles of the profile steps (within a segment) and determine a compensation factor. When figuring this out, i made a spreadsheet to check if i got it right; i will have a look if i can still find this.

Else, this is the folder to search for it.


*sorry for not sharing this up to now...

Re: Creating a track renderer/editor in HTML/JS

PostPosted: Sun Jun 11, 2017 1:39 pm
by simon-2
argh... i found the spreadsheet, but this forum does not allow spreadsheet attachments and dropbox has no public folders any longer..?? But you could send me a pm with your mail adress. For the extended java-editor with split-segment functionality, i will try to upload it somewhere else...

btw: i really like the attempt of creating a new editor, as the old one is... in need of heavy improvement :lol: but i have seen/heard of at least three such attempts within the last 2-3 years, none of them bringin up a result with better/more functionality than the "old" one, yet. i don't want to discourage you, but i think creating a really good editor is much more than chaining segments. Imho, the old editor offers a good base structure (maybe outdated, but still doing its job) with the most important functionality, and it might be less work to fix the issues and add missing functionality to this one than to code a completely new one from scratch (unless you want to do a "next generation" full 3d-editor with integrated terrain and scenery modeling, directly exporting an acc-file without the intermediate step via trackgen).

any way- good luck; and i'd love to see a better editor :)

Re: Creating a track renderer/editor in HTML/JS

PostPosted: Fri Jun 16, 2017 12:43 am
by josepedrodias
Thank you for your feedback. I'm quite new to Torcs/SD too in general, not only track editing. I found it fun to hack the format and most things are kind-of self explanatory in the format. Anyhow there should be a comprehensive reference on it all. The biggest problem for me have been curves with two radii - my results don't match trackgen's. The feedback from trackgen 1st and the game 2nd when a track has design problems aren't much help either.

My Palmela track, for instance - I ended up not using 2 radii curves to bypass that problem. My debugging process was by running it through trackgen and opening the resulting mesh on blender. It's mostly ok there but SD hangs running it...

I haven't really commit to creating a full editor. Wasn't intending to replace any endeavor, just try to author a track or two. Anyway it's good to have alternatives, particularly if they're compatible. Besides, if my tooling work ends up being relevant I'm sure it can be picked up by other people.

I'm sending you my email address so you can upload any helpful info regarding track parsing and whatnot. Cheers.