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); }
private EngineNS.Graphics.Mesh.Animation.CGfxAnimationBlendSpace CreateAnimationBlenSpace2D(EngineNS.GamePlay.Actor.GActor actor) { RName first = RName.GetRName("Mesh/Crouch_Aim_LD45" + CEngineDesc.AnimationSequenceExtension); RName second = RName.GetRName("Mesh/Crouch_Aim_RD45" + CEngineDesc.AnimationSequenceExtension); RName third = RName.GetRName("Mesh/Crouch_Aim_Center" + CEngineDesc.AnimationSequenceExtension); RName forth = RName.GetRName("Mesh/walk" + CEngineDesc.AnimationSequenceExtension); var rc = EngineNS.CEngine.Instance.RenderContext; var animationCom = new EngineNS.GamePlay.Component.GAnimationInstance(RName.GetRName("robot2.skt")); actor.AddComponent(animationCom); var firstAnim = new EngineNS.Graphics.Mesh.Animation.CGfxAnimationSequence(); firstAnim.Init(EngineNS.CEngine.Instance.RenderContext, first); var secondAnim = new EngineNS.Graphics.Mesh.Animation.CGfxAnimationSequence(); secondAnim.Init(EngineNS.CEngine.Instance.RenderContext, second); var thirdAnim = new EngineNS.Graphics.Mesh.Animation.CGfxAnimationSequence(); thirdAnim.Init(EngineNS.CEngine.Instance.RenderContext, third); var forthAnim = new EngineNS.Graphics.Mesh.Animation.CGfxAnimationSequence(); forthAnim.Init(EngineNS.CEngine.Instance.RenderContext, forth); var blendSpace = new EngineNS.Graphics.Mesh.Animation.CGfxAnimationBlendSpace(); blendSpace.AnimationPose = animationCom.AnimationPose; var meshComp = actor.GetComponent <EngineNS.GamePlay.Component.GMutiMeshComponent>(); foreach (var subMesh in meshComp.Meshes) { var skinModifier = subMesh.Value.MdfQueue.FindModifier <EngineNS.Graphics.Mesh.CGfxSkinModifier>(); skinModifier.AnimationPose = animationCom.AnimationPose; } blendSpace.AddSample(firstAnim, Vector3.Zero); blendSpace.AddSample(secondAnim, new Vector3(100, 0, 0)); blendSpace.AddSample(thirdAnim, new Vector3(0, 100, 0)); blendSpace.AddSample(forthAnim, new Vector3(100, 100, 0)); animationCom.AnimationNode = blendSpace; return(blendSpace); }
private EngineNS.Graphics.Mesh.Animation.CGfxAnimationSequence CreateMutiMeshAnimation(EngineNS.GamePlay.Actor.GActor actor, RName animationName) { var rc = EngineNS.CEngine.Instance.RenderContext; var animationCom = new EngineNS.GamePlay.Component.GAnimationInstance(RName.GetRName("robot2.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.GMutiMeshComponent>(); foreach (var subMesh in meshComp.Meshes) { var skinModifier = subMesh.Value.MdfQueue.FindModifier <EngineNS.Graphics.Mesh.CGfxSkinModifier>(); skinModifier.AnimationPose = animationCom.AnimationPose; } animationSege.AnimationPose = animationCom.AnimationPose; animationCom.AnimationNode = animationSege; return(animationSege); }
private EngineNS.GamePlay.Actor.GActor CreateActorFBX(RName assetName) { var rc = EngineNS.CEngine.Instance.RenderContext; var sa = new AssetImport.FbxImporter(); //var assetName = RName.GetRName("Mesh/AxisWithAni.FBX"); ImportOption importOption; importOption.SkeletonAssetName = null; sa.Import(assetName, RName.GetRName("Mesh"), importOption, (uint)(AssetImport.aiPostProcessSteps.aiProcess_DontSplitMeshByMaterial)); var meshName = RName.GetRName("Mesh/" + sa.MeshPrimitives.First().Key + ".gms"); var meshPrimitiveName = sa.MeshPrimitives.First().Value.Name; var mesh = CEngine.Instance.MeshManager.NewMesh(rc, meshName, meshPrimitiveName); mesh.Init(rc, meshName, sa.MeshPrimitives.First().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); } var actor = EngineNS.GamePlay.Actor.GActor.NewMeshActor(mesh); var skinModifier = mesh.MdfQueue.FindModifier <EngineNS.Graphics.Mesh.CGfxSkinModifier>(); var skeletonAnimationNode = sa.Actions.First().Value; //var skeletonAnimationNode = new EngineNS.Graphics.Mesh.Animation.CGfxAnimationSequence(); //skeletonAnimationNode.Init(sklAction); skeletonAnimationNode.AnimationPose = skinModifier.Skeleton.BoneTab; var animationCom = new EngineNS.GamePlay.Component.GAnimationInstance(); animationCom.AnimationNode = skeletonAnimationNode; actor.AddComponent(animationCom); actor.Placement.Location = new Vector3(-1.0f, 0.0f, 0.0f); actor.Placement.Scale /= 10; return(actor); }