
- •Федеральное государственное бюджетное образовательное учреждение высшего профессионального образования «донской государственный технический университет» (дгту)
- •Пояснительная записка к курсовому проекту (работе) по дисциплине «Компьютерная графика и геометрия»
- •Автор проекта (работы) Панасенко Наталья Дмитриевна
- •Федеральное государственное бюджетное образовательное учреждение высшего профессионального образования «донской государственный технический университет» (дгту)
- •Содержание
- •Введение
- •1. Описание программы
- •1.1. Общие сведения
- •2.2. Средства и порядок испытаний
- •3. Руководство системного программиста
- •3.1. Назначение и условия применения программы
- •3.2. Характеристика программы
- •3.3. Структура программы
- •3.4.Описание алгоритмов, функций и переменных
- •Разработка объектов сцены
- •Алгоритм движения
- •3. 5. Настройка программы
- •4. Руководство оператора
- •5. Задачи Задача 1 вариант 8
- •Задача 2
- •Задача 3
- •Задача 4
- •Задача 5
- •Задача 6
- •Задача 7
- •Задача 8 вариант 8
- •Заключение
- •Список использованных источников
- •Статья на тему: Разработка компьютерной графики с .Net c# и OpenGl api. Http://esate.Ru/page/uroki-OpenGl-c-sharp
- •Файл Game1.Cs
- •Файл Program.Cs
Задача 8 вариант 8
Повернуть четырехугольник, полученный в предыдущем задании, вокруг вершины C на 30 градусов против часовой стрелки вокруг оси Z.
1.Сдвигаем вершину С к началу координат:
TXcYcZc =
2
.
Вращаем
на угол 300
против
часовой стрелки вокруг оси Z:
RZ30 =
3.Сдвигаем вершину С на старое место:
T1XcYcZc =
4. Итоговая матрица преобразований:
M3 = T1XcYcZc *RZ30 * TXcYcZc * M2 =
=
Заключение
В ходе данной курсовой работы мы получили основные знания и некоторые навыки в составлении алгоритмов и написании программ на языке программирования C#. Мы приобрели навыки и умения самостоятельного составления программ на языке программирования C# для разработки игры.
Мы считаем, что язык программирования C# - это простое, достаточно удобное и мощное средство разработки самых разных приложений – от создания простых программ, предназначенных для решения несложных вычислительных задач, до разработки сложнейших реляционных систем управления базами данных - обладающее весьма широким спектром возможностей.
Список использованных источников
Статья на тему: Разработка компьютерной графики с .Net c# и OpenGl api. Http://esate.Ru/page/uroki-OpenGl-c-sharp
Горнаков С.Г. Программирование компьютерных игр под Windows в XNA Game Studio Express. – М.:ДМК Пресс, 2008.-384с.: ил.
Порев В.Н. Компьютерная графика - СПб.: БХВ-Петербург, 2002.-432 с.: ил.
Приложение 1. Листинг программы
Файл Game1.Cs
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace Kursav_progect
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Matrix[] worldMatrix = new Matrix[6];
Matrix[] dverMatrix = new Matrix[6];
Matrix okrMatrix;
double [] ugol = new double [6] {0,0,0,0,0,0};
float[] dugol = new float[6] { -0.009f, -0.009f, -0.009f, -0.009f, -0.009f, -0.009f };
Matrix viewMatrix; //Матрица наблюдателя
Matrix projectionMatrix;//Матрица проецирования
BasicEffect effect;
Texture2D t;
Texture2D bottom;
Texture2D top;
Texture2D panorama;
VertexPositionTexture[] v;
VertexPositionTexture[] v1;
VertexPositionTexture[] d;
VertexPositionTexture[] bot;
VertexPositionTexture[] pot;
VertexPositionTexture[] bock;
VertexPositionTexture[] frot;
VertexPositionTexture[] lef;
VertexPositionTexture[] rig;
int ad = -1;
int[] ind;
int[] ind1;
int[] ind2;
int[] ind3;
int[] ind4;
BoundingBox b;
bool d1 = false; //Пересечение выстрелом (лучом)
bool d2 = false; //Пересечение приближением
BoundingBox b1;
bool d3 = false; //Пересечение выстрелом (лучом)
bool d4 = false; //Пересечение приближением
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
GraphicsDevice.RenderState.CullMode = CullMode.None; //Показывать плоскости с двух сторон
okrMatrix = Matrix.CreateTranslation(new Vector3(0, 0, 0));
worldMatrix[0] = Matrix.CreateTranslation(new Vector3(-15, 0, -8));
worldMatrix[1] = Matrix.CreateTranslation(new Vector3(15, 0, -8));
worldMatrix[2] = Matrix.CreateTranslation(new Vector3(-5, 0, 0));
worldMatrix[3] = Matrix.CreateTranslation(new Vector3(5, 0, 0));
worldMatrix[4] = Matrix.CreateTranslation(new Vector3(-10, 0, 8));
worldMatrix[5] = Matrix.CreateTranslation(new Vector3(10, 0, 8));
for (int i = 0; i < 6; i++)
{
dverMatrix[i] = Matrix.CreateTranslation(new Vector3(-2.8f, 0, 1.5f)) * worldMatrix[i];
}
viewMatrix = Matrix.CreateTranslation(new Vector3(0, -2, -15));//наблюдатель
projectionMatrix = Matrix.CreatePerspective(6, 3, 1f, 1000f);
effect = new BasicEffect(GraphicsDevice, new EffectPool());
v = new VertexPositionTexture[21]; //вершины объекта
ind = new int[33]; //индексы вершин
v[0].Position = new Vector3(-3, 0, 1.5f); //позиция вертекса
v[0].TextureCoordinate = new Vector2(0, 410 / 512.0f); //координата тектуры
v[1].Position = new Vector3(-3, 0, -1.5f);
v[1].TextureCoordinate = new Vector2(325 / 512.0f, 410 / 512.0f);
v[2].Position = new Vector3(-3, 2, 1.5f);
v[2].TextureCoordinate = new Vector2(0, 280 / 512.0f);
v[3].Position = new Vector3(-3, 2, -1.5f);
v[3].TextureCoordinate = new Vector2(320 / 512.0f, 280 / 512.0f);
v[4].Position = new Vector3(3, 0, 1.5f);
v[4].TextureCoordinate = new Vector2(512.0f / 512.0f, 130 / 512.0f);
v[5].Position = new Vector3(-3, 2, 1.5f);
v[5].TextureCoordinate = new Vector2(0, 0);
v[6].Position = new Vector3(-3, 0, 1.5f);
v[6].TextureCoordinate = new Vector2(0, 130 / 512.0f);
v[7].Position = new Vector3(3, 2, 1.5f);
v[7].TextureCoordinate = new Vector2(512.0f / 512.0f, 0);
v[15].Position = new Vector3(-2.8f, 0, 1.5f);
v[15].TextureCoordinate = new Vector2(20 / 512.0f, 130 / 512.0f);
v[16].Position = new Vector3(-2.8f, 2, 1.5f);
v[16].TextureCoordinate = new Vector2(20 / 512.0f, 0);
v[17].Position = new Vector3(-2, 2, 1.5f);
v[17].TextureCoordinate = new Vector2(80 / 512.0f, 0);
v[18].Position = new Vector3(-2, 1.15f, 1.5f);
v[18].TextureCoordinate = new Vector2(80 / 512.0f, 60 / 512.0f);
v[19].Position = new Vector3(-2.8f, 1.15f, 1.5f);
v[19].TextureCoordinate = new Vector2(20 / 512.0f, 60 / 512.0f);
v[20].Position = new Vector3(-2, 0, 1.5f);
v[20].TextureCoordinate = new Vector2(80 / 512.0f, 130 / 512.0f);
v[8].Position = new Vector3(-3, 2, 1.5f);
v[8].TextureCoordinate = new Vector2(215 / 512.0f, 500 / 512.0f);
v[9].Position = new Vector3(-3, 2, -1.5f);
v[9].TextureCoordinate = new Vector2(5 / 512.0f, 500 / 512.0f);
v[10].Position = new Vector3(-3, 3, 0);
v[10].TextureCoordinate = new Vector2(110 / 512.0f, 420 / 512.0f);
v[11].Position = new Vector3(-3, 2, 1.5f);
v[11].TextureCoordinate = new Vector2(5 / 512.0f, 135 / 512.0f);
v[12].Position = new Vector3(3, 2, 1.5f);
v[12].TextureCoordinate = new Vector2(405 / 512.0f, 135 / 512.0f);
v[13].Position = new Vector3(3, 3, 0);
v[13].TextureCoordinate = new Vector2(405 / 512.0f, 275 / 512.0f);
v[14].Position = new Vector3(-3, 3, 0);
v[14].TextureCoordinate = new Vector2(5 / 512.0f, 275 / 512.0f);
ind = new int[33] { 0, 1, 2, //первый треугольник
1, 2, 3, //второй треугольник
5, 6, 15,
15, 16, 5,
16, 17, 18,
16, 18, 19,
17, 20, 4,
4, 7, 17,
8, 9, 10,
11, 12, 13,
13, 14, 11};
v1 = new VertexPositionTexture[4]; //вершины объекта
ind1 = new int[6]; //индексы вершин
v1[0].Position = new Vector3(2.8f, 0, -1.5f);
v1[0].TextureCoordinate = new Vector2(80 / 512.0f, 130 / 512.0f);
v1[1].Position = new Vector3(2, 1.15f, -1.5f);
v1[1].TextureCoordinate = new Vector2(140 / 512.0f, 60 / 512.0f);
v1[2].Position = new Vector3(2.8f, 1.15f, -1.5f);
v1[2].TextureCoordinate = new Vector2(80 / 512.0f, 60 / 512.0f);
v1[3].Position = new Vector3(2, 0, -1.5f);
v1[3].TextureCoordinate = new Vector2(140 / 512.0f, 130 / 512.0f);
ind1 = new int[6] { 0, 1, 2, //первый треугольник
0, 1, 3};
//Коробка вокруг нашей стены
b = new BoundingBox();
b.Min = new Vector3(-3, 0, -1.5f);
b.Max = new Vector3(3, 2, 1.5f);
d = new VertexPositionTexture[4]; //вершины объекта
ind2 = new int[6]; //индексы вершин
d[0].Position = new Vector3(0, 0, 0);
d[0].TextureCoordinate = new Vector2(420 / 512.0f, 275 / 512.0f);
d[1].Position = new Vector3(0.8f, 0, 0);
d[1].TextureCoordinate = new Vector2(475 / 512.0f, 275 / 512.0f);
d[2].Position = new Vector3(0, 1.15f, 0);
d[2].TextureCoordinate = new Vector2(420 / 512.0f, 137 / 512.0f);
d[3].Position = new Vector3(0.8f, 1.15f, 0);
d[3].TextureCoordinate = new Vector2(475 / 512.0f, 137 / 512.0f);
ind2 = new int[6] { 0, 1, 2, //первый треугольник
1, 2, 3};
//Коробка вокруг нашей двери
b1 = new BoundingBox();
b1.Min = new Vector3(-2.8f, 0, 1.5f);
b1.Max = new Vector3(2, 1, 1.5f);
bot = new VertexPositionTexture[4]; //вершины объекта
pot = new VertexPositionTexture[4]; //вершины объекта
bock = new VertexPositionTexture[4]; //вершины объекта
frot = new VertexPositionTexture[4]; //вершины объекта
lef = new VertexPositionTexture[4]; //вершины объекта
rig = new VertexPositionTexture[4]; //вершины объекта
ind3 = new int[6]; //индексы вершин
ind4 = new int[6]; //индексы вершин
bot[0].Position = new Vector3(-30, 0, 30);
bot[0].TextureCoordinate = new Vector2(0, 1);
bot[1].Position = new Vector3(30, 0, 30);
bot[1].TextureCoordinate = new Vector2(1, 1);
bot[2].Position = new Vector3(-30, 0, -15);
bot[2].TextureCoordinate = new Vector2(0, 0);
bot[3].Position = new Vector3(30, 0, -15);
bot[3].TextureCoordinate = new Vector2(1, 0);
pot[0].Position = new Vector3(-30, 15, 30);
pot[0].TextureCoordinate = new Vector2(0, 1);
pot[1].Position = new Vector3(30, 15, 30);
pot[1].TextureCoordinate = new Vector2(1, 1);
pot[2].Position = new Vector3(-30, 15, -15);
pot[2].TextureCoordinate = new Vector2(0, 0);
pot[3].Position = new Vector3(30, 15, -15);
pot[3].TextureCoordinate = new Vector2(1, 0);
bock[0].Position = new Vector3(-30, 0, -15);
bock[0].TextureCoordinate = new Vector2(0, 1);
bock[1].Position = new Vector3(30, 0, -15);
bock[1].TextureCoordinate = new Vector2(1, 1);
bock[2].Position = new Vector3(-30, 15, -15);
bock[2].TextureCoordinate = new Vector2(0, 0);
bock[3].Position = new Vector3(30, 15, -15);
bock[3].TextureCoordinate = new Vector2(1, 0);
frot[0].Position = new Vector3(30, 0, 30);
frot[0].TextureCoordinate = new Vector2(0, 1);
frot[1].Position = new Vector3(-30, 0, 30);
frot[1].TextureCoordinate = new Vector2(1, 1);
frot[2].Position = new Vector3(30, 15, 30);
frot[2].TextureCoordinate = new Vector2(0, 0);
frot[3].Position = new Vector3(-30, 15, 30);
frot[3].TextureCoordinate = new Vector2(1, 0);
lef[0].Position = new Vector3(-30, 15, -15);
lef[0].TextureCoordinate = new Vector2(1, 0);
lef[1].Position = new Vector3(-30, 15, 30);
lef[1].TextureCoordinate = new Vector2(0, 0);
lef[2].Position = new Vector3(-30, 0, -15);
lef[2].TextureCoordinate = new Vector2(1, 1);
lef[3].Position = new Vector3(-30, 0, 30);
lef[3].TextureCoordinate = new Vector2(0, 1);
rig[0].Position = new Vector3(30, 15, 30);
rig[0].TextureCoordinate = new Vector2(1, 0);
rig[1].Position = new Vector3(30, 15, -15);
rig[1].TextureCoordinate = new Vector2(0, 0);
rig[2].Position = new Vector3(30, 0, 30);
rig[2].TextureCoordinate = new Vector2(1, 1);
rig[3].Position = new Vector3(30, 0, -15);
rig[3].TextureCoordinate = new Vector2(0, 1);
ind3 = new int[6] { 0, 1, 2, //первый треугольник
1, 2, 3};
ind4 = new int[6] { 2, 1, 0, //первый треугольник
3, 2, 1};
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
t = Content.Load<Texture2D>("7");
bottom = Content.Load<Texture2D>("bottom");
top = Content.Load<Texture2D>("top");
panorama = Content.Load<Texture2D>("panorama");
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here\
Content.Unload();
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
KeyboardState keyboardState;
keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Keys.Escape) == true)
this.Exit();
//Повороты плавные
if (keyboardState.IsKeyDown(Keys.E) == true) //поворот вокруг Y
viewMatrix = Matrix.Multiply(viewMatrix, Matrix.CreateRotationY(0.1f));
//Шаги плавные
if (keyboardState.IsKeyDown(Keys.Left) == true) //влево
viewMatrix = Matrix.Multiply(viewMatrix, Matrix.CreateTranslation(new Vector3(0.1f, 0, 0)));
if (keyboardState.IsKeyDown(Keys.Right) == true) //вправо
viewMatrix = Matrix.Multiply(viewMatrix, Matrix.CreateTranslation(new Vector3(-0.1f, 0, 0)));
if (keyboardState.IsKeyDown(Keys.Q) == true) //вниз
viewMatrix = Matrix.Multiply(viewMatrix, Matrix.CreateTranslation(new Vector3(0, 0.1f, 0)));
if (keyboardState.IsKeyDown(Keys.W) == true) //вверх
viewMatrix = Matrix.Multiply(viewMatrix, Matrix.CreateTranslation(new Vector3(0, -0.1f, 0)));
if (keyboardState.IsKeyDown(Keys.Down) == true) //дальше
viewMatrix = Matrix.Multiply(viewMatrix, Matrix.CreateTranslation(new Vector3(0, 0, -0.1f)));
if (keyboardState.IsKeyDown(Keys.Up) == true) //ближе
viewMatrix = Matrix.Multiply(viewMatrix, Matrix.CreateTranslation(new Vector3(0, 0, 0.1f)));
d1 = false;
d2 = false;
d3 = false;
d4 = false;
for (int i = 0; i < 6; i++)
{
//Матрица m задает положение наблюдателя относительно объекта (стенки)
Matrix m = Matrix.Invert(worldMatrix[i]) * Matrix.Invert(viewMatrix);
//Задаем вектор направления взгляда из точки расположения наблюдателя
Ray r = new Ray(m.Translation, m.Forward);
//Определяем пересечение взгляда наблюдателя с коробкой вокруг объекта (стенки)
float? f1 = b.Intersects(r);
d1 = d1 || (f1 != null);//Если d1 = true then есть попадание
//Задаем сферу вокруг наблюдателя
BoundingSphere s = new BoundingSphere(m.Translation, 2.7f);
d2 = d2 || b.Intersects(s); //Если d2 = true then наблюдатель близко к объекту
//Определяем пересечение взгляда наблюдателя с коробкой вокруг объекта (стенки)
float? f2 = b1.Intersects(r);
d3 = d3 || (f2 != null);//Если d3 = true then есть попадание
//Задаем сферу вокруг наблюдателя
BoundingSphere s1 = new BoundingSphere(m.Translation, 2.5f);
d4 = d4 || b1.Intersects(s1); //Если d4 = true then наблюдатель близко к объекту
if (b1.Intersects(s1)==true)
ad=i;
}
if (keyboardState.IsKeyDown(Keys.Z) == true & d4 & ad>=0)
{
if (ugol[ad] <= 0 & ugol[ad] >= -MathHelper.PiOver2)
{ ugol[ad] += dugol[ad];
dverMatrix[ad] = Matrix.CreateRotationY(dugol[ad]) * dverMatrix[ad];
}
if (ugol[ad] > 0 | ugol[ad] < -MathHelper.PiOver2)
{ dugol[ad] = -dugol[ad];
ugol[ad] += dugol[ad];
dverMatrix[ad] = Matrix.CreateRotationY(dugol[ad]) * dverMatrix[ad];
}
}
if (keyboardState.IsKeyDown(Keys.X) == true & d4 & ad >= 0)
{
if (ugol[ad] <= 0 & ugol[ad] >= -0.8f)
{
ugol[ad] -= dugol[ad];
dverMatrix[ad] = Matrix.CreateTranslation(dugol[ad], 0, 0) * dverMatrix[ad];
}
if (ugol[ad] >= 0 | ugol[ad] <= -0.8f)
{
dugol[ad] = -dugol[ad];
ugol[ad] -= dugol[ad];
dverMatrix[ad] = Matrix.CreateTranslation(dugol[ad], 0, 0) * dverMatrix[ad];
}
}
if (keyboardState.IsKeyDown(Keys.C) == true & d4 & ad >= 0)
{
if (ugol[ad] <= 0 & ugol[ad] >= -MathHelper.PiOver2)
{
ugol[ad] -= dugol[ad]*2;
dverMatrix[ad] = Matrix.CreateRotationY(dugol[ad]*2) * dverMatrix[ad];
}
if (ugol[ad] > 0 | ugol[ad] < -MathHelper.PiOver2)
{
dugol[ad] = -dugol[ad];
ugol[ad] -= dugol[ad]*2;
dverMatrix[ad] = Matrix.CreateRotationY(dugol[ad]*2) * dverMatrix[ad];
}
}
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
// TODO: Add your drawing code here
if (d2) //Фон красный, если наблюдатель близко к объекту 1
GraphicsDevice.Clear(Color.Red);
else
if (d1) //Фон желтый, если наблюдатель направлен на объект 1 (попадет при выстреле)
GraphicsDevice.Clear(Color.Yellow);
else //Фон синий, если не попадет в объект 1 и не близко
GraphicsDevice.Clear(Color.CornflowerBlue);
if (d4) //Фон белый, если наблюдатель близко к объекту 2
GraphicsDevice.Clear(Color.White);
else
if (d3) //Фон Зеленый, если наблюдатель направлен на объект 2 (попадет при выстреле)
GraphicsDevice.Clear(Color.Green);
//Задаем учет глубины
graphics.GraphicsDevice.RenderState.DepthBufferEnable = true;
for (int i = 0; i < 6; i++)
{
//Рисование объекта 1 (стена перпендикулярно направлению взгляда)
if (ind.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = worldMatrix[i];
effect.Texture = t;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, v, 0, v.Length, ind, 0, ind.Length / 3);
pass.End();
}
effect.End();
}
//Рисование объекта 1.5 (стена-дверь)
if (ind1.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = worldMatrix[i];
effect.Texture = t;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, v1, 0, v1.Length, ind1, 0, ind1.Length / 3);
pass.End();
}
effect.End();
}
//Рисование объекта 2 (стена параллельна направлению взгляда)
if (ind.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = worldMatrix[i] * Matrix.Invert(worldMatrix[i]) * Matrix.CreateRotationY(MathHelper.Pi) * Matrix.CreateTranslation(0, 0, 0) * worldMatrix[i];
effect.Texture = t;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, v, 0, v.Length, ind, 0, ind.Length / 3);
pass.End();
}
effect.End();
}
//Рисование объекта 3 (дверь)
if (ind2.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = dverMatrix[i];
effect.Texture = t;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, d, 0, d.Length, ind2, 0, ind2.Length / 3);
pass.End();
}
effect.End();
}
}
//Рисование объекта 4 (земля)
if (ind3.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = okrMatrix;
effect.Texture = bottom;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, bot, 0, bot.Length, ind3, 0, ind3.Length / 3);
pass.End();
}
effect.End();
}
//Рисование объекта 5 (небо)
if (ind3.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = okrMatrix;
effect.Texture = top;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, pot, 0, pot.Length, ind3, 0, ind3.Length / 3);
pass.End();
}
effect.End();
}
//Рисование объекта 6 (прямо)
if (ind3.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = okrMatrix;
effect.Texture = panorama;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, bock, 0, bock.Length, ind3, 0, ind3.Length / 3);
pass.End();
}
effect.End();
}
//Рисование объекта 7 (сзади)
if (ind3.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = okrMatrix;
effect.Texture = panorama;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, frot, 0, frot.Length, ind3, 0, ind3.Length / 3);
pass.End();
}
effect.End();
}
//Рисование объекта 8 (лево)
if (ind4.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = okrMatrix;
effect.Texture = panorama;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, lef, 0, lef.Length, ind4, 0, ind4.Length / 3);
pass.End();
}
effect.End();
}
//Рисование объекта 9 (право)
if (ind3.Length > 0)
{
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = okrMatrix;
effect.Texture = panorama;
effect.TextureEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, rig, 0, rig.Length, ind4, 0, ind4.Length / 3);
pass.End();
}
effect.End();
}
base.Draw(gameTime);
}
}
}