FuriouZ Posted April 13, 2014 Posted April 13, 2014 (edited) Hello all! I have question that how i can attach dxText to vehicle component Example(guieditor) If i move camera front of the car,then i get theese errors, otherwise debug doesn't show any errors, but text doesn't appear too addEventHandler("onClientRender",root, function() local vehicle = getPedOccupiedVehicle(localPlayer) local getComponent = getVehicleComponents(vehicle) if ( vehicle ) then for k in pairs (getComponent) do local vcpX, vcpY, vcpZ = getVehicleComponentPosition(vehicle, "bump_rear_dummy") local vcpSP,vcpSP = getScreenFromWorldPosition ( vcpX, vcpY, vcpZ ) if ( vcpSP and vcpSP ) then dxDrawLine(vcpSP,vcpSP,796, 547, 871, 472, tocolor(255, 255, 255, 255), 2, true) dxDrawLine(vcpSP,vcpSP,871, 472, 1010, 473, tocolor(255, 255, 255, 255), 2, true) dxDrawText(vcpSP,vcpSP,"Damage: 100%", 871, 449, 1010, 473, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, true, false, false) end end end end ) Edited April 13, 2014 by Guest Homepage @ http://rageresources.blogspot.com/ Offical Facebook @ https://www.facebook.com/pages/Rage-Scr ... fref=photo
Gallardo9944 Posted April 13, 2014 Posted April 13, 2014 Like this? http://er-mta.net/screenshots/cloud/Scr ... _28_49.png Get offset with vehicle matrix (don't forget to calculate bounding box too), use 3D line, draw simple text over the screen with getScreenFromWorldPosition. Code Debugger - Minimalistic MTA debug line replacement
FuriouZ Posted April 13, 2014 Author Posted April 13, 2014 How i get the vehicle matrix ? something like this ? local vehicle = getPedOccupiedVehicle(localPlayer) local vehX, vehY, vehZ, vehLX, vehLY, vehLZ = getCameraMatrix (vehicle) local vcpSP,vcpSP = getScreenFromWorldPosition ( vehX, vehY, vehZ, vehLX, vehLY, vehLZ ) Homepage @ http://rageresources.blogspot.com/ Offical Facebook @ https://www.facebook.com/pages/Rage-Scr ... fref=photo
Gallardo9944 Posted April 13, 2014 Posted April 13, 2014 function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end Get the offset which equals to minX and minY of vehicle's bounding box and draw a line between the element position and that point. Code Debugger - Minimalistic MTA debug line replacement
Einheit-101 Posted April 14, 2014 Posted April 14, 2014 This wont work with all components (like misc_c) and modified vehicles could make problems, too. getVehicleComponentPosition has issues and custom vehicles can cause a dummy misplacement. But the bumper should work.
Gallardo9944 Posted April 14, 2014 Posted April 14, 2014 why would you even want a custom component? If it's something like the roof / spoiler of the car, use the bounding box, it's rather precise. Of course you can get the component position, but some components might be missing for some cars. Code Debugger - Minimalistic MTA debug line replacement
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now