Beispiel #1
0
        public Terrain( string setName, int mSetWidth )
            : base(setName)
        {
            mWidth = mSetWidth;
            Corner[,] Corners = new Corner[2,2];
            Corners[0, 0] = new Corner(new Vector3(0, 0, 0));
            Corners[0, 1] = new Corner(new Vector3(0, 0, mWidth));
            Corners[1, 0] = new Corner(new Vector3(mWidth, 0, 0));
            Corners[1, 1] = new Corner(new Vector3(mWidth, 0, mWidth));
            mRoot = new Square(1, mWidth, Corners);
            mDepth = 1;

            /*
               // mDrawWater = true;
            mWaterHeight = mTerrainTextures[0].mHeightCutoff;
            mWaterTexture = new Texture[1];
            mWaterTexture[0] = new Texture(256, 256);
            mWaterTexture[0].generateSolidTexture(Color.Blue);
            mWaterTextureGroup = new TextureGroup(mWaterTexture);
            */
        }
Beispiel #2
0
        public void subdivide(float Width)
        {
            if (mSubdivisions == null)
            {
                mSubdivisions = new Square[2, 2];

                Corner[,] Corners = new Corner[2, 2];
                Corners[0, 0] = mCorners[0, 0];
                Corners[0, 1] = new Corner((mCorners[0, 0].mLocation + mCorners[0, 1].mLocation) / 2.0f);
                Corners[1, 0] = new Corner((mCorners[0, 0].mLocation + mCorners[1, 0].mLocation) / 2.0f);
                Corners[1, 1] = new Corner((mCorners[0, 0].mLocation + mCorners[1, 1].mLocation) / 2.0f);
                mSubdivisions[0, 0] = new Square(mDepth + 1, Width, Corners);

                Corners[0, 0] = mSubdivisions[0, 0].mCorners[0, 1];
                Corners[0, 1] = mCorners[0, 1];
                Corners[1, 0] = mSubdivisions[0, 0].mCorners[1, 1];
                Corners[1, 1] = new Corner((mCorners[0, 1].mLocation + mCorners[1, 1].mLocation) / 2.0f);
                mSubdivisions[0, 1] = new Square(mDepth + 1, Width, Corners);

                Corners[0, 0] = mSubdivisions[0, 0].mCorners[1, 0];
                Corners[0, 1] = mSubdivisions[0, 0].mCorners[1, 1];
                Corners[1, 0] = mCorners[1, 0];
                Corners[1, 1] = new Corner((mCorners[1, 0].mLocation + mCorners[1, 1].mLocation) / 2.0f);
                mSubdivisions[1, 0] = new Square(mDepth + 1, Width, Corners);

                Corners[0, 0] = mSubdivisions[0, 0].mCorners[1, 1];
                Corners[0, 1] = mSubdivisions[0, 1].mCorners[1, 1];
                Corners[1, 0] = mSubdivisions[1, 0].mCorners[1, 1];
                Corners[1, 1] = mCorners[1,1];
                mSubdivisions[1, 1] = new Square(mDepth + 1, Width, Corners);
            }
            else
            {
                throw (new Exception("Square already subdivided"));
            }
        }