Exemplo n.º 1
0
 public CC3CameraBuilder()
 {
     _cameraPostion = CC3Vector.CC3VectorZero;
     _cameraTarget = CC3Vector.CC3VectorZero;
     _cameraNearClippingDistance = CC3Camera.DefaultNearClippingDistance;
     _cameraFarClippingDistance = CC3Camera.DefaultFarClippingDistance;
 }
Exemplo n.º 2
0
        public void Is_CC3VectorMinimize_Robust()
        {
            CC3Vector vecA = new CC3Vector(-2.0f, 0.0f, 2.0f);
            CC3Vector vecB = new CC3Vector(2.0f, -2.0f, -2.0f);
            CC3Vector expectedMinVec = new CC3Vector(-2.0f);

            Assert.AreEqual(CC3Vector.CC3VectorMinimize(vecA, vecB), expectedMinVec);
        }
Exemplo n.º 3
0
 public CC3CameraAction(CC3Vector cameraTranslationChange, 
                        CC3Vector cameraTargetTranslationChange,
                        CC3Vector4 cameraAxisAndRotationInDegreesChangeRelativeToCameraTarget)
     : base(cameraTranslationChange)
 {
     _cameraTargetTranslationChange = cameraTargetTranslationChange;
     _cameraRotationChangeRelativeToCameraTarget
         = new CC3AnimatableRotation(cameraAxisAndRotationInDegreesChangeRelativeToCameraTarget);
 }
Exemplo n.º 4
0
        internal CC3AnimatableRotation(CC3Vector rotationAxis, float rotationInDegrees)
        {
            _rotationAxis = rotationAxis.NormalizedVector();
            _rotationInDegrees = rotationInDegrees;
            _listOfRotationTimingInfo = new List<RotationTimingInfo>();

            this.SetupQuaternionComponents();
            this.SetupQuaternionTiming();
        }
Exemplo n.º 5
0
        public CC3DrawableNode(CC3GraphicsContext graphicsContext)
            : base()
        {
            _graphicsContext = graphicsContext;
            _drawableNodeChildren = new List<CC3DrawableNode>();

            _worldScale = CC3Vector.CC3VectorUnitCube;
            _rotationChangeRelativeToAnchorNeededToUpdate = CC3Quaternion.CC3QuaternionIdentity;
            _rotationAnchorPointRelativeToPositionUsedForUpdate = CC3Vector.CC3VectorZero;
        }
Exemplo n.º 6
0
 public CC3TransformAction(CC3Vector translationChange, 
                           CC3Vector scaleChange, 
                           CC3Vector4 axisAndRotationInDegreesChangeRelativeToAnchor,
                           CC3Vector rotationAnchorPointRelativeToPosition)
     : base(translationChange)
 {
     _scaleChange = scaleChange;
     _rotationChangeRelativeToAnchor = new CC3AnimatableRotation(axisAndRotationInDegreesChangeRelativeToAnchor);
     _rotationAnchorPointRelativeToPosition = rotationAnchorPointRelativeToPosition;
 }
 public CC3CameraPerspectiveAction(CC3Vector cameraTranslationChange, 
                                   CC3Vector cameraTargetTranslationChange,
                                   CC3Vector4 cameraAxisAndRotationInDegreesChangeRelativeToCameraTarget,
                                   float cameraFieldOfViewInRadiansChange)
     : base(cameraTranslationChange, 
            cameraTargetTranslationChange,
            cameraAxisAndRotationInDegreesChangeRelativeToCameraTarget)
 {
     _cameraFieldOfViewInRadiansChange = cameraFieldOfViewInRadiansChange;
 }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        // Users should only create camera via corresponding builder class
        internal CC3CameraOrthographic(CC3Vector cameraPosition, CC3Vector cameraTarget, 
                                      float viewWidth, float viewHeight, 
                                      float nearClippingDistance, float farClippingDistance)
            : base(cameraPosition, cameraTarget)
        {
            _viewWidth = viewWidth;
            _viewHeight = viewHeight;
            _nearClippingDistance = nearClippingDistance;
            _farClippingDistance = farClippingDistance;

            this.UpdateProjectionMatrix();
        }
Exemplo n.º 10
0
        // Users should only create camera via corresponding builder class
        internal CC3CameraPerspective(CC3Vector cameraPosition, CC3Vector cameraTarget, 
                                      float fieldOfView, float aspectRatio, 
                                      float nearClippingDistance, float farClippingDistance)
            : base(cameraPosition, cameraTarget)
        {
            _fieldOfView = fieldOfView;
            _aspectRatio = aspectRatio;
            _nearClippingDistance = nearClippingDistance;
            _farClippingDistance = farClippingDistance;

            this.UpdateProjectionMatrix();
        }
Exemplo n.º 11
0
        public static CC3Matrix CreateCameraViewMatrix(CC3Vector cameraPosition, 
                                                       CC3Vector cameraTarget,
                                                       CC3Quaternion cameraRotationRelativeToTarget,
                                                       CC3Vector 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 CC3Matrix(xnaViewMatrix);
        }
Exemplo n.º 12
0
        private void InitializeCameraForTextureTest()
        {
            CC3Vector cameraPos = new CC3Vector(750.0f, 1000.0f, 10.0f);
            CC3Vector cameraTarget = new CC3Vector(0.0f, 300.0f, 0.0f);
            float cameraFieldOfViewInDegrees = 45.0f;
            float cameraAspectRatio = _graphicsContext.ScreenAspectRatio;
            float cameraNearClippingDistance = 200.0f;
            float cameraFarClippingDistance = 10000.0f;

            CC3CameraPerspectiveBuilder cameraBuilder = new CC3CameraPerspectiveBuilder();
            cameraBuilder.PositionAtPoint(cameraPos).LookingAtPoint(cameraTarget);
            cameraBuilder.WithFieldOfView(cameraFieldOfViewInDegrees).WithAspectRatio(cameraAspectRatio);
            cameraBuilder.WithNearAndFarClippingDistances(cameraNearClippingDistance, cameraFarClippingDistance);

            _camera = cameraBuilder.Build();

            this.ActiveCamera = _camera;
        }
Exemplo n.º 13
0
        private void InitializeCamera()
        {
            CC3Vector cameraPos = new CC3Vector(0.0f, 10.0f, 5.0f);
            CC3Vector cameraTarget = new CC3Vector(0.0f, 0.0f, -10.0f);
            float cameraFieldOfViewInDegrees = 60.0f;
            float cameraAspectRatio = _graphicsContext.ScreenAspectRatio;
            float cameraNearClippingDistance = 1.0f;
            float cameraFarClippingDistance = 10000.0f;

            CC3CameraPerspectiveBuilder cameraBuilder = new CC3CameraPerspectiveBuilder();
            cameraBuilder.PositionAtPoint(cameraPos).LookingAtPoint(cameraTarget);
            cameraBuilder.WithFieldOfView(cameraFieldOfViewInDegrees).WithAspectRatio(cameraAspectRatio);
            cameraBuilder.WithNearAndFarClippingDistances(cameraNearClippingDistance, cameraFarClippingDistance);

            _camera = cameraBuilder.Build();

            // Replace above block with below to instead use an orthographic camera
            /*
            CC3CameraOrthographicBuilder cameraBuilder = new CC3CameraOrthographicBuilder();
            cameraBuilder.PositionAtPoint(cameraPos).LookingAtPoint(cameraTarget);
            cameraBuilder.WithViewWidth(10.0f * cameraAspectRatio).WithViewHeight(10.0f);
            cameraBuilder.WithNearAndFarClippingDistances(cameraNearClippingDistance, cameraFarClippingDistance);

            _camera = cameraBuilder.Build() as CC3CameraOrthographic;
            */

            this.ActiveCamera = _camera;
        }
Exemplo n.º 14
0
 protected virtual void FinishedUpdatingWorldMatrix()
 {
     _worldTranslationChangeNeededToUpdate = CC3Vector.CC3VectorZero;
 }
Exemplo n.º 15
0
        internal void IncrementallyUpdateWorldTranslation(CC3Vector translationChange)
        {
            _worldTranslationChangeNeededToUpdate = translationChange;

            this.ShouldUpdateWorldMatrix();
        }
 public CC3ActionBuilder MoveByTranslationOffset(CC3Vector translationOffset)
 {
     _translationChange = translationOffset;
     return this;
 }
Exemplo n.º 17
0
 public CC3CameraBuilder LookingInDirection(CC3Vector worldDirection)
 {
     // This assumes camera position has been set prior
     _cameraTarget = _cameraPostion + worldDirection.NormalizedVector();
     return this;
 }
Exemplo n.º 18
0
        public CC3CameraActionBuilder RotateCameraAroundAxisRelativeToTargetByDegrees(CC3Vector rotationAxis, 
                                                                                      float rotationInDegrees)
        {
            _cameraAxisAndRotationInDegreesChangeRelativeToCameraTarget = new CC3Vector4(rotationAxis, rotationInDegrees);

            return this;
        }
Exemplo n.º 19
0
        public static CC3Matrix CreateWorldMatrix(CC3Vector worldPosition, 
                                                  CC3Vector worldScale,
                                                  CC3Quaternion localRotation,
                                                  CC3Quaternion rotationRelativeToAnchor,
                                                  CC3Vector 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 CC3Matrix(xnaTranslationMatrix *
                                 Matrix.Invert(xnaRotationAnchorTranslationMatrix) *
                                 xnaRotationRelativeToAnchorMatrix *
                                 xnaRotationAnchorTranslationMatrix *
                                 xnaLocalRotationMatrix *
                                 xnaScaleMatrix);
        }
Exemplo n.º 20
0
 // Position of camera methods
 public CC3CameraBuilder PositionAtPoint(CC3Vector cameraPosition)
 {
     _cameraPostion = cameraPosition;
     return this;
 }
Exemplo n.º 21
0
        internal void IncrementallyUpdateWorldTransform(CC3Vector translationChange, 
                                                        CC3Vector scaleChange, 
                                                        CC3Quaternion rotationChangeRelativeToAnchor,
                                                        CC3Vector rotationAnchorPointRelativeToPosition)
        {
            this.WorldTranslationChangeNeededToUpdate = translationChange;
            _rotationChangeRelativeToAnchorNeededToUpdate = rotationChangeRelativeToAnchor;
            _rotationAnchorPointRelativeToPositionUsedForUpdate = rotationAnchorPointRelativeToPosition;

            _worldScale += scaleChange;

            this.ShouldUpdateWorldMatrix();
        }
Exemplo n.º 22
0
 public CC3TranslationAction(CC3Vector translationChange)
 {
     _translationChange = translationChange;
 }
Exemplo n.º 23
0
        protected override void FinishedUpdatingWorldMatrix()
        {
            _rotationChangeRelativeToAnchorNeededToUpdate = CC3Quaternion.CC3QuaternionIdentity;
            _rotationAnchorPointRelativeToPositionUsedForUpdate = CC3Vector.CC3VectorZero;

            base.FinishedUpdatingWorldMatrix();
        }
Exemplo n.º 24
0
 public CC3CameraActionBuilder PanCameraByTranslationOffset(CC3Vector panningTranslationOffset)
 {
     _translationChange = panningTranslationOffset;
     _cameraTargetTranslationChange = panningTranslationOffset;
     return this;
 }
Exemplo n.º 25
0
        public override void Reset()
        {
            base.Reset();

            _cameraTargetTranslationChange = CC3Vector.CC3VectorZero;
            _cameraAxisAndRotationInDegreesChangeRelativeToCameraTarget = new CC3Vector4(CC3Vector.CC3VectorUp, 0.0f);
        }
Exemplo n.º 26
0
 public CC3Node()
 {
     _worldTranslationChangeNeededToUpdate = CC3Vector.CC3VectorZero;
     _worldMatrix = CC3Matrix.CC3MatrixIdentity;
 }
Exemplo n.º 27
0
 public CC3CameraBuilder PositionAtNode(CC3Node node, CC3Vector offset)
 {
     _cameraPostion = node.WorldPosition + offset;
     return this;
 }
Exemplo n.º 28
0
 public CC3Node(CC3Vector worldPosition)
     : this()
 {
     _worldMatrix = CC3Matrix.CreateTranslationMatrix(worldPosition);
 }
Exemplo n.º 29
0
        public static CC3Matrix CreateTranslationMatrix(CC3Vector worldTranslation)
        {
            Matrix xnaTranslationMatrix = Matrix.CreateTranslation(worldTranslation.XnaVector);

            return new CC3Matrix(xnaTranslationMatrix);
        }
 public override void Reset()
 {
     _translationChange = CC3Vector.CC3VectorZero;
 }