我想知道是否有無數次在XNA重複地面模型無限次。例如在這個樣本http://create.msdn.com/en-US/education/catalog/sample/chasecamera?xna模型重複
Q
xna模型重複
0
A
回答
0
簡單的答案是否定的。如果您嘗試繪製無限數量的多邊形,您的內存不僅會用完,而且程序也會崩潰,但硬件會花費無限的時間渲染場景。
爲了解決這個問題,遊戲開發者使用天空盒和無法觸及的地形等技巧來讓玩家認爲世界是無限的。所以如果你想要一個具有重複地面紋理的有限世界,只需在網格中多次繪製地面紋理,並放置一個覆蓋地面外部邊緣的天空盒。
如果你真的想要一個無限的外觀世界,你可以做一個把戲,天空盒和地面隨你移動。因此,只需將地面和天空盒的速度設置爲正在移動的精靈的速度即可。
0
就這樣!這是我的自定義樣本。您可以從具有不同紋理的矩陣索引重複模型
//Draw a ground land
private void draw_groundLand1(int[,,] MatriceWorldCube,Vector3 position_model_origin)
{
int hauteur = MatriceWorldCube.GetLength(0);
int largeur = MatriceWorldCube.GetLength(1);
int longueur = MatriceWorldCube.GetLength(2);
Vector3 pos_reference = position_model_origin;
for (int epaisseur = 0; epaisseur < hauteur; epaisseur++)
{
for (int collone = 0; collone < largeur; collone++)
{
for (int ligne = 0; ligne < longueur ; ligne++)
{
//Vérifie si l'index de la matrice comporte bien un matériaux a placer
if (MatriceWorldCube[epaisseur, collone, ligne] != 0)
{
// Copy any parent transforms.
Matrix[] transforms = new Matrix[model_ground_land1.Bones.Count];
model_ground_land1.CopyAbsoluteBoneTransformsTo(transforms);
// Draw the model. A model can have multiple meshes, so loop.
foreach (ModelMesh mesh in model_ground_land1.Meshes)
{
// This is where the mesh orientation is set, as well
// as our camera and projection.
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationY(cubeGroundLand1_modelRotation) * Matrix.CreateTranslation(position_model_origin);
effect.View = View;
effect.Projection = Projection;
//Applique la texture en fonction du type de matière définit dans l'indice de la matrice
switch (MatriceWorldCube[epaisseur, collone, ligne])
{
case 1:
effect.Texture = text_ground_land1;
break;
case 2:
effect.Texture = text_ground_land2;
break;
default:
break;
}
}
// Draw the mesh, using the effects set above.
mesh.Draw();
}
}
position_model_origin.X = (float)(ligne+1);
}
position_model_origin.X = pos_reference.X;
position_model_origin.Z = (float)(collone+1);
}
position_model_origin.Z = pos_reference.Z;
position_model_origin.Y = (float)(epaisseur+1);
}
position_model_origin.Y = pos_reference.Y;
position_model_origin = pos_reference;
}
相關問題
- 1. XNA - 複製模型
- 2. 阻止重複XNA
- 3. Xna模型零件重疊其他
- 4. XNA模型翻譯是bizzarre
- 5. Xna模型網格部分
- 6. 模型的XNA方向
- 7. xna 3d模型破壞
- 8. XNA - 相同的源模型
- 9. XNA模型不會編譯?
- 10. XNA C#相機和模型
- 11. Ember重複加載模型
- 12. 動態重複模型
- 13. Django模型避免重複
- 14. 我應該在XNA中重用模型實例嗎?
- 15. XNA模型導入 - 所有網格互相重疊
- 16. XNA C#如何讓模型閃爍?
- 17. 在XNA 3.1中的多個模型
- 18. XNA 4.0繪製缸內模型
- 19. 在XNA中旋轉3D模型
- 20. 獲取模型頂點xna + winForm項目
- 21. 如何在XNA上移動3D模型?
- 22. XNA .GetData給出AccessViolationExceptions模型的紋理
- 23. 模型在XNA中顯示爲黑色
- 24. WP7 XNA顯示3D FBX模型
- 25. XNA自動加載模型紋理
- 26. C#XNA負荷模型錯誤
- 27. XNA 4.0模型紋理問題
- 28. 如何在XNA中獲取2D模型的3D模型?
- 29. Typedef代碼重複。模板類型中的模板類型
- 30. 模板重複模板重複