[NavMesh][MPQ] Geometry parsing issues menu

Shout-Out

User Tag List

Page 3 of 3 FirstFirst 123
Results 31 to 41 of 41
  1. #31
    rens's Avatar Sergeant
    Reputation
    36
    Join Date
    Sep 2012
    Posts
    38
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Tanaris4 View Post
    Are you using wowmapper @rens?
    No, I could never get that to work. I am using a modified version of meshReader; however I do plan on starting again once I understand this more.

    Originally Posted by Bananenbrot View Post
    See http://www.ownedcore.com/forums/worl...ml#post2757020 ([NavMesh][MPQ] Geometry parsing issues) and what I added at the end of the paragraph at ADT/v18 - WoWDev.
    If there is anything you didn't understand, re-PM me to get online at skype.
    I already read all this. I think my problem is that the MCVT in the MCNK header is now 0. You already said "Just read chunk after chunk, switch on the magic of the header and take what you need.", but I need that offset :P

    [NavMesh][MPQ] Geometry parsing issues
  2. #32
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The offset is the chunk's size, which is stored directly after the magic in the chunkheader iirc.

  3. #33
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @rens you don't need the offset as you can just loop through all of them (given the size of the chunk is in the header)
    https://tanaris4.com

  4. #34
    thebillkidy's Avatar Member
    Reputation
    1
    Join Date
    Apr 2009
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this exists from 5.2.0 already?

  5. #35
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since I already received about 5 PMs regarding how to implement the stuff I explained rather detailed, here is some code.
    When parsing the MCNK chunk, set your Holes field, which is a byte array, like this:
    Code:
                // McnkHeader* mcnk = ...;
                _flags = mcnk->Flags;
                Holes = _flags.HasFlag(McnkHeaderFlags.HighResHoleMap) ? mcnk->HighResHoles : TransformToHighRes(mcnk->Holes);
    Code:
            private static byte[] TransformToHighRes(ushort holes)
            {
                var ret = new byte[8];
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        int holeIdxL = (i/2)*4 + (j/2);
                        if (((holes >> holeIdxL) & 1) == 1)
                            ret[i] |= (byte)(1 << j);
                    }
                }
                return ret;
            }
    And finally you check for holes like:
    Code:
            public bool HasHole(int col, int row)
            {
                return ((Holes[row] >> col) & 1) == 1;
            }
    By the way, this is my MCNK header struct and the flags enum:
    Code:
            [Flags]
            private enum McnkHeaderFlags : uint
            {
                HighResHoleMap = 0x10000
            }
    
            private struct McnkHeader
            {
                public McnkHeaderFlags Flags;
                public int X;
                public int Y;
                int nLayers;
                int nDoodadRefs;
                uint offMcvt; // 0x14
                uint offMcnr; // 0x18
                int offMcly;
                int offMcrf;
                int offMcal;
                int sizeAlpha;
                int offMcsh;
                int sizeShadow;
                int areaId;
                int nMapObjRefs;
                public ushort Holes;
                ushort HolesAlign;
                unsafe fixed short lowQualityTexturingMap [8];
                int predTex;
                int noEffectDoodad;
                int offMcse;
                int nSoundEmitters;
                int offMclq;
                int sizeLiquid;
                public Vector3 Position;
                int offMccv;
                unsafe fixed int pad[2];
                public byte[] HighResHoles { get { return BitConverter.GetBytes(offMcvt + ((ulong)offMcnr << 32)); } } // 0x14
            }
    For C++, it's as easy as declaring (offMsvt+offMcnr)|HighResHoles as a union. Didn't want to add FieldOffset for every field here.

  6. #36
    rens's Avatar Sergeant
    Reputation
    36
    Join Date
    Sep 2012
    Posts
    38
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do you use
    Code:
    public ushort Holes;

    Edit: Like this
    Code:
            public byte[] Holes
            {
                get
                {
                    if (Header.Flags.HasFlag(McnkHeaderFlags.HighResHoleMap))// && isHoleMapEmpty(Header.HighResHoles))
                        return Header.HighResHoles;
                    else
                        return TransformToHighRes(Header.Holes);
                }
            }
    Last edited by rens; 07-10-2013 at 09:40 AM.

  7. #37
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by rens View Post
    Edit: Like this
    Code:
    snip
    Yes. ^D

  8. #38
    rens's Avatar Sergeant
    Reputation
    36
    Join Date
    Sep 2012
    Posts
    38
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Working on this again today, after follow suggestions to loop though and find the MCVT Chunk im doing this:

    Code:
            public class MapChunkHeader
            {
                public McnkHeaderFlags Flags;
                public int IndexX;
                public int IndexY;
                public int Layers;
                public int DoodadRefs;
                public uint OffsetMCVT;
                public uint OffsetMCNR;
                public int OffsetMCLY;
                public int OffsetMCRF;
                public int OffsetMCAL;
                public int SizeMCAL;
                public int OffsetMCSH;
                public int SizeMCSH;
                public int AreaId;
                public int MapObjectRefs;
                public ushort Holes;
                public ushort HolesAlign;
                public short[] LowQualityTextureMap;
                public int PredTex;
                public int NumberEffectDoodad;
                public int OffsetMCSE;
                public int SoundEmitters;
                public int OffsetMCLQ;
                public int SizeMCLQ;
                public Vector3 Position;
                public int OffsetMCCV;
                public int[] pad;
    
                //Other
                public uint MCVTOffset = uint.MaxValue;
                public byte[] HighResHoles { get { return BitConverter.GetBytes(OffsetMCVT + ((ulong)OffsetMCNR << 32)); } } // 0x14
                public void Read(Stream s)
                {
                    var r = new BinaryReader(s);
                    Flags = (McnkHeaderFlags)r.ReadUInt32();
                    IndexX = r.ReadInt32();
                    IndexY = r.ReadInt32();
                    Layers = r.ReadInt32();
                    DoodadRefs = r.ReadInt32();
                    OffsetMCVT = r.ReadUInt32();
                    OffsetMCNR = r.ReadUInt32();
                    OffsetMCLY = r.ReadInt32();
                    OffsetMCRF = r.ReadInt32();
                    OffsetMCAL = r.ReadInt32();
                    SizeMCAL = r.ReadInt32();
                    OffsetMCSH = r.ReadInt32();
                    SizeMCSH = r.ReadInt32();
                    AreaId = r.ReadInt32();
                    MapObjectRefs = r.ReadInt32();
                    Holes = r.ReadUInt16();
                    HolesAlign = r.ReadUInt16();
                    LowQualityTextureMap = new short[8];
                    for (int i = 0; i < 8; i++)
                        LowQualityTextureMap[i] = r.ReadInt16();
                    PredTex = r.ReadInt32();
                    NumberEffectDoodad = r.ReadInt32();
                    OffsetMCSE = r.ReadInt32();
                    SoundEmitters = r.ReadInt32();
                    OffsetMCLQ = r.ReadInt32();
                    SizeMCLQ = r.ReadInt32();
                    Position = Vector3Helper.Read(s);
                    OffsetMCCV = r.ReadInt32();
                    pad = new int[2];
                    for (int i = 0; i < 2; i++)
                        pad[i] = r.ReadInt32();
    
                    string sigString = "MCVT";
                    uint sigInt = BitConverter.ToUInt32(Encoding.ASCII.GetBytes(sigString).Reverse().ToArray(), 0);
                    long currentPos = r.BaseStream.Position;
                    while (MCVTOffset == uint.MaxValue && r.BaseStream.CanRead)
                    {
                        var sig = r.ReadUInt32();
                        var size = r.ReadUInt32();
    
                        if (sig == sigInt)
                        {
                            break;
                        }
    
                        currentPos = sig + size;                 
                        r.BaseStream.Position = currentPos;
                    }
                }
            }
    MCVT is always just after the padding at the end of the header.

    Edit:

    My original issue still stands, world\maps\GoldRushBG\GoldRushBG_29_31.adt and about 5 other tiles here are flat for the most part.

    Last edited by rens; 07-11-2013 at 05:33 AM.

  9. #39
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are doing it wrong. Don't use any offsets of the MCNK header, do it all by following the more or less linked list from chunk header to chunk header.
    See https://github.com/Bananenbrot/Banan...ed/MapChunk.cs and https://github.com/Bananenbrot/Banan...nkCollector.cs. ChunkCollector just iterates all chunks by scanning chunk headers and computing the next chunk based on the chunk size field.
    Obviously, if you adapt that to your stream based approach, it won't be half as pretty.

    Note also that BananaMpq has not yet the changes for 5.3. I plan to update it some time in the future, but it's a huge headache because I'm using a modified version in my own code.

  10. #40
    rens's Avatar Sergeant
    Reputation
    36
    Join Date
    Sep 2012
    Posts
    38
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Bananenbrot View Post
    You are doing it wrong. Don't use any offsets of the MCNK header, do it all by following the more or less linked list from chunk header to chunk header.
    See https://github.com/Bananenbrot/Banan...ed/MapChunk.cs and https://github.com/Bananenbrot/Banan...nkCollector.cs. ChunkCollector just iterates all chunks by scanning chunk headers and computing the next chunk based on the chunk size field.
    Obviously, if you adapt that to your stream based approach, it won't be half as pretty.

    Note also that BananaMpq has not yet the changes for 5.3. I plan to update it some time in the future, but it's a huge headache because I'm using a modified version in my own code.
    Im only using the offsets that you code shows you using in HighResHoles.

    To get MCVT location I am searching for it.

  11. #41
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by rens View Post
    Im only using the offsets that you code shows you using in HighResHoles.

    To get MCVT location I am searching for it.
    Your search doesn't set MCVTOffset. Seriously, I feel not in any way responsible for what fails at your side, if you don't even care to comprehend your own code.
    You have to search for those other chunks too, btw. Don't use the offsets in the MCNK header. Just don't.

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Parsing mpq files for navmeshes
    By karnkore in forum Diablo 3 Memory Editing
    Replies: 1
    Last Post: 04-23-2014, 03:17 AM
  2. [Release] [Mpq][C#] Geometry parser/viewer
    By Bananenbrot in forum WoW Memory Editing
    Replies: 19
    Last Post: 03-11-2014, 05:35 AM
  3. [Question] MPQ compile issue
    By Aliv3 in forum WoW ME Questions and Requests
    Replies: 1
    Last Post: 10-14-2007, 04:44 AM
  4. patching issue
    By Marlo in forum World of Warcraft General
    Replies: 0
    Last Post: 07-22-2006, 07:35 PM
  5. [Patch 1.11] - Known Issues (6-20-06)
    By Cypher in forum World of Warcraft General
    Replies: 1
    Last Post: 06-24-2006, 12:42 AM
All times are GMT -5. The time now is 11:32 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search