GithubHelp home page GithubHelp logo

unityfractal's Introduction

unityfractal

A fractal generator for Unity3D inspired by Benoit Mandelbrot's initiator-generator scheme as described in his The Fractal Geometry of Nature.

Usage

Move the contents of the Assets folder to the desired locations in your Unity project.

Basics

The most basic components are the Fractal and Generator. The Generator is essentially an abstract data type, but inherits MonoBehaviour so that you can easily organize various Generator in a scene (See the Example scene). A Generator describes how a generic line segment in a fractal will be divided. This is achieved by creating control points along the line with specific diplacements, then iteratively dividing these newly created line segments in the same way (but in their own local orientation) up to maxIteration.

Add control points along the line by adding elements to the Vector3 list generators. These control points are positioned a percentage - specified by the x parameter [0-1] - along the line (the length of which is specified later in the Fractal component), and displacements (as percentages of the line length) in the local up and right directions - specified by the y and z paramenters respectively.

Now, on a seperate GameObject with a Fractal component attached, specify the generator property to be your Generator object. Specify the length of the initiator line segment and set renderPath to true. The initiator line will have beginning vertex at transform.localPosition and terminating vertex at transform.localPosition + transform.forward*length.

Upon playing the scene, Fractal will report its approximate fractal dimension, and its vertex count, the positions of which are made available as a Vector3 array in the path property. If renderPath is true, a LineRenderer will draw the fractal by connecting each of the vertices.

Beyond

There are a few scripts included that make it easy to draw, view and capture complex, animated fractals. Check out the Example project for more details. These scripts are, in summary:

FreeFlyCamera - Attach to a camera script to fly around the scene. Bind whatever keys you like.

CameraCapture - Attach to a camera and press "K" while playing (or bind your own key) to render its view to images of arbitrary resolution. Can also capture a series of images seperated by burstInterval seconds for creating GIFS, etc. During a single run, filenames will increment. Between runs it will overwrite files that collide with the specified path.

Tracer - Attach to any GameObject and specify the fractal property to trace that fractal's path at the specified speed.

TraceReplicator - Create copies of Tracer and optionally randomize their starting position along the fractal.

Cloner - Create instances of a GameObject source by either rotating it around a pivot, translating it along the pivot or scaling it by the components of pivot.

Example

koch_curve

The above Koch Curve is generated with the following parameters:

koch_param

complex_curve

More complex geometric forms can be created with very subtle tweaks, the above curve is created with the parameters:

complex_param

unityfractal's People

Contributors

tylerpayne avatar

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.