Dec
24
2014

Mobius strip Mesh Generator

mobius_strip_mesh
^Current results.. drawn with Debug.Drawline() for now..

Trying to create möbius strip mesh using a script..

Founded some formulas here: (and it even has .obj exporter, but rather do it inside unity..)
http://www.java2s.com/Open-Source/CSharp_Free_Code/3D/Download_Helix_3D_Toolkit.htm

 TODO:
– Build mesh (möbius strip)

** Well there is now better ready working unity version available here: https://bitbucket.org/alexzzzz/procedural-shapes-for-unity

So this one was not finished, here is the current source: (MobiusMaker.cs)


// Mobius strip formula from http://www.java2s.com/Open-Source/CSharp_Free_Code/3D/Download_Helix_3D_Toolkit.htm
// Not finished.. (Enable Gizmos in GameView to see lines)

using UnityEngine;
using System.Collections;

public class MobiusMaker : MonoBehaviour {

    void Start () {
    
        float pi = Mathf.PI;
        float x=0f,y=0f,z=0f;
        Vector3 pos = Vector3.zero;
        Vector3 oldPos = Vector3.zero;

        int n = 100;
        int m = 10;

        for (int i = 0; i < n; i++)
        {
            float u = 1.0f * i / (n - 1);
            
            for (int j = 0; j < m; j++)
            {
                float v = 1.0f * j / (m - 1);
                int ij = (i * m) + j;

                u *= 2f * pi;
                v = -1f + 2f * v;

                float c1 = Mathf.Sin(u);
                float c2 = Mathf.Cos(u);
                float c3 = Mathf.Sin(u/2);
                float c4 = Mathf.Cos(u/2);
                x = c2+v*c4*c2;
                y = c1+v*c4*c1;
                z = v*c3;
                
                pos.Set(x,y,z);
                
                Debug.DrawLine(pos+new Vector3(0,0.01f,0),pos,Color.green, 100);

            }
        }
    }

}

 


3 Comments + Add Comment

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Github Join Discord Twitch Instagram BlueSky

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.