Beispiel #1
0
        public void RebuildDiffuseTextures(GDALReader reader)
        {
            SourceDataDiffuseSampler sampler = new SourceDataDiffuseSampler();

            for (int i = 0; i < nodes.Length; i++)
            {
                tex[i] = sampler.GenerateTexture(new Size(256, 256), nodes[i].Rectangles[0], gDevice, reader);
            }
        }
Beispiel #2
0
        public void ViewUpdated(Vector3 viewPos)
        {
            // TODO: determine if tree changes needed
            // TODO: Combine vis testing with tree
            demPQT.Fork(1, false);
            demPQT.Children[3].Fork(1, false);
            demPQT.Children[3].Children[3].Fork(1, false);
            demPQT.Children[1].Fork(1, false);
            demPQT.Children[1].Children[3].Fork(1, false);
            demPQT.Children[1].Children[1].Fork(1, false);

            // build local objects needed
            SourceDataDiffuseSampler sampler   = new SourceDataDiffuseSampler();
            NormalMapGenerator       normalGen = new NormalMapGenerator();

            foreach (PureQuadTreeNode leaf in demPQT)
            {
                if (leaf.Level != 0)
                {
                    // trace each leaf to see if patches required
                    ulong[] codes;
                    byte    dirs = TraceLeaf(leaf, out codes);
                    TestInternals(leaf, ref codes);

                    // create object
                    geometryTree.Add(new GpuDemSubGeometry(leaf.Location, leaf.Size, leaf.Centre, null, leaf.Code, leaf.Level, codes, (byte)leaf.ChildNum));
                    // find matching data node and create texture if needed
                    if (!texturesCache.ContainsKey(leaf.Code))
                    {
                        Point pos = new Point((int)(leaf.Location.X / 10f * /*1024f*/ 2048f), (int)(leaf.Location.Y / 10f * /*1024f*/ 2048f));
                        // find corrosponding node
                        Texture texture = null, normalTex = null;
                        for (int node = 0; node < dataNodes[leaf.Level].Length; node++)
                        {
                            if (dataNodes[leaf.Level][node].NodeArea.Location == pos)
                            {
                                texture = //TextureLoader.FromFile(gDevice, "c:/0-test.jpg");
                                          sampler.GenerateTexture(new Size(16, 16), dataNodes[leaf.Level][node].Rectangles[0],
                                                                  gDevice, reader);
                                normalTex = normalGen.GenerateTexture(new Size(256, 256),
                                                                      dataNodes[leaf.Level][node].Rectangles[0],
                                                                      gDevice, reader);
                            }
                        }
                        texturesCache[leaf.Code] = new CachedTexture(texture, leaf.Code, leaf.Level, normalTex);
                    }
                }
            }
        }