Компелятор говорит что у StorageContainer нет свойства TotalStorage, как решить эту проблему ? |
Санкт-Петербургский государственный политехнический университет
Опубликован: 09.12.2013 | Доступ: свободный | Студентов: 2053 / 30 | Длительность: 06:23:00
Темы: Программирование, Игры, Образование
Специальности: Программист
Теги:
Самостоятельная работа 5:
Основы 3Д. Текстурирование
Реализация:
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 Lab5 { /// <summary< /// This is the main type for your game /// </summary< public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; VertexDeclaration vd; VertexPositionTexture[] verts; int[] indices; BasicEffect effect; Texture2D texture; 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 effect = new BasicEffect(GraphicsDevice, null); vd = new VertexDeclaration(GraphicsDevice, VertexPositionTexture.VertexElements); verts = new VertexPositionTexture[24]; verts[0] = new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector2(0, 0)); verts[1] = new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0.5f), new Vector2(1, 0)); verts[2] = new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0.5f), new Vector2(1, 1)); verts[3] = new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0.5f), new Vector2(0, 1)); verts[4] = new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(0, 0)); verts[5] = new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(1, 0)); verts[6] = new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(1, 1)); verts[7] = new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(0, 1)); verts[8] = new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(0, 0)); verts[9] = new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector2(1, 0)); verts[10] = new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0.5f), new Vector2(1, 1)); verts[11] = new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(0, 1)); verts[12] = new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0.5f), new Vector2(0, 0)); verts[13] = new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(1, 0)); verts[14] = new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(1, 1)); verts[15] = new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0.5f), new Vector2(0, 1)); verts[16] = new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(1, 0)); verts[17] = new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(0, 0)); verts[18] = new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0.5f), new Vector2(0, 1)); verts[19] = new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector2(1, 1)); verts[20] = new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0.5f), new Vector2(1, 0)); verts[21] = new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0.5f), new Vector2(0, 0)); verts[22] = new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(0, 1)); verts[23] = new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(1, 1)); indices = new int[] { 0, 1, 2, 2, 3, 0, 4, 5, 6, 6, 7, 4, 8, 9, 10, 10, 11 ,8, 12, 13, 14, 14, 15, 12, 16, 17, 18, 18, 19, 16, 20, 21, 22, 22, 23, 20 }; 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 texture = Content.Load<Texture2D<("tex"); } /// <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 } /// <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 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) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here Matrix world = Matrix.CreateRotationY((float)gameTime.TotalGameTime.TotalSeconds); Matrix view = Matrix.CreateLookAt(new Vector3(0.5f, 1, 3), Vector3.Zero, Vector3.Up); Matrix proj = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), GraphicsDevice.Viewport.AspectRatio, 1, 10); GraphicsDevice.VertexDeclaration = vd; effect.World = world; effect.View = view; effect.Projection = proj; effect.Texture = texture; effect.TextureEnabled = true; effect.DiffuseColor = new Vector3(1, 1, 1); effect.Begin(); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Begin(); GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionTexture<(PrimitiveType.TriangleList, verts, 0, verts.Length, indices, 0, indices.Length / 3); pass.End(); } effect.End(); base.Draw(gameTime); } } }