Skip to content

More Metal Like Deforms on Meshes #36

@razzraziel

Description

@razzraziel

This is a really great project and i personally thank all who contributed.

What really improves this project is that having more metal like deformations. Like in Truss Physics:
https://www.youtube.com/watch?v=fNfChjsYLXc

I'm working on this project for my more damage based game. I'm planning to have not only crashes, also other flying objects' impacts.

Deformation takes a lot of CPU power (have 200ish mesh colliders & no collider deform) and deformation itself can be improved with more realistic way. Instead of checking all the vertices, can we handle vertices as groups with their neighbour vertices and bend object itself with predefined specific points. Displacement parts is just avoiding this realism so i put that off topic.

For example, instead of making deforming the hood with impact, we can bend the whole hood with predefined vertex points. Here is a basic bending code:

       vertices = mesh.vertices;
       //We're bending around the x axis for example but it depends on force and direction.
        if (axis == BendAxis.X)
        {
            float meshWidth = mesh.bounds.size.z;
            for (var i = 0; i < vertices.Length; i++)
            {
                float formPos = Mathf.Lerp(meshWidth / 2, -meshWidth / 2, fromPosition);
                float zeroPos = vertices[i].z + formPos;
                float rotateValue = (-rotate / 2) * (zeroPos / meshWidth);

                zeroPos -= 2 * vertices[i].x * Mathf.Cos((90 - rotateValue) * Mathf.Deg2Rad);

                vertices[i].x += zeroPos * Mathf.Sin(rotateValue * Mathf.Deg2Rad);
                vertices[i].z = zeroPos * Mathf.Cos(rotateValue * Mathf.Deg2Rad) - formPos;
            }
        }
        mesh.vertices = vertices;
        mesh.RecalculateBounds();

So maybe we can improve this and integrate with predefined point inputs per object for more pleasing damage physics with metal feel. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions