Exemplo n.º 1
0
        // Returns an ExtendedPrimGroup with a mesh for the passed heightmap.
        // Note that the returned EPG does not include any face information -- the caller must add a texture.
        public DisplayableRenderable MeshFromHeightMap(float[,] pHeightMap, int regionSizeX, int regionSizeY,
                                                       IAssetFetcher assetFetcher, OMV.Primitive.TextureEntryFace defaultTexture)
        {
            // OMVR.Face rawMesh = m_mesher.TerrainMesh(pHeightMap, 0, pHeightMap.GetLength(0)-1, 0, pHeightMap.GetLength(1)-1);
            ConvOAR.Globals.log.DebugFormat("{0} MeshFromHeightMap: heightmap=<{1},{2}>, regionSize=<{3},{4}>",
                                            _logHeader, pHeightMap.GetLength(0), pHeightMap.GetLength(1), regionSizeX, regionSizeY);
            OMVR.Face rawMesh = ConvoarTerrain.TerrainMesh(pHeightMap, (float)regionSizeX, (float)regionSizeY);

            RenderableMesh rm = ConvertFaceToRenderableMesh(rawMesh, assetFetcher, defaultTexture, new OMV.Vector3(1, 1, 1));

            RenderableMeshGroup rmg = new RenderableMeshGroup();

            rmg.meshes.Add(rm);

            return(rmg);
        }
Exemplo n.º 2
0
        private void DumpDisplayable(Displayable disp, string header, int level)
        {
            string spaces = "                                                           ";
            string spacer = spaces.Substring(0, level * 2);

            LogBProgress("{0}{1}  displayable: name={2}, pos={3}, rot={4}",
                         _logHeader, spacer, disp.name, disp.offsetPosition, disp.offsetRotation);
            RenderableMeshGroup rmg = disp.renderable as RenderableMeshGroup;

            if (rmg != null)
            {
                rmg.meshes.ForEach(mesh => {
                    LogBProgress("{0}{1}    mesh: mesh={2}. material={3}",
                                 _logHeader, spacer, mesh.mesh, mesh.material);
                });
            }
            disp.children.ForEach(child => {
                DumpDisplayable(child, "Child", level + 1);
            });
        }
Exemplo n.º 3
0
        private List <Displayable> PackMeshesIntoDisplayables(List <InvertedMesh> meshList, OMV.Vector3 gPos, CreateNameFunc createName)
        {
            return(meshList.Select(imesh => {
                /*
                 * ConvOAR.Globals.log.DebugFormat("{0} CreateInstanceForSharedMeshes: hash={1}, instPos={2}, dispPos={3}, numVerts={4}",
                 *              _logHeader, imesh.renderableMesh.mesh.GetBHash(),
                 *              imesh.containingInstance.Position,
                 *              imesh.containingDisplayable.offsetPosition,
                 *              imesh.renderableMesh.mesh.vertexs.Count);
                 */

                RenderableMeshGroup mesh = new RenderableMeshGroup();
                mesh.meshes.Add(imesh.renderableMesh);

                Displayable disp = new Displayable(mesh);
                disp.name = createName(imesh);
                disp.offsetPosition = imesh.globalPosition - gPos;
                disp.offsetRotation = imesh.globalRotation;
                disp.renderable = mesh;

                return disp;
            }).ToList());
        }