Get Forward direction if no parameters if parameter is passed - get Up direction [filippo]: now more complete, if the param is specified we can get the axis we want.
| 986 | // if parameter is passed - get Up direction |
| 987 | // [filippo]: now more complete, if the param is specified we can get the axis we want. |
| 988 | int CScriptObjectEntity::GetDirectionVector(IFunctionHandler *pH) |
| 989 | { |
| 990 | // CHECK_PARAMETERS(0); |
| 991 | assert(pH->GetParamCount() == 0 || pH->GetParamCount() == 1); |
| 992 | |
| 993 | //forward default |
| 994 | Vec3 vec(0,-1,0); |
| 995 | |
| 996 | //if there is a parameter we want to get something different by the forward vector, 0=x, 1=y, 2=z |
| 997 | if( pH->GetParamCount()==1 ) |
| 998 | { |
| 999 | int dir; |
| 1000 | pH->GetParam(1,dir); |
| 1001 | |
| 1002 | switch(dir) |
| 1003 | { |
| 1004 | default: |
| 1005 | case 0: |
| 1006 | vec.Set(0,-1,0);//forward |
| 1007 | break; |
| 1008 | case 1: |
| 1009 | vec.Set(-1,0,0);//right |
| 1010 | break; |
| 1011 | case 2:vec.Set(0,0,1);//up |
| 1012 | break; |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | //CScriptObjectVector oVec(m_pScriptSystem); |
| 1017 | |
| 1018 | //vec = m_pEntity->GetAngles(); |
| 1019 | |
| 1020 | Matrix44 tm; |
| 1021 | tm.SetIdentity(); |
| 1022 | //tm.RotateMatrix_fix( m_pEntity->GetAngles() ); |
| 1023 | tm=Matrix44::CreateRotationZYX(-m_pEntity->GetAngles()*gf_DEGTORAD)*tm; //NOTE: angles in radians and negated |
| 1024 | |
| 1025 | //CHANGED_BY_IVO |
| 1026 | //vec = tm.TransformVector(vec); |
| 1027 | vec = GetTransposed44(tm)*vec; |
| 1028 | |
| 1029 | m_pObjectAngles->BeginSetGetChain(); |
| 1030 | m_pObjectAngles->SetValue("x",vec.x); |
| 1031 | m_pObjectAngles->SetValue("y",vec.y); |
| 1032 | m_pObjectAngles->SetValue("z",vec.z); |
| 1033 | m_pObjectAngles->EndSetGetChain(); |
| 1034 | //vec.ConvertToRadAngles(); |
| 1035 | //oVec=vec; |
| 1036 | return pH->EndFunction(m_pObjectAngles); |
| 1037 | } |
| 1038 | |
| 1039 | int CScriptObjectEntity::AttachObjectToBone(IFunctionHandler *pH) |
| 1040 | { |
nothing calls this directly
no test coverage detected