예제 #1
0
        private void GetTranslationAndRotation(VdsActor actor, double timeOffset, out VdsVec3d translation, out VdsVec3d direction)
        {
            direction = _motionObjectOriginDirection;
            if (_motionSpeed == 0)
            {
                translation = _motionObjectOriginPos;
                return;
            }
            double timeTotal = 0;

            for (int i = 0; i < ActorMotionKeyPoints.ValueList.Count - 1; ++i)
            {
                double eLength = (ActorMotionKeyPoints.ValueList[i] - ActorMotionKeyPoints.ValueList[i + 1]).Length();
                timeTotal += eLength / _motionSpeed;
                if (timeTotal >= timeOffset)
                {
                    if (MotionAutoAhead.Value)
                    {
                        direction = ActorMotionKeyPoints.ValueList[i + 1] - ActorMotionKeyPoints.ValueList[i];
                        direction.Normalize();
                    }
                    translation = ActorMotionKeyPoints.ValueList[i + 1] - direction * (timeTotal - timeOffset) * _motionSpeed;
                    return;
                }
            }
            if (MotionAutoAhead.Value)
            {
                direction = ActorMotionKeyPoints.ValueList[ActorMotionKeyPoints.ValueList.Count - 1] - ActorMotionKeyPoints.ValueList[ActorMotionKeyPoints.ValueList.Count - 2];
                direction.Normalize();
            }
            translation = ActorMotionKeyPoints.ValueList[ActorMotionKeyPoints.ValueList.Count - 1];
        }
예제 #2
0
        public override void Start()
        {
            if (ActorBindingID.Value == "" || ActorBindingID.Value == null)
            {
                return;
            }
            string viewID = ParentActor.ObjectViewID.ToString();

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

            if (a != null)
            {
                _motioObject = a as VdsActor;
            }
            _soundEffect = new VdsEffectSound(true);
            _soundEffect.SoundFileName      = SoundFileName.Value;
            _soundEffect.SoundLoop          = SoundLoop.Value;
            _soundEffect.SoundGain          = SoundGain.Value;
            _soundEffect.SoundPitch         = SoundPitch.Value;
            _soundEffect.ListenerRelative   = ListenerRelative.Value;
            _soundEffect.MaxDistance        = MaxDistance.Value;
            _soundEffect.SoundRolloffFactor = SoundRolloffFactor.Value;
            _behaviourIsWorking             = true;
        }
예제 #3
0
 public override void End()
 {
     _currentView        = null;
     _targetObject       = null;
     _behaviourIsWorking = false;
     base.End();
 }
예제 #4
0
 public override void End()
 {
     if (_currentView != null && _createObject != null && _haveBeenSet)
     {
         ((IVdsGroupInterface)_currentView.GameLayer).RemoveChild(_createObject);
         _createObject = null;
     }
     _behaviourIsWorking = false;
     _currentView        = null;
     base.End();
 }
예제 #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;
        }
예제 #6
0
 public override void End()
 {
     if (_currentView != null && _motioObject != null)
     {
         _motioObject = null;
     }
     _relevanceObject    = null;
     _relevanceMatrixd   = null;
     _behaviourIsWorking = false;
     _currentView        = null;
     base.End();
 }
예제 #7
0
        private void InitMotioObject()
        {
            if (_motioObject == null)
            {
                PtrClass a = ((IVdsGroupInterface)_currentView.GameLayer).GetObjectByID(ActorBindingID.Value);
                if (a == null)
                {
                    return;
                }
                _motioObject           = a as VdsActor;
                _motionObjectOriginPos = _motioObject.ActorTranslation;
                VdsVec3d   direction = new VdsVec3d(1, 0, 0);
                VdsMatrixd rMt       = new VdsMatrixd();
                VdsMatrixd.HprToMatrix(ref rMt, _motioObject.ActorRotation);
                direction = rMt.PreMult(direction);
                _motionObjectOriginDirection = direction;
            }
            if (_relevanceObject == null && ActorRelevanceID.Value != "" && (RelevanceRotation.Value || RelevancePosition.Value))
            {
                PtrClass a = ((IVdsGroupInterface)_currentView.GameLayer).GetObjectByID(ActorRelevanceID.Value);
                if (a != null)
                {
                    _relevanceObject = a as VdsActor;
                    if (RelevancePosition.Value || RelevanceRotation.Value)
                    {
                        VdsMatrixd localToWorld = new VdsMatrixd();
                        StaticMethod.ComputeCoordinateFrame(_motioObject.ParentObject as VdsActor, ref localToWorld);
                        StaticMethod.ComputeCoordinateFrame(_relevanceObject, ref _relevanceMatrixd);
                        VdsMatrixd worldToRelevance = _relevanceMatrixd.Inverse(_relevanceMatrixd);

                        _motionObjectOriginDirection = localToWorld.PreMult(_motionObjectOriginDirection);
                        _motionObjectOriginDirection = worldToRelevance.PreMult(_motionObjectOriginDirection);
                        VdsVec3d zPos = new VdsVec3d();
                        zPos = localToWorld.PreMult(zPos);
                        zPos = worldToRelevance.PreMult(zPos);
                        _motionObjectOriginDirection = _motionObjectOriginDirection - zPos;
                        _motionObjectOriginDirection.Normalize();
                        _motionObjectOriginPos = localToWorld.PreMult(_motionObjectOriginPos);
                        _motionObjectOriginPos = worldToRelevance.PreMult(_motionObjectOriginPos);
                        List <VdsVec3d> newKeyPointsList = new List <VdsVec3d>(ActorMotionKeyPoints.ValueList.Count);
                        foreach (VdsVec3d v in ActorMotionKeyPoints.ValueList)
                        {
                            VdsVec3d newV = localToWorld.PreMult(v);
                            newV = worldToRelevance.PreMult(newV);
                            newKeyPointsList.Add(newV);
                        }
                        ActorMotionKeyPoints.ValueList = newKeyPointsList;
                    }
                }
            }
        }
        private void InitMotioObject()
        {
            if (_motioObject == null)
            {
                PtrClass a = ((IVdsGroupInterface)_currentView.GameLayer).GetObjectByID(ActorBindingID.Value);
                if (a == null)
                {
                    return;
                }
                _motioObject = a as VdsActor;
                VdsVec3d   tRotate = TargetPose;
                VdsVec3d   oRotate = _motioObject.ActorRotation;
                VdsMatrixd oMt     = new VdsMatrixd();
                VdsMatrixd.HprToMatrix(ref oMt, tRotate);
                _targetPose = oMt.GetRotate();
                VdsMatrixd tMt = new VdsMatrixd();
                VdsMatrixd.HprToMatrix(ref tMt, oRotate);
                _originPose = tMt.GetRotate();
                _originPos  = _motioObject.ActorTranslation;
            }
            if (_relevanceObject == null && ActorRelevanceID.Value != "" && (RelevanceRotation.Value || RelevancePosition.Value))
            {
                PtrClass a = ((IVdsGroupInterface)_currentView.GameLayer).GetObjectByID(ActorRelevanceID.Value);
                if (a != null)
                {
                    _relevanceObject = a as VdsActor;
                    if (RelevancePosition.Value || RelevanceRotation.Value)
                    {
                        StaticMethod.ComputeCoordinateFrame(_relevanceObject, ref _relevanceMatrixd);
                        StaticMethod.ComputeCoordinateFrame(_motioObject.ParentObject as VdsActor, ref _parentLocalToWorld);
                        VdsMatrixd worldToRelevance = _relevanceMatrixd.Inverse(_relevanceMatrixd);
                        VdsMatrixd originPoseMt     = new VdsMatrixd();
                        originPoseMt.MakeRotate(_originPose);
                        originPoseMt.PreMult(_parentLocalToWorld);
                        originPoseMt.PreMult(worldToRelevance);
                        _originPose = originPoseMt.GetRotate();

                        VdsMatrixd targetPoseMt = new VdsMatrixd();
                        targetPoseMt.MakeRotate(_targetPose);
                        targetPoseMt.PreMult(_parentLocalToWorld);
                        targetPoseMt.PreMult(worldToRelevance);
                        _originPose = targetPoseMt.GetRotate();

                        _originPos = _parentLocalToWorld.PreMult(_originPos);
                        _originPos = worldToRelevance.PreMult(_originPos);
                    }
                }
            }
        }
예제 #9
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);
        }
 public override void End()
 {
     if (_currentView != null && _motioObject != null)
     {
         _motioObject = null;
     }
     _relevanceObject    = null;
     _relevanceMatrixd   = null;
     _parentLocalToWorld = null;
     _behaviourIsWorking = false;
     _originPose         = null;
     _originPos          = null;
     _targetPose         = null;
     _currentView        = null;
     base.End();
 }
예제 #11
0
        public override void Start()
        {
            if (FollowActorID.Value == null || FollowActorID.Value == "")
            {
                return;
            }
            string viewID = ParentActor.ObjectViewID.ToString();

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

            if (a != null)
            {
                _targetObject = a as VdsActor;
            }
            _behaviourIsWorking = true;
            _haveBeenSet        = false;
        }
예제 #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 (_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();
                }
            }
        }
예제 #13
0
        public static void ComputeCoordinateFrame(VdsActor actor, ref VdsMatrixd localToWorld)
        {
            VdsActor curActor = actor;

            localToWorld.MakeIdentity();
            while (curActor != null)
            {
                VdsMatrixd transMat = new VdsMatrixd();
                transMat.MakeTranslate(curActor.ActorTranslation);
                VdsMatrixd rotateMat = new VdsMatrixd();
                VdsMatrixd.HprToMatrix(ref rotateMat, curActor.ActorRotation);
                rotateMat.PostMult(transMat);
                localToWorld.PreMult(rotateMat);
                if (curActor.ParentObject != null && curActor.ParentObject is VdsActor)
                {
                    curActor = curActor.ParentObject as VdsActor;
                }
                else
                {
                    curActor = null;
                }
            }
        }
예제 #14
0
 public VdsGameActor(VdsActor cloneFrom)
     : base(cloneFrom)
 {
 }
예제 #15
0
 public VdsActor(VdsActor cloneFrom)
     : base(false)
 {
     CloneActor(cloneFrom);
 }
예제 #16
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;
            }
        }