Steve Scott Posted January 8, 2019 Share Posted January 8, 2019 (edited) Hey Community, My conception is that I want to move a random created object with the cursor along an axis. I could create the axises with the function dxDrawLine3D and I made 3 rectangles on the end of the axis with dxDrawRectangle with help of getScreenFromWorldPosition(). A picture of it: My problem is that I can't find out the calculation which I could the object move with. Thanks for all the help! Edited January 8, 2019 by tacsa Link to comment
AlexRazor Posted January 8, 2019 Share Posted January 8, 2019 I'd try something with OnClientRender, GetCursorPosition and SetElementPosition. Link to comment
Steve Scott Posted January 8, 2019 Author Share Posted January 8, 2019 37 minutes ago, AlexRazor said: I'd try something with OnClientRender, GetCursorPosition and SetElementPosition. 35 minutes ago, Dimos7 said: Use onClientClick Thanks guys, but I'm not a beginner. I know how to get these things. I only need a calculation for the moving along the axises. Link to comment
Moderators IIYAMA Posted January 10, 2019 Moderators Share Posted January 10, 2019 (edited) On 08/01/2019 at 18:03, tacsa said: Thanks guys, but I'm not a beginner. I know how to get these things. I only need a calculation for the moving along the axises. See the first example of this page: https://wiki.multitheftauto.com/wiki/GetElementMatrix Maybe this: https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPointAndSegment2D (might need a 3D version of it) And this: function findClosestPointOf2Lines3D (line1X,line1Y,line1Z,line1VectorX,line1VectorY,line1VectorZ,line2X,line2Y,line2Z,line2VectorX,line2VectorY,line2VectorZ) local Vec1 = Vector3 (line1VectorX,line1VectorY,line1VectorZ) local Vec2 = Vector3 (line2VectorX,line2VectorY,line2VectorZ) local line1 = Vector3 (line1X,line1Y,line1Z) local line2 = Vector3 (line2X,line2Y,line2Z) local a = Vec1:dot(Vec1) local b = Vec1:dot(Vec2) local e = Vec2:dot(Vec2) local d = a*e - b*b if tostring(d) ~= "0.0f" then local r = line1 - line2 local c = Vec1:dot(r) local f = Vec2:dot(r) local s = (b*f - c*e) / d local t = (a*f - c*b) / d local closestPointLine1 = line1 + Vec1 * s local x,y,z = vectorUnpack(closestPointLine1) return x,y,z end return false,false,false end function vectorUnpack(v) return v.x, v.y, v.z end Edited January 10, 2019 by IIYAMA Link to comment
Steve Scott Posted April 4, 2019 Author Share Posted April 4, 2019 I still don't get it, any other idea? Link to comment
savour Posted April 5, 2019 Share Posted April 5, 2019 if you're talking about the math, then i would suggest you to take a look at AMT (Arezu's Mapping Toolbox), it has some good math as a begin. also, you will find this event helpful: OnClientCursorMove Link to comment
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