Example #1
0
 public void ExportTerrain(TerrainData terrainData, PrefabContext prefabContext)
 {
     WriteTerrainMaterial(terrainData, prefabContext);
     WriteHeightMap(terrainData, prefabContext);
     WriteTerrainWeightsTexture(terrainData, prefabContext);
     ExportDetails(terrainData, prefabContext);
 }
Example #2
0
        private void ExportMetadata(string metadataFileName, AnimationClip clip, PrefabContext prefabContext)
        {
            using (var file = _engine.TryCreateXml(clip.GetKey(), metadataFileName, ExportUtils.GetLastWriteTimeUtc(clip)))
            {
                if (file == null)
                {
                    return;
                }

                file.WriteStartElement("animation");
                file.WriteWhitespace(Environment.NewLine);
                foreach (var clipEvent in clip.events)
                {
                    file.WriteWhitespace("\t");
                    file.WriteStartElement("trigger");
                    file.WriteAttributeString("time", BaseNodeExporter.Format(clipEvent.time));
                    file.WriteAttributeString("type", "String");
                    file.WriteAttributeString("value", clipEvent.functionName);
                    file.WriteEndElement();
                    file.WriteWhitespace(Environment.NewLine);
                }
                file.WriteEndElement();
                file.WriteWhitespace(Environment.NewLine);
            }
        }
Example #3
0
        private void ExportDetails(TerrainData terrainData, PrefabContext prefabContext)
        {
            return;

            for (var detailIndex = 0; detailIndex < terrainData.detailPrototypes.Length; detailIndex++)
            {
                var detailPrototype = terrainData.detailPrototypes[detailIndex];
                //detailPrototype.renderMode == DetailRenderMode.GrassBillboard

                //The Terrain system uses detail layer density maps. Each map is essentially a grayscale image where each pixel value denotes the number
                //of detail objects that will be procedurally placed terrain area. That corresponds to the pixel. Since several different detail types
                //may be used, the map is arranged into "layers" - the array indices of the layers are determined by the order of the detail types
                //defined in the Terrain inspector (ie, when the Paint Details tool is selected).
                var map = terrainData.GetDetailLayer(0, 0, terrainData.detailWidth, terrainData.detailHeight, detailIndex);
                for (var y = 0; y < terrainData.detailHeight; y++)
                {
                    for (var x = 0; x < terrainData.detailWidth; x++)
                    {
                        //The return value of each element [z,x] element is an int from 0-16, which // represent the number of details placed at that location. detailLayer[z,x]
                        //So, if you want to set the number of flowers at this location to 8, just set it to 8. It would be the same as painting flowers there with the strength setting set to .5 (8 = 1/2 of 16).
                        var value = map[x, y];
                    }
                }
            }
        }
Example #4
0
        public string EvaluateLODGroupName(LODGroup lodGroup, PrefabContext prefabContext)
        {
            if (lodGroup == null)
            {
                return(null);
            }
            var lods = lodGroup.GetLODs();

            if (lods.Length == 0)
            {
                return(null);
            }
            var firstMesh = lods[0].renderers.FirstOrDefault();

            if (firstMesh == null)
            {
                return(null);
            }
            var folder = ExportUtils.ReplaceExtension(ExportUtils.GetRelPathFromAsset(_engine.Options.Subfolder, firstMesh), "");

            if (string.IsNullOrWhiteSpace(folder))
            {
                folder = prefabContext.TempFolder;
            }
            return(ExportUtils.Combine(folder, ExportUtils.SafeFileName(_engine.DecorateName(ExportUtils.GetName(firstMesh))) + ".With" + lods.Length.ToString(CultureInfo.InvariantCulture) + "Lods.mdl"));
        }
        protected bool WriteTexture(Texture texture, XmlWriter writer, string name, PrefabContext prefabContext)
        {
            Engine.ScheduleAssetExport(texture, prefabContext);
            var urhoAssetName = Engine.EvaluateTextrueName(texture);

            return(WriteTexture(urhoAssetName, writer, name, prefabContext));
        }
Example #6
0
 public string EvaluateAnimationName(AnimationClip clip, PrefabContext prefabContext)
 {
     if (clip == null)
     {
         return(null);
     }
     return(_animationExporter.EvaluateAnimationName(clip, prefabContext));
 }
Example #7
0
 public void ExportMesh(ProBuilderMesh proBuilderMesh, PrefabContext prefabContext)
 {
     if (!_engine.Options.ExportMeshes)
     {
         return;
     }
     ExportProBuilderMeshModel(proBuilderMesh, prefabContext);
 }
Example #8
0
        public string EvaluateAnimationControllerName(AnimatorController clip, PrefabContext prefabContext)
        {
            if (clip == null)
            {
                return(null);
            }
            var relPath = ExportUtils.GetRelPathFromAsset(_engine.Options.Subfolder, clip);

            return(ExportUtils.ReplaceExtension(relPath, ".json"));
        }
Example #9
0
        private void WriteHeightMap(TerrainData terrain, PrefabContext prefabContext)
        {
            var w       = terrain.heightmapResolution;
            var h       = terrain.heightmapResolution;
            var max     = float.MinValue;
            var min     = float.MaxValue;
            var heights = terrain.GetHeights(0, 0, w, h);

            foreach (var height in heights)
            {
                if (height > max)
                {
                    max = height;
                }
                if (height < min)
                {
                    min = height;
                }
            }

            if (max < min)
            {
                max = 1;
                min = 0;
            }
            else if (max == min)
            {
                max = min + 0.1f;
            }

            using (var imageFile = _engine.TryCreate(terrain.GetKey(), EvaluateHeightMap(terrain), DateTime.MaxValue))
            {
                if (imageFile != null)
                {
                    using (var binaryWriter = new BinaryWriter(imageFile))
                    {
                        WriteTgaHeader(binaryWriter, 32, w, h);
                        for (var y = h - 1; y >= 0; --y)
                        {
                            for (var x = 0; x < w; ++x)
                            {
                                var height = (heights[h - y - 1, x] - min) / (max - min) * 255.0f;
                                var msb    = (byte)height;
                                var lsb    = (byte)((height - msb) * 255.0f);
                                binaryWriter.Write((byte)0);   //B - none
                                binaryWriter.Write(lsb);       //G - LSB
                                binaryWriter.Write(msb);       //R - MSB
                                binaryWriter.Write((byte)255); //A - none
                            }
                        }
                    }
                }
            }
        }
Example #10
0
        public string ScheduleLODGroup(LODGroup lodGroup, PrefabContext prefabContext)
        {
            if (lodGroup == null)
            {
                return(null);
            }
            var name = _meshExporter.EvaluateLODGroupName(lodGroup, prefabContext);

            _meshExporter.ExportLODGroup(lodGroup, prefabContext);
            return(name);
        }
Example #11
0
        public string ExportMesh(NavMeshTriangulation mesh, PrefabContext prefabContext)
        {
            var mdlFilePath = EvaluateMeshName(mesh, prefabContext);

            if (_engine.Options.ExportMeshes)
            {
                ExportMeshModel(new NavMeshSource(mesh), mdlFilePath,
                                SceneManager.GetActiveScene().GetRootGameObjects().FirstOrDefault().GetKey(), DateTime.MaxValue);
            }

            return(mdlFilePath);
        }
Example #12
0
        private void WriteTerrainWeightsTexture(TerrainData terrain, PrefabContext prefabContext)
        {
            var layers       = terrain.terrainLayers;
            var w            = terrain.alphamapWidth;
            var h            = terrain.alphamapHeight;
            var alphamaps    = terrain.GetAlphamaps(0, 0, w, h);
            var numAlphamaps = alphamaps.GetLength(2);

            var layerIndices = GetTerrainLayersByPopularity(alphamaps, layers.Length);

            //Urho3D doesn't support more than 3 textures
            if (numAlphamaps > _maxLayers)
            {
                numAlphamaps = _maxLayers;
            }
            float[] weights        = new float[numAlphamaps];
            byte[]  encodedWeights = new byte[numAlphamaps];
            using (var imageFile = _engine.TryCreate(terrain.GetKey(), EvaluateWeightsMap(terrain), DateTime.MaxValue))
            {
                if (imageFile == null)
                {
                    return;
                }

                using (var binaryWriter = new BinaryWriter(imageFile))
                {
                    var bytesPerPixell = 4;
                    WriteTgaHeader(binaryWriter, bytesPerPixell * 8, w, h);
                    for (var y = h - 1; y >= 0; --y)
                    {
                        for (var x = 0; x < w; ++x)
                        {
                            for (var i = 0; i < bytesPerPixell && i < layerIndices.Length; ++i)
                            {
                                var layer  = layerIndices[i];
                                var weight = (byte)(alphamaps[h - y - 1, x, layer] * 255.0f);
                                weights[i] = weight;
                            }

                            EncodeWeights(weights, encodedWeights);

                            var color = EncodeWeightsToColor(encodedWeights);

                            binaryWriter.Write(color.b); //B
                            binaryWriter.Write(color.g); //G
                            binaryWriter.Write(color.r); //R
                            binaryWriter.Write(color.a); //A
                        }
                    }
                }
            }
        }
Example #13
0
        public void ExportMesh(Mesh mesh, PrefabContext prefabContext)
        {
            if (!_engine.Options.ExportMeshes)
            {
                return;
            }
            var meshSource           = new MeshSource(mesh);
            var mdlFilePath          = EvaluateMeshName(mesh, prefabContext);
            var assetKey             = mesh.GetKey();
            var lastWriteDateTimeUtc = ExportUtils.GetLastWriteTimeUtc(mesh);

            ExportMeshModel(meshSource, mdlFilePath, assetKey, lastWriteDateTimeUtc);
        }
Example #14
0
        public string EvaluateMeshName(Mesh mesh, PrefabContext prefabContext)
        {
            if (mesh == null)
            {
                return(null);
            }
            var folder = ExportUtils.ReplaceExtension(ExportUtils.GetRelPathFromAsset(_engine.Options.Subfolder, mesh), "");

            if (string.IsNullOrWhiteSpace(folder))
            {
                folder = prefabContext.TempFolder;
            }
            return(ExportUtils.Combine(folder, ExportUtils.SafeFileName(_engine.DecorateName(ExportUtils.GetName(mesh))) + ".mdl"));
        }
Example #15
0
        public void ExportLODGroup(LODGroup mesh, PrefabContext prefabContext)
        {
            if (!_engine.Options.ExportMeshes)
            {
                return;
            }

            //TODO: Export lods.
            return;
            //var meshSource = new LODGroupSource(mesh);
            //var mdlFilePath = EvaluateLODGroupName(mesh, prefabContext);
            //var assetKey = mesh.GetKey();
            //var lastWriteDateTimeUtc = ExportUtils.GetLastWriteTimeUtc(mesh);
            //ExportMeshModel(meshSource, mdlFilePath, assetKey, lastWriteDateTimeUtc);
        }
Example #16
0
            public ChildMotionJson(ChildMotion childMotion, Urho3DEngine engine, PrefabContext prefabContext)
            {
                this.cycleOffset = childMotion.cycleOffset;
                var motion = childMotion.motion;

                if (motion is AnimationClip animationClip)
                {
                    this.animationClip = engine.EvaluateAnimationName(animationClip, prefabContext);
                    engine.ScheduleAssetExport(animationClip, prefabContext);
                }
                else if (motion is BlendTree blendTree)
                {
                    this.hasBlendTree = true;
                    this.blendTree    = new BlendTreeJson(blendTree, engine, prefabContext);
                }
            }
        public void ExportMaterial(Material material, PrefabContext prefabContext)
        {
            if (material == null)
            {
                return;
            }

            foreach (var materialExporter in _exporters)
            {
                if (materialExporter.CanExportMaterial(material))
                {
                    materialExporter.ExportMaterial(material, prefabContext);
                    return;
                }
            }

            _defaultExporter.ExportMaterial(material, prefabContext);
        }
Example #18
0
        public void ExportPrefab(AssetKey assetGuid, string assetPath, GameObject gameObject)
        {
            var relativePath = EvaluatePrefabName(assetPath);

            using (var writer = _engine.TryCreateXml(assetGuid, relativePath, ExportUtils.GetLastWriteTimeUtc(assetPath)))
            {
                if (writer == null)
                {
                    return;
                }
                var prefabContext = new PrefabContext()
                {
                    TempFolder = ExportUtils.ReplaceExtension(relativePath, "")
                };

                WriteObject(writer, "", gameObject, new HashSet <Renderer>(), true, prefabContext);
            }
        }
Example #19
0
 public BlendTreeJson(BlendTree blendTree, Urho3DEngine engine, PrefabContext prefabContext)
 {
     this.name                   = engine.DecorateName(blendTree.name);
     this.blendParameter         = blendTree.blendParameter;
     this.blendParameterY        = blendTree.blendParameterY;
     this.blendType              = blendTree.blendType;
     this.maxThreshold           = blendTree.maxThreshold;
     this.minThreshold           = blendTree.minThreshold;
     this.useAutomaticThresholds = blendTree.useAutomaticThresholds;
     this.apparentSpeed          = blendTree.apparentSpeed;
     this.averageAngularSpeed    = blendTree.averageAngularSpeed;
     this.averageDuration        = blendTree.averageDuration;
     this.averageSpeed           = blendTree.averageSpeed;
     this.isHumanMotion          = blendTree.isHumanMotion;
     this.isLooping              = blendTree.isLooping;
     this.legacy                 = blendTree.legacy;
     this.children               = blendTree.children.Select(_ => new ChildMotionJson(_, engine, prefabContext)).ToArray();
 }
        private void ExportTree(XmlWriter writer, string subPrefix, TreeInstance treeInstance,
                                TerrainData terrainData, bool enabled, PrefabContext prefabContext)
        {
            var treePrototype = terrainData.treePrototypes[treeInstance.prototypeIndex];

            StartNode(writer, subPrefix);
            var position = Vector3.Scale(terrainData.size, treeInstance.position);

            WriteAttribute(writer, subPrefix, "Position", position);
            var scale = new Vector3(treeInstance.widthScale, treeInstance.heightScale, treeInstance.widthScale);

            WriteAttribute(writer, subPrefix, "Scale", scale);
            var rotation = Quaternion.AngleAxis(treeInstance.rotation, Vector3.up);

            WriteAttribute(writer, subPrefix, "Rotation", rotation);

            WriteObject(writer, subPrefix + "\t", treePrototype.prefab, new HashSet <Renderer>(), enabled, prefabContext);
            EndElement(writer, subPrefix);
        }
Example #21
0
        private void WriteTerrainMaterial(TerrainData terrain, PrefabContext prefabContext)
        {
            using (var writer =
                       _engine.TryCreateXml(terrain.GetKey(), EvaluateMaterial(terrain),
                                            ExportUtils.GetLastWriteTimeUtc(terrain)))
            {
                if (writer == null)
                {
                    return;
                }

                var layers       = terrain.terrainLayers;
                var layerIndices = GetTerrainLayersByPopularity(terrain).Take(_maxLayers).ToArray();

                var material = new UrhoPBRMaterial();
                material.Technique = "Techniques/PBR/PBRTerrainBlend.xml";
                material.TextureUnits.Add(EvaluateWeightsMap(terrain));
                Vector2 detailTiling = new Vector2(1, 1);
                for (var layerIndex = 0; layerIndex < layerIndices.Length; ++layerIndex)
                {
                    var layer = layers[layerIndices[layerIndex]];
                    detailTiling = new Vector2(terrain.size.x / layer.tileSize.x, terrain.size.z / layer.tileSize.y);
                    if (layer.diffuseTexture != null)
                    {
                        _engine.ScheduleTexture(layer.diffuseTexture);
                        var urhoAssetName = _engine.EvaluateTextrueName(layer.diffuseTexture);
                        material.TextureUnits.Add(urhoAssetName);
                    }
                    else
                    {
                        material.TextureUnits.Add(null);
                    }
                }
                material.MatSpecColor = new Color(0.0f, 0.0f, 0.0f, 1.0f);
                material.Roughness    = 1;
                material.Metallic     = 0;
                material.ExtraParameters.Add("DetailTiling", detailTiling);
                material.PixelShaderDefines.Add("TERRAINLAYERS" + layerIndices.Length.ToString(CultureInfo.InvariantCulture));

                StandardMaterialExporter.WriteMaterial(writer, material, prefabContext);
            }
        }
        protected void ExportZone(XmlWriter writer, string subPrefix, Vector3 size, string cubemap,
                                  PrefabContext prefabContext, bool enabled)
        {
            StartComponent(writer, subPrefix, "Zone", enabled);

            var subSubPrefix = subPrefix + "\t";

            WriteAttribute(writer, subSubPrefix, "Ambient Color", RenderSettings.ambientLight.linear);
            WriteAttribute(writer, subSubPrefix, "Override Mode", false);
            if (RenderSettings.fog)
            {
                WriteAttribute(writer, subSubPrefix, "Fog Color", RenderSettings.fogColor.linear);
                WriteAttribute(writer, subSubPrefix, "Fog Start", RenderSettings.fogStartDistance);
                WriteAttribute(writer, subSubPrefix, "Fog End", RenderSettings.fogEndDistance);
                //switch (RenderSettings.fogMode)
                //{
                //    case FogMode.Linear:
                //        break;
                //    case FogMode.Exponential:
                //        break;
                //    case FogMode.ExponentialSquared:
                //        break;
                //    default:
                //        throw new ArgumentOutOfRangeException();
                //}
            }


            WriteAttribute(writer, subSubPrefix, "Bounding Box Min", -(size * 0.5f));
            WriteAttribute(writer, subSubPrefix, "Bounding Box Max", size * 0.5f);

            var volume = size.x * size.y * size.z;

            if (volume != 0)
            {
                var priority = int.MaxValue / (volume * 2);
                WriteAttribute(writer, subSubPrefix, "Priority", (int)priority);
            }

            WriteAttribute(writer, subSubPrefix, "Zone Texture", "TextureCube;" + cubemap);
            EndElement(writer, subPrefix);
        }
        public string EvaluateAnimationName(AnimationClip clip, PrefabContext prefabContext)
        {
            if (clip == null)
            {
                return(null);
            }
            var relPath = ExportUtils.GetRelPathFromAsset(_engine.Options.Subfolder, clip);

            if (Path.GetExtension(relPath).ToLowerInvariant() == ".anim")
            {
                return(ExportUtils.ReplaceExtension(relPath, ".ani"));
            }
            var folder = ExportUtils.ReplaceExtension(relPath, "");

            if (string.IsNullOrWhiteSpace(folder))
            {
                folder = prefabContext.TempFolder;
            }
            return(ExportUtils.Combine(folder, ExportUtils.SafeFileName(_engine.DecorateName(clip.name)) + ".ani"));
        }
Example #24
0
            public StateJson(AnimatorState state, Urho3DEngine engine, PrefabContext prefabContext)
            {
                this.name = engine.DecorateName(state.name);
                // this.speed = state.speed;
                // this.cycleOffset = state.cycleOffset;
                var motion = state.motion;

                if (motion is AnimationClip animationClip)
                {
                    // this.animationClip = engine.EvaluateAnimationName(animationClip, prefabContext);
                    engine.ScheduleAssetExport(animationClip, prefabContext);
                }
                else if (motion is BlendTree blendTree)
                {
                    // this.hasBlendTree = true;
                    // this.blendTree = new BlendTreeJson(blendTree, engine, prefabContext);
                }

                transitions = state.transitions.Select(_ => new TransitionJson(_, engine, prefabContext)).ToArray();
            }
Example #25
0
        public void ExportAnimation(AnimationClip clip, PrefabContext prefabContext)
        {
            if (!_engine.Options.ExportAnimations)
            {
                return;
            }

            var aniFilePath = EvaluateAnimationName(clip, prefabContext);

            ExportMetadata(ExportUtils.ReplaceExtension(aniFilePath, ".xml"), clip, prefabContext);

            using (var file = _engine.TryCreate(clip.GetKey(), aniFilePath,
                                                ExportUtils.GetLastWriteTimeUtc(clip)))
            {
                if (file == null)
                {
                    return;
                }
                using (var writer = new BinaryWriter(file))
                {
                    writer.Write(new byte[] { 0x55, 0x41, 0x4e, 0x49 });
                    WriteStringSZ(writer, _engine.DecorateName(clip.name));
                    writer.Write(clip.length);

                    // Legacy animation
                    if (clip.legacy)
                    {
                        WriteTracksAsIs(clip, writer);
                    }
                    else if (clip.isHumanMotion)
                    {
                        WriteHumanoidAnimation(clip, writer);
                    }
                    else
                    {
                        WriteGenericAnimation(clip, writer);
                    }
                }
            }
        }
Example #26
0
        public string EvaluateMeshName(ProBuilderMesh mesh, PrefabContext prefabContext)
        {
            if (mesh == null)
            {
                return(null);
            }
            if (_dynamicMeshNames.TryGetValue(mesh, out var name))
            {
                return(name);
            }

            var assetUrhoAssetName = ExportUtils.GetRelPathFromAsset(_engine.Options.Subfolder, mesh);

            if (string.IsNullOrWhiteSpace(assetUrhoAssetName))
            {
                name = ExportUtils.Combine(prefabContext.TempFolder, ExportUtils.SafeFileName(_engine.DecorateName(ExportUtils.GetName(mesh))) + "." + _dynamicMeshNames.Count + ".mdl");
                _dynamicMeshNames.Add(mesh, name);
                return(name);
            }

            return(ExportUtils.ReplaceExtension(assetUrhoAssetName, "") + "/" +
                   ExportUtils.SafeFileName(_engine.DecorateName(mesh.name)) + ".mdl");
        }
Example #27
0
        public void ExportMesh(GameObject go, PrefabContext prefabContext)
        {
            if (!_engine.Options.ExportMeshes)
            {
                return;
            }
            var proBuilderMesh      = go.GetComponent <ProBuilderMesh>();
            var skinnedMeshRenderer = go.GetComponent <SkinnedMeshRenderer>();
            var meshFilter          = go.GetComponent <MeshFilter>();

            if (proBuilderMesh != null)
            {
                ExportProBuilderMeshModel(proBuilderMesh, prefabContext);
            }
            else
            {
                Mesh mesh = null;
                if (skinnedMeshRenderer != null)
                {
                    mesh = skinnedMeshRenderer.sharedMesh;
                }
                else if (meshFilter != null)
                {
                    mesh = meshFilter.sharedMesh;
                }
                var meshSource = new MeshSource(mesh, skinnedMeshRenderer);
                ExportMeshModel(meshSource, EvaluateMeshName(mesh, prefabContext), mesh.GetKey(),
                                ExportUtils.GetLastWriteTimeUtc(mesh));
            }


            for (var i = 0; i < go.transform.childCount; ++i)
            {
                ExportMesh(go.transform.GetChild(i).gameObject, prefabContext);
            }
        }
        public override void ExportMaterial(Material material, PrefabContext prefabContext)
        {
            var urhoPath = EvaluateMaterialName(material);

            using (var writer =
                       Engine.TryCreateXml(material.GetKey(), urhoPath, ExportUtils.GetLastWriteTimeUtc(material)))
            {
                if (writer == null)
                {
                    return;
                }

                var arguments    = SetupSpecularGlossinessPBR(material);
                var urhoMaterial = FromSpecularGlossiness(arguments);
                WriteMaterial(writer, urhoMaterial, prefabContext);

                //Engine.ScheduleTexture(arguments.Bump, new TextureReference(TextureSemantic.Bump));

                Engine.SchedulePBRTextures(arguments, urhoMaterial);

                Engine.ScheduleTexture(arguments.Emission);
                //Engine.ScheduleTexture(arguments.Occlusion, new TextureReference(TextureSemantic.Occlusion));
            }
        }
Example #29
0
        public override void ExportMaterial(Material material, PrefabContext prefabContext)
        {
            var urhoPath = EvaluateMaterialName(material);

            using (var writer =
                       Engine.TryCreateXml(material.GetKey(), urhoPath, ExportUtils.GetLastWriteTimeUtc(material)))
            {
                if (writer == null)
                {
                    return;
                }
                var arguments = SetupLegacy(material);
                var flags     = new LegacyTechniqueFlags();
                flags.hasAlpha    = arguments.Transparent;
                flags.hasDiffuse  = arguments.Diffuse != null;
                flags.hasEmissive = arguments.Emission != null;
                flags.hasNormal   = arguments.Bump != null;
                flags.hasSpecular = arguments.Specular != null;
                writer.WriteStartElement("material");
                writer.WriteWhitespace(Environment.NewLine);
                {
                    var bestTechnique         = Techniques[0];
                    var bestTechniqueDistance = bestTechnique.Material - flags;
                    foreach (var technique in Techniques)
                    {
                        if (technique.Material.Fits(flags))
                        {
                            var d = technique.Material - flags;
                            if (d < bestTechniqueDistance)
                            {
                                bestTechnique         = technique;
                                bestTechniqueDistance = d;
                            }
                        }
                    }

                    WriteTechnique(writer, "Techniques/" + bestTechnique.Name);
                }
                if (arguments.Diffuse != null)
                {
                    WriteTexture(arguments.Diffuse, writer, "diffuse", prefabContext);
                }
                if (arguments.Specular != null)
                {
                    WriteTexture(arguments.Specular, writer, "specular", prefabContext);
                }
                if (arguments.Bump != null)
                {
                    WriteTexture(arguments.Bump, writer, "normal", prefabContext);
                }
                if (arguments.Emission != null)
                {
                    WriteTexture(arguments.Bump, writer, "emissive", prefabContext);
                }
                writer.WriteParameter("MatDiffColor", arguments.DiffColor);
                if (arguments.HasEmission)
                {
                    writer.WriteParameter("MatEmissiveColor", BaseNodeExporter.FormatRGB(arguments.EmissiveColor));
                }
                WriteCommonParameters(writer, arguments);

                writer.WriteEndElement();
            }
        }
Example #30
0
 protected override IEnumerable <ProgressBarReport> ExportDynamicAsset(Object asset, PrefabContext prefabContext)
 {
     if (asset is ProBuilderMesh proBuilderMesh)
     {
         _meshExporter.ExportMesh(proBuilderMesh, prefabContext);
         yield break;
     }
     if (asset is Mesh mesh)
     {
         _meshExporter.ExportMesh(mesh, prefabContext);
         yield break;
     }
     if (asset is LODGroup lodGroup)
     {
         _meshExporter.ExportLODGroup(lodGroup, prefabContext);
         yield break;
     }
 }