The online racing simulator
Creating a 2D image from smx files
Hi,

Has anyone please hints how a track is drawn from smx files? Retrieving the points and vertices is easy. But how to combine them that the result looks like a track( like in the Replay Analyzer)?

What to do with the vertices and how to color that all? I searched in different forums but didn't find anything.

Is there anywhere document where it is explained in detail? The readme to the smx files doesn't explain that.

Thanks for your help
You are given the Points (vertices) in the POINT BLOCKs. The TRIANGLE BLOCKs contain the indexes of those POINT BLOCKs, giving you the 3 vertices to draw a triangle with.
For colours, just fill in the colour values given along with every point. So every triangle has 3 points where each point has a colour. When drawing the triangle you calculate and draw the final colour(s) of the triangle.
How you do this really depends on how you are drawing your 3d scene. In d3d you just give those values to d3d and it'll draw it for you. Same with OpenGL if I'm not mistaken. If you have your own software 3d engine, then you need to write the colouring and shading yourself. But tbh, if that's the case, I wonder what about this subject you don't understand! (in other words, if you can write your own software drawer you should already know about how to give faces colour).
Thanks for your answer.

Now it's clear for me.

Quote :I wonder what about this subject you don't understand! (in other words, if you can write your own software drawer you should already know about how to give faces colour).

I think I expressed myself wrong. I missed the connection between the points and the vertices. Coloring is now easy.

By the way I use Java.

Thanks a lot.
Hi Victor,

Hmmm, I thought I had it. As Attachment is a part of my result of Kyoto enclosed.

The following questions are left
1. Why are there such gaps in the image?

2. In the first block in "Kyoto Ring_2DH.smx" there are 180 (B4h) points and only 30 (1Eh) vertices. 30 vertices * 3 points per triangle result in 90 points. What is with the other 90 points?

3. What meaning has the "radius" in the Object block?

thanks for your help
Attached images
Kyoto.jpg
Correction to previous post:

Gaps in image solved.
#6 - Stuff
If you just want the image, then F1PerfView can do the trick. Just record a .raf file and open it with the program. It has the whole track, not just the configuration. It outputs something like the attached image. (That's one of my mouse laps using the UFR.) After you have the .raf loaded, take screenshots, put them together, then take out the line. Not too hard
Attached images
ky1-perfview.jpg
Thanks Stuff for the hint. It's a good idea if I only need the image. But I have to draw it myself because I want to put data from ÍnSim into the image.
I don't have a reference point for the image of F1PerfView, for example the coordinates of the lower lefthand corner. So I cannot put my data exactly into these images without a lot of trial and error and zooming also is not possible.
#8 - Stuff
Data from InSim would be possible. I did it with the objects from a .lyt file. Yeah, it is a pain to figure out the differences between LFS x,y and the image x,y.. Zooming is also possible. Check out this program I made for S1 layouts. Called the Layout Thingy. Only 0.52 still but I plan to update it for S2 and the other major AutoX layouts eventually.

Since my LFS space is down for a while, you can get it from my personal webspace.. LayoutThingy052.zip (1mb)
Hi Stuff,

Thanks for the download. Zoom and pan looks very smooth in you app. I program in Java so I cannot use the freeimage.dll. Have to look if there is something similar.

Taking an image from F1PerfView is worth a try, but nevertheless I am interested in the points 2 and 3 i mentioned before.
Quote from Stuff :
Since my LFS space is down for a while, you can get it from my personal webspace.. LayoutThingy052.zip (1mb)

Coool, so this app DOES exist (ceases work on LayoutEditor) lol
Looking good there
Hi LupusC,

did you succeed in drawing a 2D track image? I'm also trying to draw it and have the same questions spinning in my mind. Espacially I wonder, how to color the triangles. I tried to use the average value of the three vertices, but that resulted in a blue track (and I'm not drunken :tilt. And what to do with the ground colors from the header?

Then the radius in the object block. I don't know, what it is useful for.

Would be nice, if anyone had advice.

Thanks.
Mirrored track
Hi..

The connection between the ABC and the points helped me alot lol.. was confused for a while.. anyways.. it draws the track just fine exept that it is in mirror mode switching x with y didnt help much either as the triangles would be drawn.. is it me or is it suposed to be like this ?
May I ask why you're rendering the .smx files? Not that I have an objection or anything but the exact opposite! I want to be able to render them also for tracks/autocross areas in a future version of my autox editor, LYTe. Maybe we could help each other out one way or another?

And, for the mirroring effect, try making either the x or y coordinate be negative, depending on which way its being mirrored.
..
i just playing with it and maybe im gonna add some cars moving using insim.

Rendering it isnt hard as soon as u see what the "vertex A, B and C" is, in each object u get an array of points.. Vertex A, B and C has the index for what point to be used.. if A = 10.. u get the point(10) and so on.. and the radius.
When adding Vertices to directX each vertices takes a value X,Y,Z,Rhw Rhw means Radius, height, width.. if u dont know what vertices is take a look at msdn and search for CustomVertex.TransformedColored.
i didnt use the center x,y,z from the object in my app but i dont think it matters as it draws just fine



Oh and thx for the info on making x or y negative.. so all X that is negative i make positive and vice versa.. ill try it out later today i was worried that i used the wrong type when i converted it from byte and maybe that made the number negative instead of positive. im using the type int32 (32 bit signed integer) or maybe the bytes are in 'big indian'.

If u draw all the points using x and y.. (only points no triangles) and i switch X with y and y with x its not mirrored anymore.. also i had some trouble after converting the colors stored as 4 bytes.. specs say that its stored as ARGB i had to change it to RGBA maybe its just the doc that is wrong

Oh and if i got something wrong here plz correct me.. im not an expert im just a beginner when it comes to directX and triangles :P
Well its certainly a coincidence that I've been working on a similar program, a 3D replay analyser. The preview picture shows some of my braking points at Blackwood.



Quote :Espacially I wonder, how to color the triangles. I tried to use the average value of the three vertices, but that resulted in a blue track (and I'm not drunken ).

And what to do with the ground colors from the header?

Then the radius in the object block. I don't know, what it is useful for.

Just pick one of the vertice-colors, they all give the same result, just notice that a SMX-file uses a different color format, the first three bytes contain the color values, the last byte is the transparency (you don't need that). My guess is that you've directly copied the color value, which gives you blue roads.

Ground color in the header can be used as background color (I've picked another one).

Radius can be used together with the x and y pos, to see if an object lies within the visible area. (And for some LOD stuff).
Attached images
3dsmall.jpg
That looks really nice u made it in 3d i just using it in 2d atm.. but that really rocks nice work

What language did u program it in? if .net would it be posible to get the source.. what im interested in is the part where u draw the track in 3d.. as im new to dx it would be a great example for me to look at to learn more about it while trying to rewrite my own program in 3d
I used c++ and OpenGL (I don't like .NET), my previous version was software rendering in VB6, but that came out a bit slow (10fps).

3D isnt that hard, you just have to transform the x and y coordinates to fit the perspective. But I'd advice to use OpenGL which is really easy,you can just copy-paste the SMX-triangles, and OpenGL will do the work for you.

Here's a good OpenGL tutorial-page http://nehe.gamedev.net/. Just download the sourcecode of lesson #2, and add the SMX loading part to it (there are .NET implementations available).

EDIT:

Lesson #2: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=02
Site's a bit down with certain intervals

And I don't use textures, the SMX-file doesnt supply them, but it does give you all the polygons you'll need to get a wonderfully detailed view.
thnx ill look into that

hehe ya i tryed some software drawing myself at first.. Waaaaaay to slow
Thats why i changed to dx.

but it looks to me like u are using textures or is it just colors? really look like its textured

Looked at that page Lesson 2 is missing its lesson 1,6 and up

Oh and i forgot to mention im using VB.Net if u know any tutorials on opengl for VB im gonna run over to u and giveu a big big hug :P

ok that hug is otw found the vb code on that page

ok i got that opengl and the .net stuff needed.. i got it to run with the sample and then i changed it to draw the track..

This is how i do it..
For each object block i do this:

gl begin.

then i get all triangles in that onbject and loads them setting color and xyz

then i do
GL.glEnd

and do this for each block

it loads without errors but the screen is black and no objects are shown.. am i doing something wrong?
i do call the gl draw func after im done adding the objects



hmm.. just noticed the values for x y z are extremly big.. maybe this is why it wont work.. any idea how to make them smaler without destroying the layout of the track.. i tryed x / 150000 that made it visible only if also used the translate and moved it in to my screen.. but it was still waaaay to big and i know that if i use a number higher than 150000 its no good cause using integers it will round it of so most triangles will have abc at the same value

EDIT:

How in the world do u manage to render it.. my gues is u dont loop threw every triangle for each render.. is there a function that takes arrays that im not aware of ? lol

could u make the source for the function where u load it in to directx avalible plz.. im totally off here.. or maybe Victor could make an example.. this looks really confusing to me..

u displayed the whole track at once... thats alot of vertex to load.. did u add each object as a mesh or did u load all vertex (triangles) under 1 mesh / object..

I get memory error and stack overflow all the time i dont know how u managed to load all that... im using the indexbuffer and vertexbuffer atm.. and it aint going to well..

did i miss something.. its over 200k vertex on bl1 thats about 90k+ meshes and thats waaay to much.. or maybe its just me being stupid..

Anyways.. would be great if someone could give me a hint on how to load it cause im pretty sure im doing it wrong..


heres a sample of the code im using atm


ReDim Track(SM.Header.Objects.Count - 1)
ReDim mymesh(SM.Header.Objects.Count - 1)
Dim cv AsInteger

cv = 0
cc = 0

For X = 0 To (SM.Header.Objects.Count - 1) Step 1
o = SM.Header.Objects(X)
mymesh(X) = New MeshClass

ReDim mymesh(X).Vert(0 To o.Points.Count - 1)
ReDim mymesh(X).Tris(0 To (o.Tris.Count * 3) - 1)

For Y = 0 To o.Points.Count - 1
mymesh(X).Vert(Y) = New Direct3D.CustomVertex.TransformedColored
mymesh(X).Vert(Y).Color = RGB(o.Points(Y).cRed, o.Points(Y).cGreen, o.Points(Y).cBlue)
mymesh(X).Vert(Y).X = o.Points(Y).X
mymesh(X).Vert(Y).Y = o.Points(Y).Y
mymesh(X).Vert(Y).Z = o.Points(Y).Z
' mymesh(X).Vert(Y).Rhw =
Next

cc = 0

For Y = 0 To o.Tris.Count - 1
mymesh(X).Tris(cc) = o.Tris(Y).VertexC
cc = cc + 1
mymesh(X).Tris(cc) = o.Tris(Y).VertexB
cc = cc + 1
mymesh(X).Tris(cc) = o.Tris(Y).VertexA
cc = cc + 1
Next

Track(X) = New Direct3D.Mesh(UBound(mymesh(X).Tris) + 1, UBound(mymesh(X).Vert) + 1, MeshFlags.Managed, Direct3D.CustomVertex.PositionColored.Format, mobjDX9)
Next


For X = 0 To UBound(Track)
Track(X).SetIndexBufferData(mymesh(X).Tris, LockFlags.NoOverwrite) 'memory error here if array is 500 or more maybe abit below that.. but it crashes at object 27 and 28.. they are extremly big compared to the others

Track(X).SetVertexBufferData(mymesh(X).Vert, LockFlags.NoOverwrite)
Next
If anyone could convert the smx to a zmodeler file, I would appreciate it. I wanna convert an LFS track to RACER :P
-
(MonkOnHotTinRoof) DELETED by MonkOnHotTinRoof
nice what do u meen if it is 3d.. is there objects in there that is 2d.. and why didnt victor mention this in the specs for the file..

i got it to render now but it looks worst than a junk yard.. i tryed changing abc and xyz nothing helps.. checked code for missing bytes or so.. nothing..

Thnx for linking to the source.. im gonna need some time looking threw that.. im not an C# expert :P




take alook at the picture


in my opinion it looks like they are overlaping each other and isnt in the right direction or position for that matter.. any known error that could make this happend.. i checked twise now that i read the right data from the file.. anyway i needed to turn the ABC to CBA or it was even worse.. any other combination was totally messed up.. not that this one isnt.. looks cinda weird.

EDIT:

K i just checked the dimension byte in the smx file i have i asume thats what u where refering to.. its 3 so i asume its 3d..


EDIT:

NM its working 100% now

i mixed a Single for an integer

Edit:

Heres a screene

Quote from wheel4hummer :If anyone could convert the smx to a zmodeler file, I would appreciate it. I wanna convert an LFS track to RACER :P

If u have a spec for the ZModeler File format i could give it a try..
Attached images
messedup.JPG
untitled.JPG
How about ASE then? (Zmodler format is a bit hard I assume)
hi

FGED GREDG RDFGDR GSFDG