public async System.Threading.Tasks.Task <ResourceInfo> CreateEmptyResource(string Absfolder, string rootFolder, EditorCommon.Resources.IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var data = createData as MaterialInstanceResourceCreateData;

            var result = new MaterialInstanceResourceInfo();

            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(Absfolder.TrimEnd('/') + "/" + data.ResourceName, rootFolder) + EngineNS.CEngineDesc.MaterialInstanceExtension;

            result.ResourceName        = RName.GetRName(reName, data.RNameType);
            result.ParentMaterialRName = data.ParentMaterial;
            result.ReferenceRNameList.Add(data.ParentMaterial);
            var mtl = await EngineNS.CEngine.Instance.MaterialManager.GetMaterialAsync(EngineNS.CEngine.Instance.RenderContext, data.ParentMaterial);

            var mtlInst = EngineNS.CEngine.Instance.MaterialInstanceManager.NewMaterialInstance(
                EngineNS.CEngine.Instance.RenderContext,
                mtl, result.ResourceName);

            if (mtlInst == null)
            {
                EngineNS.Profiler.Log.WriteLine(EngineNS.Profiler.ELogTag.Error, "Editor", $"MaterialInstance create error");
            }

            foreach (var i in mtl.ParamList)
            {
                mtlInst.SetParam(i);
            }

            mtlInst.SaveMaterialInstance();

            return(result);
        }
Esempio n. 2
0
        public async System.Threading.Tasks.Task <ResourceInfo> CreateEmptyResource(string Absfolder, string rootFolder, EditorCommon.Resources.IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new MeshResourceInfo();

            var mcd = createData as MeshCreateData;

            if (EngineNS.CEngine.Instance.FileManager.GetFileExtension(mcd.ResourceName) != EngineNS.CEngineDesc.MeshExtension)
            {
                mcd.ResourceName = mcd.ResourceName + EngineNS.CEngineDesc.MeshExtension;
            }
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(Absfolder + "/" + mcd.ResourceName, rootFolder);

            result.ResourceName = RName.GetRName(reName, mcd.RNameType);
            var vmsInfo = await EditorCommon.Resources.ResourceInfoManager.Instance.CreateResourceInfoFromFile(mcd.GeomMesh.Address + ".rinfo", null) as MeshSourceResourceInfo;

            result.SkeletonAsset = vmsInfo.SkeletonAsset;
            RName meshPrimitives = mcd.GeomMesh;
            //var shadingEnv = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv(mcd.ShadingEnv);
            var mCurMesh = EngineNS.CEngine.Instance.MeshManager.NewMesh(
                EngineNS.CEngine.Instance.RenderContext,
                result.ResourceName, meshPrimitives /*, shadingEnv*/);
            var mtl = EngineNS.CEngine.Instance.MaterialInstanceManager.DefaultMaterialInstance;

            for (UInt32 i = 0; i < mCurMesh.MtlMeshArray.Length; i++)
            {
                await mCurMesh.SetMaterialInstanceAsync(EngineNS.CEngine.Instance.RenderContext, i, mtl, null);
            }
            mCurMesh.SaveMesh();

            return(result);
        }
        public async System.Threading.Tasks.Task <ResourceInfo> CreateEmptyResource(string Absfolder, string rootFolder, EditorCommon.Resources.IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new MaterialResourceInfo();

            var data   = createData as EditorCommon.Resources.ResourceCreateDataBase;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(Absfolder + "/" + data.ResourceName, rootFolder);

            reName += EngineNS.CEngineDesc.MaterialExtension;
            result.ResourceName = EngineNS.RName.GetRName(reName, data.RNameType);

            {
                // .var文件创建
                EngineNS.CEngine.Instance.FileManager.CreateFileAndFlush(result.ResourceName.Address + EngineNS.Graphics.CGfxMaterial.ShaderDefineExtension);

                // .code文件创建
                string codeContent = "void DoVSMaterial(in PS_INPUT input, inout MTL_OUTPUT mtl)\r\n{\r\n}\r\n";
                codeContent += "void DoPSMaterial(in PS_INPUT input, inout MTL_OUTPUT mtl)\r\n{\r\n}\r\n";
                codeContent += "#ifndef DO_VS_MATERIAL\r\n";
                codeContent += "#define DO_VS_MATERIAL DoVSMaterial\r\n";
                codeContent += "#endif\r\n";
                codeContent += "#ifndef DO_PS_MATERIAL\r\n";
                codeContent += "#define DO_PS_MATERIAL DoPSMaterial\r\n";
                codeContent += "#endif\r\n";


                EngineNS.CEngine.Instance.FileManager.WriteAllTextASCII(result.ResourceName.Address + EngineNS.Graphics.CGfxMaterial.ShaderIncludeExtension, codeContent);
            }

            var mat = EngineNS.CEngine.Instance.MaterialManager.NewMaterial(result.ResourceName);

            mat.SaveMaterial();

            return(result);
        }
        public async System.Threading.Tasks.Task <ResourceInfo> CreateEmptyResource(string Absfolder, string rootFolder, EditorCommon.Resources.IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new PhyMaterialResourceInfo();

            var data   = createData as PhyMtlCreateData;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(Absfolder + "/" + data.ResourceName, rootFolder);

            reName += EngineNS.CEngineDesc.PhysicsMaterial;
            result.ResourceName = EngineNS.RName.GetRName(reName, data.RNameType);

            var mtl = EngineNS.CEngine.Instance.PhyContext.CreateMaterial(data.StaticFriction, data.DynamicFriction, data.Restitution);

            mtl.Save2Xnd(result.ResourceName);

            return(result);
        }
Esempio n. 5
0
        public async System.Threading.Tasks.Task <ResourceInfo> CreateEmptyResource(string Absfolder, string rootFolder, EditorCommon.Resources.IResourceCreateData createData)
        {
            var result = new VertexCloudResourceInfo();

            var mcd    = createData as VertexCloudResourceInfoData;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(Absfolder + "/" + mcd.ResourceName, rootFolder) + CEngineDesc.VertexCloudExtension;

            result.ResourceName = RName.GetRName(reName, mcd.RNameType);

            var mesh = EngineNS.CEngine.Instance.MeshPrimitivesManager.GetMeshPrimitives(EngineNS.CEngine.Instance.RenderContext, mcd.GeomMesh);

            if (mesh == null)
            {
                return(null);
            }

            var density = 1.0f;

            if (mcd.Density == VertexCloudResourceInfoData.DensityType.Density2)
            {
                density = 1.5f;
            }
            else if (mcd.Density == VertexCloudResourceInfoData.DensityType.Density3)
            {
                density = 2f;
            }
            else if (mcd.Density == VertexCloudResourceInfoData.DensityType.Density4)
            {
                density = 3f;
            }

            var vcobj = await EngineNS.Graphics.Mesh.CGfxVertexCloud.CookFromMesh(EngineNS.CEngine.Instance.RenderContext, mesh, density);

            vcobj.SaveVertexCloud(result.ResourceName);

            return(result);
        }
Esempio n. 6
0
        public async System.Threading.Tasks.Task <ResourceInfo> CreateEmptyResource(string Absfolder, EditorCommon.Resources.IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new ShadingEnvResourceInfo();

            var mcd = createData as ShadingEnvCreateData;

            if (EngineNS.CEngine.Instance.FileManager.GetFileExtension(mcd.ResourceName) != EngineNS.CEngineDesc.ShadingEnvExtension)
            {
                mcd.ResourceName = mcd.ResourceName + EngineNS.CEngineDesc.ShadingEnvExtension;
            }

            var ipWin  = createData as InputWindow.InputWindow;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(Absfolder + "/" + mcd.ResourceName, EngineNS.CEngine.Instance.FileManager.Content);

            result.ResourceName = RName.GetRName(reName);
            var senv = EngineNS.CEngine.Instance.ShadingEnvManager.NewGfxShadingEnv(
                typeof(EngineNS.Graphics.CGfxShadingEnv),
                RName.GetRName(reName), mcd.Shader);

            senv.SaveShadingEnv();

            return(result);
        }