ElRotation3D cMEPCoCentrik::OneTestMatr(const ElMatrix<REAL>  & aMat,const Pt3dr & aBase,double  aCost)
{
    ShowStatMatCond = false;
    ElRotation3D aRot(aBase,aMat,true);
    double aCostIn =  PVCostMEP(mPack,aRot,0.1);
    // cInterfBundle2Image * aIBI = cInterfBundle2Image::LineariseAngle(mPack,mFoc,true);
    cInterfBundle2Image * aIBI = cInterfBundle2Image::Bundle(mPack,mFoc,true);
    aIBI->VIB2I_InitNewRot(aRot);
    for (int aKIter =0 ; aKIter < 15 ; aKIter++)
    {

        aRot = aIBI->OneIterEq(aRot,aCostIn);
        if (0) std::cout << "Cost Descent Matr " << aCostIn * mFoc << "\n";
    }
    double aCostOut = PVCostMEP(mPack,aRot,0.1);
    if (aCostOut < mCostMin)
    {
         mCostMin = aCostOut;
         mBaseMinIn = aBase;
         mBaseMinOut = aRot.tr();
    }
   // std::cout << "COSTOptR "  << aCostIn *mFoc  << " => " <<  aCostOut * mFoc  <<  aRot.tr()  << "\n\n";
  
   return aRot;
}
Beispiel #2
0
void GenCodeAppui(bool C2M,bool isFixe,bool isGL,bool isAFocal,bool wDist,const std::string & aType,bool EqDroite)
{

        std::vector<double>  aPAF;
        if (isAFocal)
        {
            aPAF.push_back(0.0);
            aPAF.push_back(0.0);
        }


// std::cout << "Type Appui = " << aType << "ENTRE GETCHAR \n"; getchar();
	cSetEqFormelles aSet;
	cParamIntrinsequeFormel * aPIF = PIF_For_GC(C2M,aType,aSet,aPAF);
	ElRotation3D aRot(Pt3dr(0,0,0),0,0,0);

        // Genere auto les appuis fixe en X et Y
         if (isFixe)
	 {
	    aPIF->NewCam(cNameSpaceEqF::eRotFigee,aRot,0,"toto",true,true);
         }
	 else
	{
	   cCameraFormelle * aCam =  aPIF->NewCam(cNameSpaceEqF::eRotFigee,aRot,0,"toto",false,false);
           if (isGL)
              aCam->SetGL(true);
	   aCam->AddForUseFctrEqAppuisInc(true,false,wDist,EqDroite);
	   aCam->AddForUseFctrEqAppuisInc(true,true,wDist,EqDroite);
	}
}
Beispiel #3
0
void GenerateCodeEqRelativeGPS()
{
     cSetEqFormelles aSet;
     ElRotation3D aRot(Pt3dr(0,0,0),0,0,0);
     cRotationFormelle * aRF1 = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);
     cRotationFormelle * aRF2 = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);

     new cEqRelativeGPS(*aRF1,*aRF2,true);
}
Beispiel #4
0
void GenCodeAppuiGrid()
{
     cSetEqFormelles aSet;
     ElRotation3D aRot(Pt3dr(0,0,0),0,0,0);
                                                                                             
     cTriangulFormelle * aTri = aSet.NewTriangulFormelleUnitaire(2);
     cRotationFormelle * aRF = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);

     aSet.NewEqAppuiGrid(*aTri,*aRF,true);

}
Beispiel #5
0
void GenerateCodeEqOffsetGPS(bool aGL)
{
     cSetEqFormelles aSet;

     ElRotation3D aRot(Pt3dr(0,0,0),0,0,0);
     cRotationFormelle * aRF = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);
     aRF->SetGL(aGL);

     cBaseGPS * aBase = aSet.NewBaseGPS(Pt3dr(0,0,0));
     aSet.NewEqOffsetGPS(*aRF,*aBase,true);
}
Beispiel #6
0
void GenCodeLiaison(const std::string & aType,cNameSpaceEqF::eModeResidu aMode)
{
     std::vector<double> aNoPAF;
std::cout << "TYPE liason = " <<  aType << "\n";
     cSetEqFormelles aSet;
     ElRotation3D aRot(Pt3dr(0,0,0),0,0,0);
     cParamIntrinsequeFormel * pPIF = PIF_For_GC(true,aType,aSet,aNoPAF); // Liaisons : tjs C2M
     cCameraFormelle * pCam1 = pPIF->NewCam(cNameSpaceEqF::eRotFigee,aRot);
     cCameraFormelle * pCam2 = pPIF->NewCam(cNameSpaceEqF::eRotBaseU,aRot);

     aSet.NewCpleCam(*pCam1,*pCam2,aMode,true);
}
void GenerateCodeBlockCam()
{
    cSetEqFormelles aSet;

    ElRotation3D aRot(Pt3dr(0,0,0),0,0,0);
    cRotationFormelle * aRotRT0 = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);
    cRotationFormelle * aRotLT0 = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);
    cRotationFormelle * aRotRT1 = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);
    cRotationFormelle * aRotLT1 = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);


    cEqObsBlockCam * aEOBC = aSet.NewEqBlockCal (*aRotRT0,*aRotLT0,*aRotRT1,*aRotLT1,true);
    DoNothingButRemoveWarningUnused(aEOBC);
}
Beispiel #8
0
void GenCodeGrid (cNameSpaceEqF::eModeResidu aMode)
{

      cSetEqFormelles aSet;
      ElRotation3D aRot(Pt3dr(0,0,0),0,0,0);

      cTriangulFormelle * aTr1 = aSet.NewTriangulFormelleUnitaire(2);
      cTriangulFormelle * aTr2 = aSet.NewTriangulFormelleUnitaire(2);

      cRotationFormelle * aRF1 = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);
      cRotationFormelle * aRF2 = aSet.NewRotation (cNameSpaceEqF::eRotLibre,aRot);

      aSet.NewCpleGridEq(*aTr1,*aRF1,*aTr2,*aRF2,aMode,true);
}
Beispiel #9
0
//-----------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------
void CPlayerCar::Reset( void )
{
	Vector3f vPos(vec3_null);
	Angle3d aRot(vec3_null);
	if(m_vLastCheckpointPos == vec3_null)
	{
		vPos = m_vResetPosition;
		aRot = m_aResetAngles;
	}
	else
		GetNearestSpawnPosition( m_vLastCheckpointPos, vPos, aRot );
	SetAnglesAndOriginAndUpdatePhysics( vPos, aRot );
	g_pPhysics->VSetActorProperties( GetIndex(), vPos, aRot, vec3_null, vec3_null );
	m_bJustResetted = true;
}
Beispiel #10
0
bool gkGameFramework::AndroidFreeModeControl( const SInputEvent &event )
{
	int32 halfWidth = gEnv->pRenderer->GetScreenWidth() / 2;
	//int32 halfHeight = gEnv->pRenderer->GetScreenHeight() / 2;
	//float fFrameTime = gEnv->pTimer->GetFrameTime();

	if (event.keyId == eKI_Android_Touch && event.state == eIS_Pressed)
	{
		// judge left or right
		if ( event.value < halfWidth )
		{
			// left
			m_uDeviceMove = event.deviceIndex;
			m_vecMoveStartPos = Vec2( event.value, event.value2 );
		}
		else if ( event.value >= halfWidth )
		{
			m_uDeviceRot = event.deviceIndex;
			
		}

		//gkLogMessage(_T("Touch: %d | pos: %.1f, %.1f"), event.deviceIndex, event.value, event.value2);

		return false;
	}
	if (event.keyId == eKI_Android_Touch && event.state == eIS_Released)
	{
 		if ( m_uDeviceMove == event.deviceIndex )
 		{
 			m_uDeviceMove = -1;
            m_vecMoveDir.set(0,0);
 		}
 		else if ( m_uDeviceRot == event.deviceIndex  )
 		{
 			m_uDeviceRot = -1; 
 		}

		//gkLogMessage(_T("Release: %d"), event.deviceIndex);
		return false;
	}
	if (event.keyId == eKI_Android_DragX && event.state == eIS_Changed)
	{
		//gkLogMessage(_T("moving: %d"), event.deviceIndex);
		if (event.deviceIndex == m_uDeviceRot)
		{
			//gkLogMessage(_T("Rotating: %d"), event.deviceIndex);
			Quat qBefore = gEnv->p3DEngine->getMainCamera()->getDerivedOrientation();
			Ang3 aRot(qBefore);

			aRot.z -= event.value * 0.002f;
			//aRot.x -= vMouseDelta.y * 0.002f;

			Quat qRot = Quat::CreateRotationXYZ(aRot);
			qRot.Normalize();
			gEnv->p3DEngine->getMainCamera()->setOrientation(qRot);
		}
 		else if (event.deviceIndex == m_uDeviceMove)
 		{
			//gkLogMessage(_T("MoveX: %d | %.1f, %.1f"), event.deviceIndex, event.value, event.value2);
 			if ( event.value2 < (m_vecMoveStartPos.x - ANDROID_MOVETUMBE_STALLPIXEL) )
 			{
 				//moveleft
 				m_vecMoveDir.x = event.value2 - (m_vecMoveStartPos.x - ANDROID_MOVETUMBE_STALLPIXEL);
 			}
 			else if (  event.value2 > (m_vecMoveStartPos.x + ANDROID_MOVETUMBE_STALLPIXEL) )
 			{
 				// moveright             
                m_vecMoveDir.x = event.value2 - (m_vecMoveStartPos.x - ANDROID_MOVETUMBE_STALLPIXEL);
 			}
 			else {
                m_vecMoveDir.x = 0;
            }
 		}

		return false;
	}
	if (event.keyId == eKI_Android_DragY && event.state == eIS_Changed)
	{
		if (event.deviceIndex == m_uDeviceRot)
		{
			Quat qBefore = gEnv->p3DEngine->getMainCamera()->getDerivedOrientation();
			Ang3 aRot(qBefore);

			aRot.x -= event.value * 0.002f;
			//aRot.x -= vMouseDelta.y * 0.002f;

			Quat qRot = Quat::CreateRotationXYZ(aRot);
			qRot.Normalize();
			gEnv->p3DEngine->getMainCamera()->setOrientation(qRot);
		}
 		else if (event.deviceIndex == m_uDeviceMove)
 		{
			//gkLogMessage(_T("MoveY: %d | %.1f, %.1f"), event.deviceIndex, event.value, event.value2);
  			if ( event.value2 < (m_vecMoveStartPos.y - ANDROID_MOVETUMBE_STALLPIXEL) )
  			{
  				//moveback
                m_vecMoveDir.y = (m_vecMoveStartPos.y - ANDROID_MOVETUMBE_STALLPIXEL) - event.value2;
  				
  			}
  			else if (  event.value2 > (m_vecMoveStartPos.y + ANDROID_MOVETUMBE_STALLPIXEL) )
  			{
  				// moveforward
  				m_vecMoveDir.y = (m_vecMoveStartPos.y - ANDROID_MOVETUMBE_STALLPIXEL) - event.value2;
  			}
            else {
                m_vecMoveDir.y = 0;
            }
 
 		}
		return false;
	}

	return false;
}
Beispiel #11
0
bool gkGameFramework::OnInputEvent( const SInputEvent &event )
{
 	if (m_pGame)
 	{
 		return false;
 	}

	if (gEnv->pSystem->IsEditor())
	{
		return false;
	}

	float fFrameTime = gEnv->pTimer->GetFrameTime();
	static float speed = 5.0f;

	switch ( event.deviceId )
	{
	case eDI_Mouse:
		{
			static bool holding = false;
			if (event.keyId == eKI_Mouse2)
			{
				if (event.state == eIS_Down)
				{
					holding = true;
				}
				else
				{
					holding = false;
				}
			}

			else if (event.keyId == eKI_MouseX && holding)
			{
				Quat qBefore = gEnv->p3DEngine->getMainCamera()->getDerivedOrientation();
				Ang3 aRot(qBefore);

				aRot.z -= event.value * 0.002f;
				//aRot.x -= vMouseDelta.y * 0.002f;

				Quat qRot = Quat::CreateRotationXYZ(aRot);
				qRot.Normalize();
				gEnv->p3DEngine->getMainCamera()->setOrientation(qRot);				
			}
			else if (event.keyId == eKI_MouseY && holding)
			{
				Quat qBefore = gEnv->p3DEngine->getMainCamera()->getDerivedOrientation();
				Ang3 aRot(qBefore);

				aRot.x -= event.value * 0.002f;
				//aRot.x -= vMouseDelta.y * 0.002f;

				Quat qRot = Quat::CreateRotationXYZ(aRot);
				qRot.Normalize();
				gEnv->p3DEngine->getMainCamera()->setOrientation(qRot);				
			}
			break;
		}
	case eDI_Keyboard:
		{
			if (event.keyId == eKI_LShift && event.state == eIS_Down)
			{
				speed = 50.0f;
			}
			else if (event.keyId == eKI_LShift && event.state == eIS_Released)
			{
				speed = 5.0f;
			}
			else if (event.keyId == eKI_W)
			{
				gEnv->p3DEngine->getMainCamera()->moveLocal( Vec3(0, fFrameTime * speed, 0) );
			}
			else if (event.keyId == eKI_S)
			{
				gEnv->p3DEngine->getMainCamera()->moveLocal( Vec3(0, -fFrameTime * speed, 0 ) );
			}
			else if (event.keyId == eKI_A)
			{
				gEnv->p3DEngine->getMainCamera()->moveLocal( Vec3(-fFrameTime * speed, 0, 0) );
			}
			else if (event.keyId == eKI_D)
			{
				gEnv->p3DEngine->getMainCamera()->moveLocal( Vec3(fFrameTime * speed, 0, 0 ) );
			}
			break;
		}
	case eDI_XBox:
		{
			if (event.keyId == eKI_Xbox_TriggerL && event.state == eIS_Changed)
			{
				speed = (event.value) * 45.0 + 15;
				return false;
			}

			if (event.keyId == eKI_Xbox_ThumbLY && event.state == eIS_Changed)
			{
				float thumbspeed = (event.value) * speed;
				gEnv->p3DEngine->getMainCamera()->moveLocal( Vec3(0, fFrameTime * thumbspeed, 0) );
				return false;
			}

			if (event.keyId == eKI_Xbox_ThumbLX && event.state == eIS_Changed)
			{
				float thumbspeed = (event.value) * speed;
				gEnv->p3DEngine->getMainCamera()->moveLocal( Vec3(fFrameTime * thumbspeed, 0, 0) );
				return false;
			}

			if (event.keyId == eKI_Xbox_ThumbRX && event.state == eIS_Changed)
			{
				Quat qBefore = gEnv->p3DEngine->getMainCamera()->getDerivedOrientation();
				Ang3 aRot(qBefore);

				aRot.z -= event.value * 0.015f;
				//aRot.x -= vMouseDelta.y * 0.002f;

				Quat qRot = Quat::CreateRotationXYZ(aRot);
				qRot.Normalize();
				gEnv->p3DEngine->getMainCamera()->setOrientation(qRot);			
				return false;
			}

			if (event.keyId == eKI_Xbox_ThumbRY && event.state == eIS_Changed)
			{
				Quat qBefore = gEnv->p3DEngine->getMainCamera()->getDerivedOrientation();
				Ang3 aRot(qBefore);

				aRot.x += event.value * 0.015f;
				//aRot.x -= vMouseDelta.y * 0.002f;

				Quat qRot = Quat::CreateRotationXYZ(aRot);
				qRot.Normalize();
				gEnv->p3DEngine->getMainCamera()->setOrientation(qRot);		
				return false;
			}
			break;
		}
	case eDI_Android:
    case eDI_IOS:
	{
		return AndroidFreeModeControl( event );

		break;
	}
        default:
            break;
            
            
	}
	return false;
}