_DrXenon

How to get the rotation!?

Recommended Posts

Good evening fellows,

Recently, I've been trying to find the rotation of one part or side of a random object but I couldn't really find the function or the way to do so therefore I'm stuck.

If you did not understand the idea, I'll explain it below;

A cube is made of 6 sides or faces, generally in MTA if we have an object with a shape of cube or any other shape, we can get its rotation by just using getElementRotation. But, if we want to get the rotation of one face of its faces it is only possible with couple mathmatic calculations which is a bit complicated when this object is on the form of a cube, therefore it would be more complex if it isn't a cube.

A simpler instance, If I was standing infront of a wall, and this wall is one side of a house, this means that house rotation isn't certainly the wall's rotation, but thier rotation is of course related to each other, How will I be able to get the rotation of the wall which is one face or side of a house/building?

If you did not understand, I may try to give clearer examples. However, if you got my point, do you have any ideas to share?

Share this post


Link to post

I am not sure if you are asking a simple question or a hard question. It might be handy to add a screenshot.

If it is a simple question, than this is one of the answers to it:
 

-- 90 (1/4), 180 (1/2), 270 (3/4), 360 round and round and round...
local rotationAdjustments = {xr = 90, yr = -90, zr = 0}
function getWallRotation (element)
	local xr,yr,zr = getElementRotation (element)
	return rotationAdjustments.xr + xr, rotationAdjustments.yr + yr, rotationAdjustments.zr + zr
end

Simple add or subtract(minus value) rotations values of the mta rotation.

 

Example:

local awesomeRotationX, awesomeRotationY, awesomeRotationZ = getWallRotation(element)

 

As @Jusonex said with processlineOfSign, which will return the exact rotation if used correctly. But you can also play a little bit with it manually. It doesn't have to be pixel perfect!!

Edited by IIYAMA
  • Like 1

Share this post


Link to post
On 10/03/2017 at 16:58, Jusonex said:

I guess you're looking for processLineOfSight. However, it does not return the rotation directly so you have to calculate it from the returned normal vector.

@Jusonex yeah, that's exactly what I wanted. the normal vector, since Its always perpendicular to the surface. Anyway, the normalx, normaly and normalz values are rotations or coordinations?

Share this post


Link to post

They are the direction vector of how the line hits on the object.

If you hit the object it will return a vector that represents how that part of the object is facing a direction.

 

I am using this function to determine how custom bullet holes are placed on to the objects in the world.

If the vector returns (0 x,0 y, 1 z) than the bullet holes would be facing up. Which is most likely the case when you hit the flat ground. (not sure if you have to invert the vector, I haven't used this function for a while)

Share this post


Link to post
Just now, IIYAMA said:

They are the direction vector of how the line hits on the object.

If you hit the object it will return a vector that represents how that part of the object is facing a direction.

 

I am using this function to determine how custom bullet holes are placed on to the objects in the world.

If the vector returns (0 x,0 y, 1 z) than the bullet holes would be facing up. Which is most likely the case when you hit the flat ground. (not sure if you have to invert the vector, I haven't used this function for a while)

Yeah, bullet holes is what i am trying to script right here. But anyway, something is still wrong with the directions... I will be trying to find out what is it.

Share this post


Link to post

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.