Esempio n. 1
0
        public void PerformUpdate(List <SyncMarker> markers)
        {
            // Start a transaction and attach it to the publisher client.
            // Note that the publisher client can only be attached to one transaction at a time.
            PublisherTransaction transaction = m_PublisherClient.StartTransaction();

            for (int i = 0; i < markers.Count; i++)
            {
                //Send the update
                transaction.Send(markers[i]);
            }

            //Finish the transaction
            transaction.Commit();

            //The publisher is finished
            transaction.Dispose();
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }