在該圖像中使用的技術是raycasting 2d。這是第一次與沃爾芬斯坦3D一起使用,並在2D上實現了假3D。
在這裏你可以找到一個tutotial http://lodev.org/cgtutor/
雖然這不是你想要的。
實現你想要的最好的方法是定義兩個三角形並使用GraphicsDevice.DrawUserPrimitives和basiceffect來繪製它。
// Init Triangles with four points A,B,C and D
VertexPOsitionTexture[] Vertex = new VertexPositionTexture[6];
Vertex[0].Position = (A.X,A.Y,0);
Vertex[1].Position = (B.X,B.Y,0);
Vertex[2].Position = (C.X,C.Y,0);
Vertex[3].Position = (C.X,C.Y,0);
Vertex[4].Position = (B.X,B.Y,0);
Vertex[5].Position = (D.X,D.Y,0);
Vertex[0].Texture= (0,0);
Vertex[1].Texture= (1,0);
Vertex[2].Texture= (0,1);
Vertex[3].Texture= (0,1);
Vertex[4].Texture= (1,0);
Vertex[5].Texture= (1,1);
// Init Effect from http://blogs.msdn.com/b/shawnhar/archive/2010/04/05/spritebatch-and-custom-shaders-in-xna-game-studio-4-0.aspx
Matrix projection = Matrix.CreateOrthographicOffCenter(0, viewport.Width, viewport.Height, 0, 0, 1);
Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
BasicEffect effect = new BasicEffect();
effect.Texture = your texture;
effect.TextureEnabled = true;
effect.World = Matrix.Identity;
effect.View = Matrix.Identity;
effect.Projection = halfPixelOffset * projection;
// Draw Triangles
effect.Apply():
GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(vertex, TriangleList, ...,...);
該代碼必須被理解爲僞代碼,它沒有被測試,但它顯示了要執行的相關操作。
看看[this](http://forums.create.msdn.com/forums/t/37143.aspx) – dowhilefor
dowhilefor,我看着它,但那不正是我所需要的...也沒有給出通用的解決方案。不過謝謝。 – NewProger