Ejemplo n.º 1
0
        /// <summary>
        /// 初始化
        /// </summary>
        public virtual void Init()
        {
            if (this.gridIndexer == null)
            {
                this.gridIndexer = new SimLab.SimGrid.GridIndexer(this.NX, this.NY, this.NZ);
            }

            if (this.ActNums == null)
            {
                this.ActNums = InitIntArray(this.DimenSize);
            }
            if (this.zeroVisibles == null)
            {
                this.zeroVisibles = InitIntArray(this.DimenSize, 0);
            }
            if (this.invisibleTextures == null)
            {
                //初始化不可视
                this.invisibleTextures = InitFloatArray(this.DimenSize, 2);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化
        /// </summary>
        public virtual void Init()
        {
            if (this.gridIndexer == null)
            {
                this.gridIndexer = new GridIndexer(this.NX, this.NY, this.NZ);
            }

            if (this.ActiveBlocks == null)
            {
                this.ActiveBlocks = ArrayHelper.NewIntArray(this.DimenSize, 1);
            }
            if (this.zeroVisibles == null)
            {
                this.zeroVisibles = ArrayHelper.NewIntArray(this.DimenSize, 0);
            }
            if (this.invisibleTextures == null)
            {
                //初始化不可视
                this.invisibleTextures = ArrayHelper.NewFloatArray(this.DimenSize, 2);
            }

            this.InitGridCoordinates();

            this.SourceActiveBounds = this.InitSourceActiveBounds();
            //初始化
            mat4 identityMat = mat4.identity();
            vec3 center = this.SourceActiveBounds.GetCenter();
            //矩形三角形移动到中心点
            this.Position = -center;

            vec3 newcenter = this.Position * center;
            //System.Console.WriteLine(center);
            vec3 destMin = this.Position * this.SourceActiveBounds.MinPosition;
            vec3 destMax = this.Position * this.SourceActiveBounds.MaxPosition;

            //变换后的三维矩形六面体
            this.TransformedActiveBounds = new BoundingBox(destMin, destMax);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化网格坐标
        /// </summary>
        protected override void InitGridCoordinates()
        {
            if (this.TOPS == null)
            {
                this.TOPS = ArrayHelper.NewFloatArray(this.DimenSize, 0);
            }
            //xcoords;
            int coordSize = (this.NX + 1) * (this.NY + 1) * (this.NZ + 1);
            float[] coordX = new float[coordSize];
            float[] coordY = new float[coordSize];
            float[] coordZ = new float[coordSize];

            float[] srcDX = this.DX;
            float[] srcDY = this.DY;
            float[] srcDZ = this.DZ;
            float[] tops = this.TOPS;

            int cnx = this.NX + 1;
            int cny = this.NY + 1;
            int cnz = this.NZ + 1;

            int dnx = this.NX;
            int dny = this.NY;
            int dnz = this.NZ;

            GridIndexer coordIndexer = new GridIndexer(cnx, cny, cnz);
            //dx, dy,dx 描述
            GridIndexer dIndexer = new GridIndexer(this.NX, this.NY, this.NZ);

            int coordIndex;
            int prevcIndex;
            int di, dj, dk, xGridIndex, yGridIndex, zGridIndex;
            for (int kcz = 1; kcz <= cnz; kcz++)
            {
                for (int jcy = 1; jcy <= cny; jcy++)
                {
                    for (int icx = 1; icx <= cnx; icx++)
                    {
                        coordIndex = coordIndexer.IndexOf(icx, jcy, kcz);

                        //处理x坐标
                        if (icx == 1)
                        {
                            coordX[coordIndex] = this.OX;
                        }
                        else
                        {
                            prevcIndex = coordIndexer.IndexOf(icx - 1, jcy, kcz);
                            //距离坐标
                            di = icx - 1;
                            dj = jcy > dny ? jcy - 1 : jcy;
                            dk = kcz > dnz ? kcz - 1 : kcz;
                            xGridIndex = dIndexer.IndexOf(di, dj, dk);
                            coordX[coordIndex] = coordX[prevcIndex] + srcDX[xGridIndex];
                        }

                        //计算(icx,jcy,kcz)网格的坐标
                        if (jcy == 1)
                        {
                            coordY[coordIndex] = this.OY;
                        }
                        else
                        {
                            prevcIndex = coordIndexer.IndexOf(icx, jcy - 1, kcz);
                            di = icx > dnx ? icx - 1 : icx;
                            dj = jcy - 1;
                            dk = kcz > dnz ? kcz - 1 : kcz;
                            yGridIndex = dIndexer.IndexOf(di, dj, dk);
                            coordY[coordIndex] = coordY[prevcIndex] + srcDY[yGridIndex];
                        }

                        if (kcz == 1)
                        {
                            int celli = icx > this.NX ? this.NX : icx;
                            int cellj = jcy > this.NY ? this.NY : jcy;
                            int cellk = kcz > this.NZ ? this.NZ : kcz;
                            int cellIndex = dIndexer.IndexOf(celli, cellj, cellk);
                            float topz = tops[cellIndex];
                            coordZ[coordIndex] = this.OZ + topz;
                        }
                        else
                        {
                            prevcIndex = coordIndexer.IndexOf(icx, jcy, kcz - 1);
                            di = icx > dnx ? dnx : icx;
                            dj = jcy > dny ? dny : jcy;
                            dk = kcz - 1;
                            zGridIndex = dIndexer.IndexOf(di, dj, dk);
                            coordZ[coordIndex] = coordZ[prevcIndex] + srcDZ[zGridIndex];
                        }
                    }
                }
            }
            this.xcoords = coordX;
            this.ycoords = coordY;
            this.zcoords = coordZ;
            this.coordIndexer = coordIndexer;
        }