3D egyforma

3D egyforma
2013-11-10T21:07:49+01:00
2013-11-10T22:31:09+01:00
2022-11-30T00:25:41+01:00
Hibrid
Sziasztok!
Model = Content.Load<Model>("haazz"); View = Matrix.CreateLookAt(new Vector3(20, 10, 20), Vector3.Zero, Vector3.Up); Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(15), GraphicsDevice.Viewport.AspectRatio, 10,100);

Szerintem itt van valahol a hiba.Nem tudom miért, de ugyanabban a méretben adja ki ha egy magasabb téglalapot modellezek le blenderben,mint hogyha az alap kockát tenném be.
Miért?


Az egész kód,amivel "dolgozok":
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; namespace jatek { /// <summary> /// This is the main type for your game /// </summary> public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; //Game World Texture2D myTexture; Rectangle myRectangle; Matrix View; Matrix Projection; Model Model; //Screen parameters int screenWidth = 1100; int screenHeight = 860; 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() { graphics.PreferredBackBufferHeight = screenHeight; graphics.PreferredBackBufferWidth = screenWidth; graphics.ApplyChanges(); 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); myTexture = Content.Load<Texture2D>("ellenseg"); myRectangle = new Rectangle(10, 100, 50, 50); Model = Content.Load<Model>("haazz"); View = Matrix.CreateLookAt(new Vector3(20, 10, 20), Vector3.Zero, Vector3.Up); Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(15), GraphicsDevice.Viewport.AspectRatio, 10,100); // TODO: use this.Content to load your game content here } /// <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(); if(Keyboard.GetState().IsKeyDown(Keys.Right)){ myRectangle.X += 4; } if (Keyboard.GetState().IsKeyDown(Keys.Left)) { myRectangle.X -= 4; } if (Keyboard.GetState().IsKeyDown(Keys.Down)) { myRectangle.Y += 4; } if (Keyboard.GetState().IsKeyDown(Keys.Up)) { myRectangle.Y -= 4; } if (myRectangle.X <= 0) { myRectangle.X = 0; } if (myRectangle.Y <= 0) { myRectangle.Y = 0; } if (myRectangle.X + myRectangle.Width >= 700) { myRectangle.X = 650; } if (myRectangle.Y + myRectangle.Height >= 700) { myRectangle.Y = 650; } 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); foreach (ModelMesh mesh in Model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.View = View; effect.World = Matrix.Identity; effect.Projection = Projection; effect.EnableDefaultLighting(); } mesh.Draw(); } spriteBatch.Begin(); spriteBatch.Draw(myTexture, myRectangle, Color.White); spriteBatch.End(); // TODO: Add your drawing code here base.Draw(gameTime); } } }
Mutasd a teljes hozzászólást!
Blender is lehet a 'ludas', ha objekt módban méretezel, és nem editben, akkor csak mátrixait nyújtja meg a hasábnak, de a vektorok pozíciója ugyanaz marad.
Ha szemmel is olvasható a modelformátum, esetleg nézd meg a vektorok értékeit, mit exportált ki.
Mutasd a teljes hozzászólást!

Tetszett amit olvastál? Szeretnél a jövőben is értesülni a hasonló érdekességekről?
abcd