public Terrain(Game pGame) : base(pGame) { const int NUM_LEVELS = 5; m_pLevels = new Level[NUM_LEVELS]; int nCounter = 0; for (int i = NUM_LEVELS - 1; i >= 0; i--) { m_pLevels[nCounter++] = new Level(this, Maths.Pow(2, i)); } m_pSky = new Sky((Torq2Game) pGame); }
public void Create(GraphicsDevice pGraphicsDevice, Level pNextFinerLevel, Level pNextCoarserLevel, IntVector2 tViewerPosition2D) { foreach (Block pBlock in m_pBlocks) { pBlock.Create(pGraphicsDevice); } m_pRingFixups.Create(pGraphicsDevice); m_pInteriorTrim.Create(pGraphicsDevice); foreach (Block pBlock in m_pCentreBlocks) { pBlock.Create(pGraphicsDevice); } m_pCentreInteriorTrim.Create(pGraphicsDevice); m_pEdgeStitches.Create(pGraphicsDevice); m_pNextFinerLevel = pNextFinerLevel; m_pNextCoarserLevel = pNextCoarserLevel; // set initial min position of level IntVector2 tViewerPosGridCoords = (tViewerPosition2D - m_tPositionMin) / m_nGridSpacing; IntVector2 tDeltaPositionTemp1 = tViewerPosGridCoords - Settings.CentralSquareMin; IntVector2 tDeltaPositionTemp2 = new IntVector2(Math.Abs(tDeltaPositionTemp1.X), Math.Abs(tDeltaPositionTemp1.Y)); IntVector2 tDeltaPositionTemp3 = tDeltaPositionTemp1 - (tDeltaPositionTemp2 % 2); m_tPositionMin += tDeltaPositionTemp3 * m_nGridSpacing; m_pElevationTexture = new RenderTarget2D(pGraphicsDevice, Settings.ELEVATION_TEXTURE_SIZE, Settings.ELEVATION_TEXTURE_SIZE, false, SurfaceFormat.Vector2, DepthFormat.None); m_pNormalMapTexture = new RenderTarget2D(pGraphicsDevice, Settings.NORMAL_MAP_TEXTURE_SIZE, Settings.NORMAL_MAP_TEXTURE_SIZE, false, SurfaceFormat.HalfVector2, DepthFormat.None); m_pNormalMapUpdateEffect = new EffectWrapper(m_pParentTerrain.ParentGame, pGraphicsDevice, @"Effects\ComputeNormals"); m_pElevationUpdateEffect = new EffectWrapper(m_pParentTerrain.ParentGame, pGraphicsDevice, @"Effects\UpdateElevation"); }