Skip to content

This Unity project demonstrates how to slice 3D objects using C#. The project employs algorithms for handling mesh manipulation, enabling real-time slicing of 3D models within the Unity engine.

Notifications You must be signed in to change notification settings

Sahira100/Mesh_Slicer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity 3D Object Slicer

A Unity plugin that enables real-time mesh slicing of 3D objects. This tool allows you to dynamically cut 3D meshes along arbitrary planes while maintaining mesh integrity, UV mapping, and proper face generation.

Initial Object Slicing Process

Features

  • Real-time mesh slicing along any plane
  • Maintains UV mapping and texture coordinates
  • Generates proper mesh faces at cut surfaces
  • Supports normal interpolation for smooth transitions
  • Automatic triangulation of cut faces
  • Translation animation for sliced parts
  • Area calculation for slice validation
  • Local to world space conversion handling

How It Works

The slicer works by:

  1. Detecting intersection points between the slice plane and mesh triangles
  2. Splitting affected triangles and creating new vertices
  3. Generating new UV coordinates through interpolation
  4. Creating proper faces for the cut surface
  5. Maintaining mesh normals for correct lighting
  6. Separating the mesh into two distinct parts

Installation

  1. Clone this repository or download the latest release
  2. Import the package into your Unity project
  3. Attach the SliceMe script to any mesh you want to make sliceable
  4. Configure the slicing parameters in the inspector

Usage

// To make an object sliceable
[RequireComponent(typeof(MeshFilter))]
public class SliceMe : MonoBehaviour
{
    // Configure in inspector
    public float translaitonSpeed;
    public float translationDistance;
}

// To perform a slice
public void Slice(SlicerPlane slicePlane)
{
    // Create slice plane and execute cut
    SlicerPlane plane = new SlicerPlane();
    yourSliceableObject.Slice(plane);
}

Configuration

The SliceMe component exposes the following properties:

  • CreateslicePart: Toggle slice part creation
  • translaitonSpeed: Speed at which sliced parts move
  • translationDistance: Distance sliced parts travel

Requirements

  • Unity 2019.4 or higher
  • Mesh objects must have proper UV mapping
  • Objects must have MeshFilter component

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details

About

This Unity project demonstrates how to slice 3D objects using C#. The project employs algorithms for handling mesh manipulation, enabling real-time slicing of 3D models within the Unity engine.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published