Esempio n. 1
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 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. 3
0
        protected async System.Threading.Tasks.Task InitDebug()
        {
            await mPoseTrajectoryDebug.Init(RName.GetRName("TitanDemo/yellowtest.instmtl"), RName.GetRName("TitanDemo/Character/test_girl/material/yellowwireframe.instmtl"));

            mPoseTrajectoryDebug.Add2World(Host.Scene.World);
            mIsInitDebug = true;
        }
Esempio n. 4
0
        private List <RName> CreateFromFBX(RName name)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;
            var sa = new AssetImport.FbxImporter();

            var          assetName  = name;
            var          meshesList = new List <RName>();
            ImportOption importOption;

            importOption.SkeletonAssetName = null;
            sa.Import(assetName, RName.GetRName("Mesh"), importOption, (uint)(AssetImport.aiPostProcessSteps.aiProcess_DontSplitMeshByMaterial | AssetImport.aiPostProcessSteps.aiProcess_GenNormals));
            foreach (var meshPri in sa.MeshPrimitives)
            {
                var meshName          = RName.GetRName("Mesh/" + meshPri.Key + CEngineDesc.MeshExtension);
                var meshPrimitiveName = meshPri.Value.Name;
                // 用createMesh 不行
                //var mesh = CEngine.Instance.MeshManager.CreateMesh(rc, meshName, CEngine.Instance.ShadingEnvManager.DefaultShadingEnv);
                var mesh = CEngine.Instance.MeshManager.NewMesh(rc, meshName, meshPrimitiveName);

                mesh.Init(rc, meshName, meshPri.Value);
                var mtl = EngineNS.CEngine.Instance.MaterialInstanceManager.GetMaterialInstance(rc, RName.GetRName("Material/defaultmaterial.instmtl"));
                for (int i = 0; i < mesh.MtlMeshArray.Length; ++i)
                {
                    mesh.SetMaterial(rc, (uint)i, mtl);
                }

                mesh.SaveMesh();
                meshesList.Add(meshName);
            }
            return(meshesList);
        }
Esempio n. 5
0
        public virtual bool LoadDataSet(
            [Editor.Editor_RNameType(Editor.Editor_RNameTypeAttribute.Excel)]
            //[EngineNS.Editor.Editor_RNameMExcelType(typeof(T))]:期待以后C#能这么写
            RName name,
            bool reg2Manager)
        {
#if !PWindow
            if (LoadXnd(RName.GetRName(name.Name + ".dateset")))
            {
                return(true);
            }
#else
            bool result = false;
            LoadDataSetFromExcel(name, ref result);
            if (result)
            {
                if (reg2Manager)
                {
                    CEngine.Instance.GameInstance?.DataSetManager?.RegDataSet(typeof(T), this);
                }
                //Save2Xnd(RName.GetRName(name.Name + ".dateset"));
                return(true);
            }
            else
            {
                if (LoadXnd(RName.GetRName(name.Name + ".dateset")))
                {
                    return(true);
                }
            }
#endif
            return(false);
        }
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);
        }
Esempio n. 7
0
        public override async Task <bool> SetInitializer(CRenderContext rc, GActor host, GComponentInitializer v)
        {
            if (await base.SetInitializer(rc, host, v) == false)
            {
                return(false);
            }

            mMeshComponent = new GamePlay.Component.GMeshComponent();
            var meshCompInit = new GamePlay.Component.GMeshComponent.GMeshComponentInitializer();

            meshCompInit.SpecialName = "VisualMesh";
            meshCompInit.MeshName    = RName.GetRName("editor/icon/icon_3D/mesh/play_start.gms", RName.enRNameType.Game);
            await mMeshComponent.SetInitializer(rc, Host, meshCompInit);

            //var mat = host.Placement.WorldMatrix;
            //mMeshComponent.OnUpdateDrawMatrix(ref mat);

            Initializer = v as AgentGeomBoxComponentInitializer;
            if (Initializer != null)
            {
                AgentGridSize = Initializer.AgentGridSize;
                StartPos      = Initializer.StartPos;
            }
            else
            {
                Initializer = new AgentGeomBoxComponentInitializer();
            }

            return(true);
        }
Esempio n. 8
0
        public void InitFiles()
        {
#if PWindow
            if (EngineNS.IO.FileManager.UseCooked != null)
            {
                return;
            }

            var files = CEngine.Instance.FileManager.GetFiles(RName.GetRName("Shaders", RName.enRNameType.Engine).Address, "*.*", SearchOption.AllDirectories);
            if (files == null)
            {
                return;
            }
            foreach (var f in files)
            {
                bool error = false;
                var  i     = CEngine.Instance.FileManager.NormalizePath(f, out error);
                if (error)
                {
                    continue;
                }
                if (i.EndsWith(".shaderinc") ||
                    i.EndsWith(".cginc") ||
                    i.EndsWith(".shadingenv") ||
                    i.EndsWith(".compute"))
                {
                    var desc = new HLSLFileDesc();
                    desc.Directory = CEngine.Instance.FileManager.GetPathFromFullName(i);
                    desc.FileName  = CEngine.Instance.FileManager.GetPureFileFromFullName(i);
                    desc.HLSLCode  = System.IO.File.ReadAllText(i);
                    Hash64.CalcHash64(ref desc.HashCode, desc.HLSLCode);
                    FileDescDict.Add(desc.Directory + desc.FileName, desc);
                }
            }
            foreach (var i in FileDescDict)
            {
                GetDepends(i.Value);
            }

            foreach (var i in FileDescDict)
            {
                if (i.Key.EndsWith(".shadingenv") || i.Key.EndsWith(".compute"))
                {
                    var allDepends = new List <HLSLFileDesc>();
                    CollectDependTree(i.Value, allDepends);
                    allDepends.Sort((left, right) =>
                    {
                        return(left.FullName.CompareTo(right.FullName));
                    });
                    string AllCode = i.Value.HLSLCode;
                    foreach (var j in allDepends)
                    {
                        AllCode += j.HLSLCode;
                    }
                    Hash64.CalcHash64(ref i.Value.HashWithDepends, AllCode);
                }
            }
#endif
        }
Esempio n. 9
0
        MetaClass CreateMetaClass(System.Type type)
        {
            var cname = RttiHelper.GetTypeSaveString(type);

            var klass = new MetaClass();

            klass.MetaType = type;
            var csIdx    = cname.IndexOf('|');
            var fileName = cname;

            if (csIdx >= 0)
            {
                fileName = cname.Substring(csIdx + 1);
            }
            klass.ClassName = RName.GetRName(MetaDirectory.Name + "/" + fileName);

            MetaData curVer = new MetaData();

            curVer.BuildMetaData(type);

            Hash64 hash = klass.GetFolderHash();
            string dir  = klass.ClassName.GetDirectory() + hash.ToString();

            if (EngineNS.CEngine.Instance.FileManager.DirectoryExists(dir))
            {
                bool hasRedirection = false;
                klass.LoadXnd(out hasRedirection);
#if PWindow
                //if (hasRedirection)
                //    klass.Save2Xnd(false);
#endif
                MetaData data = klass.FindMetaData(curVer.MetaHash);
                if (data == null)
                {
                    klass.RegMetaData(curVer.MetaHash, curVer);
                    var xnd = IO.XndHolder.NewXNDHolder();
                    curVer.Save2Xnd(xnd.Node);
                    IO.XndHolder.SaveXND(dir + "/" + curVer.MetaHash + ".MetaData", xnd);
                }
            }
            else
            {
                CEngine.Instance.FileManager.CreateDirectory(dir);

                var sw = new System.IO.StreamWriter(dir + "/typename.txt", false);
                sw.WriteLine(cname);
                sw.Close();

                klass.RegMetaData(curVer.MetaHash, curVer);
                var xnd = IO.XndHolder.NewXNDHolder();
                curVer.Save2Xnd(xnd.Node);
                IO.XndHolder.SaveXND(dir + "/" + curVer.MetaHash + ".MetaData", xnd);
            }

            klass.CurrentVersion = curVer;
            Klasses.Add(cname, klass);

            return(klass);
        }
Esempio n. 10
0
 public void SetCenterData(GCenterData cd)
 {
     mCenterDataGetter = new Macross.MacrossGetter <GCenterData>(RName.GetRName(cd.GetType().FullName), (GCenterData)cd);
     if (CenterData != null)
     {
         CenterData.HostActor = this;
     }
 }
Esempio n. 11
0
        public async System.Threading.Tasks.Task SetMaterial()
        {
            await AwaitLoadDebugActor();

            await mDebugActor.GetComponent <GamePlay.Component.GMeshComponent>().SetMaterialInstance(
                CEngine.Instance.RenderContext, 0,
                RName.GetRName("editor/icon/icon_3D/material/physical_model.instmtl"), null);
        }
Esempio n. 12
0
 public void Init(RName shaderName, List <CShaderDefinitions.MacroDefine> defs, CGfxShadingEnv env)
 {
     mShaderName = RName.GetRName(shaderName.Name, RName.enRNameType.Engine);
     //mShaderName = shaderName;
     mEnvType      = env.GetType();
     mMacroDefines = new List <CShaderDefinitions.MacroDefine>();
     mMacroDefines.AddRange(defs);
     UpdateHash64();
 }
Esempio n. 13
0
        public async System.Threading.Tasks.Task <bool> LoadXnd(IO.XndNode node)
        {
            return(await CEngine.Instance.EventPoster.Post(() =>
            {
                unsafe
                {
                    var attr = node.FindAttrib("Desc");

                    if (attr != null)
                    {
                        attr.BeginRead();
                        string name;
                        attr.Read(out name);
                        this.MeshSource = RName.GetRName(name);
                        attr.EndRead();
                    }

                    attr = node.FindAttrib("Position");
                    if (attr == null)
                    {
                        return false;
                    }
                    attr.BeginRead();
                    int length;
                    attr.Read(out length);
                    if (length == 0)
                    {
                        return false;
                    }
                    Positions = new Vector3[length];
                    fixed(Vector3 *p = &Positions[0])
                    {
                        attr.Read((IntPtr)p, sizeof(Vector3) * Positions.Length);
                    }
                    attr.EndRead();

                    attr = node.FindAttrib("Data");
                    if (attr == null)
                    {
                        return false;
                    }
                    attr.BeginRead();
                    attr.Read(out length);
                    if (length == 0)
                    {
                        return false;
                    }
                    Datas = new Vector4[length];
                    fixed(Vector4 *p = &Datas[0])
                    {
                        attr.Read((IntPtr)p, sizeof(Vector4) * Datas.Length);
                    }
                    attr.EndRead();
                }
                return true;
            }, Thread.Async.EAsyncTarget.AsyncIO));
        }
Esempio n. 14
0
        public IResourceCreateData GetResourceCreateData(string absFolder)
        {
            var result = new MeshCreateData();

            result.ResourceName = EditorCommon.Program.GetValidName(absFolder, "GfxMesh", CEngineDesc.MeshExtension);
            result.GeomMesh     = RName.GetRName("Mesh/box.vms");
            result.ShadingEnv   = RName.GetRName("ShadingEnv/fsbase.senv");
            return(result);
        }
        public LogicAnimationState CreateLAStateWithAnimClip(string name, float duration, string animFilePath, string stateMachineName)
        {
            var laState = new LogicAnimationState(mLogicAnimationStateMachineDic[stateMachineName], name);

            laState.Duration  = duration;
            laState.Pose      = mFinalPose.Clone();
            laState.Animation = RName.GetRName(animFilePath);
            return(laState);
        }
Esempio n. 16
0
        public CGfxMeshPrimitives CreateMeshPrimitives(CRenderContext rc, UInt32 atom)
        {
            var mesh = new CGfxMeshPrimitives();

            if (false == mesh.Init(rc, RName.GetRName(null), atom))
            {
                return(null);
            }

            return(mesh);
        }
Esempio n. 17
0
        //public override void Tick(GPlacementComponent placement)
        //{
        //    base.Tick(placement);
        //}

        public override async Task <bool> SetInitializer(CRenderContext rc, GamePlay.IEntity host, IComponentContainer hostContainer, GComponentInitializer v)
        {
            var init = v as GMeshComponentInitializer;

            if (init == null)
            {
                return(false);
            }

            if (ParticleModifier != null)
            {
                if (ParticleModifier.ParticleSys.IsBillBoard && ParticleModifier.ParticleSys.BillBoardType != CGfxParticleSystem.BILLBOARDTYPE.BILLBOARD_DISABLE)
                {
                    init.MeshName = RName.GetRName("@createplane");
                }
                else
                {
                    init.MeshName = ParticleModifier.ParticleSys.UseMeshRName;
                }
            }


            //设置默认值
            if (init.MeshName == null)
            {
                init.MeshName = RName.GetRName("ParticleResource/models/sphere.gms");
            }

            if (false == await base.SetInitializer(rc, host, hostContainer, v))
            {
                return(false);
            }

            Host = host as GActor;
            if (ParticleModifier != null && ParticleModifier.ParticleSys.UseMaterialRName != null)
            {
                if (mSceneMesh != null && mSceneMesh.MtlMeshArray != null)
                {
                    //await SetMaterialInstance(rc, 0, ParticleModifier.ParticleSys.UseMaterialRName, null);
                    var mtl = await CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(rc, ParticleModifier.ParticleSys.UseMaterialRName);

                    base.SetMaterialInstance(rc, 0, mtl, null);
                }
            }

            if (ParticleModifier != null && this.SceneMesh != null)
            {
                this.SceneMesh.MdfQueue.AddModifier(ParticleModifier);
                this.AddDefaultColorBuff(rc, this.SceneMesh.MeshPrimitives);
            }
            return(true);
        }
Esempio n. 18
0
        public static async System.Threading.Tasks.Task <GraphLines> Init(Vector3 start)
        {
            var mGraph = new GraphLines();

            int slt = 0;

            switch (slt)
            {
            case 0:
            {
                var rect = new McLinesGen();
                rect.Interval   = 2.0f;
                rect.Segement   = 2.0f;
                rect.Start      = start;
                rect.NextTarget = start + Vector3.UnitX * 100;
                mGraph.LinesGen = rect;
            }
            break;

            case 1:
            {
                var rect = new McRectangleGen();
                rect.Interval   = 5.0f;
                rect.Segement   = 10.0f;
                rect.NextTarget = new Vector3(300, 300, 0);
                rect.SetRect(start, 300, 200);
                mGraph.LinesGen = rect;
            }
            break;

            case 2:
            {
                var rect = new McCircleGen();
                rect.Interval = 10.0f;
                rect.Segement = 20.0f;
                rect.SetCircle(start, 150, 30);
                mGraph.LinesGen = rect;
            }
            break;
            }

            var mtl = await CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(
                CEngine.Instance.RenderContext,
                //RName.GetRName("material/defaultmaterial.instmtl"));
                RName.GetRName("material/rotator.instmtl"));

            await mGraph.Init(mtl, 0.3f);

            mGraph.UpdateGeomMesh(CEngine.Instance.RenderContext);
            return(mGraph);
        }
Esempio n. 19
0
        public static RName GetRNameFromType(Type type, bool checkFileExist, RName.enRNameType rNameType = RName.enRNameType.Game)
        {
            var fullName = GetAppTypeString(type);
            var retVal   = RName.GetRName(fullName.Replace(".", "/") + EngineNS.CEngineDesc.MacrossExtension, rNameType);

            if (checkFileExist)
            {
                if (!EngineNS.CEngine.Instance.FileManager.DirectoryExists(retVal.Address))
                {
                    return(null);
                }
            }
            return(retVal);
        }
Esempio n. 20
0
        protected virtual bool InitWorld()
        {
            mWorld = new EngineNS.GamePlay.GWorld();

            if (false == mWorld.Init())
            {
                return(false);
            }

            var scene = new EngineNS.GamePlay.SceneGraph.GSceneGraph();

            mWorld.Scenes.Add(RName.GetRName("SnapshorCreator"), scene);
            return(true);
        }
Esempio n. 21
0
        public override async Task <bool> SetInitializer(CRenderContext rc, GamePlay.IEntity host, IComponentContainer hostContainer, GComponentInitializer v)
        {
            var init = v as GParticleComponentInitializer;

            if (init == null)
            {
                return(false);
            }

            mParticleModifier = new Particle.CGfxParticleModifier();
            var sys = mParticleModifier.ParticleSys;

            sys.Effector = CEngine.Instance.MacrossDataManager.NewObjectGetter <McParticleEffector>(init.MacrossName);

            if (sys.Effector != null)
            {
                await sys.Effector.Get(false).InitSystem(sys, host as GamePlay.Actor.GActor, this, init);
            }

            //default..
            if (init.MeshName == null)
            {
                init.MeshName = RName.GetRName("ParticleResource/models/sphere.gms");
            }

            if (false == await base.SetInitializer(rc, host, hostContainer, v))
            {
                return(false);
            }

            sys.HostActor = Host;

            if (sys.UseMaterialRName != null)
            {
                await SetMaterialInstance(rc, 0, sys.UseMaterialRName, null);
            }

            if (this.SceneMesh != null && this.SceneMesh.MdfQueue != null)
            {
                this.SceneMesh.MdfQueue.AddModifier(mParticleModifier);
            }

            //Box
            {
                BoundingBox.Merge(ref Host.LocalBoundingBox, ref sys.AABB.Box, out Host.LocalBoundingBox);
                OnUpdateDrawMatrix(ref Host.Placement.mDrawTransform);
            }
            return(true);
        }
        async System.Threading.Tasks.Task PreviewMeshChanged()
        {
            if (mPreviewSceneControl == null)
            {
                return;
            }
            if (mCurrentResourceInfo.PreViewMesh == "null" || string.IsNullOrEmpty(mCurrentResourceInfo.PreViewMesh))
            {
                return;
            }
            List <RName> rNameList = new List <RName>();

            rNameList.Add(RName.GetRName(mCurrentResourceInfo.PreViewMesh));
            await ChangePreviewMeshesActor(rNameList);
        }
Esempio n. 23
0
        protected virtual async System.Threading.Tasks.Task <bool> InitWorld(string name)
        {
            mWorld = new EngineNS.GamePlay.GWorld();

            if (false == mWorld.Init())
            {
                return(false);
            }

            mWorld.CheckVisibleParam.UsePVS = false;
            var scene = await EngineNS.GamePlay.SceneGraph.GSceneGraph.CreateSceneGraph(mWorld, typeof(EngineNS.GamePlay.SceneGraph.GSceneGraph), null);

            mWorld.AddScene(RName.GetRName(name), scene);
            return(true);
        }
Esempio n. 24
0
        private async Task Init_SYJ()
        {
            return;

            await AxisShower.InitEnviroment(256, 256, "AxisShower");

            var axisAct = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName(@"editor\basemesh\box.gms"));

            //axisAct.PreUse(true);//就这个地方用,别的地方别乱用,效率不好
            //AxisShower.Camera.MakeOrtho(2, 2, 0, 2);
            //AxisShower.Camera.LookAtLH(new Vector3(-100, 0, -10), Vector3.Zero, Vector3.UnitY);
            AxisShower.World.AddActor(axisAct);
            AxisShower.World.GetScene(RName.GetRName("AxisShower")).AddActor(axisAct);

            axisAct.Placement.Location = new Vector3(0, 0, 0);

            AxisShower.Start();

            var RHICtx = EngineNS.CEngine.Instance.RenderContext;
            var image  = await EngineNS.Graphics.Mesh.CGfxImage2D.CreateImage2D(RHICtx, RName.GetRName("Material/bozi.instmtl"), -50, -50, 0, 100, 100);

            var texture = AxisShower.OffScreenTexture;

            image.SetTexture("txDiffuse", texture);

            this.RenderPolicy.OnDrawUI += (cmd, view) =>
            {
                {
                    var tmp = Matrix.Transformation(Vector3.UnitXYZ,
                                                    Quaternion.Identity, Vector3.Zero);
                    tmp.M41            = 300;
                    tmp.M42            = 300;
                    image.RenderMatrix = tmp;
                    //image.RenderMatrix.M41 = 300;
                    //image.RenderMatrix.M42 = 300; //new Vector3(300, 200, 0)
                    // Matrix.RotationZ(CEngine.Instance.EngineTime * 0.0001f);

                    var pass = image.GetPass();

                    pass.ViewPort = view.Viewport;
                    pass.BindCBuffer(pass.Effect.ShaderProgram, pass.Effect.CacheData.CBID_View, view.ScreenViewCB);
                    pass.ShadingEnv.BindResources(image.Mesh, pass);
                    cmd.PushPass(pass);
                }
            };
        }
Esempio n. 25
0
        public bool InitSystem(MainWindow window)
        {
            window.MainCtrl.PG.Instance = this;
            EngineNS.ERHIType rhiType = EngineNS.ERHIType.RHT_D3D11;//RHT_OGL;//
            EngineNS.CIPlatform.Instance.IsEditor = true;

            var ok = EngineNS.CEngine.Instance.GfxInitEngine(rhiType, 0, window.MainCtrl.VP1.DrawHandle);

            if (ok == false)
            {
                return(false);
            }

            var rc = EngineNS.CEngine.Instance.RenderContext;

            var gameDesc = new EngineNS.Editor.CEditorInstanceDesc();

            gameDesc.SceneName = gameDesc.DefaultMapName;

            InitDefaultResource(gameDesc);

            var srv = CEngine.Instance.TextureManager.GetShaderRView(rc, RName.GetRName("Texture/noused.png"));

            ScopeTickRender.Enable = true;
            ScopeTickLogic.Enable  = true;
            ScopeTickSync.Enable   = true;

            window.MainCtrl.VP1.ViewPortName = "MainEditorView";

            if (true)
            {
                window.MainCtrl.VP1.OnWindowCreated = delegate(EditorCommon.ViewPort.ViewPortControl vp)
                {
                    if (EditorInited == true)
                    {
                        return;
                    }
                    EditorInited = true;
                    var editor = this.GameEditorInstance as CEditorInstance;
                    editor?.InitEditor(window, gameDesc);
                };
            }

            return(true);
        }
Esempio n. 26
0
        private EngineNS.Graphics.Mesh.Animation.CGfxAnimationSequence CreateAnimation(EngineNS.GamePlay.Actor.GActor actor, RName animationName)
        {
            var rc           = EngineNS.CEngine.Instance.RenderContext;
            var animationCom = new EngineNS.GamePlay.Component.GAnimationInstance(RName.GetRName("delisha.skt"));

            actor.AddComponent(animationCom);
            var animationSege = new EngineNS.Graphics.Mesh.Animation.CGfxAnimationSequence();

            animationSege.Init(EngineNS.CEngine.Instance.RenderContext, animationName);//RName.GetRName("Mesh/fouraxisanim" + CEngineDesc.AnimationSegementExtension)

            var meshComp = actor.GetComponent <EngineNS.GamePlay.Component.GMeshComponent>();
            //var pose = EngineNS.CEngine.Instance.SkeletonAssetManager.GetSkeleton(rc, RName.GetRName("delisha.skt")).BoneTab.Clone();
            var skinModifier = meshComp.SceneMesh.MdfQueue.FindModifier <EngineNS.Graphics.Mesh.CGfxSkinModifier>();

            skinModifier.AnimationPose  = animationCom.AnimationPose;
            animationSege.AnimationPose = animationCom.AnimationPose;
            animationCom.AnimationNode  = animationSege;
            return(animationSege);
        }
Esempio n. 27
0
        public void CreateAnimationInstanceMacross(EngineNS.GamePlay.Actor.GActor actor)
        {
            EngineNS.Macross.MacrossGetter <EngineNS.GamePlay.Component.GAnimationInstance> macrossGetter = new EngineNS.Macross.MacrossGetter <EngineNS.GamePlay.Component.GAnimationInstance>();
            macrossGetter.Name = RName.GetRName("Animation/amc_robot.macross");
            var animationCom = macrossGetter.Get();

            animationCom.Init();
            actor.AddComponent(animationCom);
            var meshComp = actor.GetComponent <EngineNS.GamePlay.Component.GMutiMeshComponent>();

            foreach (var subMesh in meshComp.Meshes)
            {
                var skinModifier = subMesh.Value.MdfQueue.FindModifier <EngineNS.Graphics.Mesh.CGfxSkinModifier>();
                if (animationCom.AnimationPose != null)
                {
                    skinModifier.AnimationPose = animationCom.AnimationPose;
                }
            }
        }
Esempio n. 28
0
        public async System.Threading.Tasks.Task CreateRenderInfos(GamePlay.GWorld world)
        {
            //EngineNS.Bricks.GraphDrawer.GraphLines
            AgentBoxs ab = AgentDatas[0];

            Agent.GeoBox[]        ap    = ab.AgentData.ToArray();
            GamePlay.Actor.GActor actor = new GamePlay.Actor.GActor();
            //创建包围盒的每个点
            for (int i = 0; i < ap.Length; i++)
            {
                EngineNS.Bricks.GraphDrawer.GraphLines graph = new EngineNS.Bricks.GraphDrawer.GraphLines();
                var  boxgen  = new EngineNS.Bricks.GraphDrawer.McBoxGen();
                bool allface = ap[i].FaceType == face;
                boxgen.Interval = allface ? 0.05f : 0.1f;
                boxgen.Segement = allface ? 1.0f : 0.2f;

                Vector4 outv4;
                Vector3.Transform(ref ap[i].Box.Maximum, ref ab.Mat, out outv4);
                ap[i].Box.Maximum = new Vector3(outv4.X, outv4.Y, outv4.Z);
                Vector3.Transform(ref ap[i].Box.Minimum, ref ab.Mat, out outv4);
                ap[i].Box.Minimum = new Vector3(outv4.X, outv4.Y, outv4.Z);
                boxgen.SetBoundBox(ap[i].Box);

                graph.LinesGen = boxgen;
                var mtl = await CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(
                    CEngine.Instance.RenderContext,
                    //蓝线就是六个面都通了
                    RName.GetRName(allface ? "editor/icon/icon_3D/material/physical_model.instmtl" : "editor/volume/mi_volume_octree.instmtl"));//rotator

                var init = await graph.Init(mtl, 0.0f);

                graph.GraphActor.Placement.Location = Vector3.Zero;
                graph.GraphActor.SpecialName        = ActorName;
                //world.AddActor(graph.GraphActor);
                //world.DefaultScene.AddActor(graph.GraphActor);
                actor.Children.Add(graph.GraphActor);
            }

            actor.SpecialName = "NavLineDebuger";
            world.AddActor(actor);
            world.DefaultScene.AddActor(actor);
        }
Esempio n. 29
0
        public static async System.Threading.Tasks.Task CheckRebuildShaders()
        {
            await Thread.AsyncDummyClass.DummyFunc();

            var GlobalSCSetting = IO.XmlHolder.CreateObjectFromXML(RName.GetRName("Cache/GlobalShaderCacheSetting.xml")) as GlobalShaderCacheSetting;

            if (GlobalSCSetting == null)
            {
                GlobalSCSetting = new GlobalShaderCacheSetting();
                IO.XmlHolder.SaveObjectToXML(GlobalSCSetting, RName.GetRName("Cache/GlobalShaderCacheSetting.xml"));
                return;
            }

            if (GlobalSCSetting.ClearShaderInfo == true)
            {
                CEngine.Instance.FileManager.DeleteFilesInDirectory(RName.GetRName("Cache/ShaderInfo/").Address, "*.xml", System.IO.SearchOption.AllDirectories);
                GlobalSCSetting.ClearShaderInfo = false;
                IO.XmlHolder.SaveObjectToXML(GlobalSCSetting, RName.GetRName("Cache/GlobalShaderCacheSetting.xml"));
            }

            var LocalSCSetting = IO.XmlHolder.CreateObjectFromXML(RName.GetRName("Cache/LocalShaderCacheSetting.xml")) as LocalShaderCacheSetting;

            if (LocalSCSetting == null)
            {
                LocalSCSetting = new LocalShaderCacheSetting();
                IO.XmlHolder.SaveObjectToXML(LocalSCSetting, RName.GetRName("Cache/LocalShaderCacheSetting.xml"));
            }

            CEngine.mGenerateShaderForMobilePlatform = LocalSCSetting.IsCrossPlatform;

            if (LocalSCSetting.Version == GlobalSCSetting.Version)
            {
                return;
            }

            LocalSCSetting.Version = GlobalSCSetting.Version;
            var SrcDir = CEngine.Instance.FileManager.EngineRoot + "Shaders/CoreShader/";

            CEngine.Instance.FileManager.CopyDirectory(SrcDir, RName.GetRName("Shaders").Address);
            CEngine.Instance.FileManager.DeleteFilesInDirectory(RName.GetRName("Cache/Shader/").Address, "*.shader", System.IO.SearchOption.AllDirectories);
            IO.XmlHolder.SaveObjectToXML(LocalSCSetting, RName.GetRName("Cache/LocalShaderCacheSetting.xml"));
        }
Esempio n. 30
0
        public bool BuildMesh(CFontMesh fontMesh, CRenderContext rc, bool flipV)
        {
            var number = (int)SDK_FTTextDrawContext_GetDrawCall(CoreObject);

            if (number <= 0)
            {
                return(false);
            }

            unsafe
            {
                var p = stackalloc CShaderResourceView.NativePointer[number];
                {
                    var ptr = SDK_FTTextDrawContext_BuildMesh(CoreObject, rc.CoreObject, p, flipV);
                    if (ptr.Pointer == IntPtr.Zero)
                    {
                        return(false);
                    }

                    mBuildMeshSource.UnsafeReInit(ptr);
                    if (false == fontMesh.Mesh.Init(rc, RName.GetRName(null), mBuildMeshSource /*, CFTShadingEnv.GetFTShadingEnv()*/))
                    {
                        return(false);
                    }
                }

                var senv = CEngine.Instance.PrebuildPassData.Font2DShadingEnvs;
                for (int i = 0; i < number; i++)
                {
                    fontMesh.Mesh.SetMaterialWithEffects(rc, (UInt32)i, mMaterialInst, mEffects, senv);
                }

                for (int i = 0; i < number; i++)
                {
                    var pass = fontMesh.Mesh.MtlMeshArray[i].GetPass((int)PrebuildPassIndex.PPI_Default);
                    pass.ShaderResources.SetUserControlTexture(mTextureBindInfo.PSBindPoint, true);
                    pass.ShaderResources.PSBindTexturePointer(mTextureBindInfo.PSBindPoint, p[i]);
                }
            }

            return(true);
        }