This tutorial only work on Studio.exe, not is finised, not work on server, need many fix more, if you want help, please write here
Only tested on DNC Education emulator
To drive the vehicles use the arrows
is recommended to use Phyxs 3.2.3 and Apex 1.2.3 for Phyxs 3.2.3
Phyxs 3.2.3: https://mega.co.nz/#!col10I4Y!PDND-D...3TNkbPXfB4QBGM
Apex 1.2.3 for Phyxs 3.2.3: https://mega.co.nz/#!x4URAKCQ!EmPeqn...79FddXbHLG52w4
Search on r3dPCH.h
Replace:
To:Code:#define APEX_ENABLED 0 #ifdef FINAL_BUILD #define VEHICLES_ENABLED 0 #else #ifndef WO_SERVER #define VEHICLES_ENABLED 0 // temp disabled due to new PhysX API changes #else #define VEHICLES_ENABLED 0 #endif
if you have problems with d_drive_vehicles then search:Code:#define APEX_ENABLED 0 #ifdef FINAL_BUILD #define VEHICLES_ENABLED 1 #else #ifndef WO_SERVER #define VEHICLES_ENABLED 1 // temp disabled due to new PhysX API changes #else #define VEHICLES_ENABLED 1 #endif
Replace to:Code:#if VEHICLES_ENABLED REG_VAR( d_drive_vehicles, false, 0 ); #endif // VEHICLES_ENABLED #endif // FINAL BUILD
Code:#endif // FINAL BUILD #if VEHICLES_ENABLED REG_VAR( d_drive_vehicles, false, 0 ); #endif // VEHICLES_ENABLED
Search on VehicleManager.cpp
PxInitVehicleSDK(*g_pPhysicsWorld->PhysXSDK);
Replace:
To:Code:const PxMaterial *mats[] = {g_pPhysicsWorld->defaultMaterial}; surfaceTypePairs = PxVehicleDrivableSurfaceToTireFrictionPairs::create(MAX_NUM_TYRE_TYPES, MAX_NUM_SURFACE_TYPES, mats, &drivableSurfaceType);
Search for (uint32_t i = 0; i < wheelMeshes.Count(); ++iCode:surfaceTypePairs = PxVehicleDrivableSurfaceToTireFrictionPairs::allocate(MAX_NUM_TYRE_TYPES,MAX_NUM_SURFACE_TYPES); const PxMaterial *mats[] = {g_pPhysicsWorld->defaultMaterial}; surfaceTypePairs->setup(MAX_NUM_TYRE_TYPES, MAX_NUM_SURFACE_TYPES, mats, &drivableSurfaceType);
TO:Code:for (uint32_t i = 0; i < wheelMeshes.Count(); ++i) { Vertices &v = wheelMeshes[i]; wheels[i] = CreateWheelConvexMesh(&v[0], v.Count()); } PxVehicleWheelsSimData *wheelsData = PxVehicleWheelsSimData::allocate(vd->numWheels); PxVehicleDriveSimData4W driveData; bool result = CreateVehicleSimData(*vd, *hull, const_cast<const PxConvexMesh**>(wheels), *wheelsData, driveData); result; r3d_assert(result); PxRigidDynamic *vehActor = CreateVehicleActor(*vd, *hull, wheels); r3d_assert(vehActor); vd->vehicle = PxVehicleDrive4W::allocate(vd->numWheels); vd->vehicle->setup(g_pPhysicsWorld->PhysXSDK, vehActor, *wheelsData, driveData, std::max<int>(vd->numWheels - 4, 0));
Now go to \ Data \ ObjectsDepot \ GAMEPLAY \ Objects.dat and editCode:for (uint32_t i = 0; i < wheelMeshes.Count(); ++i) { Vertices &v = wheelMeshes[i]; wheels[i] = CreateWheelConvexMesh(&v[0], v.Count()); } PxVehicleWheelsSimData *wheelsData = PxVehicleWheelsSimData::allocate(vd->numWheels); PxVehicleDriveSimData4W driveData; bool result = CreateVehicleSimData(*vd, *hull, const_cast<const PxConvexMesh**>(wheels), *wheelsData, driveData); result; r3d_assert(result); PxRigidDynamic *vehActor = CreateVehicleActor(*vd, *hull, wheels); r3d_assert(vehActor); vd->vehicle = PxVehicleDrive4W::allocate(vd->numWheels); vd->vehicle->setup(g_pPhysicsWorld->PhysXSDK, vehActor, *wheelsData, driveData, std::max<int>(vd->numWheels-4, 0)); if (m->FileName == "data/objectsdepot/vehicles/drivable_stryker.sco") { vd->vehicle->setWheelShapeMapping(0, 0); vd->vehicle->setWheelShapeMapping(1, 1); vd->vehicle->setWheelShapeMapping(2, 2); vd->vehicle->setWheelShapeMapping(3, 3); vd->vehicle->setWheelShapeMapping(4, 4); vd->vehicle->setWheelShapeMapping(5, 5); vd->vehicle->setWheelShapeMapping(6, 6); vd->vehicle->setWheelShapeMapping(7, 7); } else { vd->vehicle->setWheelShapeMapping(0, 0); vd->vehicle->setWheelShapeMapping(1, 1); vd->vehicle->setWheelShapeMapping(2, 2); vd->vehicle->setWheelShapeMapping(3, 3); }
Replace:
TO:Code:9 PlayerSpawnPoint obj_PlayerSpawnPoint ItemSpawnPoint obj_ItemSpawnPoint PostBox obj_PostBox AmbientSound obj_AmbientSound MusicTriggerArea obj_MusicTriggerArea ReverbZone obj_ReverbZone ReverbZoneBox obj_ReverbZoneBox ZombieSpawn obj_ZombieSpawn PermanentNote obj_PermanentNote
Search on HUD_TPSGame.cppCode:10PlayerSpawnPoint obj_PlayerSpawnPoint ItemSpawnPoint obj_ItemSpawnPoint PostBox obj_PostBox AmbientSound obj_AmbientSound MusicTriggerArea obj_MusicTriggerArea ReverbZone obj_ReverbZone ReverbZoneBox obj_ReverbZoneBox ZombieSpawn obj_ZombieSpawn PermanentNote obj_PermanentNote VehicleSpawn obj_VehicleSpawn
replace with thisCode:wasDrivenByPlayer = true;
Now SearchCode:if(Keyboard->WasPressed(kbsE)) wasDrivenByPlayer = true;
Replace To:Code:// vehicles if(InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_INTERACT) ) { #if VEHICLES_ENABLED obj_Vehicle* target_Vehicle = pl->canEnterVehicle(); if( pl->isInVehicle() ) { pl->exitVehicle(); } else if ( target_Vehicle ) // now we're going to try to use vehicles (otherwise UAV characters can't use vehicles). { pl->enterVehicle( target_Vehicle ); } #endif }
Search on AI_Player.cppCode:// vehicles if(InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_INTERACT) ) { #if VEHICLES_ENABLED if( pl->isInVehicle() ) { pl->exitVehicle(); } else { obj_Vehicle* target_Vehicle = pl->canEnterVehicle(); if ( target_Vehicle ) // now we're going to try to use vehicles (otherwise UAV characters can't use vehicles). pl->enterVehicle( target_Vehicle ); g_pPhysicsWorld->m_VehicleManager->DriveCar(target_Vehicle->vd); } #endif }
Replace to:Code:static const float gDist_To_Allow_Vehicle_Entry = 5;
andCode:static const float gDist_To_Allow_Vehicle_Entry = 3.1;
replace:Code:if( distSq < gDist_To_Allow_Vehicle_Entry * gDist_To_Allow_Vehicle_Entry )
now this:Code:if( distSq < gDist_To_Allow_Vehicle_Entry )
Replace To:Code:void obj_Player::exitVehicle() { // first let's look for a good location obj_Vehicle* currentCar = g_pPhysicsWorld->m_VehicleManager->getRealDrivenVehicle(); r3d_assert(currentCar); r3dVector rotationVector = currentCar->GetRotationVector(); r3dMatrix Matrix; // NOTE: We might want to take out rotation in the x or z direction and only focus on the Y direction... r3dBuildRotationMatrix(Matrix, rotationVector ); bool success = false; for ( int exitIndex = 0; exitIndex < 4; exitIndex++ ) { r3dVector exitPosition; bool returnValue = currentCar->getExitSpace( exitPosition, exitIndex ); r3d_assert( returnValue ); exitPosition *= Matrix; r3dVector targetPosition = currentCar->GetPosition() + exitPosition; if ( TestExitPosition( targetPosition) ) { TeleportPlayer( targetPosition, "Exiting vehicle"); success = true; break; } }
Now go to obj_VehicleSpawn.cppCode:void obj_Player::exitVehicle() { // first let's look for a good location obj_Vehicle* currentCar = g_pPhysicsWorld->m_VehicleManager->getRealDrivenVehicle(); r3d_assert(currentCar); r3dVector rotationVector = currentCar->GetRotationVector(); r3dMatrix Matrix; // NOTE: We might want to take out rotation in the x or z direction and only focus on the Y direction... r3dBuildRotationMatrix(Matrix, rotationVector ); bool success = false; for ( int exitIndex = 0; exitIndex < 4; exitIndex++ ) { r3dVector exitPosition; bool returnValue = currentCar->getExitSpace( exitPosition, exitIndex ); // r3d_assert( returnValue ); if( !returnValue ) continue; exitPosition *= Matrix; r3dVector targetPosition = currentCar->GetPosition() + exitPosition; if ( TestExitPosition( targetPosition) ) { TeleportPlayer( targetPosition, "Exiting vehicle"); success = true; break; } }
Replace To:Code:void obj_VehicleSpawn::DoDraw() { #ifndef FINAL_BUILD #if VEHICLES_ENABLED if( g_Manipulator3d.IsSelected(this) || ( spawnedVehicle != NULL && g_Manipulator3d.IsSelected(spawnedVehicle)) ) #else if( g_Manipulator3d.IsSelected(this) ) #endif { r3dColor clr = r3dColor::blue; r3dRenderer->SetRenderingMode( R3D_BLEND_ALPHA | R3D_BLEND_ZC ); clr.A = 196; r3dBoundBox localBBox = GetBBoxLocal(); r3dBoundBox bbox; bbox.Org = GetPosition();// - 0.5f * m_bboxSize; bbox.Org.y += .5f * localBBox.Size.y ; bbox.Size = localBBox.Size; r3dVector rotation = GetRotationVector(); // there's a bug with rotation so I've to swap the axis. float temp; temp = rotation.y; rotation.y = rotation.x; rotation.x = temp; r3dDrawOrientedBoundBox( bbox, rotation, gCam, clr ); // r3dDrawUniformSphere ( GetPosition(), m_maxDist, gCam, clr ); r3dRenderer->Flush(); } #endif }
Now go to HUD_TPSGame.cppCode:void obj_VehicleSpawn::DoDraw() { //#ifndef FINAL_BUILD #if VEHICLES_ENABLED /* if( g_Manipulator3d.IsSelected(this) || ( spawnedVehicle != NULL && g_Manipulator3d.IsSelected(spawnedVehicle)) ) #else if( g_Manipulator3d.IsSelected(this) ) #endif {*/ r3dColor clr = r3dColor::blue; r3dRenderer->SetRenderingMode( R3D_BLEND_ALPHA | R3D_BLEND_ZC ); clr.A = 196; r3dBoundBox localBBox = GetBBoxLocal(); r3dBoundBox bbox; bbox.Org = GetPosition();// - 0.5f * m_bboxSize; bbox.Org.y += .5f * localBBox.Size.y ; bbox.Size = localBBox.Size; r3dVector rotation = GetRotationVector(); // there's a bug with rotation so I've to swap the axis. float temp; temp = rotation.y; rotation.y = rotation.x; rotation.x = temp; r3dDrawLine3D(GetPosition(), GetPosition() + r3dPoint3D(0, 20.0f, 0), gCam, 0.4f, r3dColor(242, 64, 0)); r3dDrawCircle3D(GetPosition(), 2.0f, gCam, 0.4f, r3dColor(242, 255, 0)); r3dRenderer->Flush(); /* }*/ #endif }
Code:#if VEHICLE_CINEMATIC_MODE r3dVector CamPos = vehicle->GetPosition(); CamPos += r3dPoint3D( 0, ( 5 ), 0 ); int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY; float glb_MouseSensAdj = CurrentRig.MouseSensetivity * g_mouse_sensitivity->GetFloat(); static float camangle = 0; camangle += float(-mMX) * glb_MouseSensAdj; if(camangle > 360.0f ) camangle = camangle - 360.0f; if(camangle < 0.0f ) camangle = camangle + 360.0f; D3DXMATRIX mr; D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-camangle), 0.0f, 0); r3dVector vehicleForwardVector = r3dVector(mr ._31, mr ._32, mr ._33); CamPos += -vehicleForwardVector * 8 ; Cam.SetPosition(CamPos); Cam.PointTo( CamPos + vehicleForwardVector * 3 + r3dVector ( 0, -1, 0) ); Cam.vUP = r3dPoint3D(0, 1, 0); #else g_pPhysicsWorld->m_VehicleManager->ConfigureCamera(Cam); #endif
New Camera, is manual with Mouse
Search on Main.cppCode://#if VEHICLE_CINEMATIC_MODE r3dVector CamPos = vehicle->GetPosition(); CamPos += r3dPoint3D( 0, ( 5 ), 0 ); int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY; float glb_MouseSensAdj = CurrentRig.MouseSensetivity * g_mouse_sensitivity->GetFloat(); static float camangle = 0; static float camangle2 = 0; camangle += float(-mMX) * glb_MouseSensAdj; camangle2 += float(-mMY) * glb_MouseSensAdj; if(camangle > 360.0f ) camangle = camangle - 360.0f; if(camangle < 0.0f ) camangle = camangle + 360.0f; if(camangle2 > 30.0f ) camangle2 = 30.0f; if(camangle2 < -25.0f ) camangle2 = -25.0f; D3DXMATRIX mr; D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-camangle), R3D_DEG2RAD(-camangle2), 0); r3dVector vehicleForwardVector = r3dVector(mr ._31, mr ._32, mr ._33); CamPos += -vehicleForwardVector * 8 ; Cam.SetPosition(CamPos); Cam.PointTo( CamPos + vehicleForwardVector * 3 + r3dVector ( 0, -1, 0) ); Cam.vUP = r3dPoint3D(0, 1, 0); //#else // g_pPhysicsWorld->m_VehicleManager->ConfigureCamera(Cam); //#endif
Search switch( r_shadows_quality->GetInt() )
replace this:
for thisCode:case 1: r_transp_shadows->SetInt( 0 ) ; r_terra_shadows->SetInt( 0 ); r_shadow_blur->SetInt( 0 ); r_dir_sm_size->SetInt( MAX_DIR_TEX_SIZE ); r_shared_sm_size->SetInt( 1024 ); r_shared_sm_cube_size->SetInt( 1024 ); r_active_shadow_slices->SetInt( NumShadowSlices - 2 ); r3d_assert( r_active_shadow_slices->GetInt() ) ; r_shadows->SetInt( 1 ); r_dd_pointlight_shadows->SetInt( 0 ); ShadowSplitDistancesOpaque = &ShadowSplitDistancesOpaqueLow[0]; break;
And now need this filesCode:case 1: r_transp_shadows->SetInt( 0 ) ; r_terra_shadows->SetInt( 0 ); r_shadow_blur->SetInt( 1 ); r_dir_sm_size->SetInt( MAX_DIR_TEX_SIZE ); r_shared_sm_size->SetInt( 1024 ); r_shared_sm_cube_size->SetInt( 1024 ); r_active_shadow_slices->SetInt( NumShadowSlices - 1 ); r_shadows->SetInt( 1 ); r_dd_pointlight_shadows->SetInt( 0 ); ShadowSplitDistancesOpaque = &ShadowSplitDistancesOpaqueLow[0]; break;
for install this fix go to Data\ObjectsDepot and delete this folders
WZ_CityBuildings
WZ_CityDecay
WZ_CityProps
WZ_CityStreets
WZ_InteriorProps
WZ_Military
WZ_Nature
WZ_NatureAmbient
WZ_RoadObjects
WZ_Settlement
WZ_Signs
WZ_Terrain
WZ_TownBuildings
WZ_TownProps
WZ_Walls
and put this folder of the zip, remember no replace
https://mega.co.nz/#!E4tlWIbb!AlOKND...ExZStAe7Y4qHgY
fixed driving power reversing giving equal selected graphic quality.
VehicleManager.cpp
Search this:
To this:Code:void VehicleManager::DoUserCarControl(float timeStep) { if (!drivableCar) return; PxVehicleDrive4W &car = *drivableCar->vehicle; //Work out if the car is to flip from reverse to forward gear or from forward gear to reverse. bool toggleAutoReverse = false; if (car.mDriveDynData.getUseAutoGears()) { toggleAutoReverse = ProcessAutoReverse(timeStep); } //If the car is to flip gear direction then switch gear as appropriate. if(toggleAutoReverse) { mInReverseMode = !mInReverseMode; if(mInReverseMode) { car.mDriveDynData.forceGearChange(PxVehicleGearsData::eREVERSE); } else { car.mDriveDynData.forceGearChange(PxVehicleGearsData::eFIRST); } } //If in reverse mode then swap the accel and brake. if(mInReverseMode) { const bool accel = carControlData.getDigitalAccel(); const bool brake = carControlData.getDigitalBrake(); carControlData.setDigitalAccel(brake); carControlData.setDigitalBrake(accel); } PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs(gKeySmoothingData, gSteerVsForwardSpeedTable, carControlData, timeStep, car); clearInputData = true; }
try to make it work with the keys A W S D but conflicts with the S key and does not workCode:void VehicleManager::DoUserCarControl(float timeStep) { if (!drivableCar) return; PxVehicleDrive4W &car = *drivableCar->vehicle; //Work out if the car is to flip from reverse to forward gear or from forward gear to reverse. bool toggleAutoReverse = false; if (car.mDriveDynData.getUseAutoGears()) { toggleAutoReverse = ProcessAutoReverse(timeStep); } //If the car is to flip gear direction then switch gear as appropriate. if(toggleAutoReverse) { mInReverseMode = !mInReverseMode; } //If in reverse mode then swap the accel and brake. if(mInReverseMode) { carControlData.setDigitalAccel(false); carControlData.setDigitalBrake(false); carControlData.setDigitalAccel(carControlData.getDigitalAccel() || Keyboard->IsPressed(kbsUp)); carControlData.setDigitalBrake(carControlData.getDigitalBrake() || Keyboard->IsPressed(kbsDown)); car.mDriveDynData.forceGearChange(PxVehicleGearsData::eREVERSE); const bool accel = carControlData.getDigitalAccel(); const bool brake = carControlData.getDigitalBrake(); carControlData.setDigitalAccel(brake); carControlData.setDigitalBrake(accel); } else { carControlData.setDigitalAccel(false); carControlData.setDigitalBrake(false); carControlData.setDigitalAccel(carControlData.getDigitalAccel() || Keyboard->IsPressed(kbsUp)); carControlData.setDigitalBrake(carControlData.getDigitalBrake() || Keyboard->IsPressed(kbsDown)); car.mDriveDynData.forceGearChange(PxVehicleGearsData::eFIRST); const bool accel = carControlData.getDigitalAccel(); const bool brake = carControlData.getDigitalBrake(); carControlData.setDigitalAccel(accel); carControlData.setDigitalBrake(brake); } PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs(gKeySmoothingData, gSteerVsForwardSpeedTable, carControlData, timeStep, car); clearInputData = true; }
Some videos
Thx to:
billyolak7
Leandro Lima
jonnybravo
Novoc
Kratos147
CoDexPo (Me haha)
I will not forget anything or anyone, I created this tutorial but there is another that is very confusing and not update the main post.
To drive, use arrows
for when the buggy tipping and its background is not transparent CR_Buggy_01.mat edit the file doublesided = 0 to DoubleSided = 1 and save
to avoid the mistake of "VehicleSetupDrivableShapeQueryFilterData not found" when compiling the server, install this patch, does not mean you run the vehicles on the server but will avoid the error when you VEHICLES_ENABLED to 1
Compilation only for the server, for install C:\WarZ\
Only Check on DNC Education
Replace files
The file is Patch2.7z
and:
PLEASE HELP!!!


Reply With Quote![[Tutorial] Enabling vehicles, Only work on Studio.exe by now](http://ragezone.com/hyper728.png)



