Jump to content

Noob question on collision meshes


Recommended Posts

Ok, so some while back I read a tutorial on making parts. And thus far, I've been able to create some. Now, I'm at a point that my parts are getting a bit more complex and the tutorial has raised questions. In the tutorial it stated that you should always use convex collision meshes. If I understand, it's because they are simple meshes and they use fewer resources. By accident, I forgot to turn on convex and I found the parts where I had it turned on had 'surfaces' where they shouldn't be but the one with convex turned off, worked perfect.

So, my question is: how important is it to use convex collision meshes in Unity and KSP?

Link to comment
Share on other sites

As far as I know, when a mesh is 'convex', it can collide with other meshes which are 'convex' too. When one of those two meshes is not convex, it can't collide with other parts, and will simply go through them. So normally, you want a 'convex' collider for your KSP parts. But there are some exceptions: Parts which should store other parts, like Fairings, shouldn't be convex, because once they decouple their convex collider will destroy all the other parts in the fairing.

Link to comment
Share on other sites

Ok, thanks. That just made magnified my learning curve by a few hundred points. Convex meshes don't exactly follow the outline of my part and I have no idea at the moment as to how to get a convex to fit the outline.

Link to comment
Share on other sites

Usually you can use several smaller convex meshes to achieve what you need. If it's a cargo bay, for instance, you'll probably want to ring the exterior in a bunch of rectangular colliders to make the walls solid, but leaving open space inside.

Stock fuel tanks use 12-sized cylindrical colliders, so for cases where I've needed to mash several colliders together to approximate the shape of the model, I've generally still tried to target that number of faces. So as an example, the MRS cargo bays use 3 rectangular colliders for each door, since the doors are quarter-cylinders (90 degrees of arc around the center).

Another example of getting pretty much the right shape with just a handful of colliders is what I did in the Joolian Discovery's command pod. A roughly 12-sided truncated sphere gets most of the pod, but two truncated cones (also 12 sided) cover the "neck" portion of the pod:

Javascript is disabled. View full album
Link to comment
Share on other sites

Ok, well, my learning now extends to how to add more than one collision mesh and to get it lined and sized properly. I'm not using Blender yet, it's way more than I'm looking to learn all at once. I am using Wings 3D. I've just been using the .obj as the collision mesh.

Link to comment
Share on other sites

As far as I know, when a mesh is 'convex', it can collide with other meshes which are 'convex' too. When one of those two meshes is not convex, it can't collide with other parts, and will simply go through them. So normally, you want a 'convex' collider for your KSP parts. But there are some exceptions: Parts which should store other parts, like Fairings, shouldn't be convex, because once they decouple their convex collider will destroy all the other parts in the fairing.

I thought KSP could -only- have convex meshes.

Link to comment
Share on other sites

I thought KSP could -only- have convex meshes.

Harvestr said something in one of the dev updates that indicated that concave colliders were possible, but the physics system required at least one of the two that are colliding to be convex in Unity 4, and Unity 5 will require ALL of them to be convex.

Link to comment
Share on other sites

The part attachment on larger cylinder allows for 2x 12 surface attachment planes oriented vertically. If you use a 12 side collider then some parts may attach below the surface of larger cylinders. This is not a problem on smaller cylinders because the lowest high on the highest cylinder is higher than 1-cosine of the radius. But on the larger cylinders parts like RCS thrusters and strut connectors can disappear below the surface. If your visible surface of your cylinder is smooth its perimeter is going to be circular, but the collider meshes surfaces are flat.

There are several solutions, make the collider with more rectangles = two trigs on the surface, or make radius of the virteces of the collider bigger. If one does the second, some parts will attach above the surface of the cylinder. A third solution is to use shade the surfaces flat visible mesh. On my space factort (Factor24 cylinder) I broke the cylinder up into eight side parts, then the change of angle per change in side is small, the number of rectangles per side is reduced and the collider mesh outer surface is easy to make.

The convex rule only applies to a collider, it does not apply to multiple colliders on part or concavities creating in crafts. So the convex rule looks problematic until you realize all the ways to get around it, and then its more of a nuisance in construction.

Link to comment
Share on other sites

The part attachment on larger cylinder allows for 2x 12 surface attachment planes oriented vertically. If you use a 12 side collider then some parts may attach below the surface of larger cylinders. This is not a problem on smaller cylinders because the lowest high on the highest cylinder is higher than 1-cosine of the radius. But on the larger cylinders parts like RCS thrusters and strut connectors can disappear below the surface. If your visible surface of your cylinder is smooth its perimeter is going to be circular, but the collider meshes surfaces are flat.

There are several solutions, make the collider with more rectangles = two trigs on the surface, or make radius of the virteces of the collider bigger. If one does the second, some parts will attach above the surface of the cylinder. A third solution is to use shade the surfaces flat visible mesh. On my space factort (Factor24 cylinder) I broke the cylinder up into eight side parts, then the change of angle per change in side is small, the number of rectangles per side is reduced and the collider mesh outer surface is easy to make.

The convex rule only applies to a collider, it does not apply to multiple colliders on part or concavities creating in crafts. So the convex rule looks problematic until you realize all the ways to get around it, and then its more of a nuisance in construction.

Ok, I think I'll just go back to php programming. Whatever the hell that is you just described sounds way more complex than it should be.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...