예제 #1
0
 private void StartUpdateMaterialPreviewLoop()
 {
     // Unholy poll. This is the only case where material previews are
     // needed other than the material panel itself.
     MainViewer3DControl.DelayExecution(new TimeSpan(0, 0, 0, 0, 1000),
                                        () =>
     {
         UpdateMaterialPreview();
         StartUpdateMaterialPreviewLoop();
     });
 }
예제 #2
0
        public MeshDetailsDialog(MainViewer3DControl host, Scene scene)
        {
            Debug.Assert(host != null);
            _host  = host;
            _scene = scene;

            InitializeComponent();
            // TODO(acgessler): Factor out preview generation and getting the checker pattern
            // background into a separate utility.
            pictureBoxMaterial.SizeMode              = PictureBoxSizeMode.Zoom;
            pictureBoxMaterial.BackgroundImage       = MaterialThumbnailControl.GetBackgroundImage();
            pictureBoxMaterial.BackgroundImageLayout = ImageLayout.Zoom;

            StartUpdateMaterialPreviewLoop();
        }
예제 #3
0
        public LogViewer(MainViewer3DControl mainWindow)
        {
            _mainWindow = mainWindow;
            InitializeComponent();

            _mainWindow.TabChanged += (tab, add) =>
            {
                if (IsDisposed)
                {
                    return;
                }
                PopulateList();
            };

            PopulateList();
        }
예제 #4
0
        public MaterialInspectionView(Scene scene, MainViewer3DControl window, FlowLayoutPanel flow)
            : base(flow)
        {
            _scene  = scene;
            _window = window;

            foreach (var mat in scene.Raw.Materials)
            {
                var dependencies = new HashSet <string>();
                var textures     = mat.GetAllMaterialTextures();
                foreach (var tex in textures)
                {
                    dependencies.Add(tex.FilePath);
                }

                AddMaterialEntry(mat, dependencies);
            }
        }
예제 #5
0
        /// <summary>
        /// Constructs a MaterialPreviewRenderer to obtain a preview image
        /// for one given material.
        /// </summary>
        /// <param name="window">Window instance that hosts the primary Gl context</param>
        /// <param name="scene">Scene instance that the material belongs to</param>
        /// <param name="material">Material to render a preview image for</param>
        /// <param name="width">Requested width of the preview image, in pixels</param>
        /// <param name="height">Requested height of the preview image, in pixels</param>
        public MaterialPreviewRenderer(MainViewer3DControl window, Scene scene, Material material, uint width, uint height)
        {
            Debug.Assert(window != null);
            Debug.Assert(material != null);
            Debug.Assert(scene != null);
            Debug.Assert(width >= 1);
            Debug.Assert(height >= 1);

            _scene    = scene;
            _material = material;
            _width    = width;
            _height   = height;

            _state = CompletionState.Pending;

            window.Renderer.GlExtraDrawJob += (sender) =>
            {
                _state = !RenderPreview() ? CompletionState.Failed : CompletionState.Done;
                OnPreviewAvailable();
            };
        }
예제 #6
0
        public ExportDialog(MainViewer3DControl main)
        {
            _main = main;
            InitializeComponent();

            using (var v = new AssimpContext())
            {
                _formats = v.GetSupportedExportFormats();
                foreach (var format in _formats)
                {
                    comboBoxExportFormats.Items.Add(format.Description + "  (" + format.FileExtension + ")");
                }
                comboBoxExportFormats.SelectedIndex         = ExportSettings.Default.ExportFormatIndex;
                comboBoxExportFormats.SelectedIndexChanged += (object s, EventArgs e) =>
                {
                    ExportSettings.Default.ExportFormatIndex = comboBoxExportFormats.SelectedIndex;
                    UpdateFileName(true);
                };
            }

            textBoxFileName.KeyPress += (object s, KeyPressEventArgs e) =>
            {
                _changedText = true;
            };

            // Respond to updates in the main window - the export dialog is non-modal and
            // always takes the currently selected file at the time the export button
            // is pressed.
            _main.SelectedTabChanged += (Tab tab) =>
            {
                UpdateFileName();
                UpdateCaption();
            };

            UpdateFileName();
            UpdateCaption();
        }
예제 #7
0
        public void SetNode(MainViewer3DControl mainWindow, Scene scene, Node node)
        {
            _node  = node;
            _scene = scene;

            var matrix4X4 = _node.Transform;

            trafoMatrixViewControlLocal.SetMatrix(ref matrix4X4);

            var mat = Matrix4x4.Identity;
            var cur = node;

            while (cur != null)
            {
                var trafo = cur.Transform;
                trafo.Transpose();
                mat = trafo * mat;
                cur = cur.Parent;
            }
            mat.Transpose();
            trafoMatrixViewControlGlobal.SetMatrix(ref mat);

            Text = node.Name + " - Node Details";

            // populate statistics
            labelMeshesDirect.Text   = node.MeshCount.ToString(CultureInfo.InvariantCulture);
            labelChildrenDirect.Text = node.ChildCount.ToString(CultureInfo.InvariantCulture);

            var meshTotal  = 0;
            var childTotal = 0;

            CountMeshAndChildrenTotal(node, ref meshTotal, ref childTotal);

            labelMeshesTotal.Text   = node.MeshCount.ToString(CultureInfo.InvariantCulture);
            labelChildrenTotal.Text = node.ChildCount.ToString(CultureInfo.InvariantCulture);
        }
예제 #8
0
 /// <summary>
 /// Construct a renderer given a valid and fully loaded MainWindow
 /// </summary>
 /// <param name="window">Main window, Load event of the GlContext
 ///    needs to be fired already.</param>
 internal Renderer(MainViewer3DControl window)
 {
     _window      = window;
     _textOverlay = new TextOverlay(this);
 }