- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- namespace OSRose_Map_Viewer.FileHandlers
- {
- public class HIM
- {
- public class Block0
- {
- public struct HIMPart
- {
- public float height2 { get; set; }
- };
- public int width { get; set; }
- public int height { get; set; }
- public int grid_count { get; set; }
- public float grid_size { get; set; }
- public HIMPart[,] HIMParts { get; set; }
- }
- public enum collision_type
- {
- }
- public class quadentry_count
- {
- public float minZ { get; set; }
- public float maxZ { get; set; }
- }
- public string FilePath { get; set; }
- #region Data Declarations
- Block0 HIMInfo { get; set; }
- quadentry_count quadentry_counts { get; set; }
- #endregion
- public HIM()
- {
- }
- public HIM(string filePath)
- {
- Load(filePath);
- }
- public void Load(string filePath)
- {
- FilePath = filePath;
- BinaryReader fh = new BinaryReader(File.OpenRead(filePath));
- HIMInfo = new Block0()
- {
- width = fh.ReadInt32(),
- height = fh.ReadInt32(),
- grid_count = fh.ReadInt32(),
- grid_size = fh.ReadSingle()
- };
- HIMInfo.HIMParts = new Block0.HIMPart[HIMInfo.height, HIMInfo.width];
- for (int j = 0; j < HIMInfo.width; j++)
- {
- for (int k = 0; k < HIMInfo.height; k++)
- {
- HIMInfo.HIMParts[j, k] = new Block0.HIMPart()
- {
- height2 = fh.ReadSingle()
- };
- }
- }
- quadentry_counts = new quadentry_count()
- {
- minZ = fh.ReadSingle(),
- maxZ = fh.ReadSingle()
- };
- }
- public void Save(string filePath)
- {
- FilePath = filePath;
- BinaryWriter fh = new BinaryWriter(File.OpenWrite(filePath));
- fh.Write(HIMInfo.width);
- fh.Write(HIMInfo.height);
- fh.Write(HIMInfo.grid_count);
- fh.Write(HIMInfo.grid_size);
- for (int x = 0; x < HIMInfo.width; x++)
- {
- for (int y = 0; y < HIMInfo.height; y++)
- {
- fh.Write(HIMInfo.HIMParts[x,y].height2);
- }
- }
- fh.Write(quadentry_counts.minZ);
- fh.Write(quadentry_counts.maxZ);
- }
- }
- }
But I am having trouble with this part of the structure:
- DEFINE quadtree_count = 1 + 4 + 16 + 32
- DWORD quadtree_count
- CALL writequadnode( 256 )
- CALL writequadnode( 128 )
- CALL writequadnode( 64 )
- CALL writequadnode( 32 )
- FUNCTION writequadnode( divisonsize )
- // I can't really write the pseudo-format for this, but it writes the min and max heights for each quadratic division of the map quadtree
This structure comes from Bretts website : http://rose.br19.com/?fid=4
If anyone has any insight on how to handle this, it would be much appreciated
rl-1