void UpdateActorsInheritScale() { var enumrableInterface = GameActors.GetType().GetInterface(typeof(IEnumerable).FullName, false); if (enumrableInterface != null) { int index = 0; foreach (var actorObj in (IEnumerable)GameActors) { var actor = actorObj as EngineNS.GamePlay.Component.IPlaceable; bool inheritScale; if (mInheritScale is EditorCommon.PropertyMultiValue) { inheritScale = (bool)((EditorCommon.PropertyMultiValue)mInheritScale).Values[index]; } else { inheritScale = System.Convert.ToBoolean(mInheritScale); } actor.Placement.InheritScale = inheritScale; index++; } } else { //var actor = GameActors as EngineNS.GamePlay.Actor.GActor; var actor = GameActors as EngineNS.GamePlay.Component.IPlaceable; actor.Placement.InheritScale = (bool)mInheritScale; } }
void UpdateScaleZ(float value) { var enumrableInterface = GameActors.GetType().GetInterface(typeof(IEnumerable).FullName, false); float ratio = 1; if (enumrableInterface != null) { int index = 0; foreach (var actorObj in (IEnumerable)GameActors) { var actor = actorObj as EngineNS.GamePlay.Component.IPlaceable; if (mScaleZ is EditorCommon.PropertyMultiValue) { if (LockXYZ) { ratio = value / (float)((EditorCommon.PropertyMultiValue)mScaleZ).Values[index]; } ((EditorCommon.PropertyMultiValue)mScaleZ).Values[index] = value; } else { if (LockXYZ) { ratio = value / System.Convert.ToSingle(mScaleZ); } mScaleZ = value; } if (mScaleY is EditorCommon.PropertyMultiValue) { ((EditorCommon.PropertyMultiValue)mScaleY).Values[index] = (float)((EditorCommon.PropertyMultiValue)mScaleY).Values[index] * ratio; } else { mScaleY = System.Convert.ToSingle(mScaleY) * ratio; } if (mScaleX is EditorCommon.PropertyMultiValue) { ((EditorCommon.PropertyMultiValue)mScaleX).Values[index] = (float)((EditorCommon.PropertyMultiValue)mScaleX).Values[index] * ratio; } else { mScaleX = System.Convert.ToSingle(mScaleX) * ratio; } index++; } } else { if (LockXYZ) { ratio = value / (float)mScaleZ; } mScaleZ = value; mScaleY = ratio * (float)mScaleY; mScaleX = ratio * (float)mScaleX; } }
void UpdateActorsTranslation() { try { var enumrableInterface = GameActors.GetType().GetInterface(typeof(IEnumerable).FullName, false); if (enumrableInterface != null) { int index = 0; foreach (var actorObj in (IEnumerable)GameActors) { var actor = actorObj as EngineNS.GamePlay.Component.IPlaceable; float x, y, z; if (mPositionX is EditorCommon.PropertyMultiValue) { x = (float)((EditorCommon.PropertyMultiValue)mPositionX).Values[index]; } else { x = System.Convert.ToSingle(mPositionX); } if (mPositionY is EditorCommon.PropertyMultiValue) { y = (float)((EditorCommon.PropertyMultiValue)mPositionY).Values[index]; } else { y = System.Convert.ToSingle(mPositionY); } if (mPositionZ is EditorCommon.PropertyMultiValue) { z = (float)((EditorCommon.PropertyMultiValue)mPositionZ).Values[index]; } else { z = System.Convert.ToSingle(mPositionZ); } actor.Placement.Location = new EngineNS.Vector3(x, y, z); index++; } } else { //var actor = GameActors as EngineNS.GamePlay.Actor.GActor; var actor = GameActors as EngineNS.GamePlay.Component.IPlaceable; actor.Placement.Location = new EngineNS.Vector3(System.Convert.ToSingle(mPositionX), System.Convert.ToSingle(mPositionY), System.Convert.ToSingle(mPositionZ)); } } catch (System.Exception) { } }
async Task UpdateActorsRotation() { await EngineNS.CEngine.Instance.EventPoster.Post(() => { mIsManual = true; return(true); }, EngineNS.Thread.Async.EAsyncTarget.Main); var delta = (float)(System.Math.PI / 180); var enumrableInterface = GameActors.GetType().GetInterface(typeof(IEnumerable).FullName, false); if (enumrableInterface != null) { int index = 0; foreach (var actorObj in (IEnumerable)GameActors) { var actor = actorObj as EngineNS.GamePlay.Component.IPlaceable; float yaw, pitch, roll; if (mRotationX is EditorCommon.PropertyMultiValue) { pitch = (((float)(((EditorCommon.PropertyMultiValue)mRotationX).Values[index]))) * delta; } else { pitch = (System.Convert.ToSingle(mRotationX)) * delta; } if (mRotationY is EditorCommon.PropertyMultiValue) { yaw = (((float)(((EditorCommon.PropertyMultiValue)mRotationY).Values[index]))) * delta; } else { yaw = (System.Convert.ToSingle(mRotationY)) * delta; } if (mRotationZ is EditorCommon.PropertyMultiValue) { roll = (((float)(((EditorCommon.PropertyMultiValue)mRotationZ).Values[index]))) * delta; } else { roll = (System.Convert.ToSingle(mRotationZ)) * delta; } actor.Placement.Rotation = EngineNS.Quaternion.RotationYawPitchRoll(yaw, pitch, roll); } } else { //var actor = GameActors as EngineNS.GamePlay.Actor.GActor; var actor = GameActors as EngineNS.GamePlay.Component.IPlaceable; actor.Placement.Rotation = EngineNS.Quaternion.RotationYawPitchRoll((System.Convert.ToSingle(mRotationY)) * delta, (System.Convert.ToSingle(mRotationX)) * delta, (System.Convert.ToSingle(mRotationZ)) * delta); var RotationAngle = GameActors as WPG.Themes.TypeEditors.TransformGradient.IRotationAngle; if (RotationAngle != null) { RotationAngle.YawPitchRoll = new EngineNS.Vector3(System.Convert.ToSingle(mRotationX), System.Convert.ToSingle(mRotationY), System.Convert.ToSingle(mRotationZ)); } } await EngineNS.CEngine.Instance.EventPoster.Post(() => { mIsManual = false; return(true); }, EngineNS.Thread.Async.EAsyncTarget.Main); }