using System;
using System.Collections.Generic;
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.Net;
using Microsoft.Xna.Framework.Storage;
namespace ModelEx
{
public class Game1 : Microsoft.Xna.Framework.Game
{
private GraphicsDeviceManager graphics; //그래픽스
private float aspectRatio;//aspect비
private Model model; //모델
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
//초기화
protected override void Initialize()
{
base.Initialize();
}
//그래픽스컨텐트 읽어오기
protected override void LoadContent()
{
//aspect비
aspectRatio =
(float)GraphicsDevice.Viewport.Width /
(float)GraphicsDevice.Viewport.Height;
//모델 읽기
model = Content.Load<Model>("wheel");
//모델 설정
foreach (ModelMesh mesh in this.model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
//라이트
effect.EnableDefaultLighting();
//뷰 변환행렬
effect.View = Matrix.CreateLookAt(
new Vector3(2.0f, 2.0f, 2.0f),//카메라위치
Vector3.Zero, //참조점
Vector3.Up //UP벡터
);
//사영변환행렬
effect.Projection = Matrix.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(45.0f),//시야각
aspectRatio, //aspect비
0.005f, //nearclip 면의 거리
1000.0f //farclip 면의 거리
);
}
}
}
//그래픽컨텐트 언로드
protected override void UnloadContent()
{
}
//업데이트
protected override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
//그리기
protected override void Draw(GameTime gameTime)
{
//배경색
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
//모델그리기
foreach (ModelMesh mesh in model.Meshes)
{
mesh.Draw();
}
//베이스그리기
base.Draw(gameTime);
}
}
}
|
댓글