Discovery Gaming Community
Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - Printable Version

+- Discovery Gaming Community (https://discoverygc.com/forums)
+-- Forum: Discovery Development (https://discoverygc.com/forums/forumdisplay.php?fid=7)
+--- Forum: Discovery Developers Forum (https://discoverygc.com/forums/forumdisplay.php?fid=183)
+---- Forum: Freelancer Modding Tutorials (https://discoverygc.com/forums/forumdisplay.php?fid=36)
+---- Thread: Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool (/showthread.php?tid=51643)

Pages: 1 2


Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - AeternusDoleo - 12-16-2010

Creating a SUR for a base or ship model using SUR splicing and the convex tool

This method, using the Convex tool, -always- produces perfectly convex shapes, and thus these SURs cannot break because of a concavity. They are typically very tight around the models, which is useful in the case of battleships and base components. They also allow for hollowed out parts, such as a shipyard, for ships to fly through.
This method can be timeconsuming when dealing with complex models.

This step by step process will show you how. To start, we need the CMP file of the model we want to create a SUR for, and the accompanying MAT file, preferably, if there is one.

Required tools:
- Milkshape (Not freeware sadly, so no link to this application. Most recent version at the time of this tutorial is 1.8.4)
- Milkshape "CMP Import" plugin
- Milkshape "CMP Export" plugin
- Milkshape "SUR Export" plugin
- Milkshape "Create Convex Skin" plugin
(All plugins combined: http://www.xs4all.nl/~hendrik0/Freelancer/...hapePlugins.zip. These files should be placed in the Milkshape program files folder, before Milkshape is started)
- Sur splicer ( http://www.xs4all.nl/~hendrik0/Freelancer/.../SurSplicer.zip )
- Optionally, for quick checking the SUR, HardCMP can be used. ( http://www.xs4all.nl/~hendrik0/Freelancer/...P_V1_0_0_23.zip )

Preparations:
Put the CMP and (optionally) MAT in a seperate folder. The CMP itself will change, so rename the existing CMP by adding a _org suffix. For the purposes of this example we'll use the filename gmg_freighter. The source files would be gmg_freighter.cmp and gmg_freighter.mat, and you'd need to rename the CMP to gmg_freighter_org.cmp.

[Image: screen1.jpg]

Next, we will use the CMP importer plugin to import the original CMP into Milkshape. I've found that this plugin sometimes freezes - if so just shut down milkshape and restart. We'll end up with a model in Milkshape looking like this:

[Image: screen2.jpg]

This particular test model does not have any hardpoints - often you will see hardpointed models as well. We are only interested in the groups bearing materials however. They have to be assigned an unique name. So highlight each group, and name them uniquely. For this model, we'll name them sequentially, starting with GMGF1, GMGF2 etc.
Once done renaming groups, save the model as a Milkshape file. This is the source Milkshape file which the new model file will be exported from.

[Image: screen3.jpg]

Now that we have the name, we will export the CMP again. As you can see this model has 9 unique groups. This means the SUR will have to consist of 9 unique parts, no more (but less is okay).
- In Milkshape: File - Export - CMP Exporter
- Click the New button, enter the filename for the model: gmg_freighter
- LOD is 0
- Model type "ship" (stations use this type too)
- Orientation back to front
- Scale down value: 1
(at this point, hit save settings and save them under the gmg_freighter filename, this will speed up the sur exporting later)
- Groups: 9 for this model
- Each now highlighted subgroup should have value 1
- Hit Continue

[Image: screen4.jpg]

Note: The new CMP is usually larger. This seems normal.
Note: On some models, the hardpoint orientation seems to break during this process. If this happens, use HardCMP to delete and recreate the neccesary hardpoints.
Note: Most simpler models have one group per material type. If you have more then 18 material bearing groups in the model, you can assign the same name to each group bearing the same material type - only 18 types can ever be exported by Milkshape. In that case, order the group list by material type, alphabetically, and group/rename accordingly, then instead of having groups with 1 shape, set the number of shapes exported to the actual amount used. There are only a few ingame models that require this though (such as the Zoner Juggernaut). The details of this will not be included in the scope of this tutorial.

You now have the new model file. Now we'll start making the accompanying SUR file. In Milkshape, save the model again under a second name. I use GMGF-Surs for this purpose. Delete any and all hardpoint groups declared in this file - they're easy to spot, they start with "HP" and have no material assigned to them. SURs do not use hardpoints.
First you'll need to analyse the model a bit. Look at it from all sides and decide how you can best split the model into less then the amount of SUR shapes you have to work with (9 for this model). I came to the conclusion to declare the following parts:
- The two top fins
- The two bottom fins
- The front cockpit section
- The back engine section
- Each of the large side hulls
This came to 8 parts total, which falls within the limit. Now comes the tedious part: Getting these parts declared as a seperate group in your mind, to be a single group in Milkshape. Milkshape has the ability to create a new group from any number of faces you select. So choose Select, and Select Faces. You can choose to select by the faces themselves, or by verts (the little dots the faces connect to). A face, by the way, is a single triangle between three verts.
For this model, the fins are easy enough to regroup. I chose to select by vert, and using the "front" view in Milkshape, could easily select the top of each fin. I had to zoom in a little around the bottom of the fins as they made a little bend there, to get the bend as well. The compound shapes in the middle are not as easy - they'll take some time to do.

[Image: screen5.jpg]
[Image: screen6.jpg]

Tip: If you find it really hard to get a specific shape done, save your model to a second milkshape file, then hack away -any- part of the model -not- belonging to the shape you're after. This will leave you with just the shape you want to draw a hitbox around. Then save this file, reopen the original surs working file and choose file - merge, and merge in your temporary copy. This will import that shape. For complex models like the AI cruiser, or Zoner Juggernaut, this trick can save you some headaches.
Tip: You can regroup as many times as you like. If you later wish to merge two groups, simply select them both by doubleclicking them in the group screen, and click Regroup. Useful if you want to quickly declare the bulk of one group, and later add detail.
Tip: Once you have declared a group and are done with that shape, you can "hide" it so it doesn't get in the way of regrouping the rest of the model.

[Image: screen7.jpg]

In the end, you'll end up with several "regroup" groups - if you did this well, the same amount as the amount of shapes you wanted to build the model from. Note that the textured window will probably look like crap now - this is normal. SURs do not use textures. Now, comes the easy part - creating the perfect concave shapes required for the SUR.
- In Milkshape, select Edit - Select All to highlight every group.
- Now select Tools - ConVexTool. Use the default values of 0 for skin width (if you want the SUR to be a little wider, add a VERY small number, < 0.01). The second number is for the maximum complexity of each shape. Even for the most complex shapes I've found 4096 to be sufficient. Milkshape will create a new group for each group you have in your SUR working model. The new groups have the suffix _convex. These new shapes will become the actual SUR components!

[Image: screen8.jpg]

Now, delete all the original groups from the model, so that you're left with just the _convex groups. Check in the 3D view if the resulting shape looks to be allright, if it resembles the model. The shape you now see -is- the collision mesh for the model, for both shots and collisions.

Note: Fighter models sometimes require a shield bubble. This is outside of the scope of this tutorial - but basically will be just an extra SUR group. Reserve one group for this purpose, and draw the shield bubble around the model you have at this point to create the shield. For stations and gunboats/transports or bigger ships, this is not needed.

Next step will be naming the SURs appropriately. First, check your groups, find one that is at or near the center of the model and move it to the top. This'll become the root of the SUR, and it will help with stability to have this centered. In our model, the cockpit shape fills that role well.

[Image: screen9.jpg]

Now we rename the groups. In the file we exported the CMP from, we named each group sequencially - GMGF1, GMGF2 etc. We'll do the same here, but each group must have the _lod1 suffix.

[Image: screen10.jpg]

Now another tedious part, but we can do some prepwork to speed it up. During the CMP model export you saved the settings, those are now in a CES file. Check the folder you're working in, create a subfolder "surs" and move the CES file in it. Also copy the SUR exporter files to it.

[Image: screen11.jpg]

Now, go back to milkshape, and from your SUR file, remove all groups except the first. Then select the first group. (Do not save the file)

[Image: screen12.jpg]

We will need to do the following for each SUR component:
- Start the Sur exporter (File - Export - Sur Exporter)
- Load the settings from the CES file by clicking Load Settings, then selecting it from the folder.
- Set the mesh to "Shrink Wrapped"
- Set the Ship Mass to about half the ship mass for the first component. Leave it at the default for all others. (If in doubt, just use the default value)
- Check "Disable DirectX Mesh Reduction"
- Leave the groups count at 1
- For the file name, choose the -exact- name of the component you're exporting. For this example we're exporting group GMGF1_lod1, so this will also be your filename for the first part. When you export the next part the filename will be GMGF2_lod1, and so on. So for this model, you'd end up with 8 seperate small SUR files which we'll later combine (splice) into one.
- Then export.

[Image: screen13.jpg]

Now hit CTRL-Z until your groups are all back in Milkshape, and repeat the above process for each individual SUR part. This will take some time, but eventually you'll have all groups exported as an individual SUR file. Now, using a text editor, open the file "SurInput.ini"

Edit it to the following:
Code:
gmg_freighter.sur
splice_cons.dat
100
1200 1200 1200
GMGF1_lod1.sur root
GMGF2_lod1.sur GMGF2_lod1
GMGF3_lod1.sur GMGF3_lod1
GMGF4_lod1.sur GMGF4_lod1
GMGF5_lod1.sur GMGF5_lod1
GMGF6_lod1.sur GMGF6_lod1
GMGF7_lod1.sur GMGF7_lod1
GMGF8_lod1.sur GMGF8_lod1
- The first line is the SUR filename to output, this must match the model name. Since we're making the gmg_freighter.cmp name, this will read gmg_freighter.sur.
- The second line is a temp file for the splicer to work with - just use this value. The splicer will create this file, and you won't use it once the sur's made.
- The third line is the length of the ship, measured in maximum distance from the origin. For small ships up to freighters, 100 is sufficient. For larger ships you'll need a much larger value - The Zoner Juggernaut for instance, needs at least 400. Gigantic stations sometimes will need as large as 1000 here. I've yet to see a drawback to using a large value, so if in doubt, go big.
Tip: If this number is chosen too low, you'll find that when testing your SUR, the edges of your shape furthest away from the center don't register hits. If this happens, simply edit the INI, raise this number, and run the splicer again - you would not need to remake or re-export every sur part.
- The fourth line is the X, Y and Z inertia of the SUR. Use three times the ship's weight for ship, for each of the three values (the GMG freighter here would weigh 400). Stations and other solar object should have very high values here - into the several millions.
- The fifth and subsequent lines are the individual SUR parts. It's comprised of two parts: The filename to process and the internal name in the SUR file to process it at. The first line needs the first filename followed by "root" - this is the center of your SUR, where everything is attached to. Subsequent lines use the file name followed by the file name without the ".sur" part, since we used those for the group names when we exported the CMP.
Save the INI file and run "spliceit.bat". It will create two additional files: splice_cons.dat, and your SUR file, gmg_freighter.sur

Move the newly spliced SUR file back to the same folder where you exported the CMP file to. And that's it! You'r done! Your model now has a collision mesh if you did everything as described above. You can briefly test it in HardCMP - load your model, then choose "Solid Wireframe". Then press the "S" key to highlight the collision mesh. You should see thin lines around every shape of the model. If a piece is not surrounded by those lines, you most likely made a misstake in exporting it, or messed up a group name - check the part again.

[Image: screen14.jpg]

Last thing to do is to test the model in a testing enviorment. My favorite method is to create the model as a solar object (nondockable starbase) and shoot at it/bump into it with a starflier. If all parts work, you're done and can submit the SUR/CMP pair. Let the dev know the CMP changed if you re-hitboxed an existing model.

Warning: When exporting the CMP after regrouping, it's been confirmed that the hardpoints of various models will mess up. Doublecheck the hardpoints for the model once you reexport it, recreate them if neccesary. Using HardCMP and the original model, you should be able to read out the values for each hardpoint and recreate them as neccesary in the new model file.

(If any part of this tutorial is unclear, toss me a private message)


Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - DAnvilFan - 12-16-2010

I'm going to give a thumbs up on this one. This is a detailed tutorial that can save many new folks a lot of grief. Check it out.


Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - kramer - 12-16-2010

Good work.

Please let me add that one should keep the wire-frame as simple as possible.



Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - Linkus - 12-16-2010

Thumbs up indeed, this will definitely help folks.
Seriously, this method is a massive time saver.


Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - Durandal - 12-16-2010

Huh...

A SUR splicing tut that actually makes sense. Random.


Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - AeternusDoleo - 12-16-2010

Fixed a few misstakes, clarified some things. Should be good now.


Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - Xalrok - 12-16-2010

I seem to be having a bit of a problem. When I save each component individually and then run the whole lot through the Sur Splicer, the final product doesn't work right. When loaded in HardCMP, if I press S to view the new hitbox, the preview window freezes, but the rest of the program doesn't freeze at all. The only way to bring the preview window back to normal is to restart HardCMP. Another problem is that the SUR seems to cause FL to crash when I try to undock in-game with it.

I've also tried exporting it whole, but that causes the hitbox to dumb itself down automatically (eg stretching across between points.) Saving it whole with a Shield Sphere instead of Shrink Wrap works, but then there's a massive auto-generated shield bubble.

What's going on? I think it may be my own fault that it doesn't work, but I'm not certain of it.

EDIT: Whenever I try to export one component individually, Milkshape crashes. I have to keep restarting it for each component of the hitbox.


Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - AeternusDoleo - 12-16-2010

Xalrok, pm me on skype: AeternusDoleo. I want to see the milkshape file you're trying to create those sur components from. I'm getting the feeling you're not reducing it to -just- the one sur group prior to export (no hardpoints, single group left in the groups list)


Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - Xalrok - 12-17-2010

Nevermind, I actually solved the problem. I started again from the beginning and it all worked out just fine. When I looked at the screenshots I noticed that the your SUR exporter dialog was different, so I went down from 1.2 to 1.1. Suddenly the crashes vanished and I fully exported the components of the sur file. After that I put it all together and it was flawless.

I'm not completely certain about it, however I'd say that using SUR exporter version 1.1 instead of 1.2 had an effect on it, especially since the 1.1 version didn't crash per export.

And that's a brilliant tutorial. I've never made a hitbox before this and already it's got an extremely tight wrap around the model. All within a single day!


Hitboxing: Creating a SUR for a base or ship model using SUR splicing and the convex tool - AeternusDoleo - 12-17-2010

The plugins in the plugin package I supplied are taken directly from my own milkshape install - they should work:)

Small warning added in regards to hardpoints - apparantly the CMP export plugin doesn't handle them correctly in every case.