示例#1
0
 public void AddBufferMap()
 {
     CudaUtil.AddBufferMap(CommonInfo.frame_buffer0_ptr);
     CudaUtil.AddBufferMap(CommonInfo.frame_buffer1_ptr);
     CudaUtil.AddBufferMap(CommonInfo.frame_buffer2_ptr);
     CudaUtil.AddBufferMap(CommonInfo.picking_buffer_ptr);
 }
示例#2
0
        public void loop()
        {
            CommonInfo.mainFormHaveShown.WaitOne();
            while (true)
            {
                if (CommonInfo.isResolutionChanged)
                {
                    CommonInfo.ChangeResolution();
                }
                //更新scene
                mf.UpdatePrimitives();
                if (commandPool.Excute() > 0)
                {
                    CudaUtil.GenerateScene();
                }

                //更新面板
                mf.RefreshTransormPanel();
                //渲染图片
                renderBuffer.signal.WaitOne();               // 若当前bitmap为不可渲状态则等待,反之进行下一步

                CudaUtil.RenderScene(renderBuffer.index, 3); // 这里应该是 renderScene()
                renderBuffer.signal.Reset();                 //渲染完成后,当前bitmap变为不可渲
                renderBuffer.theOther.signal.Set();          //渲染完成后,当前bitmap变为 可被前端显示(简称可显) 状态
                renderBuffer = renderBuffer.next;            // 切换到下一个bitmap
            }
        }
示例#3
0
 public Triangle GetTriangle(int index)
 {
     triangle.points        = CudaUtil.CheckPrimitivePoints(index);
     triangle.normal        = CudaUtil.CheckPrimitiveNormal(index);
     triangle.materialColor = CudaUtil.CheckPrimitiveColor(index);
     return(triangle);
 }
示例#4
0
 public static void AddMapToCuda()
 {
     CudaUtil.AddBufferMap(frame_buffer0_ptr);
     CudaUtil.AddBufferMap(frame_buffer1_ptr);
     CudaUtil.AddBufferMap(frame_buffer2_ptr);
     CudaUtil.AddBufferMap(picking_buffer_ptr);
 }
示例#5
0
 public Sphere GetSphere(int index)
 {
     sphere.centre        = CudaUtil.CheckPrimitiveCentre(index);
     sphere.materialColor = CudaUtil.CheckPrimitiveColor(index);
     sphere.radius        = CudaUtil.CheckPrimitiveRadius(index);
     return(sphere);
 }
示例#6
0
 public bool ChangeTriangle(int index, Triangle triangle)
 {
     CudaUtil.ChangePrimitivePoints(index, triangle.points);
     CudaUtil.ChangePrimitiveColor(index, triangle.materialColor);
     CudaUtil.ChangePrimitiveNormal(index, triangle.normal);
     return(true);
 }
示例#7
0
        public static void ChangeResolution()
        {
            switch (resolution)
            {
            case Resolution.P128X72:
                width  = 128;
                height = 72;
                break;

            case Resolution.P256X144:
                width  = 256;
                height = 144;
                break;

            case Resolution.P512X288:
                width  = 512;
                height = 288;
                break;

            case Resolution.P1024X576:
                width  = 1024;
                height = 576;
                break;

            case Resolution.P1280X720:
                width  = 1280;
                height = 720;
                break;
            }
            CudaUtil.InitializeResources(width, height);
            ResetMap();
            AddMapToCuda();
            isResolutionChanged = false;
        }
示例#8
0
 public Plane GetPlane(int index)
 {
     plane.centre        = CudaUtil.CheckPrimitiveCentre(index);
     plane.materialColor = CudaUtil.CheckPrimitiveColor(index);
     plane.normal        = CudaUtil.CheckPrimitiveNormal(index);
     return(plane);
 }
示例#9
0
 public bool ChangePlane(int index, Plane plane)
 {
     CudaUtil.ChangePrimitiveColor(index, plane.materialColor);
     CudaUtil.ChangePrimitiveNormal(index, plane.normal);
     CudaUtil.ChangePrimitiveCentre(index, plane.centre);
     Log.instance.writeLog("将平面的参数变为,质心:" + plane.centre.x.ToString() + plane.centre.y.ToString() + plane.centre.z.ToString());
     Log.instance.writeLog("法向量" + plane.normal.x.ToString() + plane.normal.y.ToString() + plane.normal.z.ToString());
     return(true);
 }
示例#10
0
        public bool ChangeSphere(int index, Sphere sphere)
        {
            CudaUtil.ChangePrimitiveCentre(index, sphere.centre);
            CudaUtil.ChangePrimitiveColor(index, sphere.materialColor);
            CudaUtil.ChangePrimitiveRadius(index, sphere.radius);
            Log.instance.writeLog("将球的参数变为,质心:" + sphere.centre.x.ToString() + sphere.centre.y.ToString() + sphere.centre.z.ToString());

            return(true);
        }
示例#11
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CudaUtil.InitializeResources(CommonInfo.width, CommonInfo.height);

            CommonInfo.MallocMap();
            CommonInfo.AddMapToCuda();
            mainForm mainForm = new mainForm( );



            Loop        loop        = new Loop(mainForm);
            ThreadStart renderStart = new ThreadStart(loop.loop);
            Thread      renderLoop  = new Thread(renderStart);
            //开启调度线程(切换图片的函数)
            ThreadStart showStart = new ThreadStart(loop.ShowImage);
            Thread      showLoop  = new Thread(showStart);

            renderLoop.Start();
            showLoop.Start();
            Application.Run(mainForm);
            CudaUtil.FreeResources();
        }
示例#12
0
 public int AddPlane()
 {
     return(CudaUtil.AddPlane());
 }
示例#13
0
 public bool DeletrPrimitive(int index)
 {
     CudaUtil.DeletePrimitive(index);
     return(true);
 }
示例#14
0
 public int AddSphere()
 {
     return(CudaUtil.AddSphere());
 }
示例#15
0
 public int AddTriangle()
 {
     return(CudaUtil.AddTriangle());
 }
示例#16
0
 public void SendCameraToCuda()
 {
     CudaUtil.SendCamera(camera, CommonInfo.width, CommonInfo.height);
 }
示例#17
0
 public void UpdateCamera()
 {
     camera.Update(CommonInfo.accumulatedX, CommonInfo.accumulatedY);
     CudaUtil.SendCamera(camera, CommonInfo.width, CommonInfo.height);
 }