public override void Tick(GPlacementComponent placement) { var now = CEngine.Instance.EngineTime; for (int i = 0; i < Timers.Count; i++) { if (Timers[i].Enable == false) { continue; } if (CIPlatform.Instance.PlayMode == CIPlatform.enPlayMode.Editor && Timers[i].OnlyForGame) { continue; } if (now - Timers[i].mPrevTriggerTime > Timers[i].Interval * 1000) { if (Timers[i].OnTimer != null) { Timers[i].OnTimer(Timers[i], this); } Timers[i].mPrevTriggerTime = now; } } }
public async Task <GActor> CreateActor(Editor.PlantableItemCreateActorParam param, RName MacrossName) { var rc = EngineNS.CEngine.Instance.RenderContext; await EngineNS.Thread.AsyncDummyClass.DummyFunc(); var actor = new EngineNS.GamePlay.Actor.GActor(); actor.ActorId = Guid.NewGuid(); var placement = new EngineNS.GamePlay.Component.GPlacementComponent(); actor.Placement = placement; placement.Location = param.Location; var init = new GParticleComponentInitializer(); init.SpecialName = "ParticleData"; init.MacrossName = MacrossName; await SetInitializer(rc, actor, actor, init); actor.AddComponent(this); var meshComp = new EngineNS.GamePlay.Component.GMeshComponent(); var meshCompInit = new EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer(); meshCompInit.SpecialName = "EditorShow"; meshCompInit.MeshName = EngineNS.RName.GetRName("meshes/icon_particle.gms", EngineNS.RName.enRNameType.Editor); await meshComp.SetInitializer(rc, actor, actor, meshCompInit); meshComp.HideInGame = true; actor.AddComponent(meshComp); return(actor); }
public Data() { EngineNS.GamePlay.Component.GPlacementComponent.GPlacementComponentInitializer mPlacementData = new EngineNS.GamePlay.Component.GPlacementComponent.GPlacementComponentInitializer(); Placement = new EngineNS.GamePlay.Component.GPlacementComponent(); var text = Placement.SetInitializer(EngineNS.CEngine.Instance.RenderContext, new EngineNS.GamePlay.Actor.GActor(), null, mPlacementData as EngineNS.GamePlay.Component.GComponent.GComponentInitializer); //Placement.SetMatrix(ref sys.Matrix); }
public sealed override void Tick(GPlacementComponent placement) { if (!mIsFirstTicked) { OnBeginPlay(placement); mIsFirstTicked = true; } Update(placement); OnTick(placement); base.Tick(placement); }
public override void Update(GPlacementComponent placement) { var mesh = Host.GetComponent <GMeshComponent>(); var skinModifier = mesh.SceneMesh.MdfQueue.FindModifier <EngineNS.Graphics.Mesh.CGfxSkinModifier>(); if (curPose == null) { curPose = CEngine.Instance.SkeletonAssetManager.GetSkeleton(CEngine.Instance.RenderContext, RName.GetRName(skinModifier.SkeletonAsset)).CreateSkeletonPose(); } var movement = Host.GetComponent <GMovementComponent>(); mGoal.HostPlacement = Host.Placement; mGoal.Trajectory = movement.FutureTrajectory; mGoal.CurrentPose = curPose; var bestMotionPose = MotionMatchingSystem.Instance.GetBestMatchingPose(motionField, mGoal); if (bestMotionPose != null) { if (currentBestMotionPose != null && currentBestMotionPose.HashName == bestMotionPose.HashName) { if (currentBestMotionPose.PlayTime - bestMotionPose.PlayTime < 5) { currentAnimTime += CEngine.Instance.EngineElapseTime; var time = currentAnimTime % (motionField.Motions[currentAnimaHash].DurationInMilliSecond + 1); curPose = motionField.Motions[currentAnimaHash].GetAnimationSkeletonPose(time * 0.001f); } else { currentBestMotionPose = bestMotionPose; currentAnimaHash = bestMotionPose.HashName; currentAnimTime = bestMotionPose.PlayTime; } } else { currentBestMotionPose = bestMotionPose; currentAnimaHash = bestMotionPose.HashName; currentAnimTime = bestMotionPose.PlayTime; } } //curPose.ExtractRootMotionPosition(true); //curPose.BlendWithTargetPose(skinModifier.AnimationPose, 0.5f); skinModifier.AnimationPose = curPose; if (!mIsDebug) { return; } DebugTick(placement); }
public override void Tick(GPlacementComponent placement) { base.Tick(placement); if (View != null) { View.DirLightColor_Intensity = new Vector4(DirLightInitializer.DirLightColor.R / 255.0f, DirLightInitializer.DirLightColor.G / 255.0f, DirLightInitializer.DirLightColor.B / 255.0f, DirLightInitializer.DirLightIntensity); //var matrix = Matrix.RotationY(CEngine.Instance.EngineTime/5000.0f); Vector3 LightDir = Vector3.TransformNormal(Vector3.UnitZ, Matrix.RotationQuaternion(placement.Rotation)); View.mDirLightDirection_Leak = new Vector4(LightDir, DirLightInitializer.ShadowAlpha); View.mSkyLightColor = new Vector3(DirLightInitializer.SkyLightColor.R / 255.0f, DirLightInitializer.SkyLightColor.G / 255.0f, DirLightInitializer.SkyLightColor.B / 255.0f); View.GroundLightColor = new Vector3(DirLightInitializer.GroundLightColor.R / 255.0f, DirLightInitializer.GroundLightColor.G / 255.0f, DirLightInitializer.GroundLightColor.B / 255.0f); } }
public override void Tick(GPlacementComponent placement) { for (int i = 0; i < Components.Count; ++i) { var comp = Components[i]; var scope = comp.GetTickTimeScope(); if (scope != null) { scope.Begin(); } comp.Tick(placement); if (scope != null) { scope.End(); } } base.Tick(placement); }
public async Task <GActor> CreateActor(Editor.PlantableItemCreateActorParam param) { var rc = EngineNS.CEngine.Instance.RenderContext; await EngineNS.Thread.AsyncDummyClass.DummyFunc(); var actor = new EngineNS.GamePlay.Actor.GActor(); actor.ActorId = Guid.NewGuid(); var placement = new EngineNS.GamePlay.Component.GPlacementComponent(); actor.Placement = placement; placement.Location = param.Location; var init = new GParticleComponentInitializer(); init.SpecialName = "ParticleData"; await SetInitializer(rc, actor, actor, init); actor.AddComponent(this); return(actor); }
void DebugTick(GPlacementComponent placement) { if (!mIsInitDebug) { return; } if (currentBestMotionPose == null) { return; } var debugTrajectory = new Support.NativeQueueForArray <Vector3>(); var hostLoc = Host.Placement.Location; foreach (var point in currentBestMotionPose.Trajectory) { var p = point.Position; p.Y = 0; debugTrajectory.Enqueue(Host.Placement.Rotation * point.Position + hostLoc + Vector3.UnitY * 0.1f); } mPoseTrajectoryDebug.SetVector3Points(debugTrajectory); mPoseTrajectoryDebug.Tick(placement); }
public void OnPlacementChanged(GPlacementComponent placement) { if (this.Host.StaticObject) { this.Host.Scene?.World?.FindNearActor(PointLightInitializer.Position, LightSphere.Radius, (Actor.GActor actor) => { actor.PointLightsSerialId = 0; return(false); }); } PointLightInitializer.Position = Placement.WorldLocation; LightSphere.Center = Placement.WorldLocation; LightSphere.Radius = PointLightInitializer.Radius; if (this.Host.StaticObject) { this.Host.Scene?.World?.FindNearActor(PointLightInitializer.Position, LightSphere.Radius, (Actor.GActor actor) => { actor.PointLightsSerialId = 0; return(false); }); } }
public virtual void OnEndPlay(GPlacementComponent placement) { }
public override void CalculateVelocity(GPlacementComponent placement, float dtSecond) { F = (mDesireVelcity - mVelocity).NormalizeValue * 10; var mFrictionVec3 = F * mFriction; if (mVelocity == Vector3.Zero || mVelocity.Length() < 0.1f) { mFrictionVec3 = Vector3.Zero; mVelocity = Vector3.Zero; } if (mDesireVelcity == Vector3.Zero) { F = Vector3.Zero; mFrictionVec3 = (mVelocity).NormalizeValue * 10 * mFriction; } mAccelerate = (F - mFrictionVec3) / Mass; var phyCtrlCom = Host.GetComponent <Bricks.PhysicsCore.GPhyControllerComponent>(); if (phyCtrlCom == null) { placement.Location += mTempVelcity * dtSecond; } if (mAccelerate == Vector3.Zero) { mTempVelcity = Vector3.Zero; } else { mTempVelcity = mTempVelcity + mAccelerate * dtSecond; } mTempVelcity = Math.Min(mTempVelcity.Length(), mMaxVelocity) * mTempVelcity.NormalizeValue; if (mHasGravity /*&& mIsInAir*/ && phyCtrlCom != null) { mGravityVelocity = mGravityVelocity + mGravity * dtSecond; } mTempVelcity.Y += mGravityVelocity; delta = mTempVelcity * dtSecond; var oldLoc = placement.Location; placement?.TryMove(ref delta, 0.0001f, dtSecond); var realLoc = placement.Location; mVelocity = (realLoc - oldLoc) / dtSecond; if (mOrientThisRotation) { if (mOrientation != Vector3.Zero) { var rot = Quaternion.GetQuaternion(Vector3.UnitZ, mOrientation); if (placement.Rotation != rot) { placement.Rotation = rot; } } } if (phyCtrlCom != null) { switch (phyCtrlCom.CollisionFlags) { case Bricks.PhysicsCore.PhyControllerCollisionFlag.eCOLLISION_None: { mIsInAir = true; } break; case Bricks.PhysicsCore.PhyControllerCollisionFlag.eCOLLISION_DOWN: { mIsInAir = false; mGravityVelocity = 0; mVelocity.Y = 0; } break; } } }
//不作用于物理 public void OnPlacementChangedUninfluencePhysics(GPlacementComponent placement) { PointLightInitializer.Position = placement.Location; }
public override void Tick(GPlacementComponent placement) { base.Tick(placement); TickEditor(); }
public virtual void Update(GPlacementComponent placement) { }
public override void OnBeginPlay(GPlacementComponent placement) { var mesh = Host.GetComponent <GMeshComponent>(); var skinModifier = mesh.SceneMesh.MdfQueue.FindModifier <EngineNS.Graphics.Mesh.CGfxSkinModifier>(); var SkeletonAssetName = RName.GetRName(skinModifier.SkeletonAsset); pose = CEngine.Instance.SkeletonAssetManager.GetSkeleton(CEngine.Instance.RenderContext, SkeletonAssetName).CreateSkeletonPose(); //var Goodrun = CreateAnim(RName.GetRName("TitanDemo/Character/test_girl/animation/goodrun.vanims"), pose); //motionField.Add(Goodrun); //var walk2jogneutral = CreateAnim(RName.GetRName("TitanDemo/Character/test_girl/animation/ntsc walk to jog neutral.vanims"), pose); //motionField.Add(walk2jogneutral); var animationFilePath = RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation"); //var files = CEngine.Instance.FileManager.GetFiles(animationFilePath.Address); //for (int i = 0; i < files.Length; ++i) //{ // if (CEngine.Instance.FileManager.GetFileExtension(files[i], true) == CEngineDesc.AnimationSequenceExtension) // { // var anim = CreateAnim(RName.EditorOnly_GetRNameFromAbsFile(files[i]), pose); // motionField.Add(anim); // } //} //var walktorun = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/ntsc_walk_to_run.anim"), pose); //motionField.Add(walktorun); //var walktorun2 = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/ntsc_walk_to_run2.anim"), pose); //motionField.Add(walktorun2); var RunLoop = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/runloop.anim"), pose); motionField.Add(RunLoop); //var RunLoopC = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/runloopc.anim"), pose); //motionField.Add(RunLoopC); var RunStart = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/runstart.anim"), pose); motionField.Add(RunStart); var RunStop = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/runstop.anim"), pose); motionField.Add(RunStop); var RunTurnL = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/runturnl.anim"), pose); motionField.Add(RunTurnL); var RunTurnR = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/runturnr.anim"), pose); motionField.Add(RunTurnR); //var Runx = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/runx.anim"), pose); //motionField.Add(Runx); var ntsc_ambeint2 = CreateAnim(RName.GetRName("TitanDemo/Character/puppet_low_ue4/animation/ntsc_ambeint2.anim"), pose); motionField.Add(ntsc_ambeint2); skinModifier.AnimationPose = pose; if (!mIsDebug) { return; } if (Host.Scene.World == null) { return; } Action action = async() => { await InitDebug(); }; action.Invoke(); }
public override void Tick(GPlacementComponent placement) { McLogicAnimation?.Tick(placement); }
public virtual void OnUnInitialize(GPlacementComponent placement) { }
public virtual void OnBeginPlay(GPlacementComponent placement) { }
public virtual void OnTick(GPlacementComponent placement) { }