SUBSIM Radio Room Forums

SUBSIM Radio Room Forums (https://www.subsim.com/radioroom/index.php)
-   SH5 Mods Workshop (https://www.subsim.com/radioroom/forumdisplay.php?f=249)
-   -   GR2 Editor/Viewer/Extractor/Importer (https://www.subsim.com/radioroom/showthread.php?t=188290)

TheDarkWraith 09-30-11 11:27 AM

I have a material binding problem somewhere:

http://www.subsim.com/radioroom/pict...pictureid=4948

After I reversed the order of the maps for a mesh subset with multiple maps I get the hull to render correctly but now the other subset (0) has an obvious incorrect material assigned to it. I have a pointer crossed somewhere.....:shifty:

TheDarkWraith 09-30-11 11:59 AM

scratch what I said about needing to reverse the order of the maps associated with a mesh subset. I was reading and binding the maps correctly to each mesh subset. The problem was a coding error in the mesh class's render function :damn: Gotta love it....:shifty:

The King GeorgeV rendered correctly:

http://www.subsim.com/radioroom/pict...pictureid=4949

That was the 'hardest' GR2 file in SH5 I could find to read/parse. God am I happy everything is working now :D

TheDarkWraith 09-30-11 01:02 PM

now that I can render the GR2 model correctly using the fixed-function pipeline it's time to convert to programmable pipeline. The reason I used fixed-function pipeline first was to minimize possible coding/shader errors. The goal was read and display model correctly then polish.

Now here's my question: I have only one set of texture coordinates for each vertex of each mesh. Don't I need 2 more sets of texture coordinates for the Self-Illumination (AO) and Bump (normal map)? :06:

Madox58 09-30-11 02:00 PM

Quote:

Originally Posted by TheDarkWraith (Post 1758249)
Now here's my question: I have only one set of texture coordinates for each vertex of each mesh. Don't I need 2 more sets of texture coordinates for the Self-Illumination (AO) and Bump (normal map)? :06:

Yes. You need the second set of Texcoords in the GR2 file for the AO.
There is no built in Structure in the granny2.dll to read them though.
So if your useing the same calls as used by Quark (Which came from gr2.Decode by the way) to read the PrimaryVertexData you'll never access them.

By-passing the granny2.dll allows reading (and writeing) them.
Here's the King George's AO texcoords extracted. (no granny2.dll was harmed during the extraction! :haha:).
http://i108.photobucket.com/albums/n.../KG_AO_UVs.jpg

For the Normals, it uses the first Texcoords set.
But you need to write the code to implement Normals.
One good thing? You don't need to write the code to calculate the Normals, Tangents, or Bitangents.
Those are already in the PrimaryVertexData.
So you only need to read them.

reaper7 09-30-11 03:33 PM

Amazing work going on here :o

Madox58 09-30-11 03:45 PM

:yep:

But I do see a trend here.
Another 'dumbmaking tool'.
:har:

And that's fine with me!
I don't program 'pretty stuff' as others do.
I program what I need and move on.
Then I'll pass on what I know to others.
So if someone else does the fancy GUI stuff? All the better for everyone here.

If I can read and write what I want?
I don't need to see it in realtime as I already know the results before I ever put it in Game or run the program.
(90% of the time it works. I can deal with a 10% WTF rate and go back)

TheDarkWraith 09-30-11 03:54 PM

ok then I need to define a structure for the second set of texture coordinates. Maybe the grannyloader.dll of SH5 can help me get to them :06: SH5 access them somehow and just have to figure out how. I'll poke around more in the granny2.dll to see if it can extract those coordinates for me.

Madox58 09-30-11 04:02 PM

It won't. I know that for a fact.
It's one reason I dropped useing the dll and went for a full understanding of the format to do what I want.

If useing built in Structures from the Granny2.dll in SH5?
You'll never get the second set of texcoords.

Those are in the second section along with all the other PrimaryVertexData information.
(Section 3 is all the faces)
Section 1 contains all the information to decide the TriGroups and MUCH more!

Madox58 09-30-11 05:06 PM

Another point.
Even if you figure out the right way to code things to use the granny2.dll?
That may violate copyrights.
Do what we want to the granny2.dll and GR2 files as long as we don't infringe.
So if you are useing something like:

nverts = (*GrannyGetMeshVertexCount)(mesh);

You may be subject to problems with RAD.

TheDarkWraith 09-30-11 05:38 PM

If you bought the SH5 game you have a license to all the files contained in it. As long as I don't modify any dlls or exe there is no legal ground for anyone to stand on. Furthermore since the app asks you to point it to your granny2.dll file it is using your licensed copy of it.

Using tools from Microsoft I inspect the granny2.dll to figure out function calls. Just now I found in the exports section all the defined vertex formats that granny uses. From that information (and some trial and error) I make my code.

Just read in all the binormal and tangent information with each vertex :cool: There is not a granny vertex format defined that reads the second UV coordinates. Thus there is some function in that dll that does this. Now to find it.

Madox58 09-30-11 05:48 PM

It's a special defined structure that is not in the granny2.dll
That I know.
Maybe in the grannyloader.dll granted.
I don't need those so I don't look at them.
The GR2 format is not that difficult to work with if you look at it as it is.
It's not compressed in SH5.
It's all layed out from start to EOF.
And SH5 does not do the CRC check.
Had SH5 used the CRC check?
We'd be screwed big time!!
Unless you fell back to an older granny2.dll
:03:

TheDarkWraith 09-30-11 06:29 PM

ok, I think I found something interesting in the King GeorgeV.gr2 file itself:

000176E0 01 01 01 01 01 01 01 01 00 00 00 00 50 6F 73 69 ............Posi
000176F0 74 69 6F 6E 00 00 00 00 4E 6F 72 6D 61 6C 00 00 tion....Normal..
00017700 54 61 6E 67 65 6E 74 00 42 69 6E 6F 72 6D 61 6C Tangent.Binormal
00017710 00 00 00 00 54 65 78 74 75 72 65 43 6F 6F 72 64 ....TextureCoord
00017720 69 6E 61 74 65 73 30 00 54 65 78 74 75 72 65 43 inates0.TextureC
00017730 6F 6F 72 64 69 6E 61 74 65 73 31 oordinates1

Basically it tells me the vertex layout:
Position
Normal
Tangent
Binormal
TextureCoordinates0
TextureCoordinates1

so if I read in this vertex format it should work....time to try :yep:

Madox58 09-30-11 06:41 PM

Yes.
All information like that is laid out in section 2 just as you see it in Grannyviewer!

It's a solid block defined by the section index and it's pointer.
Section 3 has all the faces.

That's all those sections contain.

Section 1 contains all the information as to how to divide those into seperste meshes and the textures assignments.
Plus much more.
:03:

The default for sections in a GR2 file is 8.
Max sections is 32
(That info is from the Granny history at RAD Games)

Also from a RAD Games Blog?
Most GR2 files are not modified even though Granny allows modifications.
'The First Templar' is a GREAT example of a modified GR2 file!
Easy to read/write setup for the most part.

Rongel 09-30-11 08:57 PM

I don't understand a word from that, and I don't really want to, just keep going unless police orders you to stop :D

This kind of stuff is the future of SH 5.

Probably the last WW2 subsim that humankind has to offer!

TheDarkWraith 09-30-11 09:02 PM

there looked to be a promising function in the granny2.dll: GrannyGetMeshVertexType. OllyDebug reported that it took one parameter and it was quite obvious that the one parameter was a pointer to a mesh. So I passed in the pointer to a mesh that had 2 texture coordinates per vertex defined hoping that the value returned would be a pointer to the granny vertex type defining 2 texture coordinates. I passed the returned value into the GrannyCopyMeshVertices function and looked at the returned values from that function. Result was a big fat no :shifty: It only returned the correct format for the mesh with 1 texture coordinate defined as evidenced from the returned data (the bone weight and bone indicies data contained something other than 0,0,0,0) It was worth a try :yep:

Next thing is granny viewer reports VertexData. This vertex data contains descriptors defining the vertex data along with verticies for that vertex data group. Let's see what it does.....

EDIT:

I can't make the correct structure the function call requires.....All I get is garbage back......


All times are GMT -5. The time now is 06:05 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.