vehicle calcCurrentPositionAndRotation not working

vehicle calcCurrentPositionAndRotation not working

Hi

I cant get wheel position and rotation from this function.It trigger a breakpint at setting quaternion.

void CHavokPhysic::UpdateVehicleWheel(CVehicleSimulator* C,hkpVehicleInstance* pVehicle)
{
    
    hkVector4 pos;
    hkQuaternion rot; 
    
        
    for(int i=0;i<C->GetVehicle()->GetNumWheels();i++)
    {
            
        pVehicle->calcCurrentPositionAndRotation(pVehicle->getChassis(),pVehicle->m_suspension,i,pos,rot);
       
    }
    
}

call stack:
   FrontGame.exe!hkQuaternion::setAxisAngle(const hkVector4 & axis={...}, float angle=-0.00000000)  Line 15 + 0x2a bytes    C++
     FrontGame.exe!hkpVehicleInstance::calcCurrentPositionAndRotation(const hkpRigidBody * chassis=0x025d0580, const hkpVehicleSuspension * suspension=0x003e8390, int wheelNo=0, hkVector4 & posOut={...}, hkQuaternion & rotOut={...})  Line 1033    C++

publicaciones de 5 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

Hi Hamed,

It looks like some of the parameters it is using to determine the wheel rotation are numerically invalid or inaccurate. Please check that pVehicle->m_wheelsInfo[i]->m_spinAxisChassisSpace is normalized (you can use hkVector4::isNormalized<3>()) and that pVehicle->m_data->calcCurrentPositionAndRotation is orthonormal (you can use hkRotation::isOrthonormal()).

cheers,
Josh

Josh S. Havok Developer Support Engineer www.havok.com

I have same issue, the function crashes if I switch to Left-Handed coordinate system...Please help...

I got following error:

Math\Quaternion\hkQuaternion.cpp(15): [0x34BD3B6E] Assert: al < hkReal(0.01f)Stack trace is:

y:\build\20120831_122323_pcxsperpetualkeycode\source\common\base\system\error\hkdefaulterror.cpp(135):'hkDefaultError::message'
y:\build\20120831_122323_pcxsperpetualkeycode\source\common\base\system\error\hkerror.cpp(56):'hkError::messageAssert'
y:\build\20120831_122323_pcxsperpetualkeycode\source\common\base\math\quaternion\hkquaternion.cpp(15):'hkQuaternion::setAxisAngle'
y:\build\20120831_122323_pcxsperpetualkeycode\source\physics\vehicle\hkpvehicleinstance.cpp(1033):'hkpVehicleInstance::calcCurrentPositionAndRotation'

This issue can be easyly reproduced in the Demos, 

1. open file <havok sdk dir>\Demo\Demos\DemoCommon\Utilities\VehicleApi\VehicleSetup.cpp

2. go to line 105 and change it from

data.m_chassisOrientation.setCols( hkVector4(0, 1, 0), hkVector4(1, 0, 0), hkVector4(0, 0, 1));

to

data.m_chassisOrientation.setCols( hkVector4(0, 1, 0), hkVector4(1, 0, 0), hkVector4(0, 0, -1));

Then run Car demo and you get a crash at calcCurrentPositionAndRotation call,

3. skip wheel updates and run - demo will run as expected but without wheels rendering...

Hi Sergey,

The comment in VehicleSetup::setupVehicleData assumes that you are using a right-handed coordinate system.  What it really means is 'up', 'forward', and 'side', where side is left or right depending on your coordinate system.  Side is determined as

side = forward X up.

In the case of a left-handed system, this is left.  The runtime is crashing because the chassis orientation you set inverts the coordinate system, and is therefore not a valid rotation.  Please use

data.m_chassisOrientation.setCols( hkVector4(0, 1, 0), hkVector4(1, 0, 0), hkVector4(0, 0, 1));

and apply any coordinate system adjustment on rendering.  Please see \Source\Common\Base\Math\Util\hkConvertCoordinateSpace.h for utilities to do this.

cheers,

Josh

Josh S. Havok Developer Support Engineer www.havok.com

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya