Пример #1
0
        public override void UpdateStep(object param)
        {
            if (param == null)
            {
                return;
            }
            double?t = param as double?;

            if (t == null)
            {
                return;
            }
            _curTime = (double)t;
            if (_curTime < 0)
            {
                return;
            }
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            if (!_haveBeenSet && _curTime > pEvent.EventStartTime)
            {
                if (_createObject != null)
                {
                    _createObject.ActorStatus      = ActorStatus.Value;
                    _createObject.ActorTranslation = ActorPosition;
                    _createObject.ActorRotation    = ActorRotation;
                    ((IVdsGroupInterface)_currentView.GameLayer).AddChild(_createObject);
                    _haveBeenSet = true;
                }
            }
        }
Пример #2
0
 internal void StopScript()
 {
     for (int i = _childrenList.Count - 1; i >= 0; i--)
     {
         VdsPlotEvent x = (VdsPlotEvent)_childrenList[i];
         x.StopScript();
     }
 }
Пример #3
0
 public override void AsynchronousOperationStep(object param)
 {
     for (int i = _childrenList.Count - 1; i >= 0; i--)
     {
         VdsPlotEvent x = (VdsPlotEvent)_childrenList[i];
         x.AsynchronousOperationStep(param);
     }
 }
Пример #4
0
 public override void UpdateStep(object param)
 {
     for (int i = _childrenList.Count - 1; i >= 0; i--)
     {
         VdsPlotEvent x = (VdsPlotEvent)_childrenList[i];
         x.UpdateStep(param);
     }
 }
Пример #5
0
        public override void Start()
        {
            if (ActorBindingID.Value == "" || ActorBindingID.Value == null)
            {
                return;
            }
            _haveBeenSet = false;
            string viewID = ParentActor.ObjectViewID.ToString();

            _currentView = VdsEngineSystem.Instance.GetVdsViewByID(Convert.ToInt32(viewID));
            PtrClass a = ((IVdsGroupInterface)_currentView.GameLayer).GetObjectByID(ActorBindingID.Value);

            if (a == null)
            {
                if (ActorResource.Value == "")
                {
                    return;
                }
                else
                {
                    string sourceStr = Path.GetFileName(ActorResource.Value);
                    if (sourceStr.EndsWith(".vds"))
                    {
                        _createObject = new VdsActor(sourceStr);
                    }
                    else if (sourceStr.EndsWith(".vdsa"))
                    {
                        _createObject = new VdsGameActor(sourceStr);
                    }
                    else
                    {
                        return;
                    }
                }
            }
            else
            {
                _createObject = a as VdsActor;
            }
            if (_createObject.NativeHandle == IntPtr.Zero)
            {
                _createObject = null;
                return;
            }
            if (a == null)
            {
                _createObject.ObjectBindID = ActorBindingID.Value;
                _createObject.ActorStatus  = "DefaultStatus";
            }
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            _behaviourIsWorking = true;
        }
        public override void Start()
        {
            if (ActorBindingID.Value == "" || ActorBindingID.Value == null)
            {
                return;
            }
            string viewID = ParentActor.ObjectViewID.ToString();

            _currentView = VdsEngineSystem.Instance.GetVdsViewByID(Convert.ToInt32(viewID));
            InitMotioObject();
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            _behaviourIsWorking = true;
        }
Пример #7
0
        protected void SetActorStatus(VdsActor actor, string statusName, bool repeat)
        {
            if (repeat || _curTime < 0)
            {
                actor.ActorStatus = statusName;
                return;
            }
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            if (_curTime < pEvent.EventStartTime)
            {
                if (_actorStatusCacheWait != null && _actorStatusCacheWait.Contains(actor))
                {
                    return;
                }
                actor.ActorStatus = statusName;
                if (_actorStatusCacheWait == null)
                {
                    _actorStatusCacheWait = new List <VdsActor>();
                }
                _actorStatusCacheWait.Add(actor);
                return;
            }
            if (_curTime > pEvent.EventStartTime && _curTime < pEvent.EventStartTime + pEvent.EventDurationTime)
            {
                if (_actorStatusCacheUnderway != null && _actorStatusCacheUnderway.Contains(actor))
                {
                    return;
                }
                actor.ActorStatus = statusName;
                if (_actorStatusCacheUnderway == null)
                {
                    _actorStatusCacheUnderway = new List <VdsActor>();
                }
                _actorStatusCacheUnderway.Add(actor);
                return;
            }
            if (_actorStatusCacheFinish != null && _actorStatusCacheFinish.Contains(actor))
            {
                return;
            }
            actor.ActorStatus = statusName;
            if (_actorStatusCacheFinish == null)
            {
                _actorStatusCacheFinish = new List <VdsActor>();
            }
            _actorStatusCacheFinish.Add(actor);
        }
Пример #8
0
 internal void InitPlotTimeLine()
 {
     StartTime = Int32.MaxValue;
     EndTime   = Int32.MinValue;
     for (int i = _childrenList.Count - 1; i >= 0; i--)
     {
         VdsPlotEvent t = (VdsPlotEvent)_childrenList[i];
         StartTime = Math.Min(StartTime, t.EventStartTime);
         EndTime   = Math.Max(EndTime, t.EventStartTime + t.EventDurationTime);
     }
     _childrenList.Sort(delegate(PtrClass x, PtrClass y)
     {
         VdsPlotEvent px = (VdsPlotEvent)x;
         VdsPlotEvent py = (VdsPlotEvent)y;
         return(py.EventStartTime.CompareTo(px.EventStartTime));
     });
 }
        public override void UpdateStep(object param)
        {
            if (param == null)
            {
                return;
            }
            double?t = param as double?;

            if (t == null)
            {
                return;
            }
            _curTime = (double)t;
            if (_curTime < 0)
            {
                return;
            }
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            if (_curTime > pEvent.EventStartTime && _curTime < pEvent.EventStartTime + pEvent.EventDurationTime)
            {
                if (!_haveBeenSet)
                {
                    ((IVdsGroupInterface)_currentView.GameLayer).AddChild(_loadingWidget);
                    _loadingWidget.ProgressValue = 0;
                    _haveBeenSet = true;
                }
                else
                {
                    double v = (_curTime - pEvent.EventStartTime) / pEvent.EventDurationTime * 100;
                    _loadingWidget.ProgressValue = (int)v;
                }
            }
            else if (_curTime >= pEvent.EventStartTime + pEvent.EventDurationTime && _behaviourIsWorking)
            {
                if (_haveBeenSet)
                {
                    ((IVdsGroupInterface)_currentView.GameLayer).RemoveChild(_loadingWidget);
                    _haveBeenSet = false;
                }
            }
        }
Пример #10
0
        public override void UpdateStep(object param)
        {
            if (param == null)
            {
                return;
            }
            double?t = param as double?;

            if (t == null)
            {
                return;
            }
            _curTime = (double)t;
            if (_curTime < 0)
            {
                return;
            }
            if (_motioObject == null)
            {
                PtrClass a = ((IVdsGroupInterface)_currentView.GameLayer).GetObjectByID(ActorBindingID.Value);
                if (a != null)
                {
                    _motioObject = a as VdsActor;
                }
            }
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            if (_curTime > pEvent.EventStartTime && _curTime < pEvent.EventStartTime + pEvent.EventDurationTime)
            {
                if (_motioObject != null && _soundEffect.IsIdle)
                {
                    _soundEffect.Apply(_motioObject);
                }
            }
            else
            {
                if (_soundEffect != null)
                {
                    _soundEffect.Unapply();
                }
            }
        }
Пример #11
0
        public override void Start()
        {
            if (ActorBindingID.Value == "" || ActorBindingID.Value == null)
            {
                return;
            }
            string viewID = ParentActor.ObjectViewID.ToString();

            _currentView = VdsEngineSystem.Instance.GetVdsViewByID(Convert.ToInt32(viewID));
            InitMotioObject();
            double totalLength = 0;

            for (int i = 0; i < ActorMotionKeyPoints.ValueList.Count - 1; ++i)
            {
                totalLength += (ActorMotionKeyPoints.ValueList[i] - ActorMotionKeyPoints.ValueList[i + 1]).Length();
            }
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            _motionSpeed        = totalLength / pEvent.EventDurationTime;
            _behaviourIsWorking = true;
        }
Пример #12
0
        public override void UpdateStep(object param)
        {
            if (param == null)
            {
                return;
            }
            double?t = param as double?;

            if (t == null)
            {
                return;
            }
            _curTime = (double)t;
            if (_curTime < 0)
            {
                return;
            }
            if (CameraStartPose == null)
            {
                return;
            }
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            if (!_haveBeenSet && _curTime > pEvent.EventStartTime)
            {
                VdsCamera newCamera = new VdsCamera();
                newCamera.CameraPose = CameraStartPose;
                if (_curTime > pEvent.EventStartTime + pEvent.EventDurationTime)
                {
                    newCamera.WithAnimation = false;
                }
                else
                {
                    newCamera.WithAnimation = WithAnimation.Value;
                }
                _currentView.MainCamera = newCamera;
                _haveBeenSet            = true;
            }
        }
Пример #13
0
        public override void UpdateStep(object param)
        {
            if (param == null)
            {
                return;
            }
            double?t = param as double?;

            if (t == null)
            {
                return;
            }
            _curTime = (double)t;
            if (_curTime < 0)
            {
                return;
            }
            if (_targetObject == null)
            {
                PtrClass a = ((IVdsGroupInterface)_currentView.GameLayer).GetObjectByID(FollowActorID.Value);
                if (a != null)
                {
                    _targetObject = a as VdsActor;
                }
                else
                {
                    return;
                }
            }
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            if (_curTime > pEvent.EventStartTime && _curTime < pEvent.EventStartTime + pEvent.EventDurationTime)
            {
                if (_targetObject != null && !_haveBeenSet)
                {
                    _preCamera = _currentView.MainCamera;
                    VdsCamera newCamera = new VdsCamera();
                    newCamera.TargetActorNativeHandle = _targetObject.NativeHandle;
                    newCamera.CurrentCameraMode       = CameraMode.FollowCamera;
                    newCamera.CameraPose.Eye          = new VdsVec3d(-EyeHorizontalOffset.Value, 0, EyeHeightOffset.Value);
                    if (_curTime > pEvent.EventStartTime + pEvent.EventDurationTime)
                    {
                        newCamera.WithAnimation = false;
                    }
                    else
                    {
                        newCamera.WithAnimation = WithAnimation.Value;
                    }
                    _currentView.MainCamera = newCamera;
                    _haveBeenSet            = true;
                }
            }
            else if (_curTime >= pEvent.EventStartTime + pEvent.EventDurationTime && _haveBeenSet && _behaviourIsWorking)
            {
                if (StayAtStop.Value)
                {
                    VdsCamera camera = _currentView.MainCamera;
                    camera.CurrentCameraMode = _preCamera.CurrentCameraMode;
                    _currentView.MainCamera  = camera;
                }
                else
                {
                    _currentView.MainCamera = _preCamera;
                }
                _haveBeenSet = false;
            }
        }
        public override void UpdateStep(object param)
        {
            if (param == null)
            {
                return;
            }
            double?t = param as double?;

            if (t == null)
            {
                return;
            }
            _curTime = (double)t;
            if (_curTime < 0)
            {
                return;
            }
            InitMotioObject();
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            if (_curTime > pEvent.EventStartTime && _curTime < pEvent.EventStartTime + pEvent.EventDurationTime)
            {
                if (_motioObject != null)
                {
                    VdsVec3d pos = _originPos;
                    double   interpolationValue = (_curTime - pEvent.EventStartTime) / pEvent.EventDurationTime;
                    VdsQuat  quat = VdsQuat.Slerp(interpolationValue, _originPose, _targetPose);
                    SetActorStatus(_motioObject, ActorStatus.Value, true);
                    VdsMatrixd rotateMt = new VdsMatrixd();
                    rotateMt.MakeRotate(quat);
                    if (_relevanceObject != null)
                    {
                        VdsMatrixd nowMt        = new VdsMatrixd();
                        VdsMatrixd localToWorld = new VdsMatrixd();
                        StaticMethod.ComputeCoordinateFrame(_relevanceObject, ref nowMt);
                        StaticMethod.ComputeCoordinateFrame(_motioObject.ParentObject as VdsActor, ref localToWorld);
                        VdsMatrixd worldToLocal = localToWorld.Inverse(localToWorld);
                        if (RelevancePosition.Value && !RelevanceRotation.Value)
                        {
                            nowMt.MakeTranslate(nowMt.GetTrans());
                            pos = nowMt.PreMult(pos);
                            pos = worldToLocal.PreMult(pos);
                            rotateMt.PreMult(nowMt);
                            rotateMt.PreMult(worldToLocal);
                        }
                        else if (!RelevancePosition.Value && RelevanceRotation.Value)
                        {
                            nowMt.MakeRotate(nowMt.GetRotate());
                            pos = _relevanceMatrixd.PreMult(pos);
                            pos = worldToLocal.PreMult(pos);
                            rotateMt.PreMult(nowMt);
                            rotateMt.PreMult(worldToLocal);
                        }
                        else if (RelevancePosition.Value && RelevanceRotation.Value)
                        {
                            rotateMt.PreMult(nowMt);
                            rotateMt.PreMult(worldToLocal);
                            pos = nowMt.PreMult(pos);
                            pos = worldToLocal.PreMult(pos);
                        }
                    }
                    VdsVec3d zr = new VdsVec3d();
                    VdsMatrixd.MatrixToHpr(ref zr, rotateMt);
                    VdsVec3d rotation = new VdsVec3d(0, 0, zr.Z);
                    _motioObject.ActorRotation    = rotation;
                    _motioObject.ActorTranslation = pos;
                }
            }
            else if (_motioObject != null)
            {
                SetActorStatus(_motioObject, "DefaultStatus", false);
            }
        }
Пример #15
0
        public override void UpdateStep(object param)
        {
            if (param == null)
            {
                return;
            }
            double?t = param as double?;

            if (t == null)
            {
                return;
            }
            _curTime = (double)t;
            if (_curTime < 0)
            {
                return;
            }
            InitMotioObject();
            VdsPlotEvent pEvent = ParentActor as VdsPlotEvent;

            if (_curTime > pEvent.EventStartTime && _curTime < pEvent.EventStartTime + pEvent.EventDurationTime)
            {
                if (_motioObject != null)
                {
                    VdsVec3d pos       = new VdsVec3d();
                    VdsVec3d direction = new VdsVec3d();
                    GetTranslationAndRotation(_motioObject, _curTime - pEvent.EventStartTime, out pos, out direction);
                    SetActorStatus(_motioObject, ActorStatus.Value, true);
                    if (_relevanceObject != null)
                    {
                        VdsMatrixd nowMt        = new VdsMatrixd();
                        VdsMatrixd localToWorld = new VdsMatrixd();
                        StaticMethod.ComputeCoordinateFrame(_relevanceObject, ref nowMt);
                        StaticMethod.ComputeCoordinateFrame(_motioObject.ParentObject as VdsActor, ref localToWorld);
                        VdsMatrixd worldToLocal = localToWorld.Inverse(localToWorld);
                        if (RelevancePosition.Value && !RelevanceRotation.Value)
                        {
                            nowMt.MakeTranslate(nowMt.GetTrans());
                            pos = nowMt.PreMult(pos);
                            pos = worldToLocal.PreMult(pos);
                        }
                        else if (!RelevancePosition.Value && RelevanceRotation.Value)
                        {
                            nowMt.MakeRotate(nowMt.GetRotate());
                            direction = nowMt.PreMult(direction);
                            direction = worldToLocal.PreMult(direction);
                            VdsVec3d zPos = new VdsVec3d();
                            zPos      = nowMt.PreMult(zPos);
                            zPos      = worldToLocal.PreMult(zPos);
                            direction = direction - zPos;

                            pos = _relevanceMatrixd.PreMult(pos);
                            pos = worldToLocal.PreMult(pos);
                        }
                        else if (RelevancePosition.Value && RelevanceRotation.Value)
                        {
                            direction = nowMt.PreMult(direction);
                            direction = worldToLocal.PreMult(direction);
                            VdsVec3d zPos = new VdsVec3d();
                            zPos      = nowMt.PreMult(zPos);
                            zPos      = worldToLocal.PreMult(zPos);
                            direction = direction - zPos;

                            pos = nowMt.PreMult(pos);
                            pos = worldToLocal.PreMult(pos);
                        }
                    }
                    direction.Normalize();
                    VdsVec3d   zr  = new VdsVec3d();
                    VdsMatrixd rMt = new VdsMatrixd();
                    rMt.MakeRotate(new VdsVec3d(1, 0, 0), direction);
                    VdsMatrixd.MatrixToHpr(ref zr, rMt);
                    VdsVec3d rotation = new VdsVec3d(0, 0, zr.Z);
                    _motioObject.ActorRotation    = rotation;
                    _motioObject.ActorTranslation = pos;
                }
            }
            else if (_motioObject != null)
            {
                SetActorStatus(_motioObject, "DefaultStatus", false);
            }
        }