Raised This Month: $12 Target: $400
 3% 

Rotating/modifying angles


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kinsi
Senior Member
Join Date: Apr 2013
Old 03-23-2014 , 11:53   Rotating/modifying angles
Reply With Quote #1

Hey there,

I am currently struggeling to "rotate" angles. My problem:

I am getting the rotation of an physics prop in the game, which is a chair. The angle i get is facing forward from the chairs seat. My problem: i want to edit the angles i get so that its facing downwards instead of forward, which seems easy in first place, but turns out to be harder. My first try i did was ofc to just add 90 to the first angle i get, which works fine when its actually standing, but completely messes up when its lying.

Help would be appreciated since i never worked with modifying angles in three dimensions and couldnt really find any advice on google.

Thanks!

Last edited by Kinsi; 03-23-2014 at 12:00.
Kinsi is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 03-24-2014 , 10:05   Re: Rotating/modifying angles
Reply With Quote #2

Screenshots please!
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 03-24-2014 , 12:21   Re: Rotating/modifying angles
Reply With Quote #3

Ofc!

In this one i am casting a ray from the chair into the direction i get from the chair:

http://steamcommunity.com/sharedfile.../?id=241401041

The ray i want to cast tho is supposed to face down, like this

http://steamcommunity.com/sharedfile.../?id=241406694

just adding 90 to the pitch works, kinda, fine while the chair is standing, but if the chair is slighly on a slope the beam doesnt follow the rotation of the chair, and if its not standing at all it doesnt work at all.
Kinsi is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 03-24-2014 , 12:53   Re: Rotating/modifying angles
Reply With Quote #4

Which relative world are we talking about? Facing down as in "world down" or facing down as in "towards under the chair" (in the first screenshot it would go into the direction of the chairs legs)?
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.

Last edited by Dr. Greg House; 03-24-2014 at 12:54.
Dr. Greg House is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 03-24-2014 , 12:55   Re: Rotating/modifying angles
Reply With Quote #5

Facing down from the view of the chair, basically the angle i get should be facing the directon on the second screenshot, no matter what rotation the chair has
Kinsi is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 03-24-2014 , 12:58   Re: Rotating/modifying angles
Reply With Quote #6

Okay.
Get the dataprop "m_angRotation" of the chair, use GetAngleVectors to retrieve the "up"-vector, multiply it with -1, serve with a dry red wine. Done.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.

Last edited by Dr. Greg House; 03-24-2014 at 12:58.
Dr. Greg House is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 03-24-2014 , 13:04   Re: Rotating/modifying angles
Reply With Quote #7

Jesus, its that easy? I will give it a shot in a moment since i need to go afk for a second, but if that works. Man, thank you! Been looking into a buttload of math yesterday and just gave up.
Kinsi is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 03-24-2014 , 13:39   Re: Rotating/modifying angles
Reply With Quote #8

Turns out that wasnt actually the solution to the problem, or maybe i just messed up:

http://steamcommunity.com/sharedfile.../?id=241836714

the line is always facing into that direction, no matter how the chair is roated

PHP Code:
        decl Float:Origin[3];
        
decl Float:Rotation_[3];
        
decl Float:Rotation[3];
        
        
GetEntPropVector(chairProp_Send"m_vecOrigin"Origin);
        
GetEntPropVector(chairProp_Send"m_angRotation"Rotation_);
        
        
GetAngleVectors(Rotation_NULL_VECTORNULL_VECTORRotation);
        
        
Rotation[0] *= -1.0;
        
Rotation[1] *= -1.0;
        
Rotation[2] *= -1.0;
        
        new 
Handle:trace TR_TraceRayFilterEx(OriginRotationMASK_SOLID_BRUSHONLYRayType_InfiniteTraceEntityFilter);
        
        if(
trace != INVALID_HANDLE && TR_DidHit(trace))
        {
            
decl Float:pos[3];
            
TR_GetEndPosition(postrace);
            new 
Float:Distance GetVectorDistance(Originpos);
            
            new 
Color[4] = {25500200};
            
            if(
Distance >= 19.65 && Distance <= 19.8)
            {
                
Color = {02550200};
            }
            
            
TE_SetupBeamPoints(OriginposBeamModelIndex0000.56.06.010.0Color10);
            
TE_SendToAll();
            
            
PrintToChatAll("Trace did hit! Ang: %.2f %.2f %.2f | Dist: %.2f"Rotation[0], Rotation[1], Rotation[2], Distance);
        }
        else
        {
            
PrintToChatAll("Trace didnt hit");
        }
        
CleanCloseHandle(trace); 
Edit: ignore me, forgot to convert the vector back to angles. Thank you very much mate!

Last edited by Kinsi; 03-24-2014 at 13:41.
Kinsi is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 03-24-2014 , 14:43   Re: Rotating/modifying angles
Reply With Quote #9

Cheers.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
Reply


Thread Tools
Display Modes

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 Jump


All times are GMT -4. The time now is 04:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode