Exemplo n.º 1
0
        SyncObject BuildObject(SyncMesh mesh, SyncMaterial material)
        {
            // Create a parent object
            var parentObject = new SyncObject(new SyncId("Parent id"), "Quad Object Parent")
            {
                Transform = SyncTransform.Identity
            };

            // Create a child object with geometry
            var childObject = new SyncObject(new SyncId("Child id"), "Quad Object Child")
            {
                MeshId      = mesh.Id,
                MaterialIds = new List <SyncId> {
                    material.Id
                },
                Transform = SyncTransform.Identity
            };

            parentObject.Children.Add(childObject);

            // Fill the object with metadata
            parentObject.Metadata.Add("Key 1", new SyncParameter("Value", "Group", true));
            parentObject.Metadata.Add("Key 2", new SyncParameter("Other value", "Group", true));
            parentObject.Metadata.Add("名前", new SyncParameter("テストデータくん", "Group", true));

            // Uncomment the following line to add the "Merge" metadata key.
            // Because of the rules.json file, this would trigger the MergeChildObjects action.
            //parentObject.Metadata.Add("Merge", new SyncParameter("", "Rules", true));

            return(parentObject);
        }
Exemplo n.º 2
0
        SyncMaterial BuildMaterial(SyncColor color)
        {
            // Create a basic colored material
            var material = new SyncMaterial(new SyncId("Material id"));

            material.AlbedoColor = color;
            return(material);
        }
Exemplo n.º 3
0
 static void SetReferencedSyncModelPath(SyncMaterial material, SyncManifest manifest)
 {
     SetReferencedSyncModelPath(material.AlbedoMap, manifest);
     SetReferencedSyncModelPath(material.AlphaMap, manifest);
     SetReferencedSyncModelPath(material.NormalMap, manifest);
     SetReferencedSyncModelPath(material.CutoutMap, manifest);
     SetReferencedSyncModelPath(material.EmissionMap, manifest);
     SetReferencedSyncModelPath(material.GlossinessMap, manifest);
     SetReferencedSyncModelPath(material.MetallicMap, manifest);
 }
        public Shader GetShader(SyncMaterial syncMaterial)
        {
            var transparent = StandardShaderHelper.IsTransparent(syncMaterial);

            if (syncMaterial.IsDoubleSided)
            {
                return(transparent ? m_URPDoubleTransparentShader : m_URPDoubleOpaqueShader);
            }

            return(transparent ? m_URPTransparentShader : m_URPOpaqueShader);
        }
Exemplo n.º 5
0
        protected void ExtractBasicMaterialInfo(SyncMaterial syncMaterial, out bool transparent, out bool emission, out Color color)
        {
            transparent = StandardShaderHelper.IsTransparent(syncMaterial);
            emission    = syncMaterial.Emission != SyncColor.Black || syncMaterial.EmissionMap.TextureId != SyncId.None;

            var tint = ImportersUtils.GetUnityColor(syncMaterial.Tint, false);

            color = tint * ImportersUtils.GetUnityColor(syncMaterial.AlbedoColor, false);

            if (transparent)
            {
                color.a = syncMaterial.Alpha;
            }
        }
Exemplo n.º 6
0
        public List <SyncMaterial> BuildMaterialAry()
        {
            List <SyncMaterial> materialAry = new List <SyncMaterial>();

            // Create a basic colored material
            var    material = new SyncMaterial(new SyncId("Material id"));
            Random random   = new Random();

            material.AlbedoColor = SyncColor.From256(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
            //mtl.MaterialList[0].;

            materialAry.Add(material);

            return(materialAry);
        }
        void DownloadTextures(string sourceId, SyncMaterial syncMaterial, ref List <Task <AssetEntry <ISyncModel> > > tasks, CancellationToken token)
        {
            var textureId = syncMaterial.AlbedoMap.TextureId;

            if (textureId != SyncId.None)
            {
                tasks.Add(DownloadSyncModel <SyncTexture>(sourceId, textureId, token));
            }

            textureId = syncMaterial.NormalMap.TextureId;
            if (textureId != SyncId.None)
            {
                tasks.Add(DownloadSyncModel <SyncTexture>(sourceId, textureId, token));
            }

            textureId = syncMaterial.AlphaMap.TextureId;
            if (textureId != SyncId.None)
            {
                tasks.Add(DownloadSyncModel <SyncTexture>(sourceId, textureId, token));
            }

            textureId = syncMaterial.CutoutMap.TextureId;
            if (textureId != SyncId.None)
            {
                tasks.Add(DownloadSyncModel <SyncTexture>(sourceId, textureId, token));
            }

            textureId = syncMaterial.MetallicMap.TextureId;
            if (textureId != SyncId.None)
            {
                tasks.Add(DownloadSyncModel <SyncTexture>(sourceId, textureId, token));
            }

            textureId = syncMaterial.GlossinessMap.TextureId;
            if (textureId != SyncId.None)
            {
                tasks.Add(DownloadSyncModel <SyncTexture>(sourceId, textureId, token));
            }

            textureId = syncMaterial.EmissionMap.TextureId;
            if (textureId != SyncId.None)
            {
                tasks.Add(DownloadSyncModel <SyncTexture>(sourceId, textureId, token));
            }
        }
Exemplo n.º 8
0
        public SyncMaterial BuildMaterial(Obj curObj, PublisherTransaction transaction)
        {
            SyncMaterial material = null;

            ObjParser.Types.Material mat = FindMaterial(curObj.UseMtl);
            if (mat != null)
            {
                material = new SyncMaterial(new SyncId("MaterialId_" + mat.Name), mat.Name);
                Random random = new Random();
                //material.AlbedoColor = new SyncColor((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
                material.AlbedoColor = SyncColor.From256(200, 200, 200); // test

                Console.WriteLine("\t\tColor: "
                                  + material.AlbedoColor.R.ToString() + ", "
                                  + material.AlbedoColor.G.ToString() + ", "
                                  + material.AlbedoColor.B.ToString() + ", ");

                // テクスチャが見つかった場合
                if (mat.map_Kd.Length > 0)
                {
                    //material.AlbedoFade = 1.0f; // 0.5f; //2021.5.26
                    SyncTexture texture = BuildTexture(mat);
                    if (texture != null)
                    {
                        transaction.Send(texture);
                        Console.WriteLine("\tTexture Id: " + texture.Id);
                        Console.WriteLine("\tTexture Name: " + texture.Name);

                        SyncMap albedoMap = new SyncMap(texture.Id, new Vector2(), new Vector2(1, 1));
                        material.AlbedoMap = albedoMap;
                    }
                }
            }
            else
            {
                Console.WriteLine("Warning: No Material.");
                material             = new SyncMaterial(new SyncId("MaterialId_" + "DEFAULT"), "DEFAULT");
                material.AlbedoColor = SyncColor.From256(200, 0, 0);
            }
            return(material);
        }
Exemplo n.º 9
0
        public SyncObject BuildObject(SyncMesh mesh, SyncMaterial material, int idx)
        {
            // Create a parent object
            var parentObject = new SyncObject(new SyncId("ParentId_") + mesh.Id.ToString(), "ObjectParent_" + mesh.Name)
            {
                Transform = SyncTransform.Identity
            };

            // Create a child object with geometry
            var childObject = new SyncObject(new SyncId("ChildId_") + mesh.Id.ToString(), "ObjectChild_" + mesh.Name)
            {
                MeshId      = mesh.Id,
                MaterialIds = new List <SyncId> {
                    material.Id
                },
                Transform = SyncTransform.Identity
            };

            parentObject.Children.Add(childObject);

            // Fill the object with metadata
            parentObject.Metadata.Add("Key 1", new SyncParameter("Value", "Group", true));
            parentObject.Metadata.Add("Key 2", new SyncParameter("Other value", "Group", true));
            parentObject.Metadata.Add("メッシュID", new SyncParameter(mesh.Id.ToString(), "Group", true));
            parentObject.Metadata.Add("マテリアルID", new SyncParameter(material.Id.ToString(), "Group", true));

            parentObject.Metadata.Add("図形名", new SyncParameter(obj.MeshList[idx].Name, "Group", true));
            parentObject.Metadata.Add("マテリアル名", new SyncParameter(obj.MeshList[idx].UseMtl, "Group", true));
            parentObject.Metadata.Add("頂点数", new SyncParameter(obj.MeshList[idx].VertexList.Count.ToString(), "Group", true));

            parentObject.Metadata.Add("ポリゴン数", new SyncParameter(mesh.TriangleCount.ToString(), "Group", true));

            // Uncomment the following line to add the "Merge" metadata key.
            // Because of the rules.json file, this would trigger the MergeChildObjects action.
            //parentObject.Metadata.Add("Merge", new SyncParameter("", "Rules", true));

            return(parentObject);
        }
 public void SetMaterialProperties(SyncMaterial syncMaterial, Material material, ITextureCache textureCache)
 {
     StandardShaderHelper.ComputeMaterial(syncMaterial, material, textureCache);
 }
        public Shader GetShader(SyncMaterial syncMaterial)
        {
            var transparent = StandardShaderHelper.IsTransparent(syncMaterial);

            return(transparent ? m_URPTransparentShader : m_URPOpaqueShader);
        }
Exemplo n.º 12
0
 public Shader GetShader(SyncMaterial syncMaterial)
 {
     return(currentRenderPipeline.defaultShader);
 }
Exemplo n.º 13
0
 public static Shader GetShader(SyncMaterial syncMaterial)
 {
     return(currentConverter.GetShader(syncMaterial));
 }
Exemplo n.º 14
0
 public Shader GetShader(SyncMaterial syncMaterial)
 {
     return(StandardShaderHelper.GetShader(syncMaterial));
 }
Exemplo n.º 15
0
        void PerformExportTransaction()
        {
            // Report the progress of the export to 0%
            m_PublisherClient.ReportProgress(0);

            // Start a transaction ; note that the publisher client can only run one transaction at a time.
            PublisherTransaction transaction = m_PublisherClient.StartTransaction();

            // add sample plane //
            {
                // Build a SyncMesh and send it to the server
                var mesh = BuildMesh();
                transaction.Send(mesh);

                // Build a SyncMaterial and send it to the server
                var material = BuildMaterial(SyncColor.White);
                transaction.Send(material);

                // Report in between parsing progress
                m_PublisherClient.ReportProgress(50);

                // Build a SyncObject and send it to the server.
                var obj = BuildObject(mesh, material);
                transaction.Send(obj);

                // Build a SyncObjectInstance and send it to the server
                var instance = BuildObjectInstance(obj);
                transaction.Send(instance);
            }
            // add sample plane //

            // objファイルを開く //
            DataUtil meshData = new DataUtil();

            meshData.fileName = @"D:\model\house.obj";
            meshData.OpenObj(@"D:\model\house.obj");

            int num = meshData.obj.MeshList.Count;

            for (int i = 0; i < num; i++)
            {
                ObjParser.Obj currentObj = meshData.obj.MeshList[i];
                Console.WriteLine("Mesh: " + currentObj.Name);

                SyncMesh mesh = meshData.BuildMesh(currentObj);
                transaction.Send(mesh);
                Console.WriteLine("\tMesh Id: " + mesh.Id);
                Console.WriteLine("\tMesh Name: " + mesh.Name);

                SyncMaterial material = meshData.BuildMaterial(currentObj, transaction);
                transaction.Send(material);
                Console.WriteLine("\tMaterial Id: " + material.Id);
                Console.WriteLine("\tMaterial Name: " + material.Name);

                // Report in between parsing progress
                m_PublisherClient.ReportProgress(i * num / 100);

                // Build a SyncObject and send it to the server.
                var obj = meshData.BuildObject(mesh, material, i);
                transaction.Send(obj);
                Console.WriteLine("\tObject Id: " + obj.Id);
                Console.WriteLine("\tObject Name: " + obj.Name);

                // Build a SyncObjectInstance and send it to the server
                var instance = meshData.BuildObjectInstance(obj);
                transaction.Send(instance);
                Console.WriteLine("\tObject Instance Id: " + instance.Id);
                Console.WriteLine("\tObject Instance Name: " + instance.Name);
            }

#if false
            for (int i = 0; i < meshData.obj.MeshList.Count; i++)
            {
                List <SyncMesh> meshAry = meshData.BuildMesh();
                foreach (SyncMesh mesh in meshAry)
                {
                    transaction.Send(mesh);
                }

                List <SyncMaterial> materialAry = meshData.BuildMaterial();
                foreach (SyncMaterial material in materialAry)
                {
                    transaction.Send(material);
                }

                // Report in between parsing progress
                //m_PublisherClient.ReportProgress(50);

                // Build a SyncObject and send it to the server.
                foreach (SyncMesh mesh in meshAry)
                {
                    var obj = meshData.BuildObject(mesh);
                    transaction.Send(obj);

                    // Build a SyncObjectInstance and send it to the server
                    var instance = meshData.BuildObjectInstance(obj);
                    transaction.Send(instance);
                }
            }
#endif

            // Commit the transaction, then detach it from the publisher client.
            transaction.Commit();

            // Report the completion of the export
            m_PublisherClient.ReportProgress(100);
        }