Jump to content

Drawing 3D image


FuriouZ

Recommended Posts

Hello, i have some questions

How i can attach image under the vehicle like this ?

(THIS IS SHADER)

mta-screen_2014-01-25_17-52-19.png

But is it possible to create same thing via dxDrawMaterialLine3D ?

Here is code:

local Sheild = dxCreateTexture("neons/neon_sheild.png") 
addEventHandler("onClientRender", root, 
    function()  -- x,y,z, targetx,targety,targetz,texture,width,color 
        dxDrawMaterialLine3D (0,0,2,0,0,15,Sheild, 10, tocolor(255,255,255,255)) 
    end) 

I tryed, but i don't understang how i can add it under the car with correct position

mta-screen_2014-01-25_17-52-09.png

Link to comment
getElementPosition 
-- get position of car 

getScreenFromWorldPosition 
-- get screen position from position of car  

https://wiki.multitheftauto.com/wiki/onClientRender

-- render the image

dxDrawImage 
-- draw the image using the getScreenFromWorldPosition with car position and rotation to make it flat 

Almost works, but i don't understand how to put it under the car and there's one more problem with camera position

Cam position #1

mta-screen_2014-01-25_21-07-51.png

Cam position #2

mta-screen_2014-01-25_21-07-55.png

local Sheild = dxCreateTexture("neons/neon_sheild.png") 
local gVehicle = getPedOccupiedVehicle(localPlayer) 
  
function drawImage() 
local x,y,z = getElementPosition(gVehicle) 
    dxDrawMaterialLine3D(x,y,z -1,x,y,5,Sheild, 5) 
end 
addEventHandler("onClientRender", root, drawImage) 

Link to comment

@theVenom

dxDrawImage ( float posX, float posY, float width, float height, mixed image [, float rotation = 0, float rotationCenterOffsetX = 0,  
float rotationCenterOffsetY = 0, int color = tocolor(255,255,255), bool postGUI = false ] ) 

float rotation = 0, float rotationCenterOffsetX = 0, float rotationCenterOffsetY = 0

Just use the rotation.

Link to comment

bool dxDrawMaterialLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ,

element material, int width, [, int color = white, float faceTowardX, float faceTowardY, float faceTowardZ ] )

First and second point in space (x,y,z) should be bottom back and bottom front of the vehicle. Element material is the texture then width, color white, fade toward xyz would be 0,0,-1

Link to comment

...

getElementMatrix 

You can't keep the image at the same position from the vehicle's point of view just by using position. Obviously, rotation makes difference. And matrix is the most straightforward and intuitive way to represent the rotation.

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