Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
 public override void Apply(PtrClass obj)
 {
     if (obj != null && IsIdle)
     {
         ApplyEffectInternal(NativeHandle, obj.NativeHandle, true);
         IsIdle = false;
     }
 }
Ejemplo n.º 3
0
        internal void RemoveActorInternal(string actorID)
        {
            PtrClass vActor = GetObjectByID(actorID);

            if (actorID != null)
            {
                RemoveChild(vActor);
            }
        }
Ejemplo n.º 4
0
        internal void AddActorInternal(string actorID)
        {
            PtrClass actor = GetObjectByID(actorID);

            if (actor != null)
            {
                return;
            }
            PtrClass findActor = GetInternalChildByID(actorID, false);

            AddChild(findActor);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 6
0
 public virtual void SetParent(PtrClass parent)
 {
     _parentObject = parent;
     if (parent != null)
     {
         ObjectViewID = parent.ObjectViewID;
     }
     else
     {
         ObjectViewID = -1;
     }
 }
Ejemplo n.º 7
0
 public virtual void SetParent(PtrClass parent)
 {
     if (parent is VdsActorBase)
     {
         _parentObject = parent as VdsActorBase;
         ObjectViewID  = _parentObject.ObjectViewID;
     }
     else
     {
         _parentObject = null;
         ObjectViewID  = -1;
     }
 }
Ejemplo n.º 8
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);
                    }
                }
            }
        }
Ejemplo n.º 10
0
 private void DoRemoveChild(PtrClass child)
 {
     if (_childrenList != null && _childrenList.Contains(child))
     {
         if (child.IsCreateInScript)
         {
             RemoveChildInternal(this.NativeHandle, child.NativeHandle);
         }
         lock (_locker)
         {
             _childrenList.Remove(child);
         }
         (child as IVdsNodeInterface).SetParent(null);
     }
 }
Ejemplo n.º 11
0
        public virtual void RemoveChild(PtrClass child)
        {
            if (_callRemoveChild == null)
            {
                _callRemoveChild = DoRemoveChild;
            }
            IAsyncResult result = _callRemoveChild.BeginInvoke(
                child,
                delegate(IAsyncResult ar)
            {
                _callRemoveChild.EndInvoke(ar);
            },
                null);

            result.AsyncWaitHandle.WaitOne(50, true);
        }
Ejemplo n.º 12
0
 private void DoAddChild(PtrClass child)
 {
     AddChildInternal(this.NativeHandle, child.NativeHandle);
     if (_childrenList == null)
     {
         _childrenList = new List <PtrClass>();
     }
     if (_childrenList.Contains(child))
     {
         return;
     }
     lock (_locker)
     {
         _childrenList.Add(child);
     }
     (child as IVdsNodeInterface).SetParent(this);
 }
Ejemplo n.º 13
0
 public virtual void AddChild(PtrClass child)
 {
     if (child is VdsTransform)
     {
         if (_callAddChild == null)
         {
             _callAddChild = DoAddChild;
         }
         IAsyncResult result = _callAddChild.BeginInvoke(
             child as VdsTransform,
             delegate(IAsyncResult ar)
         {
             _callAddChild.EndInvoke(ar);
         },
             null);
         result.AsyncWaitHandle.WaitOne(50, true);
     }
 }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
0
 public PtrClass GetObjectByID(string idOrBinding)
 {
     if (idOrBinding == "" || idOrBinding == null)
     {
         return(null);
     }
     for (int i = _childrenList.Count - 1; i >= 0; i--)
     {
         if (_childrenList[i] is PtrClass)
         {
             PtrClass actor = _childrenList[i] as PtrClass;
             if (actor.ObjectID == idOrBinding || actor.ObjectBindID == idOrBinding)
             {
                 return(actor);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 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 (_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();
                }
            }
        }
Ejemplo n.º 17
0
        public PtrClass GetObjectByID(string idOrBindingID)
        {
            PtrClass actor = ((IVdsGroupInterface)_rootLayer).GetObjectByID(idOrBindingID);

            if (actor != null)
            {
                return(actor);
            }
            actor = ((IVdsGroupInterface)GameLayer).GetObjectByID(idOrBindingID);
            if (actor != null)
            {
                return(actor);
            }
            if (CurrentSceneLayer != null)
            {
                actor = ((IVdsGroupInterface)CurrentSceneLayer).GetObjectByID(idOrBindingID);
                if (actor != null)
                {
                    return(actor);
                }
            }
            return(null);
        }
Ejemplo n.º 18
0
        public PtrClass GetActorByNativeHandle(IntPtr ptr)
        {
            PtrClass actor = ((IVdsGroupInterface)_rootLayer).GetActorByNativeHandle(ptr);

            if (actor != null)
            {
                return(actor);
            }
            actor = ((IVdsGroupInterface)GameLayer).GetActorByNativeHandle(ptr);
            if (actor != null)
            {
                return(actor);
            }
            if (CurrentSceneLayer != null)
            {
                actor = ((IVdsGroupInterface)CurrentSceneLayer).GetActorByNativeHandle(ptr);
                if (actor != null)
                {
                    return(actor);
                }
            }
            return(null);
        }
Ejemplo n.º 19
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;
            }
        }
Ejemplo n.º 20
0
 public abstract void Apply(PtrClass obj);