WoW世界地图分析

一.
在游戏中
mapFileName, textureHeight, textureWidth = GetMapInfo() 获取地图信息
然后获取到地图所在的图片路径
pathPrefix = “Interface\\WorldMap\\”..mapFileName..”\\”

例如荒芜之地
Badlands, 667, 768
二.
获取覆盖层数量
numOverlays = GetNumMapOverlays()


获取覆盖层信息
local texName, texWidth, texHeight, offsetX, offsetY = GetMapOverlayInfo(1-numOverlays)


拼接算法:

for texName, texID in pairs(overlayMap) do
local textureName = pathPrefix .. texName
local textureWidth, textureHeight, offsetX, offsetY = mod(texID, 2^10), mod(floor(texID / 2^10), 2^10), mod(floor(texID / 2^20), 2^10), floor(texID / 2^30)

local numTexturesWide = ceil(textureWidth / 256)
local numTexturesTall = ceil(textureHeight / 256)
local neededTextures = textureCount + (numTexturesWide * numTexturesTall)
if neededTextures > numOv then
for j = numOv + 1, neededTextures do
local texture = frame:CreateTexture(format(frameName, j), “ARTWORK”)
tinsert(textureCache, texture)
end
numOv = neededTextures
end
local texturePixelWidth, textureFileWidth, texturePixelHeight, textureFileHeight
for j = 1, numTexturesTall do
if j < numTexturesTall then texturePixelHeight = 256 textureFileHeight = 256 else texturePixelHeight = mod(textureHeight, 256) if texturePixelHeight == 0 then texturePixelHeight = 256 end textureFileHeight = 16 while textureFileHeight < texturePixelHeight do textureFileHeight = textureFileHeight * 2 end end for k = 1, numTexturesWide do textureCount = textureCount + 1 local texture = textureCache[textureCount] if k < numTexturesWide then texturePixelWidth = 256 textureFileWidth = 256 else texturePixelWidth = mod(textureWidth, 256) if texturePixelWidth == 0 then texturePixelWidth = 256 end textureFileWidth = 16 while textureFileWidth < texturePixelWidth do textureFileWidth = textureFileWidth * 2 end end texture:SetWidth(texturePixelWidth*scale) texture:SetHeight(texturePixelHeight*scale) texture:SetTexCoord(0, texturePixelWidth / textureFileWidth, 0, texturePixelHeight / textureFileHeight) texture:ClearAllPoints() texture:SetPoint("TOPLEFT", (offsetX + (256 * (k-1))) * scale, -(offsetY + (256 * (j - 1))) * scale) texture:SetTexture(format(textureName.."%d", ((j - 1) * numTexturesWide) + k))if discoveredOverlays[texName] then texture:SetVertexColor(1, 1, 1) texture:SetAlpha(1 - (alphaMod or 0)) texture:SetDrawLayer("ARTWORK") else texture:SetVertexColor(r, g, b) texture:SetAlpha(a * ( 1 - (alphaMod or 0))) texture:SetDrawLayer("BORDER") if db.debug then DEFAULT_CHAT_FRAME:AddMessage(format("|cff33ff99Mapster|r: Subzone: %s in zone: %s", texName, mapFileName)) end endtexture:Show() end end end [/lua]

Leave a Comment

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: