/// <summary>
        /// Initialize pixel location computation based on ImageSpec information.
        /// </summary>
        /// <param name="c"></param>
        public void InitializeImage(ImageSpec im)
        {
            const float kUseViewDist    = 10f;
            float       halfImageHeight = kUseViewDist * (float)Math.Tan(MathHelper.ToRadians(FOV) / 2.0);
            float       halfImageWidth  = halfImageHeight * (float)im.XResolution / (float)im.YResolution;
            Vector3     atOnImagePlane  = EyePosition + (kUseViewDist * ViewDirection);

            mPixelOrigin = atOnImagePlane + (halfImageHeight * UpVector) + (halfImageWidth * SideDirection);
            mPixeldX     = -(halfImageWidth * 2f / (float)im.XResolution) * SideDirection;
            mPixeldY     = -(halfImageHeight * 2f / (float)im.YResolution) * UpVector;
        }
Esempio n. 2
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 void SetImageSpec(ImageSpec s)
 {
     mImageSpec = s;
 }
        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>
 /// Initialize pixel location computation based on ImageSpec information.
 /// </summary>
 /// <param name="c"></param>
 public void InitializeImage(ImageSpec im)
 {
     const float kUseViewDist = 10f;
     float halfImageHeight = kUseViewDist * (float)Math.Tan(MathHelper.ToRadians(FOV) / 2.0);
     float halfImageWidth = halfImageHeight * (float)im.XResolution / (float)im.YResolution;
     Vector3 atOnImagePlane = EyePosition + (kUseViewDist * ViewDirection);
     mPixelOrigin = atOnImagePlane + (halfImageHeight * UpVector) + (halfImageWidth * SideDirection);
     mPixeldX = -(halfImageWidth * 2f / (float)im.XResolution) * SideDirection;
     mPixeldY = -(halfImageHeight * 2f / (float)im.YResolution) * UpVector;
 }
 public void SetImageSpec(ImageSpec s)
 {
     mImageSpec = s;
 }