Example #1
0
        private void _RenderLines_ICO(ref SSRenderConfig renderConfig)
        {
            // mode setup
            SSShaderProgram.DeactivateAll();             // disable GLSL
            GL.Disable(EnableCap.CullFace);
            GL.Disable(EnableCap.Texture2D);
            GL.Disable(EnableCap.Blend);
            GL.Disable(EnableCap.Lighting);

            if (icoSphereVertices == null)
            {
                var icoSphereCreator  = new IcoSphereCreator();
                var icoSphereGeometry = icoSphereCreator.Create(3);
                icoSphereVertices = icoSphereGeometry.Positions.ToArray();
                icoSphereFaces    = icoSphereGeometry.Faces.ToArray();
            }

            GL.Begin(PrimitiveType.Lines);
            GL.LineWidth(1.0f);
            GL.Color3(1.0f, 1.0f, 1.0f);

            foreach (var face in icoSphereFaces)
            {
                var v1 = icoSphereVertices[face.v1];
                var v2 = icoSphereVertices[face.v2];
                var v3 = icoSphereVertices[face.v3];

                GL.Vertex3(v1);  GL.Vertex3(v2);
                GL.Vertex3(v2);  GL.Vertex3(v3);
                GL.Vertex3(v1);  GL.Vertex3(v3);
            }
            GL.End();
        }
        static SSMeshBoundingSphere()
        {
            var icoSphereCreator  = new IcoSphereCreator();
            var icoSphereGeometry = icoSphereCreator.Create(3);

            icoSphereVertices = icoSphereGeometry.Positions.ToArray();
            icoSphereFaces    = icoSphereGeometry.Faces.ToArray();
        }
Example #3
0
    void Start()
    {
        this._starfield = GetComponent <Starfield>();
        if (this._material == null)
        {
            _material = GetComponent <Renderer>().sharedMaterial;
        }

        MeshFilter mf = GetComponent <MeshFilter>();

        mf.sharedMesh = IcoSphereCreator.Create(numberOfSides, 1);
    }
Example #4
0
    private void OnWizardCreate()
    {
        Mesh mesh = IcoSphereCreator.Create(level, radius);

        string path = EditorUtility.SaveFilePanelInProject("Save Ico Sphere", "IcoSphere", "asset", "Specify where to save the mesh.");

        if (path.Length > 0)
        {
            MeshUtility.Optimize(mesh);
            AssetDatabase.CreateAsset(mesh, path);
            Selection.activeObject = mesh;
        }
    }
Example #5
0
        public IEnumerator BuildMesh()
        {
            var timer = new Timer("build-mesh");

            Mesh mesh = null;

            timer.PrintTime(() => mesh = IcoSphereCreator.Create(7, .5f), "Create mesh");

            var wrapper = new GameObject().AddComponent <MeshWrapperBehaviour>();

            timer.PrintTime(() => sculptMesh = new SculptMesh(wrapper, mesh), "Parse mesh");

            timer.PrintTotalTime();
            timer.SaveCsv();

            Assert.AreEqual(163842, mesh.vertices.Length);

            yield return(null);
        }
        private void _Create(int divisions)
        {
            var icoSphereCreator = new IcoSphereCreator();

            geom = icoSphereCreator.Create(divisions);
            var positions = geom.Positions.ToArray();

            var vertexSoup = new Util3d.VertexSoup <SSVertex_PosNormTexDiff>();
            var indexList  = new List <UInt16>();

            // we have to process each face in the IcoSphere, so we can
            // properly "wrap" the texture-coordinates that fall across the left/right border
            foreach (TriangleIndices face in geom.Faces)
            {
                var vp1 = positions[face.v1];
                var vp2 = positions[face.v2];
                var vp3 = positions[face.v3];

                var normal1 = vp1.Normalized();
                var normal2 = vp2.Normalized();
                var normal3 = vp3.Normalized();

                float s1, s2, s3, t1, t2, t3;

                _computeEquirectangularUVForSpherePoint(normal1, out s1, out t1);
                _computeEquirectangularUVForSpherePoint(normal2, out s2, out t2);
                _computeEquirectangularUVForSpherePoint(normal3, out s3, out t3);

                // configure verticies

                var v1 = new SSVertex_PosNormTexDiff();
                v1.Position = vp1;
                v1.Normal   = normal1;
                v1.Tu       = s1;
                v1.Tv       = t1;

                var v2 = new SSVertex_PosNormTexDiff();
                v2.Position = vp2;
                v2.Normal   = normal2;
                v2.Tu       = s2;
                v2.Tv       = t2;

                var v3 = new SSVertex_PosNormTexDiff();
                v3.Position = vp3;
                v3.Normal   = normal3;
                v3.Tu       = s3;
                v3.Tv       = t3;

                // if a triangle spans the left/right seam where U transitions from 1 to -1
                bool v1_left = vp1.X < 0.0f;
                bool v2_left = vp2.X < 0.0f;
                bool v3_left = vp3.X < 0.0f;
                if (vp1.Z < 0.0f && vp2.Z < 0.0f && vp3.Z < 0.0f &&
                    ((v2_left != v1_left) || (v3_left != v1_left)))
                {
                    // we need to "wrap" texture coordinates
                    if (v1.Tu < 0.5f)
                    {
                        v1.Tu += 1.0f;
                    }
                    if (v2.Tu < 0.5f)
                    {
                        v2.Tu += 1.0f;
                    }
                    if (v3.Tu < 0.5f)
                    {
                        v3.Tu += 1.0f;
                    }
                }

                // add configured verticies to mesh..

                UInt16 idx1 = vertexSoup.digestVertex(ref v1);
                UInt16 idx2 = vertexSoup.digestVertex(ref v2);
                UInt16 idx3 = vertexSoup.digestVertex(ref v3);

                indexList.Add(idx1);
                indexList.Add(idx2);
                indexList.Add(idx3);
            }

            UpdateVertices(vertexSoup.verticies.ToArray());
            UpdateIndices(indexList.ToArray());
        }
Example #7
0
        static void Main(string[] args)
        {
            IcoSphereCreator dome = new IcoSphereCreator();

            OBJFileParser g = dome.Create(1);
        }