Page 1 of 1
Can't draw on minimap...
Posted: 05 Mar 2008, 23:04
by KDR_11k
Code: Select all
function gadget:DrawInMiniMap(mmsx, mmsy)
local hasPerk = SYNCED.perks[Spring.GetLocalTeamID()].have[5] --improved gravidar
gl.LoadIdentity()
if hasPerk then
local stepX = mmsx / gravSizeX
local stepY = mmsy / gravSizeZ
for y = 0,gravSizeZ do
l = gravdata[y]
for x = 0,gravSizeX do
--Spring.Echo(x.." "..y)
local val = sqrt(l[x]) / maxV
Color(val,val,val,.4)
Rect(x*stepX, y*stepY, (x+1)*stepX, (y+1)*stepY)
end
end
gl.Color(1,1,1,1)
else
local stepX = mmsx / lowresSizeX
local stepY = mmsy / lowresSizeZ
for y=0,lowresSizeZ do
l=lowres[y]
for x=0,lowresSizeX do
local val = sqrt(l[x]) / maxV
Color(val,val,val,.4)
Rect(x*stepX, y*stepY, (x+1)*stepX, (y+1)*stepY)
end
end
Color(1,1,1,1)
end
end
Doesn't draw anything. Practically the same code is working fine for drawing in the main view but this won't work. I've even tried just throwing a huge gl.Rect in there and that didn't show either.
Re: Can't draw on minimap...
Posted: 05 Mar 2008, 23:09
by user
write in the start of the function:
Code: Select all
gl.PushMatrix()
gl.LoadIdentity()
gl.Translate(0, 1, 0)
gl.Scale(1 / mx, 1 / mz, 1)
gl.Rotate(90, 1, 0, 0)
gl.PopMatrix()
Re: Can't draw on minimap...
Posted: 06 Mar 2008, 16:02
by KDR_11k
Isn't that just for translating world coordinates to minimap coordinates?
Re: Can't draw on minimap...
Posted: 06 Mar 2008, 16:05
by user
no, it is used to draw things on the mini map using the functions used to draw on the world.
Re: Can't draw on minimap...
Posted: 06 Mar 2008, 16:23
by KDR_11k
Well, I tried running my DrawWorld() code in DrawInMiniMap with that wrapper, doesn't do anything either.
EDIT: Okay, that had the scaling factor wrong but it just draws one color over the whole minimap
Also isn't there a way to just draw on the minimap instead of shoehorning a draw world function into a minimap drawer?
Re: Can't draw on minimap...
Posted: 06 Mar 2008, 17:21
by jK
KDR_11k wrote:Isn't that just for translating world coordinates to minimap coordinates?
it does. also the glRotate is redundant, cus a gl.Scale(1 / mx,
-1 / mz, 1) would do the same job.
Your code is missing basic informations to fix the problem, cus it is a scaling problem and how should we know what gravSizeX, etc. is?
And why do you use mmsx&mmsy if you load the identity matrix? that can't work (you have a -1 upto +1 range after gl.LoadIdenity).
PS: never change the ModelViewMatrix w/o Push's and Pop's.
Re: Can't draw on minimap...
Posted: 06 Mar 2008, 19:19
by KDR_11k
The loadidentity was probably a leftover from some testing, didn't work without it either. GravSizeX is the size of the gravdata field in X direction, 64 in this case IIRC. Step is the conversion factor between array coords and minimap coords.
BTW, isn't the rotate about projecting the z coords onto the y axis? I don't think scale would work for that.
EDIT: Ahhh, now it works (using the transformation and DrawWorld). Turns out "mx" and "mz" are supposed to be the mapsize dimensions, not the size of the minimap. I wish user had said that instead of quoting code out of context.