Предыдущая Следующая
//=========================================================================
/// <summary>
/// Листинге 18.1
/// Исходный код к книге:
/// "Программирование компьютерных игр под Windows в XNA Game Studio Express"
/// Автор книги: Горнаков С. Г.
286 Загружаем в игру модель
Рисуем модель на экране монитора 287
/// Глава 18
/// Проект: LoadingModel /// Класс: Gamel /// Загрузка модели /// <summary>
//=========================================================================
#region Using Statements using System;
using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; #endregion
namespace LoadingModel {
public class Gamel : Microsoft.Xna.Framework.Game
{
private enum CurentGameState
{
SplashScreen,
MenuScreen,
AboutScreen,
GameScreen,
GameOverScreen,
VictoryScreen
}
CurentGameState gameState = CurentGameState.GameScreen;
GraphicsDeviceManager graphics; ContentManager content; KeyboardState keyboardState; int screenWidth, screenHeight;
Matrix view; Matrix proj; Matrix world;
static float aspectRatio;
static float FOV = MathHelper.PiOver4;
static float nearClip = 1.0f;
static float farClip = 1000.0f;
private Model model;
private Vector3 positionModel;
/// <summary> /// Конструктор /// <summary public Game1()
{
graphics = new GraphicsDeviceManager(this); content = new ContentManager(Services); positionModel = new Vector3(0, 0, 0);
}
/// <summary> /// Инициализация /// <summary>
protected override void Initialize()
{
GraphicsAdapter adapter =
graphics.GraphicsDevice.CreationParameters.Adapter;
graphics.PreferredBackBufferWidth = adapter.CurrentDisplayMode.Width; graphics.PreferredBackBufferHeight = adapter.CurrentDisplayMode.Height; graphics.IsFullScreen = true; graphics.ApplyChanges();
screenWidth = graphics.PreferredBackBufferWidth; screenHeight = graphics.PreferredBackBufferHeight; aspectRatio = (float)screenWidth / (float)screenHeight;
base.Initialize();
}
/// <summary>
/// Загрузка компонентов игры /// <summary>
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
model = content.Load<Model>("Content\\Models\\Soccerball");
}
}
/// <summary>
/// Освобождаем ресурсы
/// <summary> Предыдущая Следующая
|