/// <summary> /// Unregister entity component. /// </summary> internal void UnregisterEntityComponent(MyAnimationControllerComponent entityComponent) { using (m_lock.AcquireExclusiveUsing()) { m_skinnedEntityComponentsToRemove.Add(entityComponent); } }
/// <summary> /// Unregister entity component. /// </summary> internal void UnregisterEntityComponent(MyAnimationControllerComponent entityComponent) { if (m_skinnedEntityComponents.Contains(entityComponent)) { m_skinnedEntityComponents.Remove(entityComponent); } else { Debug.Assert(false, "Entity component was not found, cannot be unregistered."); } }
public MySkinnedEntity() { this.Render = new MyRenderComponentSkinnedEntity(); Render.EnableColorMaskHsv = true; Render.NeedsDraw = true; Render.CastShadows = true; Render.NeedsResolveCastShadow = false; Render.SkipIfTooSmall = false; m_compAnimationController = new MyAnimationControllerComponent(); Components.Add(m_compAnimationController); }
public MySkinnedEntity() { this.Render = new MyRenderComponentSkinnedEntity(); Render.EnableColorMaskHsv = true; Render.NeedsDraw = true; Render.CastShadows = true; Render.NeedsResolveCastShadow = false; Render.SkipIfTooSmall = false; MyEntityTerrainHeightProviderComponent entityTerrainHeightComp = new MyEntityTerrainHeightProviderComponent(); Components.Add(entityTerrainHeightComp); m_compAnimationController = new MyAnimationControllerComponent(); m_compAnimationController.ReloadBonesNeeded = ObtainBones; m_compAnimationController.InverseKinematics.TerrainHeightProvider = entityTerrainHeightComp; Components.Add(m_compAnimationController); }
private void UpdateGraphicalWeaponPosition() { MyAnimationControllerComponent animationController = base.Character.AnimationController; MyHandItemDefinition handItemDefinition = base.Character.HandItemDefinition; if (((handItemDefinition != null) && (base.Character.CurrentWeapon != null)) && (animationController.CharacterBones != null)) { bool flag = base.Character.ControllerInfo.IsLocallyControlled() && ReferenceEquals(MySession.Static.CameraController, base.Character); bool flag2 = (base.Character.IsInFirstPersonView || base.Character.ForceFirstPersonCamera) & flag; if (MyFakes.FORCE_CHARTOOLS_1ST_PERSON) { flag2 = true; } bool jetpackRunning = base.Character.JetpackRunning; if (this.m_lastStateWasFalling & jetpackRunning) { this.m_currentAnimationToIkTime = this.m_animationToIKDelay * ((float)Math.Cos((double)(base.Character.HeadLocalXAngle - this.m_lastLocalRotX))); } if (this.m_lastStateWasCrouching != base.Character.IsCrouching) { this.m_suppressBouncingForTimeSec = m_suppressBouncingDelay; } if (this.m_suppressBouncingForTimeSec > 0f) { this.m_spineRestPositionX.Clear(); this.m_spineRestPositionY.Clear(); this.m_spineRestPositionZ.Clear(); } this.m_lastLocalRotX = base.Character.HeadLocalXAngle; if (flag2) { this.UpdateGraphicalWeaponPosition1st(handItemDefinition); } else { this.UpdateGraphicalWeaponPosition3rd(handItemDefinition); } } }
// --------------- LIVE DEBUGGING ----------------------------------------------------------------- private void LiveDebugging() { if (Session == null || Session.ControlledObject == null || MySessionComponentExtDebug.Static == null || !MySessionComponentExtDebug.Static.HasClients) { return; } MyEntity localSkinnedEntity = Session.ControlledObject.Entity as MyEntity; if (localSkinnedEntity == null) { return; } MyAnimationControllerComponent localSkinnedEntityAnimComponent = localSkinnedEntity.Components.Get <MyAnimationControllerComponent>(); if (localSkinnedEntityAnimComponent == null) { return; } // send AC name (connect / reconnect) m_debuggingSendNameCounter--; if (localSkinnedEntityAnimComponent.SourceId.SubtypeName != m_debuggingLastNameSent) { m_debuggingSendNameCounter = 0; } if (m_debuggingSendNameCounter <= 0) { LiveDebugging_SendControllerNameToEditor(localSkinnedEntityAnimComponent.SourceId.SubtypeName); m_debuggingSendNameCounter = m_debuggingSendNameCounterMax; m_debuggingLastNameSent = localSkinnedEntityAnimComponent.SourceId.SubtypeName; } // animation states LiveDebugging_SendAnimationStateChangesToEditor(localSkinnedEntityAnimComponent.Controller); }
private unsafe void UpdateGraphicalWeaponPosition3rd(MyHandItemDefinition handItemDefinition) { bool jetpackRunning = base.Character.JetpackRunning; MyAnimationControllerComponent animationController = base.Character.AnimationController; MatrixD xd = base.Character.GetHeadMatrix(false, !jetpackRunning, false, true, true) * base.Character.PositionComp.WorldMatrixInvScaled; if (animationController.CharacterBones.IsValidIndex <MyCharacterBone>(base.Character.HeadBoneIndex)) { double *numPtr1 = (double *)ref xd.M42; numPtr1[0] += animationController.CharacterBonesSorted[0].Translation.Y; } MatrixD xd2 = handItemDefinition.ItemLocation3rd; MatrixD xd3 = handItemDefinition.ItemWalkingLocation3rd; MatrixD xd4 = handItemDefinition.ItemShootLocation3rd; MatrixD itemIronsightLocation = handItemDefinition.ItemIronsightLocation; MatrixD xd6 = animationController.CharacterBones.IsValidIndex <MyCharacterBone>(base.Character.WeaponBone) ? (this.GetWeaponRelativeMatrix() * animationController.CharacterBones[base.Character.WeaponBone].AbsoluteTransform) : this.GetWeaponRelativeMatrix(); itemIronsightLocation.Translation = m_weaponIronsightTranslation; if (base.Character.CurrentWeapon is MyEngineerToolBase) { itemIronsightLocation.Translation = m_toolIronsightTranslation; } Vector4D vectord = this.UpdateAndGetWeaponVariantWeights(handItemDefinition); MatrixD weaponMatrixLocal = MatrixD.Normalize((MatrixD)((((vectord.X * xd2) + (vectord.Y * xd3)) + (vectord.Z * xd4)) + (vectord.W * itemIronsightLocation))); double num = 0.0; if (handItemDefinition.ItemPositioning3rd == MyItemPositioningEnum.TransformFromData) { num += vectord.X; } if (handItemDefinition.ItemPositioningWalk3rd == MyItemPositioningEnum.TransformFromData) { num += vectord.Y; } if (handItemDefinition.ItemPositioningShoot3rd == MyItemPositioningEnum.TransformFromData) { num += vectord.Z; } if (handItemDefinition.ItemPositioningIronsight3rd == MyItemPositioningEnum.TransformFromData) { num += vectord.W; } num /= ((vectord.X + vectord.Y) + vectord.Z) + vectord.W; double num2 = 0.0; if (handItemDefinition.ItemPositioning3rd != MyItemPositioningEnum.TransformFromAnim) { num2 += vectord.X; } if (handItemDefinition.ItemPositioningWalk3rd != MyItemPositioningEnum.TransformFromAnim) { num2 += vectord.Y; } if (handItemDefinition.ItemPositioningShoot3rd != MyItemPositioningEnum.TransformFromAnim) { num2 += vectord.Z; } if (handItemDefinition.ItemPositioningIronsight3rd != MyItemPositioningEnum.TransformFromAnim) { num2 += vectord.W; } num2 /= ((vectord.X + vectord.Y) + vectord.Z) + vectord.W; this.ApplyWeaponBouncing(handItemDefinition, ref weaponMatrixLocal, (float)(1.0 - (0.95 * vectord.W)), 0f); double *numPtr2 = (double *)ref xd.M43; numPtr2[0] += (0.5 * weaponMatrixLocal.M43) * Math.Max(0.0, xd.M32); double *numPtr3 = (double *)ref xd.M42; numPtr3[0] += (0.5 * weaponMatrixLocal.M42) * Math.Max(0.0, xd.M32); double *numPtr4 = (double *)ref xd.M42; numPtr4[0] -= 0.25 * Math.Max(0.0, xd.M32); double *numPtr5 = (double *)ref xd.M43; numPtr5[0] -= 0.05 * Math.Min(0.0, xd.M32); double *numPtr6 = (double *)ref xd.M41; numPtr6[0] -= 0.25 * Math.Max(0.0, xd.M32); MatrixD xd8 = weaponMatrixLocal * xd; MyEngineerToolBase currentWeapon = base.Character.CurrentWeapon as MyEngineerToolBase; if (currentWeapon != null) { currentWeapon.SensorDisplacement = (Vector3) - weaponMatrixLocal.Translation; } double amount = (num * this.m_currentAnimationToIkTime) / ((double)this.m_animationToIKDelay); MatrixD weaponAnimMatrix = MatrixD.Lerp(xd6, xd8, amount); this.UpdateScattering(ref weaponAnimMatrix, handItemDefinition); this.ApplyBackkick(ref weaponAnimMatrix); MatrixD matrix = weaponAnimMatrix * base.Character.WorldMatrix; this.GraphicalPositionWorld = matrix.Translation; this.ArmsIkWeight = (float)num2; ((MyEntity)base.Character.CurrentWeapon).WorldMatrix = matrix; if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW && MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_TOOLS) { MyDebugDrawHelper.DrawNamedColoredAxis(xd6 * base.Character.WorldMatrix, 0.25f, "weapon anim " + (100.0 - (100.0 * amount)) + "%", new Color?(Color.Orange)); MyDebugDrawHelper.DrawNamedColoredAxis(xd8 * base.Character.WorldMatrix, 0.25f, "weapon data " + (100.0 * amount) + "%", new Color?(Color.Magenta)); MyDebugDrawHelper.DrawNamedColoredAxis(matrix, 0.25f, "weapon final", new Color?(Color.White)); } }
/// <summary> /// Register entity component. /// </summary> internal void RegisterEntityComponent(MyAnimationControllerComponent entityComponent) { Debug.Assert(m_skinnedEntityComponents.Contains(entityComponent) == false, "Entity component was already registered."); m_skinnedEntityComponents.Add(entityComponent); }
private void OnAnimatorAdded(MyAnimationControllerComponent obj) { StateChanged(MyStringHash.NullOrEmpty, _state.CurrentState); }