Exemplo n.º 1
0
        protected override async Task <ResourceInfo> CreateResourceInfoFromResourceOverride(RName resourceName)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var retValue = new UVAnimResourceInfo();

            retValue.ResourceName = ResourceName;
            retValue.ResourceType = EngineNS.Editor.Editor_RNameTypeAttribute.UVAnim;
            return(retValue);
        }
Exemplo n.º 2
0
        public async Task <ResourceInfo> CreateEmptyResource(string absFolder, string rootFolder, IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new UVAnimResourceInfo();
            var data   = createData as ResourceCreateData;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(absFolder + "/" + data.ResourceName, rootFolder);

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

            var uvAnim = EngineNS.CEngine.Instance.UVAnimManager.CreateUVAnim(data.TextureRName, data.MaterialInstanceRName);

            // 默认有一帧
            uvAnim.Frames.Add(new EngineNS.UISystem.UVFrame()
            {
                ParentAnim = uvAnim,
            });
            uvAnim.Save2Xnd(result.ResourceName);

            return(result);
        }
Exemplo n.º 3
0
        public async Task SetObjectToEdit(ResourceEditorContext context)
        {
            await Viewport.WaitInitComplated();

            mCurrentResInfo = context.ResInfo as UVAnimResourceInfo;

            var rc = EngineNS.CEngine.Instance.RenderContext;

            mUVAnim = await EngineNS.CEngine.Instance.UVAnimManager.GetUVAnimAsync(rc, mCurrentResInfo.ResourceName);

            mUVAnim.PropertyChanged += UVAnim_PropertyChanged;
            await ImagePanel.SetUVAnim(mUVAnim);

            PG_UVAnim.Instance = mUVAnim;

            ListBox_Frames.Items.Clear();
            for (int i = 0; i < mUVAnim.Frames.Count; i++)
            {
                ListBox_Frames.Items.Add(KeyFrameWord + i);

                mUVAnim.Frames[i].PropertyChanged += Frame_PropertyChanged;
            }
            if (ListBox_Frames.Items.Count > 0)
            {
                ListBox_Frames.SelectedIndex = 0;
            }
            else
            {
                ListBox_Frames.SelectedIndex = -1;
            }

            mImage2D = await EngineNS.Graphics.Mesh.CGfxImage2D.CreateImage2D(rc, mUVAnim.MaterialInstanceRName, 0, 0, 0, 1, 1);

            var texture = EngineNS.CEngine.Instance.TextureManager.GetShaderRView(rc, mUVAnim.TextureRName);

            mImage2D.SetTexture("texture", texture);
            mImage2D.RenderMatrix = EngineNS.Matrix.Scaling(Viewport.GetViewPortWidth(), Viewport.GetViewPortHeight(), 1);
            //var list = new EngineNS.Support.NativeList<EngineNS.Vector2>();
            //list.Add(new EngineNS.Vector2(0.5f, 0.5f));
            //list.Add(new EngineNS.Vector2(1, 0.5f));
            //list.Add(new EngineNS.Vector2(1, 1));
            //list.Add(new EngineNS.Vector2(0.5f, 1));
            //mImage2D.SetUV(list, rc, false);

            Viewport.RPolicy.OnDrawUI += (cmd, view) =>
            {
                var mtlmesh = mImage2D.Mesh.MtlMeshArray[0];
                var pass    = mImage2D.GetPass();
                pass.ViewPort = view.Viewport;
                if (pass.RenderPipeline == null)
                {
                    var rplDesc = new EngineNS.CRenderPipelineDesc();
                    pass.RenderPipeline = rc.CreateRenderPipeline(rplDesc);
                }
                pass.RenderPipeline.RasterizerState   = mtlmesh.MtlInst.CustomRasterizerState;
                pass.RenderPipeline.DepthStencilState = mtlmesh.MtlInst.CustomDepthStencilState;
                pass.RenderPipeline.BlendState        = mtlmesh.MtlInst.CustomBlendState;
                //pass.ShaderSamplerBinder = mtlmesh.GetSamplerBinder(rc, pass.Effect.ShaderProgram);

                if (pass.Effect.PreUse())
                {
                    pass.BindCBuffer(pass.Effect.ShaderProgram, pass.Effect.CacheData.CBID_View, view.ScreenViewCB);
                    pass.ShadingEnv.BindResources(mImage2D.Mesh, pass);
                    cmd.PushPass(pass);
                }
            };
        }