GithubHelp home page GithubHelp logo

Comments (3)

keenanwoodall avatar keenanwoodall commented on May 27, 2024

LatticeDeformer exposes GetControlPoint and SetControlPoint helper methods as well as a flat float3[] ControlPoints array.

Here's an example script that generates game-objects for the control points.
Unity_uDmXkcS0ge

public class SetControlPoints : MonoBehaviour
{
    public LatticeDeformer deformer;

    private Transform[] controlPointAnchors;
    
    private void Start()
    {
        controlPointAnchors = deformer.ControlPoints.Select(p =>
        {
            var newAnchor = GameObject.CreatePrimitive(PrimitiveType.Cube);
            newAnchor.name = "Control Point";
            newAnchor.transform.SetParent(deformer.transform);
            newAnchor.transform.localPosition = p;
            newAnchor.transform.localScale = Vector3.one * 0.1f;
            return newAnchor.transform;
        }).ToArray();
    }

    private void Update()
    {
        for (var i = 0; i < controlPointAnchors.Length; i++)
        {
            var anchor = controlPointAnchors[i];
            if (!anchor.hasChanged)
                continue;
            anchor.hasChanged = false;
            deformer.ControlPoints[i] = deformer.transform.InverseTransformPoint(anchor.position);
        }
    }
}

from deform.

YuuZena avatar YuuZena commented on May 27, 2024

Thanks for that! It works very well. 👍

I was thinking if it would be possible to have a smoother Deformation. Currently everything is Linear, Point to Point.

image

Like a Bezier Curve from Point to Point so the Start and End are tangentially.

regards YuuZena

from deform.

keenanwoodall avatar keenanwoodall commented on May 27, 2024

I just pushed simple hermite smoothing to the develop branch 9b2d716.
Here's what simple smooth-step smoothing looks like
Unity_4VrleIyPgC
I think the proper solution would be to do some sort of tricubic interpolation like catmull-rom, but that would be nontrivial :P

from deform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.