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

plane normal


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-04-2019 , 12:44   plane normal
Reply With Quote #1

Hello, I'm trying to angulate entity according to the ground, but keep its view direction.


I tried to get global plane normal vector and convert it to angle vector, but didn't work properly.

Code:
engfunc(EngFunc_MakeVectors, vecAngles); static Float:vecPlaneNormal[3]; global_get(glb_trace_plane_normal, vecPlaneNormal); vector_to_angle(vecPlaneNormal, vecAngles); set_pev(this, pev_angles, vecAngles);

Any suggestion?
__________________








CrazY. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-04-2019 , 13:02   Re: plane normal
Reply With Quote #2

Look it lie flat plugin, it may help.
__________________
HamletEagle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-04-2019 , 22:18   Re: plane normal
Reply With Quote #3

FYI, "normal" means perpendicular to the plane, not parallel. So, the normal vector for that plane would point up, slightly to the right.
__________________
fysiks is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-06-2019 , 08:42   Re: plane normal
Reply With Quote #4

Hmm, it's not working properly with my entity, it's rotating to left/right side, not to its view direction.

Spoiler
__________________









Last edited by CrazY.; 02-06-2019 at 08:43.
CrazY. is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 02-08-2019 , 05:34   Re: plane normal
Reply With Quote #5

code form my spray plugin
PHP Code:
new IPlayerOrigin[3]
    new 
Float:AimOrigin[3]
    new 
Float:PlayerOrigin[3]
    new 
Float:AimVector[3]
    new 
Float:NormalVector[3]
    new 
Float:AngleVector[3]
    
    
entity_get_vector(idEV_VEC_v_angleAimVector)//gets players view angle
    
angle_vector(AimVectorANGLEVECTOR_FORWARDAimVector)//rotates it
    
get_user_origin(idIPlayerOrigin1);//gets user origin from eye position(differs if player is ducking or standing)
    
IVecFVec(IPlayerOriginPlayerOrigin);//from integer to float
    
    
AimVector[0] = AimVector[0] * 9999.0 PlayerOrigin[0]//idk
    
AimVector[1] = AimVector[1] * 9999.0 PlayerOrigin[1]
    
AimVector[2] = AimVector[2] * 9999.0 PlayerOrigin[2]

    new 
trace create_tr2()
    
engfunc(EngFunc_TraceLinePlayerOriginAimVectorIGNORE_MONSTERSidtrace)
    
get_tr2(traceTR_vecEndPosAimOrigin)
    
get_tr2(traceTR_vecPlaneNormalNormalVector)//getting normal plane vector perpendicular to the plane you're aiming at aka 90 degree angle with the plane
    
free_tr2(trace)
    
    
NormalVector[0]*= -1.0//because ANGLEVECTOR_LEFT does not exist I got to invert the vectors xy axis
    
NormalVector[1]*= -1.0
    
    angle_vector
AngleVectorANGLEVECTOR_RIGHTAngleVector )
    
    
vector_to_angleNormalVectorAngleVector )

        
//AngleVector the angle for the entity to lay flat on surface
        //AimOrigin origin for the entity 

Last edited by DjSoftero; 02-08-2019 at 05:35.
DjSoftero is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-25-2019 , 16:21   Re: plane normal
Reply With Quote #6

After some tests I noticed that the angles it's right, what is not right it's the velocity vector.
For some reason the car rotates while moving in a terrain not parallel (horizontal), always to left/right side.

EDIT: Actually car still rotates even if not moving.
__________________









Last edited by CrazY.; 02-25-2019 at 19:23.
CrazY. is offline
Reply



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 22:31.


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