Example #1
0
        public CC3DrawableNode(CC3GraphicsContext graphicsContext)
            : base()
        {
            _graphicsContext = graphicsContext;
            _drawableNodeChildren = new List<CC3DrawableNode>();

            _worldScale = CC3Vector.CC3VectorUnitCube;
            _rotationChangeRelativeToAnchorNeededToUpdate = CC3Quaternion.CC3QuaternionIdentity;
            _rotationAnchorPointRelativeToPositionUsedForUpdate = CC3Vector.CC3VectorZero;
        }
Example #2
0
        // Users should only create camera via corresponding builder class
        internal CC3Camera(CC3Vector cameraPosition, CC3Vector cameraTarget)
            : base(cameraPosition)
        {
            _cameraTarget = cameraTarget;
            _cameraRotationChangeRelativeToTargetNeededToUpdate = CC3Quaternion.CC3QuaternionIdentity;

            _cameraUpDirection
                = CC3Vector.CC3VectorUp + (cameraPosition - cameraTarget).NormalizedVector();

            this.UpdateViewMatrix();
        }
Example #3
0
        public static LCC3Matrix4x4 CreateCameraViewMatrix(LCC3Vector cameraPosition, 
                                                           LCC3Vector cameraTarget,
                                                           CC3Quaternion cameraRotationRelativeToTarget,
                                                           LCC3Vector cameraUpDirection)
        {
            Vector3 xnaCameraPosAfterRotation
                = Vector3.Transform(cameraPosition.XnaVector - cameraTarget.XnaVector,
                                    cameraRotationRelativeToTarget.XnaQuaternion);

            xnaCameraPosAfterRotation += cameraTarget.XnaVector;

            Matrix xnaViewMatrix = Matrix.CreateLookAt(xnaCameraPosAfterRotation,
                                                       cameraTarget.XnaVector,
                                                       cameraUpDirection.XnaVector);

            return new LCC3Matrix4x4(xnaViewMatrix);
        }
 internal RotationTimingInfo(CC3Quaternion quaternion, 
                             float startingTimeFraction, 
                             float durationTimeFraction,
                             float rotationAmountInDegrees)
 {
     _quaternion = quaternion;
     _startingTimeFraction = startingTimeFraction;
     _durationTimeFraction = durationTimeFraction;
     _rotationAmountInDegrees = rotationAmountInDegrees;
 }
 internal RotationTimingInfo(CC3Quaternion quaternion)
     : this(quaternion, 0.0f, 0.0f, 0.0f)
 {
 }
Example #6
0
        public static LCC3Matrix4x4 CreateWorldMatrix(LCC3Vector worldPosition, 
                                                      LCC3Vector worldScale,
                                                      CC3Quaternion localRotation,
                                                      CC3Quaternion rotationRelativeToAnchor,
                                                      LCC3Vector anchorPointRelativeToPosition)
        {
            Matrix xnaTranslationMatrix = Matrix.CreateTranslation(worldPosition.XnaVector);
            Matrix xnaScaleMatrix = Matrix.CreateScale(worldScale.XnaVector);
            Matrix xnaLocalRotationMatrix = Matrix.CreateFromQuaternion(localRotation.XnaQuaternion);
            Matrix xnaRotationRelativeToAnchorMatrix = Matrix.CreateFromQuaternion(rotationRelativeToAnchor.XnaQuaternion);
            Matrix xnaRotationAnchorTranslationMatrix = Matrix.CreateTranslation(anchorPointRelativeToPosition.XnaVector);

            return new LCC3Matrix4x4(xnaTranslationMatrix *
                                     Matrix.Invert(xnaRotationAnchorTranslationMatrix) *
                                     xnaRotationRelativeToAnchorMatrix *
                                     xnaRotationAnchorTranslationMatrix *
                                     xnaLocalRotationMatrix *
                                     xnaScaleMatrix);
        }
Example #7
0
        public CC3Quaternion LocalRotationOfTransformMatrix()
        {
            CC3Quaternion localRotation = CC3Quaternion.CC3QuaternionIdentity;
            Vector3 xnaTranslation;
            Vector3 xnaScale;
            Quaternion xnaRotation;

            if (this.XnaMatrix.Decompose(out xnaScale, out xnaRotation, out xnaTranslation) == true)
            {
                localRotation = new CC3Quaternion(xnaRotation);
            }

            return localRotation;
        }
Example #8
0
        internal void IncrementallyUpdateWorldTransform(CC3Vector translationChange, 
                                                        CC3Vector scaleChange, 
                                                        CC3Quaternion rotationChangeRelativeToAnchor,
                                                        CC3Vector rotationAnchorPointRelativeToPosition)
        {
            this.WorldTranslationChangeNeededToUpdate = translationChange;
            _rotationChangeRelativeToAnchorNeededToUpdate = rotationChangeRelativeToAnchor;
            _rotationAnchorPointRelativeToPositionUsedForUpdate = rotationAnchorPointRelativeToPosition;

            _worldScale += scaleChange;

            this.ShouldUpdateWorldMatrix();
        }
Example #9
0
        protected override void FinishedUpdatingWorldMatrix()
        {
            _rotationChangeRelativeToAnchorNeededToUpdate = CC3Quaternion.CC3QuaternionIdentity;
            _rotationAnchorPointRelativeToPositionUsedForUpdate = CC3Vector.CC3VectorZero;

            base.FinishedUpdatingWorldMatrix();
        }
Example #10
0
        private void FinishedUpdatingViewMatrix()
        {
            _cameraRotationChangeRelativeToTargetNeededToUpdate = CC3Quaternion.CC3QuaternionIdentity;

            base.FinishedUpdatingWorldMatrix();
        }
Example #11
0
        // Update view matrix methods
        internal void IncrementallyUpdateViewTransform(CC3Vector cameraTranslationChange, 
                                                       CC3Vector cameraTargetTranslationChange,
                                                       CC3Quaternion cameraRotationChangeRelativeToTarget)
        {
            this.WorldTranslationChangeNeededToUpdate = cameraTranslationChange;
            _cameraRotationChangeRelativeToTargetNeededToUpdate = cameraRotationChangeRelativeToTarget;
            _cameraTarget += cameraTargetTranslationChange;
            _cameraUpDirection = _cameraUpDirection.RotatedVector(cameraRotationChangeRelativeToTarget);

            this.ShouldUpdateViewMatrix();
        }