Beispiel #1
0
        //-----------------------
        public UberTexturePainter()
        {
            this.Plane          = new Plane();
            IsRestrictedToPlane = false;

            // create the cameras.
            _maskCamera   = new Camera(new Vector3(), new Matrix3x3(), new Projection(-1.0f, 1.0f, -1.0f, 1.0f, 10.0f));
            _sourceCamera = new Camera(new Vector3(), new Matrix3x3(), new Projection(-1.0f, 1.0f, -1.0f, 1.0f, 10.0f));

            // create the rasterizer.
            _rasterizer = new UberTextureRasterizer();

            // allocate the index array.
            _visibleTriangles = new ushort[65536];

            // initialize to additive.
            _maskPaintMode = MaskMode.Add;
        }
        //================================
        // public methods.
        //================================

        //--------------------------------
        public void Cast()
        {
            // if we've already started casting, simply return.
            if (_started)
            {
                return;
            }

            // mark the operation as started and begin running.
            _started = true;

            // initialize the progress callback delegate.
            UberTextureRasterizer.CastProgressCallback progressCallback = new
                                                                          UberTextureRasterizer.CastProgressCallback(CastCallback);

            bool castNormal   = (_castOptions.Options & DetailCastDialog.CastOptions.CastNormal) != 0;
            bool castBump     = (_castOptions.Options & DetailCastDialog.CastOptions.CastBump) != 0;
            bool smoothSource = (_castOptions.Options & DetailCastDialog.CastOptions.SmoothSource) != 0;

            // start the casting operation.
            try
            {
                UberTextureRasterizer rasterizer = new UberTextureRasterizer();
                rasterizer.CastGeometry(progressCallback, _castOptions.ObjFilePath, _castOptions.MaxRayLength,
                                        castNormal, castBump, _castOptions.BumpScale, smoothSource);
            }
            catch (System.ApplicationException)
            {
                // done.
                this.Close();
            }

            // update the dialog here to show that we're finished.
            lblStatus.Text = "Done!\n";
            bnOK.Enabled   = true;

            GC.KeepAlive(progressCallback);
        }