Tokio

[HELP] Why not show the blips in renderTarget?

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

Share this post


Link to post
Posted (edited)
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

Share this post


Link to post
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

Share this post


Link to post
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.

 

Share this post


Link to post
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 

Share this post


Link to post
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.

Share this post


Link to post
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 

Share this post


Link to post
Posted (edited)
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

Share this post


Link to post
		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...

Share this post


Link to post
Posted (edited)
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

Share this post


Link to post
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

 

Share this post


Link to post
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))

 

Share this post


Link to post
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

Share this post


Link to post
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.

 

 

 

Share this post


Link to post
6 minutes ago, IIYAMA said:

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.

 

 

 

Then what can i do?

Share this post


Link to post
1 hour ago, Tokio said:

Then what can i do?

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.

Share this post


Link to post
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

Share this post


Link to post
1 minute ago, Tokio said:

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

Uzptl3b.png

 

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

Share this post


Link to post
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))

 

Share this post


Link to post

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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.