示例#1
0
        // Billboard effect orients the mesh so that it is always turned towards the camera
        private void ApplyBillboardMatrix()
        {
            Matrix3D view, proj;
            bool     isMatrixValid = Camera1.GetCameraMatrices(out view, out proj);

            if (!isMatrixValid)
            {
                return;
            }

            // To create a billboard effect, we invert the camera's view matrix and reset the offset components
            view.Invert();
            view.OffsetX = 0;
            view.OffsetY = 0;
            view.OffsetZ = 0;

            var matrixTransform3D = _shownLineModel3D.Transform as MatrixTransform3D;

            if (matrixTransform3D != null && !matrixTransform3D.IsFrozen)
            {
                matrixTransform3D.Matrix = view;
            }
            else
            {
                _shownLineModel3D.Transform = new MatrixTransform3D(view);
                MeshInspector.Transform     = _shownLineModel3D.Transform;
            }
        }