Discovery Gaming Community

Full Version: Making hitboxes using SUR Splicing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This method is the more "advanced" and tedious version, but normally has a 100% success rate unless you screw up somewhere along the way. furthermore, if you were to make a base model, you have no choice but to use this method to make a hitbox, since a base model cannot have a shield bubble, or it will cause the game to crash if i remember correctly.

I thought why write a tutorial when Star Trader (from the starport) has already written one which explains everything in a rather simple fashion? here we go:

===============================================================================

Hello gang.

Ready for another mammoth tutorial from StarTrader?

I had a lot of problems making close-fitting .sur files for my big odd-shaped ships because of following other tutorials to the letter.

But anyway, many thanks to Argh, Cold_Void, Bejaymac and Dev, and all the other guys who made my life miserable for months!

Well, I learned from my mistakes and from theirs too.

Their way is not entirely needed for what I do.

BUT - the principle is most definitely the same, the ship MUST be in several groups. You need to have them for sur file part names. The sur file CANNOT be in one part for a concave ship. I don't need break-offable bits, for me it's enough that the ship breaks apart when it is destroyed, and as long as it is made in more than one group this happens automatically in FL. But I do need a surface file that follows the outline of my ships, so that firing into empty areas between ship parts does not hit the ship. And I do NOT want big shield bubbles on my big ships.

So - here is another mammoth "My Way" tutorial again.

Tools

You will need:-

MilkShape 1.82 or 1.83
CMP Importer plugin for MilkShape
Exporter v03 plugin for MilkShape
SUR Exporter plugin for MilkShape
MAT Exporter plugin for MilkShape
The GIMP or PAINT.NET for making or editing materials / textures / colouring.
DDSConverter2 to convert your textures to DDS format
OR Photoshop + the NVIDIA Photoshop Plugin (this achieves the same result with using the dds converter)
HardCMP
UTF Editor (I use v3)
Sur-Splicer

Method

1. Import your ship model into MilkShape using the CMP Importer plugin, or make it using MilkShape or your favourite modelling program (that is Beyond The Scope Of This Tutorial (BTSOTT)!) and then import it into MilkShape by whatever means your modelling program allows. There are many plugins for MilkShape for most modelling formats, including 3DS.

Make sure your ship is NOT in a single MilkShape group before going to step 2!

If it is, then you need to break it up into several groups. This is easy to do, follow my Tutorial on splitting a model into multiple groups. But remember the max that the exporter can handle is 18 main groups. and the same applies to the number of sur main groups too!

Make sure your ship groups are named (shipname)_Hull and (shipname)_LWing etcetera. I will again use the Excalibur as my ship name for this tutorial, so my main groups are named Excalibur_Hull, Excalibur_LWing etc. Replace "Excalibur" with your own ship name. This will make your life easier when making the similar-named sur groups to match the ship groups. If you choose not to follow this naming scheme then you will need to translate my tutorial naming example more difficultly!

2. Making The SUR file

Firstly, what were my biggest problems?

a) Making the ROOT sur convex.

Why? Because I always thought the ROOT sur had to follow the shape of the largest part of the ship, the hull.

It does NOT.

b) Getting the sur group names correct.

Because some tutorial writer, who shall remain nameless and shall stay uncredited here, named his ship parts and sur parts zomgxxx_blah_blah and then failed to describe to me how to undo this correctly. Wrong!

Cost me days and weeks and months, 'cos I tried too hard to follow their way closely. Wrong - of me!

OK - the ROOT of the problem is easily solved...

c) I was until last week under the impression that ONLY the ROOT sur should be convex. WRONG! According to Bejaymac, only the root sur needs to be convex if your ship will have a shield bubble.

I bow to his greater knowledge.

I don't fit shield bubbles as I'm working on large ships and they would be dead ducks with huge great shield bubbles.

So for ships similar to the ones I am working on, ALL sur groups MUST BE CONVEX!!

And this means they cannot have sub-components either as those would make them concave somewhere or other.

Solving these problems

a) Open your new ship model. Make a sphere of at least 6 stacks and 12 slices in MilkShape that fits neatly anywhere inside the main body (fuselage) of your ship. Make sure it's not visible outside the ship body. I like to put mine in the main ship body where it is thickest, but it's not too important. Try to get it fairly central because we will give this sphere the biggest part of the ship's total mass later, and doing this will give more handling stability.

BUT - it MUST be named Excalibur_Hull_lod1 or similar, where the name is EXACTLY the same as your own ship's hull group, and with the suffix "_lod1" at the end.

And it MUST be the FIRST group that you list in Sur-Splicer's input file later on. So it's good practice to put this group at the top of the Groups tab list in MilkShape.

Why a sphere and not an oblongular globule or cube or...???

'Cos... a SPHERE is the MOST CONVEX shape EVER!

So - the CONVEX ROOT SUR problem is neatly and swiftly SOLVED!

OK - now it's your turn for the remaining sur shapes (we call them groups here to match MilkShape)!

Go and make whatever simple, low-polygon shapes you want to follow the contours of your own ship. Use ONLY spheres and cylinders. Do not use boxes, and definitely NOT faces and NOT vertices! (Boxes sometimes work but often do not, and will waste your time and effort).

Make one sur part for each of the main ship groups (the groups starting with Excalibur_ in their name).

Each time your sur group takes on a concavity, remove it and start with a new sphere or cylinder. Don't try to fix a sphere or cylinder that's gone bad on you, it takes too long and you can make it worse.

NOTE:- You will need to inspect your sur shapes very closely, sometimes when you make a bent surface it looks convex, but the faces can crease between two vertices lower into the surface than the others next to them, and this will cause a dip (concavity) in the surface. Even if it's only slight, it will still cause your sur to make the game freeze or bomb out. Mine did!

If you are lucky, reversing the direction of the face crease and making it between the two higher vertices (called Turn Edge in MilkShape) can cure the concavity. It worked for me at times. At other times I had to delete the faces and reconstruct new ones with additional vertices.

If your sur group will take on a concavity as you continue to follow your ship's contours, remove the concavity, stop that group and start a new one. You can overlap sur parts to get the coverage you want.

None of your sur groups should have any sub-components, to be sure each one remains completely convex.

Ensure that EVERY sur group is completely closed all round (i.e. it has faces on ALL surfaces) including ones that meet up with other groups or are overlapping with other groups or are inside other groups!

Ensure that each and every sur group has WELDED vertices! Pretend it's a water tank and has to hold water!

Of course if you use only spheres and cylinders you will not have these problems.

Remember again, the max number of main groups that the exporter can handle is 18, so limit your sur groups to max 18 too, or you will definitely have nowhere to anchor your 19+ ones!

Unhide all, select all, and WELD the vertices again.

If you were careful, you will have solved the ROOT and sur group concavities problems.

b) ENSURE that each SUR group is named EXACTLY the SAME as the SHIP group it will be associated with, plus ending with the "_lod1" suffix.

So if it's for Excalibur_TopLFin then it MUST be named Excalibur_TopLFin_lod1

Done them all? SAVE your model as a NEW name, e.g. ExcaliburNewSurs.cmp

CHECK that you have named all of your sur groups in the format xxxx_lod1

CHECK that you have NOT assigned any materials to any of the SUR groups. This can happen accidentally when you duplicate a shape.

So - Problem b is SOLVED! We don't need to faff about updating the cons_fix data in the sur file manually now!

Well Done!

Let's go EXPORT!

1. Close MilkShape and restart it, and open your sur model. This will save you heartache that I went through when MilkShape's buffers or pointers or whatever don't get reset properly. You will see another one of these bugs later in any case.

2. CAREFULLY DELETE ALL of the SHIP main groups, SHIP group sub-components, and ALL of the hardpoints, and the hardpoint placement group if you made one. LEAVE ONLY the SUR groups.

SAVE as a NEW name, e.g. ExcaliburNewSursOnly.ms3d

3. This step needs VERY GREAT CARE! DO NOT SAVE at any step!

a. In MilkShape, leave the topmost sur group (your Excalibur_Hull_lod1), and CAREFULLY delete all other sur groups. You can do it a little faster by ensuring Select is by Face, selecting the group you want to keep, press Ctrl+I, and then Delete.

If you make a mistake use Ctrl-Z to undo it. DO NOT SAVE!

b. Copy the main group's xxxx_lod1 name from the Rename window (select it all, press Ctrl-C).

c. Start the SUR Exporter plugin (File... Export... go find it).

d. Click Load CMP Settings (.ces) and retrieve the settings you saved earlier when you exported the ship cmp file. If you didn't, don't worry, the next steps will fix it for you anyway...

e. Ensure Orientation = Back to Front, Scale Down Value = 1, Collision Mesh = Shrink Wrapped, Disable DirectX Mesh Reduction is checked, Number of Groups = 1

f. Click Browse... and paste (Ctrl-V) the main group name (Excalibur_Hull_lod1) into the filename window, and click Save

g. In Ship Mass, put in a value that is about half of the total ship's mass. This is for the root sphere that is near the centre of the ship and will help stability.

If you decided to not use a sphere, give this mass to the sur group you chose as your root sur (the top one in your list).

h. Click OK.

If all went well, you have exported the first sur group successfully.

If not, then you need to do this part again - sorry, but yes, you do.

i) If all did go well so far, repeat this step for the next sur group. This needs care! I usually leave MilkShape open and use Ctrl-Z repeatedly to undo the group deletions, then delete the other groups and sub-groups that I don't want. Here is where the thoughtful sub-group naming is important.

ii) Do the same for the remaining sur main groups and their sub-components. In step 3g, set a mass appropriate to the piece you are covering, and ensure the total of all masses is close to the total mass of your ship. Balance the mass of left and right parts to be the same, i.e. mass of the left wing should be the same as the mass of the right wing etc.

BUT - Don't do this when you are sleepy!

If you get a message saying "Failed to start 3D Device" or similar, DO NOT SAVE! Close and restart MilkShape. This is the bug I referred to earlier. Don't worry, now just re-open your saved SURs ms3d file again.

All done? Well done again.

Splicing Them Together

4. Now we need to use Sur-Splicer to stitch the multiple surs into one...

a. Go to the folder where you placed a copy of sur-splicer, and make a new file with Notepad named splice-it.bat and enter this into it...

sur_splice.exe SurInput.ini
pause

Save it.

b. Make another new file with Notepad named SurInput.ini and enter these following lines into it, adapting the names to your own sur files - this example is for my Enterprise D - Remember to change the group names to match your ship sur groups names, and don't enter my comments in {brackets}...

NewEntDSpliced.sur {This is the name of your new sur file when it's done}
EntD_cons_fix.dat (This is not needed by us but sur-splicer needs it to be named.}
550 {Make this the radius of your own ship in metres}
18600 18600 18600 {This is the X, Y & Z inertia but use your ship's mass 3 times}
EntD_Hull_lod1.sur root {This is our ROOT sphere}
EntD_HullNacelle_lod1.sur EntD_HullNacelle_lod1
EntD_Pylon_lod1.sur EntD_Pylon_lod1
EntD_Saucer_lod1.sur EntD_Saucer_lod1
EntD_Wing_lod1.sur EntD_Wing_lod1
EntD_LEng_lod1.sur EntD_LEng_lod1
EntD_LEngPyl_lod1.sur EntD_LEngPyl_lod1
EntD_LPylRoot_lod1.sur EntD_LPylRoot_lod1
EntD_REng_lod1.sur EntD_REng_lod1
EntD_REngPyl_lod1.sur EntD_REngPyl_lod1
EntD_RPylRoot_lod1.sur EntD_RPylRoot_lod1

Note the two entries on each line are identical except that the second entry does not have the .sur suffix, and that they are separated by one or more spaces, or a tab. Extra spaces do not show in this forum.

Save SurInput.ini

c. Copy all of your sur files into this same folder.

d. Run splice-it.bat by double-clicking on it.

Check the run messages for any errors.

If all is well, close the DOS window.

If it does not seem to be OK then go back and check the names you used in SurInput.ini

e. Copy the NewEntDSpliced.sur or whatever you named your sur file into your ship model work folder and rename it to match your ship's .cmp file.

All done.

f. Check your model and Sur file using HardCMP, press S to see your sur file.

If HardCMP crashes on trying to open your ship model, it's most likely to be that your SUR file is bad - rename or delete it from the folder temporarily to check. If it is the cause - well, you just have to go back and do it again more carefully. Been there!

Don't worry unnecessarily if the sur file parts are not all showing in bright white in HardCMP, this doesn't matter in my experience. But make sure that no bits are missing altogether, this will be a problem.

Shoot it up!

Go check it out in the game. You will need to copy these files:-
yournewship.mat
yournewship.cmp
yournewship.sur

into the DATA\SHIPS\yourshipname folder.

You will also need a cockpit.ini file there for the camera views, and you will also need to make a full and correct entry in shiparch.ini and also in goods.ini and in market_ships.ini to be able to buy it, and you will need to start two game characters, one with the new ship and one for another ship to crash into it and shoot it up! WBTSOTT!

But you can also make it a stationary solar to test it - see my tutorial on that.

But if you do it this way, remember you are not testing the sur fully because you will not be able to destroy the ship, and so you will not detect any sur problems which occur when the model breaks apart. You need to have another player or NPC use the ship and then destroy it to test for these problems.

I also found that with this test method, I could shoot it up and crash into it and bounce off, but concave sur parts were not detected! So the game only froze when I gave the ship to NPCs and flew around them.

Problem Symptoms

To isolate if any of these following problems are to do with your sur file, use a resized vanilla sur temporarily by renaming your own sur file or removing it from the ship folder, and renaming the resized one to suit your ship cmp file, and run again to see if you get the same problem. Use FL Model Tool to resize a vanilla sur to fit your ship.

Error messages in C:\fl-server-errors.log that the new sur file contains bad or unrecognised information? Yeh, it's bad!

You cannot target the ship that is using a new sur? Hmmph! It was not my new sur file. My new .MAT file was bad!

HardCMP crashes when you are trying to open the ship model? Probably your new sur is bad.

FL Server hangs or crashes when you fly a ship with your new sur, Frelancer appears to continue after a short hang but no connection to FL Server (connectivity icon flashes red)? Yep, sur file is bad!

Freelancer crashes to desktop when trying to open your character when it uses your new sur, or when a ship in the area where your character is trying to spawn is using the new sur? Yep, your new sur is bad. Mine had a very slightly concave part of a tail group (it was extremely hard to see where it was concave in MilkShape!) and froze when I was near it!

Freelancer freezes when you are trying to launch in a ship using the new sur, flying a ship using the new sur, or near a ship using the new sur, or you destroy a ship using the new sur, or you have just destroyed a ship using or carrying a weapon that is using a new sur. Yep... you guessed it, your new sur is bad.

All three of the last symptoms happened to me when I found my sur groups had concavities. Mainly it was the FL Server crash, Freelancer would lose connection with it but still let me do stuff that didn't need FL Server response, like just fly around.

Tip: DON'T make new ship sur AND new weapon surs and fit them on the same ship or its weapons at the same time! I did it!

Your shots don't hit some areas of the ship even though you know there is a sur group covering it, and you can see that in HardCMP? Did you weld all vertexes in MilkShape? Did you ensure that EVERY sur group is closed all round (i.e. faces on ALL surfaces) including ones that meet up with other groups or are overlapping with other groups? Is that sur group REALLY convex all over?

It's very late and I'm in a rush, hope I haven't made any blunders - let me know and I'll fix them next time I get here.