Пример #1
0
        public Form1()
        {
            InitializeComponent();

            bool results = Geometry.SphereBoundProbe(new Vector3(5, 0, 0), 1, new Vector3(0, 0, 0), new Vector3(1, 0, 0));

            OcTree.OcTree <TestItem> tree = new OcTree.OcTree <TestItem>(20);
            tree.Insert(new TestItem(new Vector3(5, 5, 0), new Vector3(10, 10, 10), 10));
            tree.Insert(new TestItem(new Vector3(5, 5, 0), new Vector3(3, 3, 3), 3));
            tree.Insert(new TestItem(new Vector3(5, 5, 5), new Vector3(0.1f, 0.1f, 0.1f), 0.1f));
            tree.Insert(new TestItem(new Vector3(5, 1, 15), new Vector3(1.6f, 1.6f, 1.6f), 1.6f));

            tree.Insert(new TestItem(new Vector3(1, 0, 0), new Vector3(1, 1, 1), 1));
            tree.Insert(new TestItem(new Vector3(15, 15, 0), new Vector3(1, 1, 1), 1));
            tree.Insert(new TestItem(new Vector3(5, 15, 5), new Vector3(1, 1, 1), 1));
            tree.Insert(new TestItem(new Vector3(18, 1, 1), new Vector3(3, 5, 6), 6));


            //object hit = tree.RayIntersectFirst(new Vector3(0, 0, 0), new Vector3(1, 0, 0));

            //PresentParameters pParams = new PresentParameters();
            //pParams.SwapEffect = SwapEffect.Copy;
            //pParams.Windowed = true;
            //pParams.AutoDepthStencilFormat = DepthFormat.D16;
            //pParams.EnableAutoDepthStencil = true;

            //device = new Device(0, DeviceType.Hardware, this.panel1, CreateFlags.SoftwareVertexProcessing, pParams);
            //device.RenderState.Lighting = false;

            //detail = 12;
            //int numPoints = detail * (detail / 2) * 6;

            //CustomVertex.PositionNormalTextured[] points = new CustomVertex.PositionNormalTextured[numPoints];
            //CreateSphere2(new Vector3(), 2, detail, points);

            //vBuffer = new VertexBuffer(typeof(CustomVertex.PositionNormalTextured), numPoints, device, Usage.None, CustomVertex.PositionNormalTextured.Format, Pool.Managed);
            //vBuffer.SetData(points, 0, LockFlags.None);
            //numVerts = numPoints;//((8 * 4) + 2) * 4;

            /*SphereMathHelper.SphereN sphereN = SphereMathHelper.CalcSphereWNormals(10, 10, 1, new Vector3(), true);
             *
             * vBuffer = new VertexBuffer(typeof(CustomVertex.PositionTextured), sphereN.Positions.Length, device, Usage.None, CustomVertex.PositionTextured.Format, Pool.Managed);
             * CustomVertex.PositionTextured[] sphere = (CustomVertex.PositionTextured[])vBuffer.Lock(0, LockFlags.None);
             * for (int i = 0; i < sphereN.Positions.Length; i++)
             * {
             *  sphere[i].Position = sphereN.Positions[i];
             *  sphere[i].Tu = sphereN.TexCoords[i].X;
             *  sphere[i].Tv = sphereN.TexCoords[i].Y;
             * }
             * vBuffer.Unlock();
             *
             * numVerts = sphereN.Positions.Length;*/

            //texture = TextureLoader.FromStream(device, NoiseTextureBuilder.BuildSphericalTexture());
            //FromFile(device, "c:/earth.bmp");
        }
Пример #2
0
        public Form1()
        {
            InitializeComponent();

            bool results = Geometry.SphereBoundProbe(new Vector3(5, 0, 0), 1, new Vector3(0, 0, 0), new Vector3(1, 0, 0));

            OcTree.OcTree<TestItem> tree = new OcTree.OcTree<TestItem>(20);
            tree.Insert(new TestItem(new Vector3(5, 5, 0), new Vector3(10, 10, 10), 10));
            tree.Insert(new TestItem(new Vector3(5, 5, 0), new Vector3(3, 3, 3), 3));
            tree.Insert(new TestItem(new Vector3(5, 5, 5), new Vector3(0.1f, 0.1f, 0.1f), 0.1f));
            tree.Insert(new TestItem(new Vector3(5, 1, 15), new Vector3(1.6f, 1.6f, 1.6f), 1.6f));

            tree.Insert(new TestItem(new Vector3(1, 0, 0), new Vector3(1, 1, 1), 1));
            tree.Insert(new TestItem(new Vector3(15, 15, 0), new Vector3(1, 1, 1), 1));
            tree.Insert(new TestItem(new Vector3(5, 15, 5), new Vector3(1, 1, 1), 1));
            tree.Insert(new TestItem(new Vector3(18, 1, 1), new Vector3(3, 5, 6), 6));


            //object hit = tree.RayIntersectFirst(new Vector3(0, 0, 0), new Vector3(1, 0, 0));

            //PresentParameters pParams = new PresentParameters();
            //pParams.SwapEffect = SwapEffect.Copy;
            //pParams.Windowed = true;
            //pParams.AutoDepthStencilFormat = DepthFormat.D16;
            //pParams.EnableAutoDepthStencil = true;

            //device = new Device(0, DeviceType.Hardware, this.panel1, CreateFlags.SoftwareVertexProcessing, pParams);
            //device.RenderState.Lighting = false;

            //detail = 12;
            //int numPoints = detail * (detail / 2) * 6;

            //CustomVertex.PositionNormalTextured[] points = new CustomVertex.PositionNormalTextured[numPoints];
            //CreateSphere2(new Vector3(), 2, detail, points);

            //vBuffer = new VertexBuffer(typeof(CustomVertex.PositionNormalTextured), numPoints, device, Usage.None, CustomVertex.PositionNormalTextured.Format, Pool.Managed);
            //vBuffer.SetData(points, 0, LockFlags.None);
            //numVerts = numPoints;//((8 * 4) + 2) * 4;
            
            /*SphereMathHelper.SphereN sphereN = SphereMathHelper.CalcSphereWNormals(10, 10, 1, new Vector3(), true);

            vBuffer = new VertexBuffer(typeof(CustomVertex.PositionTextured), sphereN.Positions.Length, device, Usage.None, CustomVertex.PositionTextured.Format, Pool.Managed);
            CustomVertex.PositionTextured[] sphere = (CustomVertex.PositionTextured[])vBuffer.Lock(0, LockFlags.None);
            for (int i = 0; i < sphereN.Positions.Length; i++)
            {
                sphere[i].Position = sphereN.Positions[i];
                sphere[i].Tu = sphereN.TexCoords[i].X;
                sphere[i].Tv = sphereN.TexCoords[i].Y;
            }
            vBuffer.Unlock();
            
            numVerts = sphereN.Positions.Length;*/

            //texture = TextureLoader.FromStream(device, NoiseTextureBuilder.BuildSphericalTexture());
            //FromFile(device, "c:/earth.bmp");
        }