/// <summary>
 /// Visits the specified transformation to collect data if required by the current Visitor derivate.
 /// </summary>
 /// <param name="transformation">The transformation.</param>
 public virtual void Visit(Transformation transformation)
 {
 }
 /// <summary>
 /// Init is called upon creation of an ActionCode Object and utilizes the access to a SceneEntitie's transform and renderer objects.
 /// </summary>
 /// <param name="entity">The owner entity of this component.</param>
 public void Init(SceneEntity entity)
 {
     SceneEntity = entity;
     transform = SceneEntity.transform;
     renderer = SceneEntity.renderer;
 }
        /// <summary>
        /// Adds the transform object to the internal stack.
        /// </summary>
        /// <param name="transform">The transform.</param>
        private void AddTransform(Transformation transform)
        {
            if (_mtxModelViewStack.Count > 0)
            {
                if (transform.GlobalMatrixDirty)
                {
                    transform.Matrix = transform.GlobalMatrix*float4x4.Invert(_mtxModelViewStack.Peek());
                    transform.SetGlobalMat(_mtxModelViewStack.Peek()*transform.Matrix);
                    _mtxModelViewStack.Push(_mtxModelViewStack.Pop()*transform.Matrix);
                    //Debug.WriteLine("Matrix: " + transform.GlobalMatrix + " Point: " + transform.GlobalPosition);

                        _hasTransform.Pop();
                        _hasTransform.Push(true);

                    if (HasRenderingTriple())
                    {
                        AddRenderJob(_mtxModelViewStack.Peek(), _meshStack.Peek(), _RendererStack.Peek());
                    }
                    return;
                }

                transform.SetGlobalMat(_mtxModelViewStack.Peek()*transform.Matrix);
                _mtxModelViewStack.Push(_mtxModelViewStack.Pop()*transform.Matrix);
                //Debug.WriteLine("Matrix: " + transform.GlobalMatrix + " Point: " + transform.GlobalPosition);

                    _hasTransform.Pop();
                    _hasTransform.Push(true);

                if (HasRenderingTriple())
                {
                    AddRenderJob(_mtxModelViewStack.Peek(), _meshStack.Peek(), _RendererStack.Peek());
                }

            }else
            {
                _mtxModelViewStack.Push(transform.GlobalMatrix);
                //Debug.WriteLine("Matrix: " + transform.GlobalMatrix + " Point: " + transform.GlobalPosition);

                    if (_hasTransform.Count > 0)
                    {
                        _hasTransform.Pop();
                    }

                    _hasTransform.Push(true);

                if (HasRenderingTriple())
                {
                    AddRenderJob(_mtxModelViewStack.Peek(), _meshStack.Peek(), _RendererStack.Peek());
                }

            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Camera"/> class. The ViewMatrix will be set to a provided float 4x4 matrix.
 /// </summary>
 /// <param name="cameratransformation">The matrix that will become the Viewmatrix.</param>
 public Camera(Transformation cameratransformation)
 {
     ViewMatrix = cameratransformation.GlobalMatrix;
     ProjectionType(proj);
 }
 /// <summary>
 /// Visits the specified <see cref="Transformation"/>.
 /// </summary>
 /// <param name="transform">The transformation instance.</param>
 public override void Visit(Transformation transform)
 {
     AddTransform(transform);
 }