Search Unity

Question New to Unity - What is the best way to develop "malleable" 3D objects?

Discussion in 'General Graphics' started by jordanpeper, May 10, 2023.

  1. jordanpeper

    jordanpeper

    Joined:
    May 8, 2023
    Posts:
    5
    I am new to Unity, but very familiar with coding and 3D modeling software. A project that I am working on is implementing multivariate data into 3D objects for use in a VR setting. The Unity primitive shapes are not ideal for this project, so I will need to use mesh that has parameters tied to C# variables. What is the best way to go about this? For instance, I may want to create a hollow cylinder whose wall thickness can be adjusted. I have seen that you can code mesh entirely in a script, but also import it from software like Blender. If you just point me in the right direction, I would be grateful.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,437
    easier if you can build those meshes in Blender, Houdini or other external tools.
    where parametric modeling tools are ready to use, but this wont work at runtime. (unless you have runtime .fbx importer)

    in unity you can create procedural meshes too,
    but might have to code those features yourself (unless can find suitable plugins)..

    some basic mesh generation example
    https://github.com/ogrew/Unity-ProceduralPrimitives

    there's also tools like
    https://assetstore.unity.com/packages/tools/modeling/archimatix-pro-59733


    Do you need to adjust those meshes at runtime or generate once in Editor?
     
    jordanpeper likes this.
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,638
    You could try using Blend Shapes in Unity (In Blender they're called "shape keys"). In your example with the cylinder thickness, you'd essentially model a cylinder with minimum thickness, set that as one shape key, then modify your model so it's maximum thickness and set that as a shape key. Then, in Unity you can set a value 0 to 1 to lerp between the two:

    https://docs.blender.org/manual/en/latest/animation/shape_keys/introduction.html
    https://docs.unity3d.com/Manual/BlendShapes.html

    I've not yet actually learned how to use these yet so I can't really provide more details. You might have to experiment to establish a good Blender->Unity workflow.
     
    jordanpeper likes this.