void StopMotors() { bool previousState = getMotorStatus(); setMotorStatus(previousState); if(previousState == false) { printStatus("Motor stopped!"); InvertUART(); } else { ResetInputData(); InvertUART(); printStatus("Motor started!"); } }
void PhysXVehicle::SetToRestState() { vehicleDrive->setToRestState(); ResetInputData(); }
PhysXVehicle::PhysXVehicle( PhysXScene* scene, PhysXBody* baseBody, PhysXVehicleInitData* generalData, PhysXVehicleInitData* wheelFrontLeftData, PhysXVehicleInitData* wheelFrontRightData, PhysXVehicleInitData* wheelRearLeftData, PhysXVehicleInitData* wheelRearRightData ) { PhysXVehicleInitData* wheelDatas[ 4 ]; wheelDatas[ 0 ] = wheelFrontLeftData; wheelDatas[ 1 ] = wheelFrontRightData; wheelDatas[ 2 ] = wheelRearLeftData; wheelDatas[ 3 ] = wheelRearRightData; this->scene = scene; this->baseBody = baseBody; this->wheelCount = 4; vehicleDrive = NULL; surfaceTirePairs = NULL; surfaceTirePairsUsedMaterialsVersion = 0; ResetInputData(); this->baseBody->ownerVehicle = this; //Scene query data for to allow raycasts for all suspensions of all vehicles. sceneQueryData = new PhysXVehicleSceneQuery(scene->mScene, wheelCount); PxVehicleWheelsSimData* wheelsSimData = PxVehicleWheelsSimData::allocate(wheelCount); PxVehicleDriveSimData4W driveSimData; PxConvexMesh* wheelConvexMeshes[ 4 ]; PxVec3 wheelCenterOffsets[ 4 ]; for( int n = 0; n < 4; n++ ) { PhysXShape* shape = baseBody->mShapes[ n ]; shape->isWheel = true; //PhysXShape* shape = baseBody->mShapes[ n + 1 ]; wheelConvexMeshes[ n ] = shape->mShape->getGeometry().convexMesh().convexMesh; wheelCenterOffsets[ n ] = shape->mShape->getLocalPose().p; } PxConvexMesh* chassisConvexMesh = baseBody->mShapes[ 4 ]->mShape->getGeometry().convexMesh().convexMesh; //PxConvexMesh* chassisConvexMesh = baseBody->mShapes[0]->mShape->getGeometry().convexMesh().convexMesh; CreateVehicle4WSimulationData( chassisConvexMesh, wheelConvexMeshes, wheelCenterOffsets, *wheelsSimData, driveSimData, generalData, wheelDatas ); vehicleDrive = PxVehicleDrive4W::allocate( wheelCount ); vehicleDrive->setup( world->mPhysics, (PxRigidDynamic*)baseBody->mActor, *wheelsSimData, driveSimData, 0 ); //vehicleDrive->setWheelShapeMapping(0, 1); //vehicleDrive->setWheelShapeMapping(1, 2); //vehicleDrive->setWheelShapeMapping(2, 3); //vehicleDrive->setWheelShapeMapping(3, 4); //Free the sim data because we don't need that any more. wheelsSimData->free(); //configure tireFrictionMultipliers { tireFrictionMultipliers[ L"" ] = 1; for( int n = 0; ; n++ ) { char s[50]; sprintf( s, "tireFrictionMaterial%d", n ); if(!generalData->IsStringParameterExist(s)) break; WString materialName = generalData->GetStringParameter( s ); sprintf( s, "tireFrictionValue%d", n ); float value = generalData->GetFloatParameter( s ); tireFrictionMultipliers[ materialName ] = value; } } //Set the transform and the instantiated car and set it be to be at rest. SetToRestState(); ForceGearChange( 0 ); }