Ejemplo n.º 1
0
 public void QueueDispatch(RayGroup group)
 {
     lock (instQueue)
     {
         instQueue.Enqueue(group);
     }
 }
Ejemplo n.º 2
0
 public void DispatchRayGroupReq(RayGroup group)
 {
     // try and add
     lock (dispatches)
     {
         if (dispatches.Count < maxNumThreads)
         {
             dispatches.Add(new RayDispatch(group.Trace, group, this));
         }
     }
 }
Ejemplo n.º 3
0
        public void ExecutionComplete(RayDispatch dispatch)
        {
            lock (dispatches)
            {
                dispatches.Remove(dispatch);

                // check for queued items to replace thread with
                lock (instQueue)
                {
                    if (instQueue.Count > 0)
                    {
                        RayGroup group = (RayGroup)instQueue.Dequeue();
                        dispatches.Add(new RayDispatch(group.Trace, group, this));
                    }
                }
                processedThreads++;
            }
        }
Ejemplo n.º 4
0
 public void QueueDispatch(RayGroup group)
 {
     dispatcher.QueueDispatch(group);
 }
Ejemplo n.º 5
0
        public void CollectData()
        {
            //Rectangle3D rect = new Rectangle3D(new Vector3D(-5, 0, -5), new Vector3D(5, 0, 5), new PlaneD(new Vector3D(0, 1, 0), 0));
            //Vector3D iPoint;
            //bool result = rect.IntersectWithLine(new Vector3D(5, 5, 0), new Vector3D(0, -1, 0), out iPoint);

            // create frame buffer to store data
            buffer = new FrameData(viewArea.Width, viewArea.Height, false, Color.Black);

            CameraView cView = new CameraView();
            cView.Centre = new Vector3D(3, 5, 3);
            cView.Direction = cView.Centre - new Vector3D(0, 0, 0);
            cView.Direction.Normalize();
            cView.XUV = Vector3D.Cross(cView.Direction, Vector3D.Up);
            cView.XUV.Normalize();
            cView.YUV = Vector3D.Cross(cView.XUV, cView.Direction);
            cView.YUV.Normalize();
            cView.ViewArea = new Vector2D(1, 1);
            Vector3D halfX = cView.XUV * 0.5 * cView.ViewArea.X;
            Vector3D halfY = cView.YUV * 0.5 * cView.ViewArea.Y;
            cView.Corners = new Vector3D[] { cView.Centre - halfX + halfY, // top left
                                             cView.Centre + halfX + halfY, // top right
                                             cView.Centre - halfX - halfY, // bottom left
                                             cView.Centre + halfX - halfY // bottom right
                                           };
            cView.Frustum = new PlaneD[] { PlaneD.FromPointNormal(cView.Corners[0], -cView.XUV),
                                           PlaneD.FromPointNormal(cView.Corners[1], cView.XUV),
                                           PlaneD.FromPointNormal(cView.Corners[2], cView.YUV),
                                           PlaneD.FromPointNormal(cView.Corners[3], -cView.YUV)
                                         };
            cView.Area = viewArea;
            cView.ProjectionScale = new Vector2D(0.2, 0.2);

            texture = Bitmap.FromFile("c:/checkers2.bmp");
            //Bitmap texture2 = (Bitmap)Bitmap.FromFile("c:/newheightmap.jpg");

            // setup temp scene
            SimpleSceneManager scene = new SimpleSceneManager(new RGBA_D(0.2, 0.2, 0.2, 1));

            /*scene.AddObject(new TriangleGroupSceneObject(new Vector3D(0, 0, 2),
                                                         new MaterialShader(new RGBA_D(1, 1, 1, 1),
                                                                            15, 0.1, 0, 0, 1),
                                                         1.1));*/
            /*scene.AddObject(new SphereSceneObject(new Vector3D(0, 0, 0),
                                                  new MaterialShader(new RGBA_D(0, 0, 1, 1),
                                                                     15, 0, 0, 0, 1),
                                                  1));*/
            /*scene.AddObject(new SphereSceneObject(new Vector3D(0, 0, 0),
                                                  new MaterialShader(new RGBA_D(1, 0, 0, 1),
                                                                     15, 1, 0, 0, 1),
                                                  1));
            scene.AddObject(new SphereSceneObject(new Vector3D(-3, -1, -3),
                                                  new MaterialShader(new RGBA_D(0.2, 1, 0.1, 1),
                                                                     15, 0, 0, 0, 1, texture2),
                                                  1));
            scene.AddObject(new SphereSceneObject(new Vector3D(2, 0, 0),
                                                  new MaterialShader(new RGBA_D(1, 1, 0, 1),
                                                                     10, 0.1, 0, 0, 1),
                                                  1));
            scene.AddObject(new SphereSceneObject(new Vector3D(0.5, 1, 0),
                                                  new MaterialShader(new RGBA_D(1, 1, 1, 1),
                                                                     5, 0, 0, 0, 1, texture),
                                                  0.8));
            
            scene.AddObject(new PlaneSceneObject(new Vector3D(0, -5, 0), new Vector3D(0, 1, 0),
                                                 new MaterialShader(new RGBA_D(0.1, 0.1, 0.1, 1.0),
                                                                    5, 0, 0, 0, 1), -1));
            */
            scene.AddObject(new HeightFieldObject(new Vector3D(),
                                                  new MaterialShader(new RGBA_D(1, 1, 1, 1),
                                                                     5, 0, 0, 0, 1, texture),
                                                  new Vector2D(2, 2), (Bitmap)texture));
            /*
            IOpticalSceneObject obj;
            Vector3D iPos;
            double iDist;
            uint subIdx;
            scene.GetFirstIntersection(new Vector3D(10, 0.5, 0), new Vector3D(1, 0, 0), 100, out obj, out iPos, out iDist, out subIdx);
            */
            // collect data
            DateTime start = DateTime.Now;
            RayGroup initialGroup = new RayGroup(true, 100,
                                                 cView.Area, scene, null, buffer, cView);
            rayDispatch.DispatchRayGroupReq(initialGroup);

            rayDispatch.WaitForCompletion();
            DateTime end = DateTime.Now;
            TimeSpan time = end - start;

            string aaFilter = buffer.AALayer != null ? "true[5_point_star]" : "false"; 
            stats = string.Format("threads={0} rays={1} pixels={2} time={3}ms AA={4}", rayDispatch.ProcessedThreads,
                                                                                rayDispatch.ProcessedRays,
                                                                                viewArea.Width * viewArea.Height,
                                                                                time.TotalMilliseconds,
                                                                                aaFilter);
        }
Ejemplo n.º 6
0
 public void QueueDispatch(RayGroup group)
 {
     dispatcher.QueueDispatch(group);
 }
Ejemplo n.º 7
0
 public void QueueDispatch(RayGroup group)
 {
     lock (instQueue)
     {
         instQueue.Enqueue(group);
     }
 }
Ejemplo n.º 8
0
 public void DispatchRayGroupReq(RayGroup group)
 {
     // try and add
     lock (dispatches)
     {
         if (dispatches.Count < maxNumThreads)
         {
             dispatches.Add(new RayDispatch(group.Trace, group, this));
         }
     }
 }