Board index Roller Coaster Games No Limits Coaster libnltrack Static Library

libnltrack Static Library

Discuss anything involving No Limits Coaster Simulation.

Post April 6th, 2008, 2:20 pm

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany
Hello Everybody,
As you guys know, I'm currently working on my "NoLimits to Cinema 4D" exporter Project.
While devloping my exporter, I noticed my code was structured like a library with usefull and easy functions, so it is also easy to use for my other things.

My code was a collection of functions, to ready everthing from a NoLimits Track File.

I think many of you have saw the source code released for the Auto-Supporter project by the user "Popcorned".
I have talked about it and we kept in touch and collected ideas and talked about many things.
One day we have talked about the SDK we miss for NoLimits to develop easy 3rd party tools for NoLimits. However, for many programmers, it is troublesome to deal with the nltrack file and type.

We thought we would have a crack at developing our own SDK for Nolimits. We created a shared C Library with easy usable and usefull functions such as to add supports with only one function.
Also everything the NL track file format is usable with the library.(modified, deleted or added).

With this library, it will make it a lot easier for people to developer thier own NoLimits 3rd party tools.
It's also great for beginners, the library very interesting, understandable and easy to use functions, making it perfect for beginners to start making their own tools.

We are currently working on documentation and the programming is almost ready.

You can see sample C code at the bottom and a picture which was generated with the this library.

  int i=0;
   
  Color colorwhite = createColorARGB(255, 255, 255, 255);
       
  NlTrack track;
   
  initNewNlTrack(&track);
  setCoasterStyle( HYPER_COASTER, &track );
  setUse16friction(1, &track);
  setNumTrains (2, &track);
  setNumCars (7, &track);
   
  setAuthorComments("This is a libnltrack Test!", &track);   
   
  float a = 1.0f / 255.0f;
  float t = 0.0f;
   
  for(t=0; t<=1; t=t+a)
  {
     float x=sin(3.14 * t * 2) * 10;
     float y=cos(3.14 * t * 2) * 5;
     float z=10+tan(3.14 * t * 2) / 10;

     int freenode = addFreeNode(x, z, y, &track);
       
     addSupport ( NODE_FREE, freenode, 0,
            NODE_FREE, freenode+1,   0,
            TUBE_LARGE, 0, 0, &track);
  }
                                                   
   NlSave("test2.nltrack", &track);   


Image
Last edited by geforcefan on April 6th, 2008, 2:38 pm, edited 1 time in total.

Post April 6th, 2008, 2:30 pm

Posts: 2748
Points on hand: 4,830.00 Points
Location: Medinah, Il, USA

Sounds like you made something really helpful here. This may make us look at No Limits in a whole new way. Good job!

Post April 6th, 2008, 2:55 pm

Posts: 1830
Points on hand: 3,960.00 Points
Location: London, United Kingdom

man that looks mint

gotta run, discuss later
Rarwh

Post April 6th, 2008, 3:31 pm

Posts: 3185
Points on hand: 3,780.00 Points
Location: USA

Post April 7th, 2008, 10:16 am

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany
Hello Everybody,

the development of the lib going very fast, and there is already a tool, which is coded with the lib.

Its a PHP Script, which generates a Layout Picture from a nltrack file:

Image

What do you think about it ?

Ercan

Post April 7th, 2008, 10:26 am
Oscar User avatar
Founding Member
Founding Member

Posts: 14409
Points on hand: 11,999.60 Points
Bank: 187,052.60 Points
Location: California, USA

The layout picture is what Tyler at coastergames.net did years ago. Only this one is black and white and displays the control points. It could be a real mess when people stick their rides through AHG and see white bars all over the track.
But the progress looks good from what yo mad ein post #1 up there. Keep it up, thanks.
Support Us! - Click Here To Donate $5 Monthly!
Paradox wrote:
No need to tell Oscar about the problems. He is magic.

Post April 7th, 2008, 10:29 am

Posts: 1605
Points on hand: 3,805.00 Points
Bank: 0.00 Points
Location: UK
omg this looks amzing, although im still not sure what it does, does it help you create coding for your own tool or does it have loads of tools built in?
Cradled by two loving arms that I'd die for,
One little kiss and Felina goodbye.

Post April 7th, 2008, 10:33 am
Oscar User avatar
Founding Member
Founding Member

Posts: 14409
Points on hand: 11,999.60 Points
Bank: 187,052.60 Points
Location: California, USA

I am hearing we will be able to create tracks with php, can you confirm this?
Support Us! - Click Here To Donate $5 Monthly!
Paradox wrote:
No need to tell Oscar about the problems. He is magic.

Post April 7th, 2008, 10:37 am

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany
The layout picture is what Tyler at coastergames.net did years ago. Only this one is black and white and displays the control points. It could be a real mess when people stick their rides through AHG and see white bars all over the track.
But the progress looks good from what yo mad ein post #1 up there. Keep it up, thanks.


The PHP code is only a little test, wheather the functions working ;)
I can remove the control points ;)

Originally posted by Oscar

I am hearing we will be able to create tracks with php, can you confirm this?


For the moment, its only a C library, you can use it with C++/C, but I will code a PHP extension too.

Then you can use this lib in PHP, and create NlTracks with PHP.

Ercan

Post April 7th, 2008, 11:08 am

Posts: 1830
Points on hand: 3,960.00 Points
Location: London, United Kingdom

Ah man this is good stuff

Auto-Layouts on coastercrazy of tracks people upload ;P
Rarwh

Post April 7th, 2008, 5:29 pm

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany
Hello Everybody,
there is a Big Update:
+ Supports Added

Picture:
Image

Thanks, Ercan

Post April 9th, 2008, 1:54 pm

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany

Post April 9th, 2008, 3:03 pm

Posts: 1830
Points on hand: 3,960.00 Points
Location: London, United Kingdom


Post April 9th, 2008, 3:14 pm

Posts: 937
Points on hand: 829.00 Points
Location: Leeuwarden, Netherlands


Post May 19th, 2008, 9:17 am

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany
Hello Everybody,
I have almost finished the development of the library. The next step was, to find an interface for php and the library, because we want also to use the library in PHP.

My first idea was to develop an extension for PHP, but its disavantages are too big, like the fact, that it works only on PHP webserver, where you can load own extensions.

I have thought about a solution, and found a better one.
Many Webservers are supporting CGI and so on. (for execute ELF or EXE files).

So I have coded an little tool, where my library is used, that exports the nltrack into an XML file, with relevant information. For the first only the supports and beziers will be exported.

This is an EXE file (ELF for Unix operated webservers).

You have only to use this function in PHP:

system("nltrack2xml -e nltrackfile.nltrack");

You will get an XML file. There is a seperate PHP class, which treats and parses the XML outputed nltrack.

At this moment, I have coded an PHP file, which generates the 3D-Layout from a nltrack directly, without any manuelly help.

I will post an link, where you can test the 3D-Layout generator for the next time.

Here a Screenshot from Euro-Mir:

Image

Ercan

Post May 19th, 2008, 5:57 pm
rcmaniac25 User avatar
Premium Member
Premium Member

Posts: 276
Points on hand: 7,275.00 Points
Location: NJ, USA

Insane, this will be very interesting to work with when it is done.

Post May 19th, 2008, 7:44 pm

Posts: 2892
Points on hand: 9,697.00 Points
Location: Philadelphia, Pennsylvania
I don't understand what it's useful for.
X2 ??? Intimidator 305 ??? Millennium Force ??? Iron Rattler ??? El Toro ??? Fury 325 ??? Maverick ??? Skyrush ??? Twisted Timbers ??? Voyage
250

Post May 20th, 2008, 10:55 am

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany
...One day we have talked about the SDK we miss for NoLimits to develop easy 3rd party tools for NoLimits. However, for many programmers, it is troublesome to deal with the nltrack file and type.

We thought we would have a crack at developing our own SDK for Nolimits. We created a shared C Library with easy usable and usefull functions such as to add supports with only one function.


Ercan

Post May 25th, 2008, 5:22 pm

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany
The first beta version of the library is released!

Only the C Library is released, without the PHP bindings. Tomorrow,I'll post here a little tutorial, how to getting started with libnltrack.

I'll show you, how to create such supports:

Image Insert:
Image
133.26 KB

You can find the library here:

http://code.google.com/p/libnltrack/

To compile the library, you need Dev-CPP (or something else which uses GCC).
I havent tested it on Visual C Compiler, but you have only to compile simply a static library from the source files in the "libnltrack" directory.

Just move the compiled library in your "lib" directory and the include files into your "include" directory.

You have to link your Test-Apps with the static library.

It works on Linux too.

Just write into the console:

$ cd libnltrack-1.0.0
$ ./configure
$ make
$ make install


thats it ;)

The documentation is only 70% finished. But if you understand the 70%, you will also understand the other 30%.


You can find the documentation in the "doc" dirctory.

Have fun,
Ercan

Post May 26th, 2008, 2:21 pm

Posts: 405
Points on hand: 1,346.00 Points
Location: Philadelphia, Pennsylvania, USA


Post May 26th, 2008, 2:41 pm

Posts: 39
Points on hand: 1,581.00 Points
Location: Minnesota, USA

Post May 26th, 2008, 2:53 pm

Posts: 405
Points on hand: 1,346.00 Points
Location: Philadelphia, Pennsylvania, USA


Post May 26th, 2008, 3:44 pm

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany
This is not a app... Its a library... Ich have sent you a PM

Post May 26th, 2008, 4:07 pm

Posts: 325
Points on hand: 2,268.00 Points
Location: Chula Vista, California, USA

My brain just melted.
Hates oscar for taking points...

Post May 26th, 2008, 5:04 pm

Posts: 57
Points on hand: 1,594.00 Points
Location: Frankfurt, Germany
Hello Everybody,

Now its time to getting started with libnltrack. For the first, we need Dev-C++ (a GNU C Compiler).

Just install it!

After the installation, download please the library source from Google Code and extract it anywhere on your Desktop.

Open the extracted lib folder libnltrack-1.0.0.

For the first, you will find two folders and many files. The folder doc contains the documentation of libnltrack and libnltrack the source files.

Okay lets start to compile the library from source. Open the Dev-C++ project file libnltrack.dev.

To compile the library, press CRTL+F9.

You will get a file called lnltrack.a.

Image Insert:
Image
78.11 KB

Image Insert:
Image
103.29 KB

Okay, have now compiled the library from source.

We have to copy the files into the Dev-C++ folder, because Dev-C++ should use the library.

Just copy the file lnltrack.a into C:/Dev-Cpp/lib and the contents of libnltrack into C:/Dev-Cpp/include/libnltrack

Image Insert:
Image
198.14 KB

Now you can use the library.

Please close all windows. We will create a simple Auto Supporter.
Open Dev-C++ and create a new C-Console-Application Project.

Create a folder on desktop called "Auto Supporter" and save the project into it.

You will see a source code into the Dev-C++ window. Just remove its content and we will begin with the Auto Supporter.

Please include our library

#include <libnltrack/libnltrack.h>


we need a main routine:

int main(int argc, char *argv[])
{
}


We need a NlTrack variable. This will contain all track datas.

NlTrack test;


Now we'll open a nltrack file with the function NlOpen()

NlOpen("newtrack.nltrack", &test);


Okay, til now we only opened the nltrack file. The next step is to read out all Segment Nodes and add a fundament under the segment nodes.

Each Node, each segment, each bezier is numbered from 0 to the number of it self.

They are called index numbers. For example we have 3 Supports. The first support have the index 0, the second one the index 1 and the last one the index 2.

Its the same for everything else.

All segment nodes have an index number too, but they begin to count each segment by 0.

That means, if we have 2 segments and 3 nodes on each of them, tha?????????n we have:

 .......SEGMENT 0................SEGMENT 1
|-----------------------|-----------------------|
.....O.....O.....O...........O.....O.......O
.....0.....1.....2...........0.....1.......2


Lets read the number of Segments:

int totalSegments = getTotalSegments(&test);


Now we will loop each segment:
    int i, t;

    for(i = 0; i < totalSegments; i++)
    {


And now we have too loop all track nodes on each segment.
We will need the number of the track nodes.
          int totalSegmentNode = getTotalTrackNodes(i, &test);


and just loop them, too:
          for(t = 0; t < totalSegmentNode; t++)
          {


Okay, lets find out the position of each node
                Vertex nodePos = getPosSegmentNode(t, i, &test);


t stands for the index number of the current node, and i for the current segment.

Now add a Fundament
                int funindex = addFundNode(0,0,0,0, 0x0 ,0, nodePos.x, 0, nodePos.z, &test);


Please look at the documentation, for what the arguments for addFundNode() standing.

addFundNode() will return th index of the added fundament. Its important, to connect the track node and the added fundament to a support.

Now connect the track node with the added fundament to a support:

                int supportindex = addSupport( NODE_SEGMENT, t, i,
                                               NODE_FUND, funindex, 0,
                                               0,0,0,&test);


NODE_SEGMENT shows the lib, that the first node is a segment node. t is the node index and i the segment index. Segment index is only needed, if the node type is a segment.

The same for the second node. Its the fundament node (NODE_FUND). funindex is the returned index, by adding our fundament. You can read the documentation, for knowing, for what the rest is standing for.

Okay, now close the loop, and save the file:

}
    }
   
    NlSave("newtrack2.nltrack", &test);


Now you have to link your Project woth the nltrack library (Project->Project Options->Parameter->Linker: -lnltrack)

Image Insert:
Image
29.54 KB

Just compile and run the project with F9.

You need before you run the tool, a track, called newtrack.nltrack to test our tool. You will get an outputed file called newtrack2.nltrack. Look into it and have Fun.

Image Insert:
Image
204.67 KB

Here is the Source code:

#include <libnltrack/libnltrack.h>

int main(int argc, char *argv[])
{
    NlTrack test;
   
    NlOpen("newtrack.nltrack", &test);
   
    int i, t;
   
    int totalSegments = getTotalSegments(&test);
    int totalFreeNode = getTotalFreeNodes(&test);
    int totalFundNode = getTotalFundNodes(&test);
   
    for(i = 0; i < totalSegments; i++)
    {
          int totalSegmentNode = getTotalTrackNodes(i, &test);
         
          for(t = 0; t < totalSegmentNode; t++)
          {
                Vertex nodePos = getPosSegmentNode(t, i, &test);
                int funindex = addFundNode(0,0,0,0, 0x0 ,0, nodePos.x, 0, nodePos.z, &test);
               
                int supportindex = addSupport( NODE_SEGMENT, t, i,
                                               NODE_FUND, funindex, 0,
                                               0,0,0,&test);
          }
    }
   
    NlSave("newtrack2.nltrack", &test);

}



Download the Project:

http://code.google.com/p/libnltrack/dow ... akechanges

Ercan

Next

Return to No Limits Coaster

 


  • Related topics
    Replies
    Views
    Last post
cron