cbhacks / CrashEdit

Unofficial Crash Bandicoot 1/2/3 Level Editor
https://www.cbhacks.com/tools/crashedit/
Other
133 stars 25 forks source link

Crash 2 Model Export #67

Open NetyashaRoozi opened 9 years ago

NetyashaRoozi commented 9 years ago

I looked into a entity entity and am trying to rip ripper roo and it said obj but no save feature Idk if this is technically a issue for me or is not implemented yet ALSO I saw in screenshots that there is a model viewer but I cant find such viewer I can only view the scenery :\ I still love this program and hope someday there will be a update :)

ManDude commented 9 years ago

It's a Crash 1-only feature.

NetyashaRoozi commented 9 years ago

Thx ManDude hopefully somehow it will be implemented to crash 2-3 cause I wanted to get the crash 2 crash model and some levels

warenhuis commented 8 years ago

I don't know if this is related to the issue, but I am currently reverse-engineering the Crash 2 model format (the visual parts of it, at least).

I will write documentation about my findings soon but there are still some things that i need to work out. I might need some help because I dont have a lot of experience in game modding. Just wanted to let you know.

ManDude commented 8 years ago

Please do focus on the models (but I think someone on the CM Forums already decoded them but I never asked how). The uncompressed animation format for Crash 2/3 is already known.

warenhuis commented 8 years ago

If this page is the CM forum where you are reffering to, that was me: http://hpzr.proboards.com/thread/6948/random-crash-thoughts?page=318 Otherwise I must've overlooked something, in which case I would like to receive a link.

Anyway, as you know there are really 2 types of models in Crash 2. The 5-item one and the 6-item one. I am almost done with understanding the 5-item one, but not the 6-item one (Crash Bandicoot's model is a 6-item one unfortunately).

For the 5-item modeltype I now have:

For the colors and location of the textures I need help from someone who knows how the texturechunks and palette-coloring work in memory. Some recommended reading would be nice.

The 6-item model is more difficult because it always corresponds to animations where the said amount of vertices in the T1-header (maybe these are morphtargets?) do not match up with the expected size of the item.

I'll wrap up the documentation for the 5-item one first.

ManDude commented 8 years ago

Oh, nice. Anyway, wurlitzerfox has detailed documentation as to how it maps textures right here: http://crash-hacking.wikia.com/wiki/World#Extracting_Texture_Information somewhere

I'm pretty sure each vertice maps to an index of the color list (unlike Crash 1, eugh),

Also, compressed frames have 3 extra Int32's in their header which might be compression settings (or weird indexes to the 6th item?).

NetyashaRoozi commented 8 years ago

Thank you for this amazing news! Now if only we could also get one for CTR so I can make custom tracks for games like MKWii and ect

ughman commented 8 years ago

Wow, I must have completely missed that post on the CM forums. This is really awesome.

There's some decent information on the playstation's GPU here: http://problemkaputt.de/psx-spx.htm#gpurenderpolygoncommands http://problemkaputt.de/psx-spx.htm#gpuvideomemoryvram

The important commands are probably these ones:

GP0(34h) - Shaded Textured three-point polygon, opaque, texture-blending
GP0(36h) - Shaded Textured three-point polygon, semi-transparent, tex-blend
GP0(3Ch) - Shaded Textured four-point polygon, opaque, texture-blending
GP0(3Eh) - Shaded Textured four-point polygon, semi-transparent, tex-blend
  1st  Color1+Command    (CcBbGgRrh)
  2nd  Vertex1           (YyyyXxxxh)
  3rd  Texcoord1+Palette (ClutYyXxh)
  4th  Color2            (00BbGgRrh)
  5th  Vertex2           (YyyyXxxxh)
  6th  Texcoord2+Texpage (PageYyXxh)
  7th  Color3            (00BbGgRrh)
  8th  Vertex3           (YyyyXxxxh)
  9th  Texcoord3         (0000YyXxh)
 (10th) Color4           (00BbGgRrh) (if any)
 (11th) Vertex4          (YyyyXxxxh) (if any)
 (12th) Texcoord4        (0000YyXxh) (if any)

From what I understand, Page selects which 256x256 section of VRAM will be used, and then Xx and Yy texcoords are within that area. Clut * 16 would then be the address of the palette in VRAM, I suppose. I never actually managed to get texture rendering into any of CrashEdit's 3d viewers, so I'm not completely certain on any of this.

The person to talk to would be wurlitzerfox, but I'm not sure what the best way is to contact him/her.

There are some people on IRC in freenode #psxugnd and efnet #psxdev who may be more helpful.

ughman commented 8 years ago

Regarding the 6-item format, a few excerpts from Andy Gavin's online postings:

We had a really sophisticated vertex packing algorithm to fit all the animation. It stored all the vertex positions using a 4 dimensional delta (both positional and temporal) using a bit based code so each vertex offset only used the minimum number of bits. It did around 30-50 to 1 compression!!! And the decompressor was all written in assembly.
http://all-things-andy-gavin.com/2011/02/04/making-crash-bandicoot-part-3/

 

The Crash characters have a crazy bit based compression scheme invented by Mark.
(not clear if he was talking about the platformers or CTR) http://all-things-andy-gavin.com/2012/04/29/diablo-3-commercial/

 

In addition, since Crash 2 has about 8 times the animation of the first game, we needed to really reduce the size of the data without sacrificing the quality of the animation. After numerous rewrites the animation was stored as a special bitstream compressed in all 4 dimensions.
http://all-things-andy-gavin.com/2011/03/28/crash-bandicoot-teaching-an-old-dog-new-bits-part-3/

NetyashaRoozi commented 8 years ago

I think he was talking about crash platformer's after the first

ManDude commented 8 years ago

Well, Crash 1 has lots of obselete formats (mainly and mostly models).

At least the zone format is very simple and small (and effective). Sadly the game will not function properly if you have over 400 objects in a single level. There's also the low polygon count.

Also, do note that Crash 1 uses dummy files. The actual size of (PAL) Crash 1 is a little over 200MB. NTSC-U Crash 3 is like 144MB which is the 2nd smallest in the entire franchise excluding handheld/mobile titles. If you're wondering what is the smallest, it's Bash at about 60MB.

warenhuis commented 8 years ago

My apologies, I deleted my post because I misspoke about the algorithm but you already responded. But yeah, it is a strange development.

The normals are obviously used for the character lighting in Crash 1, but in Crash 2 lighting doesn't really exist. All the artistic shadow relies solely on vertexcolors and darkness-flags.

The faces in Crash 2 do have 'directions', but they are indicated with a single half-byte.

warenhuis commented 8 years ago

Update: the vertexcoloring works almost as it is supposed to. There are still some out-of-place colors but they are rare. Every vertex in the animframe must be duplicated multiple times to support different vertexcolors, which is really tedious but necessary. models

I will delve into the texturing next. Thanks for the useful links by the way! Together with the 6-item model decompressing, these will be the hardest parts by a long shot.

NetyashaRoozi commented 8 years ago

I cant wait till it gets ripped with textures, Soon we can start ripping characters and levels with full texture support, by soon I mean like in 2-10 weeks

ManDude commented 8 years ago

If it makes you feel any better, I ripped some level models.

NetyashaRoozi commented 8 years ago

Mandude that's amazing! are you going to attempt to put the textures on? does the Uv mapping data stay the same in the rip or does it change?

ManDude commented 8 years ago

Possibly? I don't think there is any format that supports vertex shading + texturing.

warenhuis commented 8 years ago

No, but PLY does support UV mapping - so it is just a matter of slamming on the texture once it is imported.

The challenge is that some UV segments use textures that are stretched (like 2 times as wide as they normally would be) while other segments use the normal dimensions.

warenhuis commented 8 years ago

unt2

Luckily, aside from the frameheaders, the CB3: Warped formats seem to be the same as the Crash 2 ones. Note how the groundshadows are just model geometry.

ManDude commented 8 years ago

I know about the shadows being textureless semi-transparent polygons (some shadows are also just textures). Not a bad idea actually.

warenhuis commented 8 years ago

Update: I made a working texture reader now. It is all in a experimental phase, but It won't be long before I release my documentation.

untitled

ughman commented 8 years ago

Awesome.

I didn't even know they had an N on their uniforms.

ManDude commented 8 years ago

Please tell me that N was added by you because I literally never saw that.

warenhuis commented 8 years ago

There, the first fully textured CB2 export. image image

Going to write the docs now.

NetyashaRoozi commented 8 years ago

Oooh the jet pack, I wanted to model that for my character but I could never find a good texture rip and my texturing skills are.... well not that good

warenhuis commented 8 years ago

Everything is generated automatically, so you don't have to worry about ripping.

NetyashaRoozi commented 8 years ago

thank you waren, do you have a program setup yet? also does it also work with ingame sprites?

warenhuis commented 8 years ago

Yes, I have a tool by which one can check:

It also exports, but it only works with 5-item models as of yet.

What do you mean by ingame sprites?

NetyashaRoozi commented 8 years ago

Well I mean sprites, Idk why I put ingame in it

ManDude commented 8 years ago

If you mean stuff like the wumpa, you can't because its generated by code. You can just rip textures using PVV.

warenhuis commented 8 years ago

Are the HUD and the wumpa's 'models' or not?

NetyashaRoozi commented 8 years ago

No, They are not models BUT I have seen people rip them

ghost commented 8 years ago

I'm sure you could extract the flat planes that sprites are projected onto, relevant to the issue's topic.

warenhuis commented 8 years ago

If it is just sprites you're after, you can use software like 3D Ripper DX and an emulator. You can also read the texturechunks by loading them into PVV and find the right colorpalette that is included in the chunk.

ManDude commented 8 years ago

^Exactly. It's the only way to get a clean rip.

And no they're not models. The game generates quads using code ans maps textures to them.

ghost commented 8 years ago

Am I correct in thinking that this tool would also work for 5-item models in CB3?

warenhuis commented 8 years ago

Yes, as you can see with the medieval goat (in this issue), the tool only needs a few tweaks to get it to export CB3 models. I have not implemented it yet though.

I have to say, I've seen some terrible results with more complex models, so I'm not 100% sure.

ghost commented 8 years ago

Very good. I'm quite excited now.

ManDude commented 8 years ago

The models were made for low resolutions anyway (256x256x256 animations aren't exactly smooth).

ughman commented 8 years ago

Are the HUD and the wumpa's 'models' or not?

I believe the GOOL entry 6th items define sprites, there's a writeup on how it works in Crash 1 here, but it does appear to match up with what I remember from Crash 2. http://crash-hacking.wikia.com/wiki/GOOL_Executable

Pretty sure the pause menu is a model, though.

warenhuis commented 8 years ago

https://github.com/warenhuis/Crash-Bandicoot-2-Modelexport

Ok I've put the tool online so that you can get your feet wet with the Crash 2 modeltypes. The documentation is also on there. The tool was written in the free edition of Gamemaker 7.0 (I'm not a real programmer).

The conversion is not 100% accurate yet as you will notice after some exports. Hopefully this will lead to new insights, because I will be busy for the coming months (I will follow a very intense semester at university).

ManDude commented 8 years ago

Dang, I've always wanted to write some sort of non-game program in GameMaker hehe.

Anyway this is good stuff! Maybe this can be ported and programmed into an actual programming language.

ughman commented 8 years ago

Awesome, I'm reading through the PDF now.

This vertex coloring scheme is surprisingly complex, a lot moreso than the scenery was/is. Guess I'll be rereading this several times over.

warenhuis commented 8 years ago

Glad you guys appreciate it. Imagine what the 6-item model has got in store. If I have any free time in the coming months, I will get back to it. We might need mr. Gavin on this project, lol.

ughman commented 8 years ago

Alright, I think I'm finally wrapping my head around this whole concept.

This format is sufficiently complicated that I don't think I can devise a single interface that every model format could "implement" to allow them all to share one renderer, one OBJ exporter, etc. Nor do I believe I can actually design an editor for this format, because this is truly insane. Modifying texture mappings does look relatively simple, though.

Instead, I will focus on developing an intermediate format. The various crash models would have code to convert to the intermediate format, and then the intermediate format would support rendering and exporting to various formats.

Will definitely have texture remapping functionality for the various models though, this is just too good.

warenhuis commented 8 years ago

Important quick update on the texturing:

In the docs I said that the 12-byte structure had the mapping points in order: 3, 2, 1. It is more complicated however. The order depends on the "triangle type" that refers to the texinfo. So for "triangle type "AA"" and "BB" this is still 3, 2, 1 but for "CC" it is 1, 2, 3 (the latter is probably true for scenery as well).

Then there is another texturetype which are the animated textures, that seem to follow another mapping system altogether (this is where the 5th item comes in I think), but it needs more research.

Edit: Got it fixed. I reuploaded the tool and documentation. To see what is fixed, please re-read item 3 and item 4 in the docs.

untitled

NetyashaRoozi commented 8 years ago

Oh wow I had no idea those things actually looked like that. Huh weird. Can I use the program to rip models for my game? Its free and its just a project for school

ManDude commented 8 years ago

Ohhh so that's what the red beam texture from the night ruins levels is for. I legit thought it was some unused thing all this time. The more you know...

Anyway WOW this is fucking brilliant. I am absolutely amazed.

warenhuis commented 8 years ago

Yes Harley, that is what the tool is for. I'm making a game of my own as well. Looking forward to see what you do with it.

ManDude commented 8 years ago

So uh, since I still don't quite get the format, what would I have to do to the model entry (BI10G) to remove the right side and back of an iron crate (for example)?