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 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 04-16-11, 01:19 PM   #1
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


[TEC] Adding/Importing new units / SH5 Damage/collision models

This will document how to add/import new units to SH5. It will also document the damage/collision models present in SH5. I'm pretty certain this will get stickied as the information it contains is needed for ship builders/new unit builders/unit importers for SH5

Let's open up the NLL ship in the goblin editor (it's .GR2 file, .sim and .zon files):


Now I need to discuss the damage/collision models used in SH5. SH5 has two damage/collision models. One is for damage/collision with other units and the terrain. The other is for damage/collision with shells/torpedoes/DCs.

The damage/collision model for units and terrain can be seen by showing the damage for each hull part/part of the ship. Here we'll look at hull02 of the NLL ship. We view the sphere's for collision testing by selecting a hull part or another part of the ship (any part except the root of the tree which is NLL in this case) and right clicking and selecting Edit Damage:


Notice all the sphere's. These sphere's denote areas that can be collided with. Now when a collision happens with a sphere the game engine then looks to see if any boxes are located in that area and calculates which boxes are affected by the collision. Now you may be asking how do I see the boxes? It's easy. If you right click on the topmost object (NLL in this case) and select Edit Damage you'll see all the boxes for the unit:


Now when a collision happens with another unit/terrain the game engine looks to see which sphere's are affected and then looks to see which boxes are affected to calculate damage/flooding.

So one might be asking what are these boxes for? These boxes denote the compartments on the ship. Each box has a Type value which is drawn from the Zones.cfg file. This type value then tells the game engine how the compartment behaves flooding wise via the entries in the Zones.cfg file. It also tells the game engine which effects to play when the damage to that compartment exceeds certain defined values.

One thing to note is that boxes CANNOT be used for collision detection. They are for damage/flooding model only.

Now we need to talk about the other damage/collision model used in SH5. This model is used for collision detection of shells/torpedoes/DCs with units. This model, to me, seems to be very CPU intensive. This model exists, I'm almost 100% certain, because of the granny way of doing things. Instead of using sphere's for collision detection the game engine uses a 3D model. See why I say CPU intensive? It appears that the game engine uses the resulting bounding box from the 3D model as a first test for collision detection with shells/torpedoes. If that test passes then it goes down to a face level to see where the collision happened. How this is better than the sphere way is beyond me Once the face(s) have been determined then the game engine looks at which boxes are effected some how. I haven't quite figured out how it does this but I do know this is how it's done. Once the box(es) are determined then it goes about calculating the damage to the resulting boxes from the MinEF and MaxEF and MinRadius and MaxRadius of the shell/torpedo/DC.

Now you can probably see why the magnetic detonators don't work in SH5. As the granny way of doing things needs to see a collision happen and by nature magnetic detonators never collide with anything nothing ever happens! The torpedo just sails on underneath the unit

So how do we see this 3D model that is used for collision detection with shells/torpedoes/DCs? Once again it's quite easy. First let me bring to your attention an entry found in EVERY unit in SH5. This entry is viewable in Goblin editor and it starts with this 'DMG_col_x' where x is the name of the unit/part. This entry is always in bold and in an italics font. Now something special about this entry is that it's hidden (not viewable - hence the bold text and italicized text). Another thing that is interesting about this entry is that it contains a very simplified 3D model of the unit/part it represents (to minimize CPU time calculating which face(s) was/were intersected).

Now from above we looked at hull02 of the NLL ship. You saw the 3D model that is rendered in game. Now we're going to hide the actual 3D model used in game by right clicking on NLL_Hull02 and selecting Toggle Hide/View. Thus you should see the below:



Notice that hull02 is not viewable anymore. Now let's view the 3D model used for collision detection with shells/torpedoes/DCs by right clicking on DMG_col_NLL02 located under NLL_Hull02 and selecting Toggle Hide/View. You should see the below:


Notice the very simplified 3D model used for Hull02 in this case.

And that is the two damage/collision models used in SH5.

Using this information one can import/make new units for SH5 using .dat files. My next post in this thread will be about importing a unit from SH3 and porting it over to SH5.


See here for a tutorial from Rongel on how to take a unit from SH4 and place into SH5: http://www.subsim.com/radioroom/show...&postcount=432


Last edited by TheDarkWraith; 05-18-11 at 10:57 AM.
TheDarkWraith is offline   Reply With Quote
Old 04-16-11, 01:39 PM   #2
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by stoianm View Post
Awsome... so you just show us how to do and we need somebody to import the ships and to put in the campaigns?
It's a little more involved than simply taking a unit from SH3/4 and putting it into SH5. Wait for my next post on importing a unit from SH3 to see how it's done correctly
TheDarkWraith is offline   Reply With Quote
Old 04-16-11, 02:08 PM   #3
urfisch
Sea Lord
 
Join Date: Mar 2005
Location: Deep down in Germany
Posts: 1,969
Downloads: 42
Uploads: 0
Default

great stuff!!!
__________________


urfisch is offline   Reply With Quote
Old 04-16-11, 03:49 PM   #4
aergistal
Chief
 
Join Date: May 2010
Location: France
Posts: 326
Downloads: 23
Uploads: 1
Default

Quote:
Originally Posted by TheDarkWraith View Post
Now you can probably see why the magnetic detonators don't work in SH5. As the granny way of doing things needs to see a collision happen and by nature magnetic detonators never collide with anything nothing ever happens! The torpedo just sails on underneath the unit :nope
Couldn't they have just used another set of bounding-spheres for magnetic detonation? With a probability of detonation on hit.

So this doesn't only not work, but it's not implemented at all?
aergistal is offline   Reply With Quote
Old 04-16-11, 03:55 PM   #5
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by aergistal View Post
Couldn't they have just used another set of bounding-spheres for magnetic detonation? With a probability of detonation on hit.

So this doesn't only not work, but it's not implemented at all?
If you go back and re-read what I posted you'll see that bounding-sphere's are NOT used in collision detection with shells/torpedoes/DCs. An actual 3D model is used for this collision detection. So as the magnetic detonator never collides with the 3D model it never triggers
TheDarkWraith is offline   Reply With Quote
Old 04-16-11, 04:07 PM   #6
jwilliams
Ace of the Deep
 
Join Date: Nov 2009
Location: New Zealand
Posts: 1,013
Downloads: 124
Uploads: 0
Default

Can a transparent model be added to the torpedo? after say 500 meters a 1 meter tube model is redered around the torpedo that is transparent to account for the magetics.
__________________
Windows 7, 64bit. Phenom II 965BE (OC 4cores @ 3.8 Ghz).
Radeon HD4870 (1gb gddr5). 6gb Ram.
jwilliams is offline   Reply With Quote
Old 04-16-11, 04:09 PM   #7
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by jwilliams View Post
Can a transparent model be added to the torpedo? after say 500 meters a 1 meter tube model is redered around the torpedo that is transparent to account for the magetics.
I think the easier solution is to add to the DMG_col_x model of the ship. I'll post about that here soon after I finish my importing an SH3 unit into SH5.
TheDarkWraith is offline   Reply With Quote
Old 04-16-11, 04:12 PM   #8
aergistal
Chief
 
Join Date: May 2010
Location: France
Posts: 326
Downloads: 23
Uploads: 1
Default

Quote:
Originally Posted by TheDarkWraith View Post
If you go back and re-read what I posted you'll see that bounding-sphere's are NOT used in collision detection with shells/torpedoes/DCs. An actual 3D model is used for this collision detection. So as the magnetic detonator never collides with the 3D model it never triggers
And what I said was that they should've used bounding-spheres to simulate the ship's magnetic field.
So it basically needs a hack of some sort to make it work...
aergistal is offline   Reply With Quote
Old 04-16-11, 04:31 PM   #9
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Now we'll import a unit from SH3 into SH5. The unit we will import is NPT_Br. What I'm about to tell you applies ONLY to single hull ships (applies to airplanes as well)!!

Copy the whole NPT_Br folder from Silent Hunter III\data\Sea to your Silent Hunter 5\data\Sea folder.

Open up the Silent Hunter 5\data\Sea\NPT_Br folder. There are some files that are not used by SH5 and thus we need to delete them. Delete the following files:
- NPT_Br_en.txt and
- NPT_Br_ge.txt

Now convert the NPT_PatrolBoat_shp.tga file into a .dds file using a convert program (I use Photoshop CS4).

Now open up the NPT_PatrolBoat_sil.tga file with an image editor. Once again I use Photoshop CS4. Add an alpha channel to the image. Make the alpha channel mirror the image in the non-alpha channels. Save as .dds file using DXT5 format with interpolated alpha. All of this is very important is you wish to have the unit display in the stock ship recognition manual and in my SOAN.

Open up the NPT_Br.cfg file. Edit it to make it look like the below:

[Unit]
ClassName=PTElco
3DModelFileName=data/Sea/NPT_Br/NPT_Br
UnitType=0
MaxSpeed=44
Length=24.7
Width=6.6
Mast=5
Draft=1.2
Displacement=35
RenownAwarded=35
CrewComplement=3
SurvivalRate=70
SurvivalPercentage=40
RecManualCategory=EscortShip
BowShape=Raked

;*********** THE END **************

Now the above highlighted in yellow is very important! The path is the path to the unit and the file is the main (no parent) Type 4/100 node of the unit.

Save the file and close it.

Now open up the NPT_Br.eqp file and make it look like the below:

[Equipment 1]
NodeName=A01
LinkName=20mmSingle_PT
StartDate=19380101
EndDate=19451231

[Equipment 2]
NodeName=A02
LinkName=20mmSingle_PT
StartDate=19380101
EndDate=19451231

[Equipment 3]
NodeName=A03
LinkName=20mmGBSingle
StartDate=19380101
EndDate=19451231

[Equipment 4]
NodeName=L01
LinkName=NULL;REF_small01
StartDate=19380101
EndDate=19451231

I will provide a link to the SH3 gun files at the end of this post. Save the file and close it.

The .zon file is compatible with SH5 so nothing to edit there (you have to ensure that all the zone types have compatible entries in SH5's Zones.cfg file!). The .sns file contains entries that SH5 has for sensors so nothing to edit there either. The .dsd, .sim, and .val files are compatible also so nothing to edit there either. All that is left to do is edit the NPT_Br.dat file to give it a collision model for shells/torpedoes/DCs.

What you have to do is add another Type 4/100 node with the parent as NPT_Br (ID of 0x8D1E68F58AFDFFFF). The 3D model for this Type 4/100 node will be the same as the 3D model of NPT_Br (ID of 0x4A6B640E3041299F). One could make a simplified 3D model of the ship and use that 3D model in place of the actual 3D model like I did here. The X,Y,Z,Pitch,Yaw, and Roll for this Type 4/100 will all be 0x0. There will be NO texture for this Type 4/100 node. This Type 4/100 Node will NOT be visible either! This Type 4/100 node will be named 'DMG_col_NPT_Br'. It HAS to be this name!! This type 4/100 Node will provide the unit with the ability to take damage/collision from shells/torpedoes/DCs.
Now delete every instance of SHD_, DynamicShadow, and reflect_ (and their child nodes!) as they are not supported in SH5. If you try and leave water reflections you will get strange artifacts on the horizon from them.

Now the last thing we have to do in the .dat file for this unit is adjust the textures so that the disable z-buffer write + enable alpha blend is NOT enabled. I use hex editor to make these adjustments. The value for this will be 0x1C850000 vice 0x1D850000. ALL textures have to have this disabled!

Now we have a functional unit that will be rendered in SH5. It will take damage from shells/torpedoes/DCs and from collisions with other units. This is just the basic needed to get a unit into SH5.

What needs to be done next is tweaking the ship wake (actually redoing the shipwake with the new controllers from SH5), adjusting the bow splash and other tweaking.

Now to have the unit be able to be used in SH5 you have to create roster entries for it. I'll include files for this at the end of this post.

Like I said this is the BARE minimum to get a unit into SH5. This just gets a new unit into SH5.

Here is everything needed to get this new unit into the game. It includes a single mission to see it also. Unzip straight to MODS folder. You can use this for reference on importing/making your own single hull units into SH5. This applies to airplanes as well!

http://www.gamefront.com/files/20231..._Br_For_SH5_7z

Once I figure out how to import multi-hull units into SH5 I will make another post. Until then I'm hoping to see some new single hull units and aircraft from you all!!

Last edited by TheDarkWraith; 04-16-11 at 04:50 PM.
TheDarkWraith is offline   Reply With Quote
Old 04-16-11, 06:39 PM   #10
iambecomelife
Silent Hunter
 
Join Date: Apr 2005
Posts: 4,584
Downloads: 297
Uploads: 0


Default

I have been thinking about a workaround for the inability to create units that break up:

Why not designate the ship's bow as, for instance, a mast or ventilation duct in the S3ditor zones property tree? While modding SH3 I designated pieces of deck cargo as "masts", with no ill effect.

For instance, masts are designated as "type 15"; just create half a ship as the parent object and then import the bow, designating it "type 15" in the editor and maneuvering it into the right place.

This would have the added benefit of making it possible for a ship to lose its bow without being destroyed, as was the case on certain occasions (see, for instance, the attack on "Esso Nashville" in 1942):

http://uboat.net/allies/merchants/ships/1461.html
iambecomelife is offline   Reply With Quote
Old 04-16-11, 07:42 PM   #11
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

One step closer to importing units with multiple hulls. Recognize this beauty? It's SH3's NKC3


And here it is being torpedoed!


It was destroyed by torpedoes and sunk without CTD or any problems. The only problem was the hull didn't split into two pieces like it should. One step closer.........More work to do
TheDarkWraith is offline   Reply With Quote
Old 04-16-11, 07:47 PM   #12
stoianm
Ocean Warrior
 
Join Date: Dec 2010
Location: Montreal, Canada
Posts: 2,776
Downloads: 833
Uploads: 11
Default

nice... the ships design imported from sh3.... can be improuved to look a bit closer to sh5 ships graphics?
stoianm is offline   Reply With Quote
Old 04-16-11, 07:53 PM   #13
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by stoianm View Post
nice... the ships design imported from sh3.... can be improuved to look a bit closer to sh5 ships graphics?
yes they can. Since these ships are using .dat files one can export the 3D models out of them, fix them up, then import them back into the .dat files. Very easy to do

And it looks like we won't be able to have multiple hulled ships splitting in two when they are killed. This isn't really a game killer though. At least we can get multi-hulled units into SH5 now!
TheDarkWraith is offline   Reply With Quote
Old 04-16-11, 07:57 PM   #14
stoianm
Ocean Warrior
 
Join Date: Dec 2010
Location: Montreal, Canada
Posts: 2,776
Downloads: 833
Uploads: 11
Default

Quote:
Originally Posted by TheDarkWraith View Post
yes they can. Since these ships are using .dat files one can export the 3D models out of them, fix them up, then import them back into the .dat files. Very easy to do

And it looks like we won't be able to have multiple hulled ships splitting in two when they are killed. This isn't really a game killer though. At least we can get multi-hulled units into SH5 now!
in this case i say is really awsome.... i was afraid that we will get stuck with that old grafic for ships
stoianm is offline   Reply With Quote
Old 04-16-11, 08:01 PM   #15
Jester_UK
Electrician's Mate
 
Join Date: Aug 2010
Posts: 131
Downloads: 107
Uploads: 0
Default

This is fantastic news!!

I've always felt that the lack of variety amongst the merchants was SH5's biggest flaw.

Great work TDW!!
Jester_UK 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 05:39 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.