Exemplo n.º 1
0
        public override void Import(string targetFolderFullPath)
        {
            targetFolderFullPath = System.IO.Path.Combine(targetFolderFullPath, Name);
            Directory.CreateDirectory(targetFolderFullPath);
            var reader = _fileFormat.CreateProactiveReader(new ReaderContext());
            var scene  = reader.Read(Open());

            scene = new EnsureUniqueIds().Apply(scene);
            if (Scale != 1)
            {
                scene = new Scale(Scale).Apply(scene);
            }
            if (FlipFaces)
            {
                scene = new FlipFaces().Apply(scene);
            }
            if (FlipNormals)
            {
                scene = new FlipNormals().Apply(scene);
            }
            var urhoModel = new Urho3DMdlFileFormat();

            foreach (var sceneGeometry in scene.Geometries)
            {
                using (var f = Create(System.IO.Path.Combine(targetFolderFullPath, sceneGeometry.Id)))
                {
                    var s = new Scene();
                    s.Geometries.Add(sceneGeometry);
                    s.Nodes.Add(new Node {
                        Meshes = { new MeshReference(sceneGeometry) }
                    });
                    urhoModel.Write(f, s);
                }
            }
        }
Exemplo n.º 2
0
    void UpdateMesh()
    {
        var mr = GetComponent <MeshRenderer>();

        if (mr == null)
        {
            mr = gameObject.AddComponent <MeshRenderer>();
        }

        var mf = GetComponent <MeshFilter>();

        if (mf == null)
        {
            mf = gameObject.AddComponent <MeshFilter>();
        }

        var m = mf.sharedMesh;

        if (m == null)
        {
            m             = new Mesh();
            mf.sharedMesh = m;
        }


        if (Mathf.Abs(R1) < RLense)
        {
            return;
        }


        //generate cylinder
        var cyl  = GenCylinder.Execute(new Geometry(), RLense, Thickness, tessR);
        var cap1 = GenSphericalCap.Execute(new Geometry(), RLense, R1, tessR, tessC);

        cap1 = VectorOffset.Execute(cap1, new Vector3(0, Thickness * 0.5f, 0));

        var cap2 = GenSphericalCap.Execute(new Geometry(), RLense, R2, tessR, tessC);

        cap2 = VectorOffset.Execute(cap2, new Vector3(0, -Thickness * 0.5f, 0));
        cap2 = FlipFaces.ExecuteStatic(cap2);

        AttachGeometry.Execute(new Geometry(), new [] { cyl, cap1, cap2 }).StoreToMesh(m);
    }
Exemplo n.º 3
0
    public static Geometry ExecuteStatic(Geometry geometry)
    {
        var processor = new FlipFaces();

        return(processor.Execute(geometry));
    }