SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SHIII Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 12-06-24, 06:08 PM   #1
Jeff-Groves
GLOBAL MODDING TERRORIST
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,649
Downloads: 137
Uploads: 0


Default Harbor Editor

Just looking into creating a Harbor Editor and wondering if it's something needed?
ref had a crude version once but that was like 15+ years ago?

What I have done so far is.....
Export the Harbor_kit.dat
Write a Script for 010 to grap the ID of everything and make a list of them.
Working on a Script to Rename all files exported to the IDs.

To Do.....
Write a Script to change the Names on Exported files to proper ID.
Write many more Scripts to read the Locations files and build a complete Harbor from them.


Now I have Blender 2.79 set up to do batch imports of Obj files. So that is taken care of.
It's the transitional information I'm working on upon import.

Needless to say You'd need 010 to use My work flow.

Notes:
I used Pack3D to export the Harbor_Kit...........
It's flawed when it comes to textures used by 3D objects. Not much of an issue as We want placement information.

Last edited by Jeff-Groves; 12-06-24 at 07:34 PM.
Jeff-Groves is offline   Reply With Quote
Old 12-06-24, 09:48 PM   #2
Jeff-Groves
GLOBAL MODDING TERRORIST
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,649
Downloads: 137
Uploads: 0


Default

Started the Code to read the Terrain Locations dat files so I can Translate the Placements.

Just a quick peek at some of the code.

void setUpRotationMatrix(float angle, float u, float v, float w) {
float L = (u*u + v * v + w * w);
angle = angle * M_PI / 180.0; // converting to radian value
float u2 = u * u;
float v2 = v * v;
float w2 = w * w;
rotationMatrix[0][0] = (u2 + (v2 + w2) * cos(angle)) / L;
rotationMatrix[0][1] = (u * v * (1 - cos(angle)) - w * sqrt(L) * sin(angle)) / L;
rotationMatrix[0][2] = (u * w * (1 - cos(angle)) + v * sqrt(L) * sin(angle)) / L;
rotationMatrix[0][3] = 0.0;
rotationMatrix[1][0] = (u * v * (1 - cos(angle)) + w * sqrt(L) * sin(angle)) / L;
rotationMatrix[1][1] = (v2 + (u2 + w2) * cos(angle)) / L;
rotationMatrix[1][2] = (v * w * (1 - cos(angle)) - u * sqrt(L) * sin(angle)) / L;
rotationMatrix[1][3] = 0.0;
rotationMatrix[2][0] = (u * w * (1 - cos(angle)) - v * sqrt(L) * sin(angle)) / L;
rotationMatrix[2][1] = (v * w * (1 - cos(angle)) + u * sqrt(L) * sin(angle)) / L;
rotationMatrix[2][2] = (w2 + (u2 + v2) * cos(angle)) / L;
rotationMatrix[2][3] = 0.0;
rotationMatrix[3][0] = 0.0;
rotationMatrix[3][1] = 0.0;
rotationMatrix[3][2] = 0.0;
rotationMatrix[3][3] = 1.0;
}
Jeff-Groves is offline   Reply With Quote
Old 12-07-24, 02:16 PM   #3
propbeanie
CTD - it's not just a job
 
propbeanie's Avatar
 
Join Date: May 2016
Location: One hour from Music City USA!
Posts: 10,098
Downloads: 451
Uploads: 2


Default

You can "build" a pre-Placement dat with S3D Jeff, using Blender to make your "placements" in its grid. The problem comes in the "translation" from the Blender to the S3D coordinate system, in that Blender will "import" obj files "vertically" unless you do an import transposition, and the same for export. The coordinates themselves for X, Y & Z are the same, except the "Y" coordinate will be the opposite between the two, such that a "2.671" in Blender will have to be "-2.671" in S3D, and vice versa. With the Rotation coordinates, you are better off with the "degress" setting in S3D, since that's what is 'native' to Blender. It is also best to not exceed 0 to 180 and 0 to -180 for the rotation settings. After a "harbor" (or whatever) is built in Blender, it almost directly translates into a file for S3D, with the tedium being the hex identifiers for the assets used, as well as the Coordinates and Rotation for each of those. Animations and Sounds can also be placed, but those use a slightly different set-up from the "Placement" nodes in S3D, as you're already familiar with and seen. I was attempting to look at what Swasjer posted on GitHub for his libraries, which might translate well into your 010 scripts, and might actually be able to be used as the basis for a self-contained program... as you mention though, "... wondering if it's something needed?" It would be very nice to have when needed / wanted, but, is it worth the effort to do all this? it is rather recursive to implement, perfect for programming, but it's those "details" that kill ya with this...
__________________

"...and bollocks to the naysayers" - Jimbuna
propbeanie is offline   Reply With Quote
Old 12-07-24, 02:57 PM   #4
Jeff-Groves
GLOBAL MODDING TERRORIST
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,649
Downloads: 137
Uploads: 0


Default

Roger on all that propbeanie.

Now why would I look into doing all that hard work?
I'm retired now and enjoy wasting my time doing things no one else does. Or are less likely to do anyways.


It's mostly to see IF I can do it for Me.


One thing I hate about S3D is the way it shows the ID in Hex. It's a backwards display compared to what one sees in a hex editor.

Oh. Just so anyone knows? The reason for renaming the obj files to it's ID is because the names found in location dats don't mean much for my needs.
It's the object ID that never changes.
And when you export from Blender? You can change the settings to Y up and more.

Last edited by Jeff-Groves; 12-07-24 at 04:58 PM.
Jeff-Groves is offline   Reply With Quote
Old 12-08-24, 02:48 PM   #5
iambecomelife
Silent Hunter
 
Join Date: Apr 2005
Posts: 4,706
Downloads: 300
Uploads: 0


Default

Wow! This stuff goes way over my head - but it is fascinating all the same! Thanks for your continued work for those of us who aren't too familiar with making these changes.

A harbor editor would definitely be nice because even back in the late 2000's SH3 and SH4's harbors were not my favorite .... too similar looking. Now in 2024 they are showing their age even more. In real life of course each harbor has unique breakwaters, orientation of harbor facilities North or South, etc. It would be great to have each harbor look more like it really did historically.


Eagerly looking forward to this!
iambecomelife is offline   Reply With Quote
Old 12-08-24, 04:16 PM   #6
Jeff-Groves
GLOBAL MODDING TERRORIST
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,649
Downloads: 137
Uploads: 0


Default

After a lot of thinking on it? I've got most of it worked out in my head.
I'm not good at programing things for 3D viewing but I can manipulate the heck out of the obj format! As 010 does use a type of C coding? I may even make a stand alone program at some point to handle the transformations.


Now I know just enough about Blender (Even less about Wings3D) to be dangerous! So those that use those programs? I'll need some help.

I can tell you that Pack3D does a good job doing the mass export of needed files. BUT. Since many objects have multipule UVs? It stacks them all into the obj file. But that is not a problem as I only need the verts to do all the Math on.
Moving the objects is just a matter of adding the XYZ from a location.dat file to a given object file. Rotation is more complicated Math but I've already coded that!
The stuff I'm coding will do the heavy lifting work. Once you edit things in a 3D program and export the objects? The codeing will reverse that and spit out a PROPER Location.dat! You'll only need to MAYBE change IDs.
I've got a way to do that automagically also in my head and have posted before on how one can do that!

I've started the code to grab ID's and names of all 3D models in the Harbor_Kit.dat
That will rename all the 3D objects I've exported to the ID's.

Then I'll rip the needed stuff from a Location.dat to get things ready to import to a 3D program. It's pretty intense but I'm haveing a BLAST doing a Jethro Bodine on this!


Oh Yeah. I'll also be extracting the needed areas with ref's SH3 Tool and converting that information to an object file! Making it easier to do a Harbor or other location. Already did that kind of tool for SH5.

Last edited by Jeff-Groves; 12-08-24 at 04:25 PM.
Jeff-Groves is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 04:51 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.