Jump to content

Retrovisor DX


aka Blue

Recommended Posts

Posted

Buenas. No sé exactamente como explicar ésto así que dejaré una imagen a continuación. Básicamente quiero scriptear un retrovisor DX con el cual se pueda ver la parte trasera del vehículo para posteriormente ver si viene un vehículo, el lugar por donde hemos pasado, etc.

PHrg4yE.png

Gracias de antemano.

Posted

Creo que puedes setear un setCameraMatrix en un onClientPreRender, llamar dxUpdateScreenSource y en onClientRender setCameraTarget(localPlayer), pero no estoy seguro.

Posted

Hay un script en la comunidad que se llama cam2rt que hace exactamente eso. Inclusive, tiene lo que pides en 'test.lua':

evPaf9s.png

Claro, yo lo edite un poco para hacerlo de esa forma de la fotografía, pero la funcion original "de fabrica", tiene lo que dices.^_^

Posted

A mi me funciono bien O.o. Es el segundo, en test.lua hay 3 pruebas. Una con una pantalla "real" en el mundo, otra con dxDrawImage y no recuerdo la otra. La de dxDrawImage es la que muestra la cámara trasera.

Posted

@Sergioks A mi no me funciona. Me tira error en el 5 argumento del draw de la imagen, dice que es nil.

local thisImage = nil 

addEventHandler( "onClientResourceStart", resourceRoot, function()
	local cameraMat = getCamera():getMatrix()
	thisImage = cam2RTImage:create( cameraMat, true )
	if thisImage then
		outputChatBox( "kitipasa" )
	end
end
)

addEventHandler( "onClientResourceStop", resourceRoot, function()
	thisImage:destroy()
end
)

addEventHandler( "onClientPreRender", root, function()
	if thisImage then
		local mat = localPlayer:getMatrix()
		local pos = mat:getPosition() - mat:getForward() * 2
		local rot = mat:getRotation() - Vector3( 0, 0, 180 )
		local camMatrix = Matrix( pos, rot)
		thisImage:setCameraMatrix( camMatrix )
	end
end
)

local sx, sy = guiGetScreenSize ()
addEventHandler( "onClientHUDRender", root, function()
	if thisImage then
		myImage = thisImage:getRenderTarget()
		local colR, colG, colB = getSkyGradient()
		dxDrawRectangle(sx / 2 - sy * 0.25, 0, sy * 0.5, sy * ((sy/ sx) * 0.4), tocolor(colR, colG, colB, 255))
		dxDrawImage(sx / 2 - sy * 0.25, 0, sy * 0.5, sy * ((sy/ sx) * 0.4), myImage)
	end
end
)

 

Posted
42 minutes ago, aka Blue said:

@Sergioks A mi no me funciona. Me tira error en el 5 argumento del draw de la imagen, dice que es nil.


local thisImage = nil addEventHandler( "onClientResourceStart", resourceRoot, function()	local cameraMat = getCamera():getMatrix()	thisImage = cam2RTImage:create( cameraMat, true )	if thisImage then		outputChatBox( "kitipasa" )	endend)addEventHandler( "onClientResourceStop", resourceRoot, function()	thisImage:destroy()
end
)

addEventHandler( "onClientPreRender", root, function()
	if thisImage then
		local mat = localPlayer:getMatrix()
		local pos = mat:getPosition() - mat:getForward() * 2
		local rot = mat:getRotation() - Vector3( 0, 0, 180 )
		local camMatrix = Matrix( pos, rot)
		thisImage:setCameraMatrix( camMatrix )
	end
end
)

local sx, sy = guiGetScreenSize ()
addEventHandler( "onClientHUDRender", root, function()
	if thisImage then
		myImage = thisImage:getRenderTarget()
		local colR, colG, colB = getSkyGradient()
		dxDrawRectangle(sx / 2 - sy * 0.25, 0, sy * 0.5, sy * ((sy/ sx) * 0.4), tocolor(colR, colG, colB, 255))
		dxDrawImage(sx / 2 - sy * 0.25, 0, sy * 0.5, sy * ((sy/ sx) * 0.4), myImage)
	end
end
)

 

mi test.lua esta asi:

--
-- test.lua
--

--[[
local thisMirror = nil

addEventHandler( "onClientResourceStart", resourceRoot, function()
	setCameraInterior ( 15 )
	setElementInterior( localPlayer, 15 )
	setElementPosition( localPlayer, 2222, -1151, 1026 )
	local mirrorMat = Matrix( Vector3( 2217.229, -1150.458, 1026.796 ), Vector3( 0, 0, 275 ))
	thisMirror = cam2RTMirror:create( mirrorMat, Vector2( 4, 3 ))
end
)

addEventHandler( "onClientResourceStop", resourceRoot, function()
	thisMirror:destroy()
end
)

addEventHandler( "onClientPreRender", root, function()
	if thisMirror then
		thisMirror:draw()
	end
end
)
--]]

--[[
local thisScreen = nil

addEventHandler( "onClientResourceStart", resourceRoot, function()
	setCameraInterior ( 15 )
	setElementInterior( localPlayer, 15 )
	setElementPosition( localPlayer, 2222, -1151, 1026 )
	local screenMat = Matrix( Vector3( 2217.229, -1150.458, 1026.796 ), Vector3( 0, 0, 275 ))
	local cameraMat = Matrix( Vector3( 2217.229, -1150.458, 1026.796 ), Vector3( 0, 0, 275 ))
	thisScreen = cam2RTScreen:create( cameraMat, screenMat, Vector2( 4, 3 ))
end
)

addEventHandler( "onClientResourceStop", resourceRoot, function()
	thisScreen:destroy()
end
)

addEventHandler( "onClientPreRender", root, function()
	if thisScreen then
		thisScreen:draw()
	end
end
)

--]]--

--[
local thisImage = nil

addEventHandler( "onClientResourceStart", resourceRoot, function()
	outputChatBox('You might want to change world drawing range by changing shader range from 60 to 0 - look in c_cam2RTImage.lua line 12, 13')
	local cameraMat = getCamera():getMatrix()
	thisImage = cam2RTImage:create( cameraMat, true )
end
)

addEventHandler( "onClientResourceStop", resourceRoot, function()
	thisImage:destroy()
end
)

addEventHandler( "onClientPreRender", root, function()
	if thisImage then
		local mat = localPlayer:getMatrix()
		local pos = mat:getPosition() - mat:getForward() * 2
		local rot = mat:getRotation() - Vector3( 0, 0, 180 )
		local camMatrix = Matrix( pos, rot)
		thisImage: setCameraMatrix( camMatrix )
	end
end
)

local sx, sy = guiGetScreenSize ()
addEventHandler( "onClientHUDRender", root, function()
	if thisImage then
		myImage = thisImage:getRenderTarget()
		local colR, colG, colB = getSkyGradient()
		dxDrawRectangle(sx / 2 - sy * 0.25, 0, sy * 0.5, sy * ((sy/ sx) * 0.4), tocolor(colR, colG, colB, 255))
		dxDrawImage(sx / 2 - sy * 0.25, 0, sy * 0.5, sy * ((sy/ sx) * 0.4), myImage)
	end
end
)

--]]--

y me funciona 

14808900_1146841528686553_1405256228_o.p

O.o

  • Recently Browsing   0 members

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