mholeys / roadtrip-choroq-tools

RoadTrip Adventure / ChoroQ 2 HG model/texture extractor
3 stars 0 forks source link

'list' object has no attribute 'writeMeshToType when trying to extract track models #1

Closed Facepalm38 closed 4 months ago

Facepalm38 commented 4 months ago

Hey man, I keep getting this issue when trying to extract the COURSE and FLD models


  File "D:\Work\CQExtract\choroq-extractor.py", line 254, in <module>
    process_courses(folderIn, folderOut, outputFormats)
  File "D:\Work\CQExtract\choroq-extractor.py", line 95, in process_courses
    mesh.writeMeshToType(outType, fout)
    ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'writeMeshToType' ```
mholeys commented 4 months ago

Hello, first off, thank you for having a go at using my tool, its a work in progress, but you have spotted something that should work. I have only just seen this, but I think I have found the issue and have pushed the changes.

This was down to me changing how the extraction system works, but not updating the command line tool. I have also fixed the tool for the ACTIONS, as I had missed that bit of code completely, so thank you for making me look at this properly.

I have tested the changes for the whole set of supported files (COURSE/ACTION/FIELDS/CARS) but I have likley missed something, so please let me know if it works, or if you have any other issues.

The code should process the Courses, then the Actions, then the Fields, and finally the Cars. If you only want some of that, edit the choroq-extractor.py file, around line 314 (https://github.com/mholeys/roadtrip-choroq-tools/blob/master/choroq-extractor.py#L314), and comment out the bits you do not want (# before the process_actions(...) for example)

Also as a little FYI, the output will be missing things, the main one being that all models have no link to their textures, the textures usually get extracted, but I have not worked out how each mesh references textures. This is a manual process for now, and can be slow.

I have updated the size estimate, as the files have gotten bigger, ~4GB for everything in PLY

Facepalm38 commented 4 months ago

You're a legend, millions of thanks! What does the ACTION folder have anyway?

mholeys commented 4 months ago

No problem hope it helps :-) Actions are the little mini games like golf and one is the cloud city town, but I cant remember which.

Facepalm38 commented 4 months ago

Ah I see them yea. Last one is the Cloudhill Race minigame against Travis, one of the residents.

Last question, am I going to have to assemble all the OBJ files or will just importing them do the trick?

mholeys commented 4 months ago

If you load the files into something like blender/unity they load in the right place, as each bit of the level keeps its position.

I have tried working on making the files into bigger parts with less files. I will try and integrate that into the extractor within the next hour or so. That should create objs with multiple parts and save on files.

Facepalm38 commented 4 months ago

That's incredible.

I already can't believe I can finally have the entire world map to tinker with.

I can also confirm it's extracting the Japanese game's models just fine, so I'd say it's safe to presume it works for all versions as well

mholeys commented 4 months ago

Quick change of code, and now you can use 3 for the output format, which should place all meshes that share the same texture together (now in a folder called matLinked), the files should load in obj programs, but blender does some times crash on me. YMMV hope this saves some hdd space/time. This also should allow texturing to be faster, as thats the whole reason I started to work on that grouping.

Facepalm38 commented 4 months ago

Hey man, sorry to reopen this thread but I do have a few last questions

How do I import the world pieces? Importing the merged ones puts them all on the center of the workspace. Do I have to manually arrange the world map by hand? I'm not sure what the blender combine python script does either.

It also seems some pieces and textures don't export for some of the tracks? I tried Desert Raceway and Ninja Temple Raceway, and some meshes were missing alongside their textures.

Also, would you potentially make this tool also support the game's sequel, Gadget Racers/HG3? The format should be largely the same afaik

mholeys commented 4 months ago

Feel free to keep messaging me on here. The merged meshes should keep their positions. I will have a look at this later today, away from desk currently.

Last time I exported the files, all meshes were exported, however missing textures is to be expected at this point.

I have not worked out how some of the less common (usually smaller) textures are stored. The main chunk being Fuji city field, that one misses most. If one texture fails to be read, all textures stored after this are missed and there isn't really a way around this, the way I currently process the files.

In regards with HG3 I have attempted, but the files are different. When I get time I do plan to work on this, and I have started a little but its very unusable in its current form. The meshes are a little different, I assume the format has the same basic structure, but it probably was refined between games.

Facepalm38 commented 4 months ago

I will try to re-export the track files, but so far I've only noticed those two tracks having that issue. Basically what I think it does is it fails to read the texture, and therefore the material, so the combined exporter doesn't read the meshes and it doesn't keep them in.

As for the positioning, the combined mesh exports don't seem to keep the positioning, instead having one corner of the map chunk be almost at 0, 0, 0 which leads to all imported chunks basically being centered on the same spot and all of them being stacked.

mholeys commented 4 months ago

Yes if you mean say field A would be at 0,0,0 then yes this is to be expected, as I do not change any values. If you mean each part of one course/action/field are all overlapping at 0,0,0 then that is unexpected.

mholeys commented 4 months ago

I may have misread your earlier message, yes, you will have to place each field manually, the coords can be calculated based on the three digit field number.

Each field is 1600 wide, and are in an offset grid, first row is at 0, second at +800 third at 0, and so on for the horizontal space (EAST/WEST). For vertical (NORTH/SOUTH) the fields are just 1600 high.

If the field is 223 C = 2, B = 2, A = 3 (peach town btw) X pos would be B 3200 + (A remainder 2) 1600 + (800 if A > 1) Z/Y pos would be C * 3200 + (1600 if A > 1) Which would be X = 8800, Z= 8000

You could offset all this to make one field the center, but the offset can be calulated as above. Hope this is what you meant.

Textures, and meshes are read in different sections of code, and so missing textures should not cause any meshes to be read. However please let me know in a bit more detail what is missing please, thanks.

image

Facepalm38 commented 4 months ago

Thank you for the response! It's neat that there's a formula to make all of the assembling somewhat easier! I have no idea how I'd deal with importing all pieces and then having to assign textures one by one otherwise.

Here's the problem I'm encountering, using Desert Raceway as an example. The faces of this building (and some others that share the same texture) did not show up in any of the combined meshes, and I think they don't appear in the exports in general either. I'm not sure if this is because of any error or because of the regional difference, but I doubt it's a regional difference when the only changes are textures.

image

mholeys commented 4 months ago

Thank you for pointing this out it is the same in my copy, I had missed this, I am looking into this now. There my be a better way of calculating the position, but that was what I worked out initially.

mholeys commented 4 months ago

I have found the cause, there are more meshes in certain chunks, I have been missing these but logging this, and so I am now working through the files with in correctly read chunk numbers.

For reference the following files have been missing things: ACTION/A18 COURSE/C04 FIELD/F000 FIELD/F010 FIELD/F100 FIELD/F222 FIELD/F300 FIELD/F320

Facepalm38 commented 4 months ago

What units should I be using to position all the pieces in the workspace?

mholeys commented 4 months ago

I have been using the default units in both unity and blender, which I think is meters. So each field is 1600 meters square. Importing mesh units as meters.

I think you may need to flip one of the axis on import, I noticed in the screen shot your finish line is the wrong side.

Facepalm38 commented 4 months ago

Yea, I flip them all once I've imported them fully. 3DS Max only flips on the XY axis for some reason, so I gotta make do

Facepalm38 commented 4 months ago

So how does My City work? All the textures for the buildings are in the folder, but none of the buildings themselves are there.