当前位置: 首页>>代码示例>>C#>>正文


C# Octree类代码示例

本文整理汇总了C#中Octree的典型用法代码示例。如果您正苦于以下问题:C# Octree类的具体用法?C# Octree怎么用?C# Octree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Octree类属于命名空间,在下文中一共展示了Octree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main(string[] arguments)
        {
            if (arguments.Length != 1)
            {
                Console.WriteLine("Expected 1 parameter: path to the file with test case data.");
                return;
            }

            using (var scenarioReader = new ScenarioReader(new StreamReader(arguments[0])))
            {
                foreach (var scenario in scenarioReader.EnumerateScenarios())
                {
                    Utilities.EnsureAllPositionsAreValid(scenario.BombPositions, SpaceSize);

                    var octree = new Octree(SpaceSize);
                    var furthestOctant = octree.GetFurthestOctant(scenario.BombPositions);

                    /*
                    var safestPoint = furthestOctant.Item1.Center;

                    Console.WriteLine("Safest point: ({0}, {1}, {2}), distance to closest bomb: {3}.",
                        Math.Round(safestPoint.X),
                        Math.Round(safestPoint.Y),
                        Math.Round(safestPoint.Z),
                        Math.Round(furthestOctant.Item2));
                    */

                    // Requirement:
                    // Output T integers, one per test case each on its own line, representing the square of distance to the
                    // nearest bomb from the safest point in the cube.
                    Console.WriteLine(Math.Round(furthestOctant.Item2 * furthestOctant.Item2));
                }
            }
        }
开发者ID:krabicezpapundeklu,项目名称:Exercises,代码行数:34,代码来源:Program.cs

示例2: World

 public World(GameObject scene, float size, Vector3 center, int maxLevel, float normalExtension, bool progressive = true, Graph.GraphType type = Graph.GraphType.CENTER) {
     space = progressive ? new ProgressiveOctree(size, center - Vector3.one * size / 2, maxLevel) : new Octree(size, center - Vector3.one * size / 2, maxLevel);
     space.BuildFromGameObject(scene, normalExtension);
     spaceGraph = 
         type == Graph.GraphType.CENTER ? space.ToCenterGraph() :
         type == Graph.GraphType.CORNER ? space.ToCornerGraph() : space.ToCrossedGraph();
 }
开发者ID:supercontact,项目名称:PathFindingEnhanced,代码行数:7,代码来源:World.cs

示例3: Quantize

 public override QuantizedImage Quantize(ImageBase image, int maxColors)
 {
     colors = NumUtils.Clamp(maxColors, 1, 255);
     if (octree == null){
         octree = new Octree(GetBitsNeededForColorDepth(maxColors));
     }
     return base.Quantize(image, maxColors);
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:8,代码来源:OctreeQuantizer.cs

示例4: Add

 public void Add(Octree<Volume> octree)
 {
     List<Volume> list = octree.toList();
     foreach (Volume volume in list)
     {
         if( volume.Visible ) Add(volume);
     }
 }
开发者ID:asarudick,项目名称:Soapvox,代码行数:8,代码来源:World.cs

示例5: OctreeCuller

 /// <summary>
 /// Initializes a new instance of the <see cref="OctreeCuller"/> class.
 /// </summary>
 /// <param name="worldSize">Size of the world.</param>
 /// <param name="loose">The loose.</param>
 /// <param name="maxDepth">The max depth.</param>
 /// <param name="center">The center.</param>
 /// <param name="DebugDrawer">The debug drawer. We strong recomend you to DONT JUST this DebugDrawer for nothing anymore, if you need, create another</param>
 public OctreeCuller(float worldSize, float loose, int maxDepth, Vector3 center, DebugShapesDrawer DebugDrawer = null)
 {
     oct = new Octree<IObject>(worldSize, loose, maxDepth, center);
     if (DebugDrawer != null)
     {
         DebugDrawer.DrawAllShapesEachFrame = false;
         oct.DebugDraw = DebugDrawer;                
     }            
 }        
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:17,代码来源:OctreeCuller.cs

示例6: setData

 public void setData(Octree tree, int count, Vector3[] voxMins, uint[] voxMats, Octree.GPUVOX[] voxs, Vector3 min, int octreeSize)
 {
     i_Tree = tree;
     i_Count = count;
     i_VoxMins = voxMins;
     i_VoxMaterials = voxMats;
     i_Voxs = voxs;
     i_Min = min;
     i_Size = octreeSize;
 }
开发者ID:Colt-Zero,项目名称:DualContouringGPU,代码行数:10,代码来源:ThreadedChunkLoading.cs

示例7: OctreeQuantizer

        /// <summary>
        /// Construct the octree quantizer
        /// </summary>
        /// <remarks>
        /// The Octree quantizer is a two pass algorithm. The initial pass sets up the octree,
        /// the second pass quantizes a color based on the nodes in the tree
        /// </remarks>
        public OctreeQuantizer(BitDepth pBitDepth)
            : base(false)
        {
            var maxColors = GetMaxColors(pBitDepth);
            var maxColorBits = GetMaxColorBits(pBitDepth);

            _octree = new Octree(maxColorBits);

            _maxColors = maxColors;
        }
开发者ID:akmurray,项目名称:aaronkmurray-blog-tools,代码行数:17,代码来源:OctreeQuantizer.cs

示例8: OctreeQuantizer

		/// <summary>
		/// Construct the octree quantizer
		/// </summary>
		/// <remarks>
		/// The Octree quantizer is a two pass algorithm. The initial pass sets up the octree,
		/// the second pass quantizes a color based on the nodes in the tree
		/// </remarks>
		/// <param name="maxColors">The maximum number of colors to return</param>
		/// <param name="maxColorBits">The number of significant bits</param>
		public OctreeQuantizer ( int maxColors , int maxColorBits ) : base ( false )
		{
			if ( maxColors > 255 )
				throw new ArgumentOutOfRangeException ( "maxColors" , maxColors , "The number of colors should be less than 256" ) ;

			if ( ( maxColorBits < 1 ) | ( maxColorBits > 8 ) )
				throw new ArgumentOutOfRangeException ( "maxColorBits" , maxColorBits , "This should be between 1 and 8" ) ;

			// Construct the octree
			_octree = new Octree ( maxColorBits  ) ;
			_maxColors = maxColors ;
		}
开发者ID:roman-yagodin,项目名称:R7.ImageHandler,代码行数:21,代码来源:OctreeQuantizer.cs

示例9: Main

        static void Main(string[] args)
        {

            var root = OctreeNode<object>.Filled(Vect3.Zero, 5, 0, new object());
            
            var tree = new Octree<object>(root.Split());

            using (var win = new Window<object>(tree, node => Color.Blue))
            {
                win.Run();
                Console.ReadLine();
            }
        }
开发者ID:EngrIO,项目名称:Engr.Octree,代码行数:13,代码来源:Program.cs

示例10: Generate

        public static Octree<Volume> Generate( int width, int depth )
        {
            Octree<Volume> octree = new Octree<Volume>(new Volume(new Vector3(0,0,0), new Vector3(width, 64, depth), new Color()), Volume.AddHandler, Volume.RemoveHandler, Volume.SearchHandler, Volume.SetRootHandler, Volume.RemoveAllHandler);

            List<Vector3> coords = new List<Vector3>();
            int hills = rand.Next(10);
            int height = 0;
            for (int i = 0; i < hills; i++)
            {
                coords.Add( new Vector3( rand.Next(width), 0, rand.Next(depth)));
            }
            System.Drawing.Color c = System.Drawing.Color.LawnGreen;
            int r, g, b;
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < depth; j++)
                {
                    octree.Add(
                                new Volume(
                                new Vector3(i, 0, j),
                                new Vector3(1, 1, 1),
                                new Color(c.R, c.G, c.B))
                                );
                }
            }
            foreach (Vector3 coord in coords)
            {
                for (int x = -10; x < 10; x++)
                {
                    for (int z = -10; z < 10; z++)
                    {
                        c = System.Drawing.Color.LawnGreen;
                        r = (int)(0.1f * (float)height * (int)c.R);
                        g = (int)c.G;
                        b = (int)(0.1f * (float)height * (int)c.B);

                        if (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255;
                        height = Math.Min(20 - Math.Abs(z), 20 - Math.Abs(x));
                        c = System.Drawing.Color.FromArgb(r, g, b);
                        octree.Add(
                            new Volume(
                            new Vector3(coord.X + x, height, coord.Z + z),
                            new Vector3(1, 1, 1),
                            new Color(c.R, c.G, c.B))
                            );
                    }
                }
            }

            return octree;
        }
开发者ID:asarudick,项目名称:Soapvox,代码行数:51,代码来源:TerrainGenerator.cs

示例11: World

 public World( int size )
 {
     RemoveQueue = Queue.Synchronized(new Queue());
     AddQueue = Queue.Synchronized(new Queue());
     faceBatch = new FaceBatch<VertexPositionNormalColor>();
     octree = new Octree<WorldVolume>(new WorldVolume(new Vector3(-(int)Math.Pow(2.0f, size) / 2, -(int)Math.Pow(2.0f, size) / 2, -(int)Math.Pow(2.0f, size) / 2),
                                             new Vector3((int)Math.Pow(2.0f, size), (int)Math.Pow(2.0f, size), (int)Math.Pow(2.0f, size)),
                                             new Color()),
                                             WorldVolume.AddHandler,
                                             WorldVolume.RemoveHandler,
                                             WorldVolume.SearchHandler,
                                             WorldVolume.SetRootHandler, WorldVolume.RemoveAllHandler);
     thread = new Thread(new ThreadStart(Do));
 }
开发者ID:asarudick,项目名称:Soapvox,代码行数:14,代码来源:World.cs

示例12: firstPass

        private void firstPass(Octree tree, BitmapData data, int width, int height)
        {
            byte* srcRow = (byte*)data.Scan0.ToPointer();
            Int32* srcPxl;

            for (int row = 0; row < height; ++row)
            {
                srcPxl = (Int32*)srcRow;
                for (int col = 0; col < width; ++col, ++srcPxl)
                    tree.addColor((Color32*)srcPxl);

                srcRow += data.Stride;
            }
        }
开发者ID:Leonscape,项目名称:ESWCtrls,代码行数:14,代码来源:ReduceColor.cs

示例13: Start

		protected override async void Start()
		{
			base.Start();
			Input.SubscribeToKeyDown(k => { if (k.Key == Key.Esc) Exit(); });
			Input.SubscribeToTouchEnd(OnTouched);

			// 3D scene with Octree
			var scene = new Scene(Context);
			octree = scene.CreateComponent<Octree>();

			// Camera
			var cameraNode = scene.CreateChild(name: "camera");
			cameraNode.Position = new Vector3(10, 14, 10);
			cameraNode.Rotation = new Quaternion(-0.121f, 0.878f, -0.305f, -0.35f);
			camera = cameraNode.CreateComponent<Camera>();

			// Light
			Node lightNode = cameraNode.CreateChild(name: "light");
			var light = lightNode.CreateComponent<Light>();
			light.LightType = LightType.Point;
			light.Range = 100;
			light.Brightness = 1.3f;

			// Viewport
			var viewport = new Viewport(Context, scene, camera, null);
			Renderer.SetViewport(0, viewport);
			viewport.SetClearColor(new Color(0.4f, 0.4f, 0.4f));

			plotNode = scene.CreateChild();
			var baseNode = plotNode.CreateChild().CreateChild();
			var plane = baseNode.CreateComponent<StaticModel>();
			plane.Model = ResourceCache.GetModel("Models/Plane.mdl");

			int size = 5;
			baseNode.Scale = new Vector3(size * 1.5f, 1, size * 1.5f);
			for (var i = 0f; i < size * 1.5f; i += 1.5f)
			{
				for (var j = 0f; j < size * 1.5f; j += 1.5f)
				{
					var boxNode = plotNode.CreateChild();
					boxNode.Position = new Vector3(size / 2f - i + 0.5f, 0, size / 2f - j + 0.5f);
					var box = new Bar(h => Math.Round(h, 1).ToString(), new Color(Sample.NextRandom(), Sample.NextRandom(), Sample.NextRandom(), 0.9f));
					boxNode.AddComponent(box);
					box.Value = (Math.Abs(i) + Math.Abs(j) + 1) / 2f;
				}
			}
			await plotNode.RunActionsAsync(new EaseBackOut(new RotateBy(2f, 0, 360, 0)));
			movementsEnabled = true;
		}
开发者ID:cianmulville,项目名称:urho-samples,代码行数:49,代码来源:Charts.cs

示例14: Chunk

    public Chunk()
    {
        int primModCount = 300;
        primitiveMods = new DensityPrimitive[primModCount];

        //primitiveMods[0] = new DensityPrimitive(1, 0, new Vector3 (20, 20, 0), new Vector3(10, 10, 10));
        //primitiveMods[1] = new DensityPrimitive(0, 1, new Vector3 (20, 25, 0), new Vector3(5, 3, 5));

        vertices = new List<Vector3>();
        normals = new List<Vector3>();
        indices = new List<int>();

        tree = new Octree();
        meshObject = null;
        voxelMesh = null;
        meshObject = (GameObject) GameObject.Instantiate(Resources.Load("ChunkMesh"), Vector3.zero, Quaternion.identity);
    }
开发者ID:Colt-Zero,项目名称:DualContouringGPU,代码行数:17,代码来源:Chunk.cs

示例15: OctreeQuantizer

        /// <summary>
        /// Construct the octree quantizer
        /// </summary>
        /// <remarks>
        /// The Octree quantizer is a two pass algorithm. The initial pass sets up the octree,
        /// the second pass quantizes a color based on the nodes in the tree
        /// </remarks>
        /// <param name="maxColors">The maximum number of colors to return</param>
        /// <param name="maxColorBits">The number of significant bits</param>
        /// <param name="enableTransparency">If true, then one color slot in the palette will be reserved for transparency. 
        /// Any color passed through QuantizePixel which does not have an alpha of 255 will use this color slot.
        /// If false, then all colors should have an alpha of 255. Otherwise the results may be unpredictable.</param>
        public OctreeQuantizer(int maxColors, bool enableTransparency) 
            : base(false)
        {
            if (maxColors > 256)
            {
                throw new ArgumentOutOfRangeException("maxColors", maxColors, "The number of colors should be 256 or less");
            }

            if (maxColors < 2)
            {
                throw new ArgumentOutOfRangeException("maxColors", maxColors, "The number of colors must be 2 or more");
            }

            this.octree = new Octree(8); // 8-bits per color
            this.enableTransparency = enableTransparency;
            this.maxColors = maxColors - (this.enableTransparency ? 1 : 0); // subtract 1 if enableTransparency is true
        }
开发者ID:metadeta96,项目名称:openpdn,代码行数:29,代码来源:OctreeQuantizer.cs


注:本文中的Octree类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。