Jump to content

Bad math?


Jayceon

Recommended Posts

Posted (edited)

Hello. I have a custom F11 map, but i has some problem with "waypoint" create.

When i'm click on map, the waypoint makes not in the cursor position, the waypoint has a small offset (left, right, up, down) and this is not good.

 

local screenX, screenY = guiGetScreenSize()

local mapTextureSize = 3072
local bigmapMapUnit = mapTextureSize / 6000

local bigmapWidth = screenX - 60
local bigmapHeight = screenY - 60
local bigmapX = 30
local bigmapY = 30
local bigmapCurrentZoom = 1.5

local playerX, playerY, playerZ = 0, 0, 0 -- automatic updating in render

function getWorldFromMapPosition(mapX, mapY) -- This function dont work correctly (mapX, mapY = cursor relative X,Y)
	local worldX = playerX + ((mapX * (((bigmapX + bigmapWidth) / bigmapCurrentZoom) * 2)) - ((bigmapX + bigmapWidth) / bigmapCurrentZoom))
	local worldY = playerY - ((mapY * (((bigmapY + bigmapHeight) / bigmapCurrentZoom) * 2)) - ((bigmapY + bigmapHeight) / bigmapCurrentZoom))
	
	return worldX, worldY
end

function getMapFromWorldPosition(worldX, worldY)
	local mapX = (bigmapX + bigmapWidth / 2) + ((worldX - playerX) * bigmapCurrentZoom) * bigmapMapUnit
	local mapY = (bigmapY + bigmapHeight / 2) - ((worldY - playerY) * bigmapCurrentZoom) * bigmapMapUnit
	
	return mapX, mapY
end

 

Thanks the replies.

Edited by Jayceon
Posted (edited)

Is it an issue with 2D display of waypoint on the custom map or the actual 3D position of the blip/marker/whatever?

Edited by Investor

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...