Jump to content

[HELP] Why not show the blips in renderTarget?


Tokio

Recommended Posts

	for index, info in ipairs(blips) do
dxSetRenderTarget(MiniMap["RenderTarget"], true)

		local bx = info.x
		local by = info.y
		local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by)
		local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2))
				local rot = findRotation(bx, by, playerX, playerY)-camZ
				
				local blipX, blipY = 
				getPointFromDistanceRotation(
					(MiniMap_x+MiniMap["width"]+MiniMap_x)/2, 
					(MiniMap_y+MiniMap_y+MiniMap["height"])/2, 
					math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)),
					rot
				)
				

				
				local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX))
				local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))
				local color = 255
				dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,2555,255,255))
dxSetRenderTarget()		
	end

Why not working? No errors/warnings..

Link to comment
On 19/05/2019 at 05:38, Tokio said:
  1. for index, info in ipairs(blips) do
  2. dxSetRenderTarget(MiniMap["RenderTarget"], true)
  3.  
  4. local bx = info.x
  5. local by = info.y
  6. local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by)
  7. local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2))
  8. local rot = findRotation(bx, by, playerX, playerY)-camZ
  9.  
  10. local blipX, blipY =
  11. getPointFromDistanceRotation(
  12. (MiniMap_x+MiniMap["width"]+MiniMap_x)/2,
  13. (MiniMap_y+MiniMap_y+MiniMap["height"])/2,
  14. math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)),
  15. rot
  16. )
  17.  
  18.  
  19.  
  20. local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX))
  21. local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))
  22. local color = 255
  23. dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,2555,255,255))
  24. dxSetRenderTarget()
  25. end

After this you have to draw that render target also 

like this 

	for index, info in ipairs(blips) do
		dxSetRenderTarget(MiniMap["RenderTarget"], true)

		local bx = info.x
		local by = info.y
		local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by)
		local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2))
				local rot = findRotation(bx, by, playerX, playerY)-camZ
				
				local blipX, blipY = 
				getPointFromDistanceRotation(
					(MiniMap_x+MiniMap["width"]+MiniMap_x)/2, 
					(MiniMap_y+MiniMap_y+MiniMap["height"])/2, 
					math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-			(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)),
					rot
				)
				

				
				local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX))
				local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))
				local color = 255
				dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255))
				dxSetRenderTarget()		
	end

	dxDrawImage(MiniMap_x,MiniMap_y,MiniMap["width"],MiniMap["height"], MiniMap["RenderTarget"],0,0,0,tocolor(255,255,255,255))



And also you have a typo in dxDrawImage in tocolor. I fixed it.

Edited by Ayush Rathore
Link to comment
6 hours ago, Ayush Rathore said:

After this you have to draw that render target also 

like this 


	for index, info in ipairs(blips) do
		dxSetRenderTarget(MiniMap["RenderTarget"], true)

		local bx = info.x
		local by = info.y
		local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by)
		local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2))
				local rot = findRotation(bx, by, playerX, playerY)-camZ
				
				local blipX, blipY = 
				getPointFromDistanceRotation(
					(MiniMap_x+MiniMap["width"]+MiniMap_x)/2, 
					(MiniMap_y+MiniMap_y+MiniMap["height"])/2, 
					math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-			(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)),
					rot
				)
				

				
				local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX))
				local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))
				local color = 255
				dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255))
				dxSetRenderTarget()		
	end

	dxDrawImage(MiniMap_x,MiniMap_y,MiniMap["width"],MiniMap["height"], MiniMap["RenderTarget"],0,0,0,tocolor(255,255,255,255))



And also you have a typo in dxDrawImage in tocolor. I fixed it.

The blips are not showing.. :s

Link to comment
  • Scripting Moderators
13 hours ago, Ayush Rathore said:

After this you have to draw that render target also 

like this 


	for index, info in ipairs(blips) do
		dxSetRenderTarget(MiniMap["RenderTarget"], true)

		local bx = info.x
		local by = info.y
		local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by)
		local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2))
				local rot = findRotation(bx, by, playerX, playerY)-camZ
				
				local blipX, blipY = 
				getPointFromDistanceRotation(
					(MiniMap_x+MiniMap["width"]+MiniMap_x)/2, 
					(MiniMap_y+MiniMap_y+MiniMap["height"])/2, 
					math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-			(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)),
					rot
				)
				

				
				local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX))
				local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))
				local color = 255
				dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255))
				dxSetRenderTarget()		
	end

	dxDrawImage(MiniMap_x,MiniMap_y,MiniMap["width"],MiniMap["height"], MiniMap["RenderTarget"],0,0,0,tocolor(255,255,255,255))



And also you have a typo in dxDrawImage in tocolor. I fixed it.

Did you tried to add outputDebugString to check if code actually runs? If it doesn't show, a problem might be ipairs loop, which iterates only indexed table (in your case blips).

Try to use pairs instead.

 

Link to comment
14 hours ago, majqq said:

Did you tried to add outputDebugString to check if code actually runs? If it doesn't show, a problem might be ipairs loop, which iterates only indexed table (in your case blips).

Try to use pairs instead.

 

I tried outputDebugString, but does not show. I tried pairs too, but does not working too.. :s 

Link to comment
  • Moderators
13 hours ago, Tokio said:

I tried outputDebugString, but does not show. I tried pairs too, but does not working too.. :s 

Set the rendertarget recording BEFORE the loop.

Your current code only records 1 blip, clears+sets the rendertarget, records 1 blip, clears+sets the rendertarget, etc.

 

 

Also unset the rendertarget AFTER the loop. Which I can't see in your current code because it is cut off.

Link to comment
On 5/24/2019 at 9:14 AM, IIYAMA said:

Set the rendertarget recording BEFORE the loop.

Your current code only records 1 blip, clears+sets the rendertarget, records 1 blip, clears+sets the rendertarget, etc.

 

 

Also unset the rendertarget AFTER the loop. Which I can't see in your current code because it is cut off.

I tried that, but does not working. :s 

Link to comment
  • Moderators
1 hour ago, Tokio said:

I tried that, but does not working. :s 

Your reply is just a status update, nothing more, nothing less...

 

Do

Work iterative

Creating > Problem?

> show code/results and ask for feedback

> apply changes > TEST > Does it not work?

> show NEW code/results and ask for feedback

> apply changes > TEST > Does it not work?

> show NEW code/results and ask for feedback > etc.

Edited by IIYAMA
Link to comment
		dxSetRenderTarget(MiniMap["RenderTarget"], true)
for index, info in pairs(blips) do


		local bx = info.x
		local by = info.y
		local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by)
		local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2))
				local rot = findRotation(bx, by, playerX, playerY)-camZ
				
				local blipX, blipY = 
				getPointFromDistanceRotation(
					(MiniMap_x+MiniMap["width"]+MiniMap_x)/2, 
					(MiniMap_y+MiniMap_y+MiniMap["height"])/2, 
					math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)),
					rot
				)
				

				
				local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX))
				local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))
				local color = 255
				dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255))

	end
				dxSetRenderTarget()		
						dxDrawImage(MiniMap_x, MiniMap_y, MiniMap["width"], MiniMap["height"], MiniMap["RenderTarget"], 0, 0, 0, tocolor(255,255,255,255))

This is the code...

Link to comment
  • Moderators
1 hour ago, Tokio said:

		dxSetRenderTarget(MiniMap["RenderTarget"], true)
for index, info in pairs(blips) do


		local bx = info.x
		local by = info.y
		local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by)
		local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2))
				local rot = findRotation(bx, by, playerX, playerY)-camZ
				
				local blipX, blipY = 
				getPointFromDistanceRotation(
					(MiniMap_x+MiniMap["width"]+MiniMap_x)/2, 
					(MiniMap_y+MiniMap_y+MiniMap["height"])/2, 
					math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)),
					rot
				)
				

				
				local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX))
				local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))
				local color = 255
				dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255))

	end
				dxSetRenderTarget()		
						dxDrawImage(MiniMap_x, MiniMap_y, MiniMap["width"], MiniMap["height"], MiniMap["RenderTarget"], 0, 0, 0, tocolor(255,255,255,255))

This is the code...

 

 

Where are the blips located when the rendertarget is not being used? (screenshot ?)

And what are the properties of the rendertarget?

 

 

Edited by IIYAMA
Link to comment
  • 2 weeks later...
On 25/05/2019 at 21:53, IIYAMA said:

 

 

Where are the blips located when the rendertarget is not being used? (screenshot ?)

And what are the properties of the rendertarget?

 

 

Blips:

function addBlip(blipID, x, y, text, color)
	data = {
		blipID = blipID,
		x = x,
		y = y,
		text = text,
		color = color
	}
	table.insert(blips, data)
end

addBlip(52, -1940.97986, 568.07715, "Bank", tocolor(255,255,255,255))
addBlip(1, 256.24149, 2961.22998, "North", tocolor(255,255,255,255))
addBlip(18 ,1368.36072 ,-1279.73596, "Üzletek", tocolor(255,255,255,255))
addBlip(999999 ,1553.59485, -1675.84521, "Rendorseg", tocolor(255,255,255,255))
addBlip(10001,1850.17493, -1856.35034, "Rendorseg", tocolor(255,255,255,255))
addBlip(3223,-2053.66650, -49.28458, "Templom", tocolor(255,255,255,255))
addBlip(4324,268.89667 ,-1873.54370, "versenypálya", tocolor(255,255,255,255))
addBlip(969696,703.92871, -2829.69507, "bringarace", tocolor(255,255,255,255))
addBlip(543210 ,1932.81152, -1773.87366, "deli", tocolor(255,255,255,255))
addBlip(543210 ,1045.06812, -901.50098, "északi", tocolor(255,255,255,255))
addBlip(51 ,2779.62866, -2417.62134, "depo", tocolor(255,255,255,255))
addBlip(69 ,-1958.69971, 296.35953, "aszallito", tocolor(255,255,255,255))
addBlip(696 ,1769.72644, -1944.25537, "buszizej", tocolor(255,255,255,255))
addBlip(66999 ,830.25916 ,858.30060, "banyasz", tocolor(255,255,255,255))
addBlip(29 ,2104.32251 ,-1809.31726, "pizzafutarka", tocolor(255,255,255,255))
addBlip(65 ,-2126.23120, -200.79074, "vasasmelo", tocolor(255,255,255,255))
addBlip(123450 ,2192.60425,1990.83911, "bolti elado", tocolor(255,255,255,255))
addBlip(32321 ,2806.90942, 911.94543, "kukasssmelo", tocolor(255,255,255,255))

Rendertarget:

function MiniMap.start()
	MiniMap["RenderTarget"] = dxCreateRenderTarget(MiniMap["width"], MiniMap["height"], true)
end

 

Link to comment
  • Moderators
2 hours ago, Tokio said:

addBlip(52, -1940.97986, 568.07715, "Bank", tocolor(255,255,255,255))

 

addBlip(52, -1940.97986, 568.07715, "Bank", tocolor(255,255,255,255))

 

On 25/05/2019 at 21:53, IIYAMA said:

Where are the blips located when the rendertarget is not being used? (screenshot ?)

* Where on your screen? *

 

local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX))

local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))

 

Link to comment
26 minutes ago, IIYAMA said:

 

addBlip(52, -1940.97986, 568.07715, "Bank", tocolor(255,255,255,255))

 

* Where on your screen? *

 

local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX))

local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))

 

Here when the rendertarget is not used

pfz40eW.png

Link to comment
  • Moderators
1 hour ago, Tokio said:

Here when the rendertarget is not used

pfz40eW.png

The rendertarget will capture the image from the LEFT + TOP corner of the screen.

As it is now, it will not be recorded within the rendertarget.

 

 

 

Link to comment
29 minutes ago, IIYAMA said:

Render them at the top + left corner instead of the bottom + left corner. That shouldn't be a problem, it is your code after all.

Now i see the blips with render target, but outside the radar.. how to fix this?

Uzptl3b.png

Link to comment
1 hour ago, IIYAMA said:

 

I do not know what you are doing or have done.

I created a new render target for blips, and now show the blips just inside the radar, but not in the right positions.. why? I just added the render target, i didn't changed anything..

local screenWidth, screenHeight = guiGetScreenSize()
local worldWidth, worldHeight = 3000, 3000
MiniMap["width"]  = math.floor(screenWidth/1920  * 450)
MiniMap["height"] = math.floor(screenHeight/1080  * 250)
local blipSize = 21
local PlayerBlipSize = 17
local MiniMap_x, MiniMap_y = 7, screenHeight - MiniMap["height"] - 10
local worldMaxSize = 6000

rt = dxCreateRenderTarget(MiniMap["width"], MiniMap["height"], true)
dxSetRenderTarget(rt,true)
for index, info in pairs(blips) do


		local bx = info.x
		local by = info.y
		local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by)
		local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2))
				local rot = findRotation(bx, by, playerX, playerY)-camZ
				
				local blipX, blipY = 
				getPointFromDistanceRotation(
					(MiniMap_x+MiniMap["width"]+MiniMap_x)/2, 
					(MiniMap_y+MiniMap_y+MiniMap["height"])/2, 
					math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)),
					rot
				)				
				local color = 255

				dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255))


				if info.blipID == 1 then
				dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/1.png",0,0,0,tocolor(255,255,255,255))
				end
	end
	dxSetRenderTarget()
		dxDrawImage(MiniMap_x, MiniMap_y, MiniMap["width"], MiniMap["height"], rt, 0, 0, 0, tocolor(255,255,255,255))

 

Link to comment
  • Moderators

Confusing

 

 

Did you use this function perhaps? https://wiki.multitheftauto.com/wiki/DxSetAspectRatioAdjustmentEnabled

 

Or did you not refresh the resource properly?

 

Is the box at the right position?

dxDrawRectangle (MiniMap_x, MiniMap_y, MiniMap["width"], MiniMap["height"])

 

Does the rendertarget actually capture the blips? (disable line 28 temporary)

 

Where are the blips now located when the rendertarget doesn't capture?

 

 

 

 

 

Edited by IIYAMA
Link to comment

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...