Example #1
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);
                    }
                }
            }
        }
Example #3
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;
                }
            }
        }