Esempio n. 1
0
        public static Parallelepiped fromBounding(TgcBoundingAxisAlignBox b)
        {
            var box = new Parallelepiped();

            var size = b.calculateSize();
            var pos  = b.calculateBoxCenter();

            box.setVertex(size, pos);
            return(box);
        }
Esempio n. 2
0
        /// <summary>
        ///     Construye la grilla
        /// </summary>
        private GrillaRegularNode[,,] buildGrid(List <TgcMesh> modelos, TgcBoundingAxisAlignBox sceneBounds, Vector3 cellDim)
        {
            var sceneSize = sceneBounds.calculateSize();

            var gx = (int)FastMath.Ceiling(sceneSize.X / cellDim.X) + 1;
            var gy = (int)FastMath.Ceiling(sceneSize.Y / cellDim.Y) + 1;
            var gz = (int)FastMath.Ceiling(sceneSize.Z / cellDim.Z) + 1;

            var grid = new GrillaRegularNode[gx, gy, gz];

            //Construir grilla
            for (var x = 0; x < gx; x++)
            {
                for (var y = 0; y < gy; y++)
                {
                    for (var z = 0; z < gz; z++)
                    {
                        //Crear celda
                        var node = new GrillaRegularNode();

                        //Crear BoundingBox de celda
                        var pMin = new Vector3(sceneBounds.PMin.X + x * cellDim.X, sceneBounds.PMin.Y + y * cellDim.Y,
                                               sceneBounds.PMin.Z + z * cellDim.Z);
                        var pMax = Vector3.Add(pMin, cellDim);
                        node.BoundingBox = new TgcBoundingAxisAlignBox(pMin, pMax);

                        //Cargar modelos en celda
                        node.Models = new List <TgcMesh>();
                        addModelsToCell(node, modelos);

                        grid[x, y, z] = node;
                    }
                }
            }

            return(grid);
        }