GR2 Editor/Viewer/Extractor/Importer
For approximately the last 8 months I've been gathering information on the GR2 format. I've found info from the net and from this one magical place on the net dealing with QuArK. This one magical place has been a major source of the information I've attained about the GR2 format. Another huge source of information was the GrannyViewer app from RAD games (the 'maker' of the granny format - a free app from them). That app tells you everything that is contained in the GR2 file - the trick is figuring where the info displayed resides in the GR2 file. I used that app extensively in the making of this app. Last, but not least, Privateer provided the last missing piece to the puzzle when he released his GR2 template for the 010 editor. I couldn't figure out how to read the very beginning of the file and that template provided information that allowed me to figure it out.
The pointers contained in section 0 of the GR2 file will tell you everything you need to know to do what I've done. http://www.subsim.com/radioroom/pict...pictureid=5515 The screenshot above shows NSS_Uboat7a (with hull mesh turned off to show rooms). All waypoints are shown also. Since I have all this data and I know how to interpret it correctly I can do basically anything with it. An extractor will be coded in to allow you to extract meshes from the GR2 file into OBJ format (might even code it for Microsoft's X format also). I hope to also figure out how to import new items into the GR2 file via the app. Now I know someone is going to say "We have the goblin editor and Granny viewer to see GR2 files graphically. Why reinvent the wheel?" And that would be a good and valid question. Here's why: - If I can display the information I read from the file graphically and it renders correctly then I'm reading the file correctly. Most important. - To do things that either of them can't do (picking, moving bones, rotating meshes, etc.) For anyone that's curious: - developed using Visual Studio 2008 C# - currently uses DirectX fixed-function pipeline (I plan on converting it to the programmable pipeline [aka shaders] once everything is working). I use the fixed-function pipeline because it's easier to code initially. Goal is to get everything working then go back and polish. - uses DirectX 9.0c for rendering (no OpenGL or anything like that) current version v1.1.459.1: https://www.mediafire.com/?0c360d3g4jx3qah NOTE: CURRENT VERSION IS IN ALPHA STATE. ENSURE TO BACKUP YOUR WORK BEFORE SAVING WITH APP! :|\\ In hopes of getting some open-source type thing going on here is the C# AntiGranny code file (old and outdated but still full of useful info). Since there was no participation in my open-source adventure I will not be updating the source code below anymore: http://www.gamefront.com/files/20890...10_15_2011_zip |
Speechless :rock:
|
TheDarkWraith :rock:
Privateer :rock: Subsim community :rock: Great. :sunny: |
Very Nice Mate!
:salute: I'm sure some of the information I have will help alot. |
Supercalifragilisticexpialidocious! :rock:
Not that I understand any of it, but I can see that it's awesome! |
First texture render (lighting disabled):
http://www.subsim.com/radioroom/pict...pictureid=4940 As you can see I have more work to do on it. Not bad for first render with textures though! The textures and how they are defined in the GR2 file are somewhat confusing. You have a pointer that can point to the actual material or it could point to another pointer that can point to another pointer......so on and so forth :shifty: I obviously don't have my pointers straight :DL By looking at this graphically I can see that I'm not reading this part of the file correctly. |
The problem above is due to multiple textures defined per a mesh subset. I'm not reading those correctly. When I try a simple item like the CMD_small_boat it renders fine:
http://www.subsim.com/radioroom/pict...pictureid=4941 Back to the Granny Viewer we go! |
Quote:
Looks tempting ... Good luck. :up: |
Well I'm miffed :shifty: According to granny viewer all my ducks are in a row regarding textures, vertices, texture coordinates, etc. for the King George gr2 file. But the hull still renders incorrectly. Now one thing I have noticed is that on some units where the hull is rendered incorrectly if I place the camera inside the hull (inside the ship) and look at the hull it's rendered correctly (with culling set to none). Puzzling :hmmm:
Another thing that maybe someone knows the answer to: how does one correctly render the other maps beside the diffuse map (self-illumination and bump)? :06: Some units have all 3 of these maps defined for a mesh and I'm currently only using the diffuse one. |
Quote:
Anyway, awesome work! :DL:DL:DL:DL:DL:DL:DL:DL:DL:DL:DL:DL:DL:woot: I really hope that you guys will break some locks that SH 5 has, and open the game to new possibilities! |
Quote:
2. Shaders and correct use of index/vertex buffers... Here's S3D's shaders (diffuse, specular and ambient occlusion, no bump)... You know, that dumbmaking tool that did similar things to what you are making now for SH5! :har: Code:
|
Don't think it's a matrix problem. The bone associated with the King GeorgeV hull is positioned at world center (0,0,0) with no rotations so for all intensive purposes the world matrix is Matrix.Identity.
The index buffer and vertex buffer for the mesh match what the granny viewer shows. The texture coordinates for the verticies in the vertex buffer also match what granny viewer shows. The normals for the verticies in the vertex buffer also match what granny viewer shows. Everything renders correctly geometry wise and everything except the hull renders correctly texture wise. The hull mesh has two subsets and I've noticed that anything with more than 1 subset in the mesh doesn't render correctly texture wise. I'm currently using the fixed-function pipeline for rendering. I'll convert to programmable pipeline (shaders) after I get everything working correctly. This hull rendering problem is really starting to annoy me :shifty: |
If you've got a 'small' world/view matrix error (or related, RH/LH system mixup), the entire unit still renders correctly (at least, might) but the uv-map thus can be offset. All I'm saying, it's a common and classic mistake, and you are not the first to make it. [edit] and PS, it's exactly why flipping the culling from CW to CCW or vice versa sort of fixes it (obviously it's not fixed, since it renders inside out). This generally means a matrix error (just a single 'sign' - somewhere, usually, the identity)
Of course it can have other causes, like not using map channels correctly, loading uv table incorrectly... but my first comment is something worth looking into because I've seen this error many times... |
I think I have an incorrect map assigned for subset 2. Subset 1 renders fine:
http://www.subsim.com/radioroom/pict...pictureid=4946 I'm going to try forcing subset 2 to use subset 1's map EDIT: same result. The inside of the hull of the King George renders incorrectly also so it's not a matter of triangle verticies flipped. |
ok, I think I found the problem:
http://www.subsim.com/radioroom/pict...pictureid=4947 If a mesh has multiple subsets then of course it has maps assigned to each subset. When I read the maps assigned to a mesh with multiple subsets from the GR2 file I need to reverse the order of them. Another strange quirk of the GR2 format. |
All times are GMT -5. The time now is 06:04 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.