Page 1 of 5

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 03, 2009 4:11 am
by jeff_1amstudios
Hey guys - I am looking into writing an open-source carmageddon 1 engine in c# :)

Currently after a couple of nights of work I have models loading (no texturing yet) - so this includes cars and tracks.

Does anyone have any good information on file formats (like .MAT, .DAT, .PIX)? It would make my work easier for sure :)

For a bit of background on me, check out my NFS1 engine -
http://www.1amstudios.com/games/NeedForSpeed/


cheers
Jeff

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 03, 2009 8:35 am
by Toshiba-3
Hello!
Very interesting project ofcourse. I'll try to help as I can!
Getting the models loading so fast is impressive IMO. As the BRender format is not well known at all.
I can link you to some stuff I wrote for C1 and some very similar stuff another person wrote for C2.
This is what I wrote about the C1 pix pack data:
https://rr2000.cwaboard.co.uk/blog/index ... 1-PIX-DATA
This however doesn't speak at all about the image PIX format itself. I think it shouldn't be hard to figure out either seeing it uses an external 256 palette and cannot have transluency information.

and here are two other text files about C2 formats etc. but there are a lot of similarities with C2 (C2 is build over C1):
https://rr2000.cwaboard.co.uk/R4/PC/C2FORMAT.TXT
https://rr2000.cwaboard.co.uk/R4/PC/C2MATRIX.TXT (this is more about the ACT files)

I think the MAT and ACT files are kinda easy to figure out, plus you seem to be an advanced programmer so that won't stop you at all I guess.
Sadly I don't think there's anything we can do to help you more, we are just modders and most programmers left some years ago. Beroc could have totaly helped you on the DAT/ACT/MAT formats seeing he wrote several programs and 3dsmax scripts (for C2 though).

Don't hesitate to ask anything though, your project seems awesome and seeing what you did with NFS1 we can hope for the best with C1!
Also if you can at some point explain us a bit about your discoveries that'd be great :] C1 has a really simple deformation engine in comparison to C2 but no one ever could figure out how the crush data works.

Ah well, good luck!

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 03, 2009 9:01 pm
by jeff_1amstudios
Sweet, thanks for that. the c2format.txt is super useful.

A long time ago I wrote a .pix texture viewer in QBasic - I dont have the code or any memory of the file format now but should be able to figure it out.

Image

Im pretty busy at work atm, but will try and post up some better screenshots this week. This one is obviously Otis, and the hump in the middle of the roof is the wheel model which somehow ended up there... I'll have to figure that one out!

hehe, and hopefully the idea of an opensource engine means that someone else can help figure out the really hard stuff (like the deformations!)

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 03, 2009 9:15 pm
by TTR
Yeah those .DAT models if you open those with anything else then PT2 they end up there in the middle, probably because there mostly written to 0,0,0 (xyz) but then again what do i know lol...

Cool project, hope to see this work :grin:

NFS1 was cool, that you remade it is cool too :smile:

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 03, 2009 10:34 pm
by Razor
[quote=TTR]Yeah those .DAT models if you open those with anything else then PT2 they end up there in the middle, probably because there mostly written to 0,0,0 (xyz) but then again what do i know lol...[/quote]
This is true, with both games built on the original Carma engine.

--

Your Need For Speed remake seems to be much smoother than I remember the original being, I like it and might give the game a go, well done.

Good luck with this project, I look forward to seeing your progress.

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 03, 2009 10:36 pm
by Toshiba-3
Quick reply: yes all the models (thus the DAT files) in C1 are centered at the origin, it's the ACT file which contain the transformation matrix for each component that tells where they should be placed ingame.
The DAT file assign the materials (and IDs?) to each polygon and the game loads them from the MAT file. If they are not present in the MAT file, then they are loaded from "generic" MATs placed in the REG folder etc. (such as 'simpmats' which are just diffuse colors (used on simple models (lod)).

Even if the game is pretty old and the engine yet older, it actually already support smoothing groups and multi subs (several textures on a single object (thus using matIDs)). Smoothing groups are only used with untextured materials (such as simpmats thus) to calculate the shading, or for the fake env mapping (substituing the shading by the texture loaded in the material).

About the C2format.txt file, the flag values are often different between C1 and C2 but the structure is almost the same. Though I don't see why there would be a difference in the DAT format. I just guess the ACT files utility was increased to support more transformations (just a guess!).

Good work, sir!

Carmageddon 1 XNA / OpenC1

Posted: Sat Jul 04, 2009 9:23 pm
by jeff_1amstudios
Cool, thanks for the info. I'll dig into those .act files.

I loaded up a couple of tracks and saw some strange things like checkpoints sitting inside of buildings, so that will be why.

Razor - thx. The difference between the original NFS and my XNA remake is most noticeable when you look at them side by side. Most people didnt believe it was using exactly the same textures and models. :) And those models weren't able to be normal-mapped, unlike the C1 models.

Have you guys read this? Making of Carmageddon Its a pretty cool article

Carmageddon 1 XNA / OpenC1

Posted: Sat Jul 04, 2009 10:04 pm
by Razor
[quote=jeff]Cool, thanks for the info. I'll dig into those .act files.

I loaded up a couple of tracks and saw some strange things like checkpoints sitting inside of buildings, so that will be why.

Razor - thx. The difference between the original NFS and my XNA remake is most noticeable when you look at them side by side. Most people didnt believe it was using exactly the same textures and models. :) And those models weren't able to be normal-mapped, unlike the C1 models.

Have you guys read this? Making of Carmageddon Its a pretty cool article[/quote]
You're welcome and yes I went and searched for my old copy of NFS, once I found it I installed it and yes there is a great deal of difference, I like how clean you've made it.

Oh and yes, we've all read it (most likely), I know I have: http://www.stainlessgames.com/news/go/75


--I've just noticed the link to the .PDF from Stainless Games' site wont load (at least not for me), so I've uploaded it to my site (I downloaded a while ago) https://razor.cwaboard.co.uk/Downloads/EDG ... don_hi.pdf

Carmageddon 1 XNA / OpenC1

Posted: Sat Jul 04, 2009 11:31 pm
by jeff_1amstudios
Awesome, the pdf is way better than the online article :) I love seeing the early concept art, haha and the die anna part about only being 14 was funny!

I played the C1 demo and full version for ages when they came out - I still remember being amazed that they let you drive anywhere you wanted, instead of just along the track. Well that, and getting cunning stunt bonuses :) One of the first programs I ever released was to let you drive the opponents cars in the splat pack demo.... good times :)

Damn, if I wasn't so busy at work (Im in the office on a sunday morning, New Zealand time) I'd be coding on carmageddon right now :)

Carmageddon 1 XNA / OpenC1

Posted: Wed Jul 08, 2009 7:42 am
by Harmalarm
Interesting project there Jeff! This might also give us again more insight in the file structure and format's of the files, but an alternative carmageddon engine would be really nice! Any new progress lately?

Carmageddon 1 XNA / OpenC1

Posted: Thu Jul 09, 2009 6:24 pm
by Errol
Hi Jeff,

I notice you're using XNA (3.1 I assume?), do you plan on including netcode? I could probably help you out with state-management and things of that nature if you need. Also I'm pretty proficient at AI coding.

Thanks to Harmalarm for pointing this topic out to me, I'm going to keep a close eye on it.

Also, my wife is already cursing your name, Harm. I've started fiddling around with C2 for the first time in years thanks to your email today. Damn you ;)

-Errol

Carmageddon 1 XNA / OpenC1

Posted: Thu Jul 09, 2009 8:59 pm
by TTR
Wow lol, why do i get the feeling this would be epic? :)

Carmageddon 1 XNA / OpenC1

Posted: Thu Jul 09, 2009 9:05 pm
by Harmalarm
:D WHOOPS... what did I do? :) Great to see you get back here Errol! And indeed TTR, this topic gives me kind of butterflies...

Carmageddon 1 XNA / OpenC1

Posted: Thu Jul 09, 2009 10:50 pm
by jeff_1amstudios
Hey,

I've got .MAT, .ACT, .DAT and .PIX files loading. What I need to do next is hook them together, so when you draw an actor, it draws the associated model using the associated materials, using the associated textures. Currently having a bit of trouble getting the actor transformations to apply correctly to the model, but its in progress!

Once that is done, getting the textures working should be pretty easy, then I can post some more interesting screenshots :)

Errol, yes, I am using XNA 3. I havent done much in the way of AI, so some help there would definitely be great once Ive got the basic engine running.

Im also planning to use JigLibX (a free physics engine), which will hopefully mean we can jump ramps and smash lightposts/phoneboxes/etc. I used it for a while for my Need For Speed remake, but at the time it just wasn't working well enough to be fun. But I had a look at their demo app a couple of nights ago, and it looks great now :)

Carmageddon 1 XNA / OpenC1

Posted: Thu Jul 09, 2009 11:23 pm
by Errol
Hi Jeff,

I knocked together a basic physics/collision library when I was working on a 3d flightsim thing in XNA a couple of years back for the first DreamBuildPlay. It wasn't anywhere near accurate enough for car physics but it could form the basis of something nifty. If that library you mentioned doesn't work out.

As more of a practise exercise I'm knocking together a Carma2 model viewer in XNA too, content pipeline and all that jazz. If it works I'll happily share the source if it could help you in any way.

-Errol

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 10, 2009 2:26 am
by jeff_1amstudios
You're obviously a fellow coder, cool :)

How do you like XNA? I made a few games with c++/DirectX a long time ago, and while it was fun, XNA is a much nicer place to be. That and the fact that I can code in c# which I use everyday for work.

I havent done much with the ContentPipeline - doesn't that mean you have to load in your model at design time? I love the idea of being able to drop my Carmageddon.exe into the original Carma1 folder and it reads all the original files. Thats how I did it for NFS.

What was your DreamBuildPlay entry? A friend of mine makes Sharkys AirLegends which has been doing really well on the marketplace - http://sharky.bluecog.co.nz/?page_id=244

How far have you got with the model viewer? Have you looked at applying the actor transform to the model?

Jeff

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 10, 2009 2:49 am
by Errol
Yeah, a coder born and bred. A curse more than a blessing if you ask me, we see the world wonky ;)

I like XNA, I too did some game programming in times past and XNA makes things far more straight forward. I'm not too sure but I think you can runtime load things through the content pipeline, at least I hope so. If not then this is purely a learning exercise...

My DreamBuildPlay entry was a 3d flightsim thing called Nanocytes. It was my first ever project and was pretty crappy to be honest, I plan on entering again this year with something called "That Fighting Game", an isometric sprite with over-the-top weapons, enemies and stuff. Hand drawing all the art assets.

I'm not all that far with the model viewer yet but I should have the meshes rendering in an hour or so. Guess I'm going to bed after the sun rises again ;)

-Errol

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 10, 2009 3:39 am
by jeff_1amstudios
Thats when some of the best coding gets done :)

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 10, 2009 4:50 am
by Errol
[img]http://www.everhard-entertainment.co.uk ... /cobra.jpg[/img]

Woot :)

Edit:
Bah! I've hit a roadblock with loading tif files. Their file format is just plain stupid. While I could just go for .pix support that would require downloaded vehicles to have been loaded into C2 beforehand to generate them.

I guess I could runtime convert the tiffs to tgas but that seems hacky and cheap ;)

Double Edit:
Now with incorrect textures!

-Errol

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 10, 2009 4:55 am
by jeff_1amstudios
Nice one :)

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 10, 2009 8:58 am
by Harmalarm
My goodness, this topic is growing fast... You guys get fast results both of you. I was thinking that this model viewer would be fucking nice if it were integrated with carstockalypse in a way, but I will refrain from making that an official request... just an idea ;) The pix/tiff problem sounds annoying yes. Some of us now only upload with pix files in the archive, though a tiff2pix conversion is quite essential for all the older cars.

Good to hear that you have all file formats loading now jeff! Geez... in a week!

I am very interested in how this topic will evolve :sglasses:

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 10, 2009 9:24 am
by Errol
I think the dependancies for XNA projects would kill a carstockalypse integration. I doubt anyone would be willing to install 30meg+ worth of craps just to add a new car ;)

-Errol

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 10, 2009 9:49 am
by Harmalarm
Ah, I see, i thought it would end up as a single small proggie.

Carmageddon 1 XNA / OpenC1

Posted: Fri Jul 10, 2009 9:06 pm
by Razor
I'd just like to say one thing:- Welcome back Errol, good to see you.

Carmageddon 1 XNA / OpenC1

Posted: Sat Jul 11, 2009 1:16 am
by jeff_1amstudios
Success :)

[img]http://1amstudios.com/_1am/games/carmag ... carma1.jpg[/img]
[img]http://1amstudios.com/_1am/games/carmag ... carma4.jpg[/img]
[img]http://1amstudios.com/_1am/games/carmag ... carma3.jpg[/img]
Somethings not quite right with the wheel texture here...!
[img]http://1amstudios.com/_1am/games/carmag ... carma2.jpg[/img]

Whats the problem with loading tiff files errol? Theres a few c# samples for loading tiff files floating around the net. Or does c2 have some weird format?

Carmageddon 1 XNA / OpenC1

Posted: Sat Jul 11, 2009 1:45 am
by jeff_1amstudios
Holy crap, heres the hidden\secret\not finished track 'Sumo' -

[img]http://www.1amstudios.com/games/carmage ... s/sumo.jpg[/img]

Carmageddon 1 XNA / OpenC1

Posted: Sat Jul 11, 2009 2:07 am
by Errol
Methinks your Googling skills are stronger than mine, any chance of a couple of links for C# tiff processing?

The things I've found all require things like System.Drawing which isn't available within the XNA pipeline.

Also, cracking job so far chap. Looking awesome indeed.

Update:

[img]http://www.everhard-entertainment.co.uk ... cobra2.jpg[/img]

Finished coding the custom content pipeline thingy for uncompressed tiff files. Now just the LZW compressed ones.

-Errol

Carmageddon 1 XNA / OpenC1

Posted: Sat Jul 11, 2009 8:21 am
by Harmalarm
Nice work guys.

@Jeff, you took the model from the demo of carma 2 didn't you? Or was it also a pat of c1? Where did the textures actually come from? It looks very much like the actual sumo map of c2, but is missing the top crusher coming down.

Great stuff here guys, really cool! Wish I was able to do these things, though... who knows what the future might bring. ;)

Carmageddon 1 XNA / OpenC1

Posted: Sat Jul 11, 2009 1:29 pm
by Razor
Looks like the C2 Sumo, maybe the C2 Sumo was using the existing C1 Sumo model; that's if this is from C1.

@Jeff: I see the active window says "NeedForSpeed", are you building over your Need For Speed remake?

Carmageddon 1 XNA / OpenC1

Posted: Sat Jul 11, 2009 8:27 pm
by jeff_1amstudios
thanks :)


Its the C1 sumo track. All models and textures are from C1.

Sumo was never in the actual game, but the data files are there. If youve got C1, you can change Maim Street to Sumo by changing the Races.txt

I last tried it a couple of years ago, and I think it crashes after playing for 30 seconds. Theres a couple of other tracks that arent in the official game, I'll try and find them.

@Errol, yours too. Good work getting the c2 model going there. I didnt realise you cant use system.drawing in the pipeline - i guess that wouldnt be good for xbox compatibility!

@Razor, good spotting, yep, Ive got a bunch of useful code for drawing/audio/controls etc so I copied my NFS codebase, removed all the NFS-specific code and started :)

Carmageddon 1 XNA / OpenC1

Posted: Sun Jul 12, 2009 1:21 am
by Errol
Yup, the lack of system.drawing is a bitch ;)

Still, who doesn't love parsing binary files 9 bits at a time. DAMN YOU TIFF, 9 bits!? Madness!

Anyway...

[img]http://www.everhard-entertainment.co.uk ... cobra3.jpg[/img]

Still have alpha channels to deal with. and I need to find out why the data errors out in the normal files (causing the black bars on some textures).

Almost there!

Edit:
The black bars were caused by my outright retardation. Just alpha channels to go!

Re-Edit:
Boosh! Now to fix those damn wheels.

Another-hour,-another-edit:
Jeff, how are you loading all the content on-the-fly? You mentioned you're planning on just dropping an exe into the root folder and letting it do its thing. I just read somewhere that the content pipeline isn't part of the XNA redist package and I think asking people to install the full game studio is a bit much.
Do you know of any tutorials or such for doing what you're doing?

Final edit:

[img]http://www.everhard-entertainment.co.uk ... mtrose.jpg[/img]

Tested it out with a couple of other cars including AlanEconobrick's fancy Hantrose 880. Everything seems to be loading properly.

-Errol

Carmageddon 1 XNA / OpenC1

Posted: Sun Jul 12, 2009 9:15 am
by jeff_1amstudios
Very nice, the transparency is sweet!

I've got cars and tracks loading from their config files (so I can load Data\Cars\Vlad.txt, and Races\Citya1.txt) and all the associated textures models and materials are loaded). Haven't done any performance tuning yet, so its a bit slow but heres a shot of CityB. Note the dense fog - very original carmageddon! The kerb material isn't being applied for some reason which is why its bright white.


Image

Next step is to get a skybox running with the carmageddon horizon texture to get rid of that white sky.

To load stuff outside the pipeline you have to take care of VertexBuffers and use graphicsDevice::DrawPrimitives to draw each (or set) of triangles. Riemers tutorials are quite good, heres one on using a VertexBuffer - here

Not sure how its different to the pipeline, but I:

1) Load model verticies, faces, texture coords from the carmageddon data files
2) Create a list of VertexPositionNormalTexture from my data
3) Create a VertexBuffer and add the list from 2)

To draw, device.Vertices[0].SetSource(_vertexBuffer)
device.DrawPrimitives(...)

I've had a great weekend, been able to work on this most of the time without my girlfriend getting too annoyed :)

Carmageddon 1 XNA / OpenC1

Posted: Sun Jul 12, 2009 9:35 am
by Harmalarm
hey wow, loading from the carname.txt file also means that extra grooves can be read, so that groove parts that are rotated within the txt file show up as they should in-game.

btw Jeff, those missing kerb material is actually not a missing material but a missing mesh. I noticed this when using the tracks for my grandcarma mod, all those meshes were simply not there. The original backgrounds all have a black bottom, causing it to show up black in the end.

keep it up guys ;)

Carmageddon 1 XNA / OpenC1

Posted: Sun Jul 12, 2009 9:55 am
by Toshiba-3
Actually no, there's a mesh there. Ingame it doesn't show up black but dark grey. When you preprocess a track you can choose to replace thin uvw maps materials by something else. I guess for these sidewalks they simply choosed a simpmat or created one (easier in C1 than C2). This problem during the preprocessing can be avoided easily (there's a short ref somewhere on my blog) so I really wonder why these long and thin uvw maps were a problem and why they didn't sort it out. Oh well.

That C1 Sumo track is simply a multiplayer track just like the C2 one :heh:
And Errol, that'd be Econo's Hamtrose 880!

Damn nice work there both of you guys! I'm still crossing fingers for the crush data!
Now that I think about it, the final executable will have to be compatible with the installations that still have the crypted txt files. I guess it's an easy thing to sort out with the finishing touches.

Carmageddon 1 XNA / OpenC1

Posted: Sun Jul 12, 2009 10:18 am
by Errol
Oops, my reading comprehension ain't so hot without sleep ;) Thanks for the catch Toshiba.

Jeff, bleugh, I hate rendering that way, I'm a mesh.Draw(); man by preference. The only file reference I currently need to have in Content is the .dat file, it goes off and finds the act, mat, txt and wam as well as the tiffrgb files on its own. I reckon I could just reference a txt file and parse it with a custom pipeline and have it find EVERYTHING. The txt file likely won't need any contents either, as soon as Content.Load(""); gets called I can do all sorts of magic. I'll have a play with that later.

Also, impressive that you have the maps rendering so nicely so quickly. I hear ya on the lady issues. I've been working through the night after the wife has gone to bed. Shame I'm sleeping through the day ;)

Toshiba, has anything been discovered with regards to the crush data? That's the bit I want to play with most as breaking stuff is fun! A little pointer in the right direction would go a long way.
Also, I've been putting together a more indepth C2 File Format doc. I think I've worked out what some of the "unknown" values do and how to use them. I'll upload it somewhere when I'm done.

-Errol