/// <summary>
        /// Service routine for "Reload" button.
        ///     1. Create a new RT engine to parse command file
        ///     2. Sets the Debug state to the RT engine (Debug pixel/rays)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mReloadCmdFile_Click(object sender, EventArgs e)
        {
            if (System.IO.File.Exists(mCmdFileName))
            {
                StopRT(sender, e);

                String fileName = System.IO.Path.GetFileName(mCmdFileName);
                mCmdFileNameEcho.Text = fileName;
                mStatusArea.Text      = "Parsing command file: " + fileName;

                if (null != mRT)
                {
                    mRT.AbortRTThread();
                }
                mRT = new RTCore(this, mCmdFileName, mMeshLoader);
                mRT.SetDebugPixels(DebugPixels.Checked);
                mRT.SetDebugRays(DebugRays.Checked);
                mRT.SetShowPixelInWorld(PixelInWorld.Checked);
                mRT.SetDrawDB(DrawDB.Checked);
                mRT.SetOrthoRT(OrthoRT.Checked);
                mRT.SetMultiThreadCompute(MultiThreadCompute.Checked);
                mRT.SetAnaglyph(listAnaglyph.SelectedItem.ToString());
                mNewSceneForGUI = true;
            }
            else
            {
                mStatusArea.Text = "Invalid Command File: " + mCmdFileName;
            }
        }
        public void AddDebugPixel(RayTracer_552.RTCore rtCore, Vector3 cameraPos)
        {
            if (null == rtCore)
            {
                return;
            }

            while ((mShownPixelY < rtCore.CurrentY) ||
                   (((mShownPixelY == rtCore.CurrentY) && (mShownPixelX < rtCore.CurrentX))))
            {
                lock (rtCore)
                {
                    Vector3 p = new Vector3();
                    System.Drawing.Color c = new System.Drawing.Color();
                    float dist;
                    rtCore.GetPixelValues(mShownPixelX, mShownPixelY, out p, out c, out dist);

                    GetPixelPosition(ref p, cameraPos, dist);
                    {
                        ShowOneDebugPixelAt(p, c);
                        mNumPixelNodesUsed++;
                    }

                    mShownPixelX++;
                    if (mShownPixelX >= rtCore.ImageWidth)
                    {
                        mShownPixelX = 0;
                        mShownPixelY++;
                    }
                }
            }
        }
Exemple #3
0
 internal void AddPixelInWorld(RayTracer_552.RTCore rtCore)
 {
     if (null == rtCore)
     {
         return;
     }
     mPixelInWorld.AddDebugPixel(rtCore, mCameraPosition);
 }
        /// <summary>
        /// Constructor (called from RayTraceViewer::Initialization. Build a temporary GUI frame.
        /// </summary>
        public RTWindow()
        {
            InitializeComponent();

            mRT = null;

            int w = kInitImageW;
            int h = kInitImageH;

            int totalW = 2 * w + kXOffset + 3 * kSpace;
            int totalH = h + kYOffset + 2 * kSpace;
            SetClientSizeCore(totalW, totalH);
        }
        /// <summary>
        /// Constructor (called from RayTraceViewer::Initialization. Build a temporary GUI frame.
        /// </summary>
        public RTWindow()
        {
            InitializeComponent();

            mRT = null;

            int w = kInitImageW;
            int h = kInitImageH;

            int totalW = 2 * w + kXOffset + 3 * kSpace;
            int totalH = h + kYOffset + 2 * kSpace;

            SetClientSizeCore(totalW, totalH);
        }
Exemple #6
0
        internal void AddDebugRays(RayTracer_552.RTCore rtCore)
        {
            if (null == rtCore)
            {
                return;
            }

            while ((mShownRayY < rtCore.CurrentY) ||
                   (((mShownRayY == rtCore.CurrentY) && (mShownRayX < rtCore.CurrentX))))
            {
                lock (rtCore)
                {
                    Vector3 p = new Vector3();
                    System.Drawing.Color c = new System.Drawing.Color();
                    float dist;
                    rtCore.GetPixelValues(mShownRayX, mShownRayY, out p, out c, out dist);

                    if (rtCore.DisplayDebugRays())
                    {
                        UWB_PrimitiveLine line = new UWB_PrimitiveLine();
                        Vector3           v    = p - mCameraPosition;
                        float             len  = v.Length();
                        v /= len;
                        if (dist > (float.MaxValue / 2f))
                        {
                            dist = len;
                        }
                        p = mCameraPosition + dist * v;
                        line.setStartPoint(mCameraPosition.X, mCameraPosition.Y, mCameraPosition.Z);
                        line.setEndPoint(p.X, p.Y, p.Z);
                        line.Material.Diffuse  = Vector4.Zero;
                        line.Material.Specular = Vector4.Zero;
                        line.Material.Ambient  = Vector4.Zero;
                        line.Material.Emissive = Vector4.One;
                        mRaysToShow.append(line);
                    }

                    mShownRayX++;
                    if (mShownRayX >= rtCore.ImageWidth)
                    {
                        mShownRayX = 0;
                        mShownRayY++;
                    }
                }
            }
        }
Exemple #7
0
        internal void AddImageFrame(RayTracer_552.RTCore rtCore)
        {
            if (null == rtCore)
            {
                return;
            }

            // construct the image frame
            Vector3           tl = rtCore.GetTopLeftPixelPosition();
            Vector3           tr = rtCore.GetTopRightPixelPosition();
            Vector3           bl = rtCore.GetBottomLeftPixelPosition();
            Vector3           br = rtCore.GetBottomRightPixelPosition();
            UWB_PrimitiveLine t, b, l, r;

            t = new UWB_PrimitiveLine();
            b = new UWB_PrimitiveLine();
            l = new UWB_PrimitiveLine();
            r = new UWB_PrimitiveLine();

            t.setStartPoint(tr.X, tr.Y, tr.Z);
            t.setEndPoint(tl.X, tl.Y, tl.Z);
            t.Material.Emissive = Vector4.UnitX;

            l.setStartPoint(tl.X, tl.Y, tl.Z);
            l.setEndPoint(bl.X, bl.Y, bl.Z);
            l.Material.Emissive = Vector4.UnitX;

            b.setStartPoint(br.X, br.Y, br.Z);
            b.setEndPoint(bl.X, bl.Y, bl.Z);
            b.Material.Emissive = Vector4.UnitX;

            r.setStartPoint(tr.X, tr.Y, tr.Z);
            r.setEndPoint(br.X, br.Y, br.Z);
            r.Material.Emissive = Vector4.UnitX;

            mCameraPrimitives.append(t);
            mCameraPrimitives.append(b);
            mCameraPrimitives.append(l);
            mCameraPrimitives.append(r);
        }
Exemple #8
0
        public CommandFileParser(String cmdFile, ContentManager meshLoader, System.Windows.Forms.TextBox statusArea, RTCore rt, SceneDatabase scene)
        {
            mStatusArea = statusArea;

            mFullPath = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(cmdFile));

            mParser = new XmlTextReader(cmdFile);
            mParser.WhitespaceHandling = WhitespaceHandling.None;

            ParserRead();
            while (!IsEndElement("RayTracer_552"))
            {
                if (IsElement() && (!IsElement("RayTracer_552")))
                {
                    if (IsElement("camera"))
                    {
                        RTCamera c = new RTCamera(this);
                        rt.SetCamera(c);
                        ParserRead();
                    }
                    else if (IsElement("sphere"))
                    {
                        RTSphere s = new RTSphere(this);
                        scene.AddGeom(s);
                        ParserRead();
                    }
                    else if (IsElement("rectangle"))
                    {
                        RTRectangle r = new RTRectangle(this);
                        scene.AddGeom(r);
                        ParserRead();
                    }
                    else if (IsElement("triangle"))
                    {
                        RTTriangle t = new RTTriangle(this);
                        scene.AddGeom(t);
                        ParserRead();
                    }
                    else if (IsElement("mesh"))
                    {
                        RTTriangle.ParseMeshForTriangles(this, meshLoader, scene);
                        ParserRead();
                    }
                    else if (IsElement("imagespec"))
                    {
                        ImageSpec s = new ImageSpec(this);
                        rt.SetImageSpec(s);
                        ParserRead();
                    }
                    else if (IsElement("rtspec"))
                    {
                        rt.Parse(this);
                        ParserRead();
                    }
                    else if (IsElement("material"))
                    {
                        RTMaterial m = new RTMaterial(this);
                        scene.AddMaterial(m);
                        ParserRead();
                    }
                    else if (IsElement("light"))
                    {
                        RTLight l = new RTLight(this);
                        scene.AddLight(l);
                        ParserRead();
                    }
                    else if (IsElement("texture"))
                    {
                        RTTexture t = new RTTexture(this);
                        scene.AddTexture(t);
                        ParserRead();
                    }
                    else
                    {
                        ParserError("Main Parser:");
                    }
                }
                else
                {
                    ParserRead();
                }
            }
            mParser.Close();

            if (!mHasError)
            {
                mStatusArea.Text = "Parsing Completed!";
            }
        }
        public CommandFileParser(String cmdFile, ContentManager meshLoader, System.Windows.Forms.TextBox statusArea, RTCore rt, SceneDatabase scene)
        {
            mStatusArea = statusArea;

            mFullPath = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(cmdFile));

            mParser = new XmlTextReader(cmdFile);
            mParser.WhitespaceHandling = WhitespaceHandling.None;

            ParserRead();
            while (!IsEndElement("RayTracer_552"))
            {
                if (IsElement() && (!IsElement("RayTracer_552")) )
                {
                    if (IsElement("camera"))
                    {
                        RTCamera c = new RTCamera(this);
                        rt.SetCamera(c);
                        ParserRead();
                    }
                    else if (IsElement("sphere"))
                    {
                        RTSphere s = new RTSphere(this);
                        scene.AddGeom(s);
                        ParserRead();
                    }
                    else if (IsElement("rectangle"))
                    {
                        RTRectangle r = new RTRectangle(this);
                        scene.AddGeom(r);
                        ParserRead();
                    }
                    else if (IsElement("triangle"))
                    {
                        RTTriangle t = new RTTriangle(this);
                        scene.AddGeom(t);
                        ParserRead();
                    }
                    else if (IsElement("mesh"))
                    {
                        RTTriangle.ParseMeshForTriangles(this, meshLoader, scene);
                        ParserRead();
                    }
                    else if (IsElement("imagespec"))
                    {
                        ImageSpec s = new ImageSpec(this);
                        rt.SetImageSpec(s);
                        ParserRead();
                    }
                    else if (IsElement("rtspec"))
                    {
                        rt.Parse(this);
                        ParserRead();
                    }
                    else if (IsElement("material"))
                    {
                        RTMaterial m = new RTMaterial(this);
                        scene.AddMaterial(m);
                        ParserRead();
                    }
                    else if (IsElement("light"))
                    {
                        RTLight l = new RTLight(this);
                        scene.AddLight(l);
                        ParserRead();
                    }
                    else if (IsElement("texture"))
                    {
                        RTTexture t = new RTTexture(this);
                        scene.AddTexture(t);
                        ParserRead();
                    }
                    else
                        ParserError("Main Parser:");
                }
                else
                    ParserRead();
            }
            mParser.Close();

            if (!mHasError)
                mStatusArea.Text = "Parsing Completed!";
        }
        /// <summary>
        /// Service routine for "Reload" button.
        ///     1. Create a new RT engine to parse command file
        ///     2. Sets the Debug state to the RT engine (Debug pixel/rays)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mReloadCmdFile_Click(object sender, EventArgs e)
        {
            if (System.IO.File.Exists(mCmdFileName)) {

                StopRT(sender, e);

                String fileName = System.IO.Path.GetFileName(mCmdFileName);
                mCmdFileNameEcho.Text = fileName;
                mStatusArea.Text = "Parsing command file: " + fileName;

                if (null != mRT)
                    mRT.AbortRTThread();
                mRT = new RTCore(this, mCmdFileName, mMeshLoader);
                mRT.SetDebugPixels(DebugPixels.Checked);
                mRT.SetDebugRays(DebugRays.Checked);
                mRT.SetShowPixelInWorld(PixelInWorld.Checked);
                mRT.SetDrawDB(DrawDB.Checked);
                mRT.SetOrthoRT(OrthoRT.Checked);
                mRT.SetMultiThreadCompute(MultiThreadCompute.Checked);
                mRT.SetAnaglyph(listAnaglyph.SelectedItem.ToString());
                mNewSceneForGUI = true;

            } else {
                mStatusArea.Text = "Invalid Command File: " + mCmdFileName;
            }
        }