1
간단한 아이소 메트릭 게임 엔진을 만들려고하는데 카메라에 문제가 있습니다. 내가 이것을 좋아할 때 나는 앞에서 내 모델을 볼 수있다. 그러나 나는 등각 투영의 관점에서 그것을보고 싶다. 나는 많은 방법을 사용하여 시도했지만 아무 것도 작동하지 않는 것 같습니다. 아마도 코드 자체에 갇혀 있을까요? 아마 코드를 도와 줄 수 있습니까?XNA C# 3D 모델로 등각 투영 뷰 만들기
public class Camera : PositionedObject
{
#region Fields
private Matrix cameraRotation;
#endregion
#region Properties
public Matrix View
{
get;
set;
}
public Matrix Projection
{
get;
protected set;
}
public Vector3 Target
{
get;
set;
}
#endregion
#region Constructor
public Camera(Game game, Vector3 position, Vector3 target, Vector3 rotation, bool Orthographic, float near, float far)
: base(game)
{
Position = position;
RotationInRadians = rotation;
Target = target;
if (Orthographic)
{
Projection = Matrix.CreateOrthographic(Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height,
near, far);
}
else
{
Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
(float)Game.Window.ClientBounds.Width/(float)Game.Window.ClientBounds.Height, near, far);
}
}
#endregion
#region Public Methods
public override void Initialize()
{
base.Initialize();
cameraRotation = Matrix.Identity;
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
cameraRotation = Matrix.CreateFromAxisAngle(cameraRotation.Forward, RotationInRadians.Z)
* Matrix.CreateFromAxisAngle(cameraRotation.Right, RotationInRadians.X)
* Matrix.CreateFromAxisAngle(cameraRotation.Up, RotationInRadians.Y);
Target = Position + cameraRotation.Forward;
View = Matrix.CreateLookAt(Position, Target, cameraRotation.Up);
}
public void Draw(BasicEffect effect)
{
effect.View = View;
effect.Projection = Projection;
}
#endregion
}
정말 감사합니다. 나는 참으로 멋진 등각 투영 뷰를 얻습니다. 내가 직면 한 유일한 문제는 항상 그 지점에 초점을 맞추고 있다는 것입니다. 그래서 카메라를 움직이면 카메라가 움직이지 않는 것처럼 움직이지 않습니다. 아마 내가 초점의 요점에 너무 가깝기 때문일거야. 난 그냥 내 모든 물건과 카메라를 다시 초점 지점에서 움직여야합니까? 아니면 카메라를 움직일 때 항상 특정 각도를 보게하고 실제로 등각보기를 만들 수있는 방법이 있습니까? 물론 카메라 대신 모든 물건을 움직여야합니다. 이 경우 가장 좋은 선택은 무엇입니까? 좋은 답변 주셔서 감사합니다! – Worempie
카메라를 움직이려면 FocusPoint를 "이동"하면 카메라가 정확한 위치와 방향을 계속 유지합니다. –
고정 : D 고마워요! – Worempie