SA-MP Forums [Include] i_quat - Quaternions and spatial geometry
 New Account Members List Search Today's Posts Mark Forums Read

 02/10/2017, 07:22 PM #11 Pottus Godfather     Join Date: Jun 2012 Posts: 5,419 Reputation: 1240 Re: i_quat - Quaternions and spatial geometry I was taking a look at this and it seems you have a lot of rotation problems solved. I always had trouble with this function. Code: `CA_RayCastLineAngle(Float:StartX, Float:StartY, Float:StartZ, Float:EndX, Float:EndY, Float:EndZ, &Float:x, &Float:y, &Float:z, &Float:rx, &Float:ry, &Float:rz)` It does work to a certain extent but I could never figure out how to improve the returned rotations so you can rotate the object correctly. This is used in Texture Studio by the mangle module which rotates objects to the rotation of the a surface. The main issue is located here. Code: ```int ColAndreasWorld::performRayTestAngle(const btVector3& Start, const btVector3& End, btVector3& Result, btScalar& RX, btScalar& RY, btScalar& RZ, uint16_t& model) { btCollisionWorld::ClosestRayResultCallback RayCallback(Start, End); dynamicsWorld->rayTest(Start, End, RayCallback); if (RayCallback.hasHit()) { btVector3 Rotation = RayCallback.m_hitNormalWorld; RX = -(asin(Rotation.getY())*RADIAN_TO_DEG); RY = asin(Rotation.getX())*RADIAN_TO_DEG; // I think there is a way to calculate this not sure how yet RZ = 0.0; Result = RayCallback.m_hitPointWorld; model = RayCallback.m_collisionObject->getUserIndex(); return 1; } return 0; }``` Maybe you have input that could offer some direction that could be taken to improve this function. If update an objects position/rotation while aiming with a weapon and use this function you will see the issue it has.
 02/10/2017, 07:29 PM #12 Kar High-roller     Join Date: May 2010 Location: Black Asylum Posts: 3,184 Reputation: 506 Re: i_quat - Quaternions and spatial geometry Thanks for this. I can finally edit my vehicle objects without the vehicle facing 0.0. __________________
02/10/2017, 10:50 PM   #13
IllidanS4
Huge Clucker

Join Date: Feb 2013
Posts: 288
Reputation: 120
Re: i_quat - Quaternions and spatial geometry

Quote:
 Originally Posted by Pottus Maybe you have input that could offer some direction that could be taken to improve this function. If update an objects position/rotation while aiming with a weapon and use this function you will see the issue it has.
I am not sure what you mean, do you want to align an object with the surface normal of the hit? I don't use ColAndreas, but if that is the case, returning the normal directly would be more practical than Euler angles. If you want to convert that to "some" rotation (there is an infinite number of them that could represent the normal), you can either create that using the product of elementary quaternions (in the correct order), or maybe try this function from my Cinematic Mode:
Code:
```stock SetObjectFrontVector(objectid, Float:vx, Float:vy, Float:vz)
{
new Float:r = VectorSize(vx, vy, vz);
new Float:rx = acos(vz/r)+90.0;
new Float:rz = -atan2(vx, vy)+180.0;
SetObjectRot(objectid, rx, 0.0, rz);
}```
But it wasn't tested much, to be honest.
__________________
PawnPlus
YSF
Yet Another Lua Plugin
Long Function Names
•　i_quat.inc　•

kingsofsa.cz:8888 running Cinematic Mode

 08/06/2018, 03:01 PM #14 Sasino97 High-roller     Join Date: Dec 2010 Location: Italy Posts: 1,440 Reputation: 106 Re: i_quat - Quaternions and spatial geometry This must be great to create flight instruments for aircrafts. __________________ Desktop, Web, Mobile and Game DeveloperSA-MP Game Modes and Filter Scripts (PAWN, SQL) (8 years experience) Windows Applications (WPF, UWP) Android Applications (Java Android SDK, Xamarin) Web Design and Development (Wordpress, ASP.NET MVC, PHP, SQL) Game Development (Unity3D, GameMaker Studio, LibGDX) sasinosoft@gmail.com I hope I don't get banned for using gmail, lol

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules

All times are GMT. The time now is 10:46 AM.

 -- (EN) English -- (RU) Русски Contact Us - SA-MP - Archive - Top