Jump to content
  • Advertisement
Sign in to follow this  
PrajayShetty_120286

Where is mine model? i am not seeing it

This topic is 2594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



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 Avtar
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Model sphere;
Matrix world=Matrix.Identity;
SpriteFont sf;
int curx;
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

base.Initialize();
}

/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
///
protected override void Update(GameTime gameTime)
{
KeyboardState gc = Keyboard.GetState();
if (gc.IsKeyDown(Keys.A)) {
world = calculateA();
}

base.Update(gameTime);
}
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
sphere = this.Content.Load<Model>("tiger");
// TODO: use this.Content to load your game content here
sf = this.Content.Load<SpriteFont>("SpriteFont1");

}

/// <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>

/// <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);
spriteBatch.Begin(SpriteSortMode.Deferred,null);
spriteBatch.DrawString(sf, world.ToString(), new Vector2(0, 0), Color.White);
spriteBatch.End();
Matrix mi = Matrix.CreateLookAt(new Vector3(-10, 0, 0), Vector3.Zero, Vector3.Up);


// TODO: Add your initialization code here



Matrix identity = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), GraphicsDevice.DisplayMode.AspectRatio, 0.1f, 100.0f);
foreach (ModelMesh mis in sphere.Meshes)
{

foreach (BasicEffect bs in mis.Effects)
{


bs.EnableDefaultLighting();
bs.World = world;
bs.View = mi;
bs.Projection = identity;
foreach (EffectPass pass in bs.CurrentTechnique.Passes)
{
pass.Apply();
}
}

mis.Draw();
}

// TODO: Add your drawing code here

base.Draw(gameTime);
}


public Matrix calculateA()
{
Vector3 x = new Vector3(1,0,0);
x.Normalize();

//Up Vector
Vector3 y = new Vector3(0,1,0);
y.Normalize();
Vector3 z = Vector3.Cross(x, y);
z.Normalize();

Matrix YRot = new Matrix();
YRot.Right = x;
YRot.Up = y;
YRot.Backward = z;
return Matrix.Identity * YRot;


}

}
}





i am unable to see mine tiger on the screen whats the problem in it , am i creating the orientation matrix properly.. ,

am i using this perfectly

z=cros(x,y) is this logic correct please help me :P please tell me how do i create mine world matrix if i have to move from one postion to another in same direction ,is this method correct , sorry ,this is mine first post

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!