public EnhancedMesh[][] GetMeshListLOD() { EnhancedMesh[][] result; int geo_index = 0; int perm_index = 0; result = new EnhancedMesh[m_Regions.Length][]; for (int region = 0; region < m_Regions.Length; region++) { geo_index = m_Regions[region].Permutations[perm_index].LodMeshIndex[(int)m_ActiveLOD]; result[geo_index] = new EnhancedMesh[m_MeshList[geo_index].Length]; for (int i = 0; i < m_MeshList[geo_index].Length; i++) { result[geo_index][i] = m_MeshList[geo_index][i]; } } return(result); }
public void LoadDefaultModel(UtilityShader skin) { float scale = 0.1f; //create a cube model m_MeshList = new EnhancedMesh[1][]; m_MeshList[0] = new EnhancedMesh[1]; m_MeshList[0][0] = new EnhancedMesh(12); m_MeshList[0][0].AllocateVertexBuffer(MeshFormat.Model, 36); //back face (0,1,2) (3,4,5) m_MeshList[0][0].RegisterUtilityShader(skin); m_MeshList[0][0].LoadVertex(0, -scale, -scale, scale, -1, 0, 0, 0, 1); m_MeshList[0][0].LoadVertex(1, -scale, scale, scale, -1, 0, 0, 1, 1); m_MeshList[0][0].LoadVertex(2, -scale, -scale, -scale, -1, 0, 0, 0, 0); m_MeshList[0][0].LoadVertex(3, -scale, scale, scale, -1, 0, 0, 1, 1); m_MeshList[0][0].LoadVertex(4, -scale, scale, -scale, -1, 0, 0, 1, 0); m_MeshList[0][0].LoadVertex(5, -scale, -scale, -scale, -1, 0, 0, 0, 0); //right face (6,7,8) (9,10,11) m_MeshList[0][0].LoadVertex(6, -scale, scale, scale, 0, 1, 0, 0, 1); m_MeshList[0][0].LoadVertex(7, scale, scale, scale, 0, 1, 0, 1, 1); m_MeshList[0][0].LoadVertex(8, -scale, scale, -scale, 0, 1, 0, 0, 0); m_MeshList[0][0].LoadVertex(9, scale, scale, scale, 0, 1, 0, 1, 1); m_MeshList[0][0].LoadVertex(10, scale, scale, -scale, 0, 1, 0, 1, 0); m_MeshList[0][0].LoadVertex(11, -scale, scale, -scale, 0, 1, 0, 0, 0); //left face (12,13,14) (15,16,17) m_MeshList[0][0].LoadVertex(12, scale, -scale, scale, 0, -1, 0, 0, 1); m_MeshList[0][0].LoadVertex(13, -scale, -scale, scale, 0, -1, 0, 1, 1); m_MeshList[0][0].LoadVertex(14, scale, -scale, -scale, 0, -1, 0, 0, 0); m_MeshList[0][0].LoadVertex(15, -scale, -scale, scale, 0, -1, 0, 1, 1); m_MeshList[0][0].LoadVertex(16, -scale, -scale, -scale, 0, -1, 0, 1, 0); m_MeshList[0][0].LoadVertex(17, scale, -scale, -scale, 0, -1, 0, 0, 0); //front face (18,19,20) (21,22,23) m_MeshList[0][0].LoadVertex(18, scale, scale, scale, 1, 0, 0, 0, 1); m_MeshList[0][0].LoadVertex(19, scale, -scale, scale, 1, 0, 0, 1, 1); m_MeshList[0][0].LoadVertex(20, scale, scale, -scale, 1, 0, 0, 0, 0); m_MeshList[0][0].LoadVertex(21, scale, -scale, scale, 1, 0, 0, 1, 1); m_MeshList[0][0].LoadVertex(22, scale, -scale, -scale, 1, 0, 0, 1, 0); m_MeshList[0][0].LoadVertex(23, scale, scale, -scale, 1, 0, 0, 0, 0); //top face (24,25,26) (27,28,29) m_MeshList[0][0].LoadVertex(24, scale, scale, scale, 0, 0, 1, 0, 1); m_MeshList[0][0].LoadVertex(25, -scale, scale, scale, 0, 0, 1, 1, 1); m_MeshList[0][0].LoadVertex(26, scale, -scale, scale, 0, 0, 1, 0, 0); m_MeshList[0][0].LoadVertex(27, -scale, scale, scale, 0, 0, 1, 1, 1); m_MeshList[0][0].LoadVertex(28, -scale, -scale, scale, 0, 0, 1, 1, 0); m_MeshList[0][0].LoadVertex(29, scale, -scale, scale, 0, 0, 1, 0, 0); //bottom face (30,31,32) (33,34,35) m_MeshList[0][0].LoadVertex(30, -scale, scale, -scale, 0, 0, -1, 0, 1); m_MeshList[0][0].LoadVertex(31, scale, scale, -scale, 0, 0, -1, 1, 1); m_MeshList[0][0].LoadVertex(32, -scale, -scale, -scale, 0, 0, -1, 0, 0); m_MeshList[0][0].LoadVertex(33, scale, scale, -scale, 0, 0, -1, 1, 1); m_MeshList[0][0].LoadVertex(34, scale, -scale, -scale, 0, 0, -1, 1, 0); m_MeshList[0][0].LoadVertex(35, -scale, -scale, -scale, 0, 0, -1, 0, 0); m_MeshList[0][0].UpdateDxBuffer(); m_MeshList[0][0].AllocateAndSetIndexBuffer(PrimitiveType.TriangleList, Model3D.m_BoxIndices, 0, Model3D.m_BoxIndices.Length); m_Regions = new Region[1]; m_Regions[0] = new Region(); m_Regions[0].Name = "default cube"; m_Regions[0].Permutations = new Permutation[1]; m_Regions[0].Permutations[0] = new Permutation(); m_Regions[0].Permutations[0].LodMeshIndex[0] = 0; m_Regions[0].Permutations[0].LodMeshIndex[1] = 0; m_Regions[0].Permutations[0].LodMeshIndex[2] = 0; m_Regions[0].Permutations[0].LodMeshIndex[3] = 0; m_Regions[0].Permutations[0].LodMeshIndex[4] = 0; m_Regions[0].Permutations[0].LodMeshIndex[5] = 0; m_Regions[0].Permutations[0].Name = "default"; }
public void LoadDirectionModel() { //create a cube model m_MeshList = new EnhancedMesh[1][]; m_MeshList[0] = new EnhancedMesh[6]; short[] ind = new short[6]; for (short i = 0; i < 6; i++) { ind[i] = i; } for (int i = 0; i < 6; i++) { m_MeshList[0][i] = new EnhancedMesh(2); m_MeshList[0][i].AllocateVertexBuffer(MeshFormat.Model, 6); m_MeshList[0][i].AllocateAndSetIndexBuffer(PrimitiveType.TriangleList, ind, 0, ind.Length); } //back face (0,1,2) (3,4,5) m_MeshList[0][0].RegisterUtilityShader(UtilityShader.NX); m_MeshList[0][0].LoadVertex(0, -1.0f, -1.0f, 1.0f, -1, 0, 0, 0, 1); m_MeshList[0][0].LoadVertex(1, -1.0f, 1.0f, 1.0f, -1, 0, 0, 1, 1); m_MeshList[0][0].LoadVertex(2, -1.0f, -1.0f, -1.0f, -1, 0, 0, 0, 0); m_MeshList[0][0].LoadVertex(3, -1.0f, 1.0f, 1.0f, -1, 0, 0, 1, 1); m_MeshList[0][0].LoadVertex(4, -1.0f, 1.0f, -1.0f, -1, 0, 0, 1, 0); m_MeshList[0][0].LoadVertex(5, -1.0f, -1.0f, -1.0f, -1, 0, 0, 0, 0); //right face (6,7,8) (9,10,11) m_MeshList[0][1].RegisterUtilityShader(UtilityShader.PY); m_MeshList[0][1].LoadVertex(0, -1.0f, 1.0f, 1.0f, 0, 1, 0, 0, 1); m_MeshList[0][1].LoadVertex(1, 1.0f, 1.0f, 1.0f, 0, 1, 0, 1, 1); m_MeshList[0][1].LoadVertex(2, -1.0f, 1.0f, -1.0f, 0, 1, 0, 0, 0); m_MeshList[0][1].LoadVertex(3, 1.0f, 1.0f, 1.0f, 0, 1, 0, 1, 1); m_MeshList[0][1].LoadVertex(4, 1.0f, 1.0f, -1.0f, 0, 1, 0, 1, 0); m_MeshList[0][1].LoadVertex(5, -1.0f, 1.0f, -1.0f, 0, 1, 0, 0, 0); //left face (12,13,14) (15,16,17) m_MeshList[0][2].RegisterUtilityShader(UtilityShader.NY); m_MeshList[0][2].LoadVertex(0, 1.0f, -1.0f, 1.0f, 0, -1, 0, 0, 1); m_MeshList[0][2].LoadVertex(1, -1.0f, -1.0f, 1.0f, 0, -1, 0, 1, 1); m_MeshList[0][2].LoadVertex(2, 1.0f, -1.0f, -1.0f, 0, -1, 0, 0, 0); m_MeshList[0][2].LoadVertex(3, -1.0f, -1.0f, 1.0f, 0, -1, 0, 1, 1); m_MeshList[0][2].LoadVertex(4, -1.0f, -1.0f, -1.0f, 0, -1, 0, 1, 0); m_MeshList[0][2].LoadVertex(5, 1.0f, -1.0f, -1.0f, 0, -1, 0, 0, 0); //front face (18,19,20) (21,22,23) m_MeshList[0][3].RegisterUtilityShader(UtilityShader.PX); m_MeshList[0][3].LoadVertex(0, 1.0f, 1.0f, 1.0f, 1, 0, 0, 0, 1); m_MeshList[0][3].LoadVertex(1, 1.0f, -1.0f, 1.0f, 1, 0, 0, 1, 1); m_MeshList[0][3].LoadVertex(2, 1.0f, 1.0f, -1.0f, 1, 0, 0, 0, 0); m_MeshList[0][3].LoadVertex(3, 1.0f, -1.0f, 1.0f, 1, 0, 0, 1, 1); m_MeshList[0][3].LoadVertex(4, 1.0f, -1.0f, -1.0f, 1, 0, 0, 1, 0); m_MeshList[0][3].LoadVertex(5, 1.0f, 1.0f, -1.0f, 1, 0, 0, 0, 0); //top face (24,25,26) (27,28,29) m_MeshList[0][4].RegisterUtilityShader(UtilityShader.PZ); m_MeshList[0][4].LoadVertex(0, 1.0f, 1.0f, 1.0f, 0, 0, 1, 0, 1); m_MeshList[0][4].LoadVertex(1, -1.0f, 1.0f, 1.0f, 0, 0, 1, 1, 1); m_MeshList[0][4].LoadVertex(2, 1.0f, -1.0f, 1.0f, 0, 0, 1, 0, 0); m_MeshList[0][4].LoadVertex(3, -1.0f, 1.0f, 1.0f, 0, 0, 1, 1, 1); m_MeshList[0][4].LoadVertex(4, -1.0f, -1.0f, 1.0f, 0, 0, 1, 1, 0); m_MeshList[0][4].LoadVertex(5, 1.0f, -1.0f, 1.0f, 0, 0, 1, 0, 0); //bottom face (30,31,32) (33,34,35) m_MeshList[0][5].RegisterUtilityShader(UtilityShader.NZ); m_MeshList[0][5].LoadVertex(0, -1.0f, 1.0f, -1.0f, 0, 0, -1, 0, 1); m_MeshList[0][5].LoadVertex(1, 1.0f, 1.0f, -1.0f, 0, 0, -1, 1, 1); m_MeshList[0][5].LoadVertex(2, -1.0f, -1.0f, -1.0f, 0, 0, -1, 0, 0); m_MeshList[0][5].LoadVertex(3, 1.0f, 1.0f, -1.0f, 0, 0, -1, 1, 1); m_MeshList[0][5].LoadVertex(4, 1.0f, -1.0f, -1.0f, 0, 0, -1, 1, 0); m_MeshList[0][5].LoadVertex(5, -1.0f, -1.0f, -1.0f, 0, 0, -1, 0, 0); for (int i = 0; i < 6; i++) { m_MeshList[0][i].UpdateDxBuffer(); } m_Regions = new Region[1]; m_Regions[0] = new Region(); m_Regions[0].Name = "default cube"; m_Regions[0].Permutations = new Permutation[1]; m_Regions[0].Permutations[0] = new Permutation(); m_Regions[0].Permutations[0].LodMeshIndex[0] = 0; m_Regions[0].Permutations[0].LodMeshIndex[1] = 0; m_Regions[0].Permutations[0].LodMeshIndex[2] = 0; m_Regions[0].Permutations[0].LodMeshIndex[3] = 0; m_Regions[0].Permutations[0].LodMeshIndex[4] = 0; m_Regions[0].Permutations[0].LodMeshIndex[5] = 0; m_Regions[0].Permutations[0].Name = "default"; }