Thread Tools Display Modes
06-30-11, 09:35 PM   #1
Bleckpan
A Fallenroot Satyr
 
Bleckpan's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 22
Accessing a texture within a texture.

http://wowprogramming.com/BlizzArt/I...P/POIIcons.png Say I want to use the blue horse, how would I be able to use it? As far as I can tell, there are no extra arguments that I can call while setting the texture. I know that the blue horse is index number 38, does this help?

Last edited by Bleckpan : 06-30-11 at 09:35 PM. Reason: Bad wording.
  Reply With Quote
06-30-11, 10:08 PM   #2
Verttex
Super Monkey
 
Verttex's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 297
Crop it out, convert to BLP?
__________________
  Reply With Quote
06-30-11, 10:18 PM   #3
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
http://www.wowwiki.com/API_Texture_SetTexCoord

Allows you to display a sub-region within a texture.


I.e, this will show the bottom-left quarter of a texture:
Code:
texture:SetTexture(MyFile)
texture:SetTexCoord(0, 0.5, 0.5, 1)
or for a blue horsey:
Code:
texture:SetTexture(MyFile)
texture:SetTexCoord(10/14, 11/14, 2/14, 3/14)
or something Never really used them before.

Last edited by Nibelheim : 06-30-11 at 10:27 PM.
  Reply With Quote
07-05-11, 07:06 AM   #4
Bleckpan
A Fallenroot Satyr
 
Bleckpan's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 22
In case if anyone is wondering about this, I found that in the World Map lua file, blizzard uses this function:
Code:
local function GetPOITextureCoords(index)
	local worldMapPixelsPerIcon = 18;
	local worldMapIconDimension = 16;
	
	local offsetPixelsPerSide = (worldMapPixelsPerIcon - worldMapIconDimension)/2;
	local normalizedOffsetPerSide = offsetPixelsPerSide * 1/WORLDMAP_POI_TEXTURE_WIDTH;
	local xCoord1, xCoord2, yCoord1, yCoord2; 
	local coordIncrement = worldMapPixelsPerIcon / WORLDMAP_POI_TEXTURE_WIDTH;
	local xOffset = mod(index, NUM_WORLDMAP_POI_COLUMNS);
	local yOffset = floor(index / NUM_WORLDMAP_POI_COLUMNS);
	
	xCoord1 = xOffset * coordIncrement + normalizedOffsetPerSide;
	xCoord2 = xCoord1 + coordIncrement - normalizedOffsetPerSide;
	yCoord1 = yOffset * coordIncrement + normalizedOffsetPerSide;
	yCoord2 = yCoord1 + coordIncrement - normalizedOffsetPerSide;

        return xCoord1, xCoord2, yCoord1, yCoord2
You simply call this to get the correct coordinates to use for "SetTexCoords".
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Accessing a texture within a texture.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off