├── .gitignore ├── Config ├── DefaultEditor.ini ├── DefaultEditorPerProjectUserSettings.ini ├── DefaultEngine.ini ├── DefaultGame.ini └── DefaultInput.ini ├── Content ├── Geometry │ └── Meshes │ │ ├── 1M_Cube.uasset │ │ ├── 1M_Cube_Chamfer.uasset │ │ ├── CubeMaterial.uasset │ │ └── TemplateFloor.uasset ├── PostProcess │ ├── OpticalFlowTarget.uasset │ ├── OpticalFlowTarget_Mat.uasset │ └── VelocityMaterial.uasset ├── VehicleAdv │ ├── ArenaMesh │ │ ├── BumpWave.uasset │ │ ├── BumpWaveSmall.uasset │ │ ├── BumpWedge.uasset │ │ ├── CubeMaterial.uasset │ │ ├── LoopBig.uasset │ │ ├── LoopSmall.uasset │ │ ├── RampLarge.uasset │ │ ├── RampTwist.uasset │ │ ├── RoadSegment_01.uasset │ │ ├── StraightFull.uasset │ │ ├── StraightHalf.uasset │ │ ├── StraightQuarter.uasset │ │ ├── Turn_45.uasset │ │ ├── Turn_90.uasset │ │ ├── Turn_90Large.uasset │ │ ├── pole.uasset │ │ └── turn_22andhalf.uasset │ ├── Materials │ │ ├── Fixed_Template_Master.uasset │ │ ├── Landscape.uasset │ │ ├── MasterGrid.uasset │ │ ├── MasterSolidColor.uasset │ │ └── MaterialInstances │ │ │ ├── BlackGrid.uasset │ │ │ ├── LandscapeNoHole.uasset │ │ │ ├── RedGrid.uasset │ │ │ ├── SolidOrange.uasset │ │ │ ├── SolidRed.uasset │ │ │ └── Template_BaseBlue.uasset │ ├── PhysicsMaterials │ │ ├── NonSlippery.uasset │ │ └── Slippery.uasset │ ├── Sound │ │ ├── Engine_Loop_Cue.uasset │ │ ├── Engine_Speed_01_Loop.uasset │ │ ├── Engine_Speed_02_Loop.uasset │ │ ├── Engine_Speed_03_Loop.uasset │ │ ├── Engine_Speed_04_Loop.uasset │ │ ├── Engine_Speed_05_Loop.uasset │ │ ├── Engine_Speed_06_Loop.uasset │ │ └── Engine_att.uasset │ ├── Textures │ │ ├── VehicleJoystick_BackgroundL.uasset │ │ └── VehicleJoystick_BackgroundR.uasset │ └── Vehicle │ │ ├── LeftVirtualJoystickOnly.uasset │ │ ├── VehicleAnimationBlueprint.uasset │ │ ├── VehicleBodyCollision.uasset │ │ ├── VehiclePhysicsAsset.uasset │ │ ├── VehicleSkeleton.uasset │ │ ├── Vehicle_SkelMesh.uasset │ │ └── WheelData │ │ ├── Vehicle_BackTireConfig.uasset │ │ ├── Vehicle_BackTireType_TireConfig.uasset │ │ ├── Vehicle_FrontTireConfig.uasset │ │ └── Vehicle_FrontTireType_TireConfig.uasset └── VehicleAdvCPP │ └── Maps │ ├── LayerInfo │ ├── Desert_LayerInfo.uasset │ └── Track_LayerInfo.uasset │ └── VehicleAdvExampleMap.umap ├── OpticalFlowDemo.uproject ├── README.md ├── Source ├── OpticalFlowDemo.Target.cs ├── OpticalFlowDemo │ ├── OpticalFlowDemo.Build.cs │ ├── OpticalFlowDemo.cpp │ ├── OpticalFlowDemo.h │ ├── OpticalFlowDemoGameMode.cpp │ ├── OpticalFlowDemoGameMode.h │ ├── OpticalFlowDemoHud.cpp │ ├── OpticalFlowDemoHud.h │ ├── OpticalFlowDemoPawn.cpp │ ├── OpticalFlowDemoPawn.h │ ├── OpticalFlowDemoWheelFront.cpp │ ├── OpticalFlowDemoWheelFront.h │ ├── OpticalFlowDemoWheelRear.cpp │ └── OpticalFlowDemoWheelRear.h └── OpticalFlowDemoEditor.Target.cs └── UE4.patch /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio 2015 user specific files 2 | .vs/ 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | 22 | # Compiled Static libraries 23 | *.lai 24 | *.la 25 | *.a 26 | *.lib 27 | 28 | # Executables 29 | *.exe 30 | *.out 31 | *.app 32 | *.ipa 33 | 34 | # These project files can be generated by the engine 35 | *.xcodeproj 36 | *.xcworkspace 37 | *.sln 38 | *.suo 39 | *.opensdf 40 | *.sdf 41 | *.VC.db 42 | *.VC.opendb 43 | 44 | # Precompiled Assets 45 | SourceArt/**/*.png 46 | SourceArt/**/*.tga 47 | 48 | # Binary Files 49 | Binaries/* 50 | Plugins/*/Binaries/* 51 | 52 | # Builds 53 | Build/* 54 | 55 | # Whitelist PakBlacklist-.txt files 56 | !Build/*/ 57 | Build/*/** 58 | !Build/*/PakBlacklist*.txt 59 | 60 | # Don't ignore icon files in Build 61 | !Build/**/*.ico 62 | 63 | # Built data for maps 64 | *_BuiltData.uasset 65 | 66 | # Configuration files generated by the Editor 67 | Saved/* 68 | 69 | # Compiled source files for the engine to use 70 | Intermediate/* 71 | Plugins/*/Intermediate/* 72 | 73 | # Cache files for the editor to use 74 | DerivedDataCache/* 75 | -------------------------------------------------------------------------------- /Config/DefaultEditor.ini: -------------------------------------------------------------------------------- 1 | [UnrealEd.SimpleMap] 2 | SimpleMapName=/Game/VehicleAdv/Maps/VehicleAdvExampleMap 3 | 4 | [EditoronlyBP] 5 | bAllowClassAndBlueprintPinMatching=true 6 | bReplaceBlueprintWithClass= true 7 | bDontLoadBlueprintOutsideEditor= true 8 | bBlueprintIsNotBlueprintType= true 9 | [/Script/HardwareTargeting.HardwareTargetingSettings] 10 | TargetedHardwareClass=0 11 | DefaultGraphicsPerformance=0 12 | 13 | -------------------------------------------------------------------------------- /Config/DefaultEditorPerProjectUserSettings.ini: -------------------------------------------------------------------------------- 1 | [ContentBrowser] 2 | ContentBrowserTab1.SelectedPaths=/Game/VehicleAdv -------------------------------------------------------------------------------- /Config/DefaultEngine.ini: -------------------------------------------------------------------------------- 1 | [/Script/EngineSettings.GameMapsSettings] 2 | EditorStartupMap=/Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap 3 | LocalMapOptions= 4 | TransitionMap= 5 | bUseSplitscreen=True 6 | TwoPlayerSplitscreenLayout=Horizontal 7 | ThreePlayerSplitscreenLayout=FavorTop 8 | GameInstanceClass=/Script/Engine.GameInstance 9 | GameDefaultMap=/Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap 10 | ServerDefaultMap=/Engine/Maps/Entry 11 | GlobalDefaultGameMode=/Script/OpticalFlowDemo.OpticalFlowDemoGameMode 12 | GlobalDefaultServerGameMode=None 13 | 14 | [/Script/IOSRuntimeSettings.IOSRuntimeSettings] 15 | MinimumiOSVersion=IOS_9 16 | 17 | 18 | [/Script/Engine.Engine] 19 | +ActiveGameNameRedirects=(OldGameName="TP_VehicleAdv",NewGameName="/Script/OpticalFlowDemo") 20 | +ActiveGameNameRedirects=(OldGameName="/Script/TP_VehicleAdv",NewGameName="/Script/OpticalFlowDemo") 21 | +ActiveClassRedirects=(OldClassName="TP_VehicleAdvWheelRear",NewClassName="OpticalFlowDemoWheelRear") 22 | +ActiveClassRedirects=(OldClassName="TP_VehicleAdvWheelFront",NewClassName="OpticalFlowDemoWheelFront") 23 | +ActiveClassRedirects=(OldClassName="TP_VehicleAdvPawn",NewClassName="OpticalFlowDemoPawn") 24 | +ActiveClassRedirects=(OldClassName="TP_VehicleAdvHud",NewClassName="OpticalFlowDemoHud") 25 | +ActiveClassRedirects=(OldClassName="TP_VehicleAdvGameMode",NewClassName="OpticalFlowDemoGameMode") 26 | 27 | [/Script/HardwareTargeting.HardwareTargetingSettings] 28 | TargetedHardwareClass=Desktop 29 | AppliedTargetedHardwareClass=Desktop 30 | DefaultGraphicsPerformance=Maximum 31 | AppliedDefaultGraphicsPerformance=Maximum 32 | 33 | [/Script/Engine.PhysicsSettings] 34 | DefaultGravityZ=-980.000000 35 | DefaultTerminalVelocity=4000.000000 36 | DefaultFluidFriction=0.300000 37 | SimulateScratchMemorySize=262144 38 | RagdollAggregateThreshold=4 39 | TriangleMeshTriangleMinAreaThreshold=5.000000 40 | bEnableAsyncScene=False 41 | bEnableShapeSharing=False 42 | bEnablePCM=True 43 | bEnableStabilization=False 44 | bWarnMissingLocks=True 45 | bEnable2DPhysics=False 46 | PhysicErrorCorrection=(PingExtrapolation=0.100000,ErrorPerLinearDifference=1.000000,ErrorPerAngularDifference=1.000000,MaxRestoredStateError=1.000000,PositionLerp=0.000000,AngleLerp=0.400000,LinearVelocityCoefficient=100.000000,AngularVelocityCoefficient=10.000000,ErrorAccumulationSeconds=0.500000,ErrorAccumulationDistanceSq=15.000000,ErrorAccumulationSimilarity=100.000000) 47 | LockedAxis=Invalid 48 | DefaultDegreesOfFreedom=Full3D 49 | BounceThresholdVelocity=200.000000 50 | FrictionCombineMode=Average 51 | RestitutionCombineMode=Average 52 | MaxAngularVelocity=3600.000000 53 | MaxDepenetrationVelocity=0.000000 54 | ContactOffsetMultiplier=0.020000 55 | MinContactOffset=2.000000 56 | MaxContactOffset=8.000000 57 | bSimulateSkeletalMeshOnDedicatedServer=True 58 | DefaultShapeComplexity=CTF_UseSimpleAndComplex 59 | bDefaultHasComplexCollision=True 60 | bSuppressFaceRemapTable=False 61 | bSupportUVFromHitResults=False 62 | bDisableActiveActors=False 63 | bDisableKinematicStaticPairs=False 64 | bDisableKinematicKinematicPairs=False 65 | bDisableCCD=False 66 | bEnableEnhancedDeterminism=False 67 | MaxPhysicsDeltaTime=0.033333 68 | bSubstepping=True 69 | bSubsteppingAsync=False 70 | MaxSubstepDeltaTime=0.016667 71 | MaxSubsteps=6 72 | SyncSceneSmoothingFactor=0.000000 73 | AsyncSceneSmoothingFactor=0.990000 74 | InitialAverageFrameRate=0.016667 75 | PhysXTreeRebuildRate=10 76 | DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2) 77 | 78 | [/Script/Engine.RendererSettings] 79 | r.BasePassOutputsVelocity=True 80 | 81 | -------------------------------------------------------------------------------- /Config/DefaultGame.ini: -------------------------------------------------------------------------------- 1 | [/Script/EngineSettings.GeneralProjectSettings] 2 | ProjectID=D5B6656E9049472F835A9782075B4858 3 | ProjectName=Vehicle Game Template 4 | -------------------------------------------------------------------------------- /Config/DefaultInput.ini: -------------------------------------------------------------------------------- 1 | [/Script/Engine.InputSettings] 2 | +AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 3 | +AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 4 | +AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 5 | +AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 6 | +AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 7 | +AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 8 | bUseMouseForTouch=False 9 | +ActionMappings=(ActionName="Handbrake",Key=SpaceBar,bShift=False,bCtrl=False,bAlt=False,bCmd=False) 10 | +ActionMappings=(ActionName="Handbrake",Key=Gamepad_LeftShoulder,bShift=False,bCtrl=False,bAlt=False,bCmd=False) 11 | +ActionMappings=(ActionName="SwitchCamera",Key=Tab,bShift=False,bCtrl=False,bAlt=False,bCmd=False) 12 | +ActionMappings=(ActionName="ResetVR",Key=R,bShift=False,bCtrl=True,bAlt=False,bCmd=False) 13 | +ActionMappings=(ActionName="ResetVR",Key=MotionController_Left_Grip1,bShift=False,bCtrl=False,bAlt=False,bCmd=False) 14 | +ActionMappings=(ActionName="SwitchCamera",Key=Gamepad_Special_Left,bShift=False,bCtrl=False,bAlt=False,bCmd=False) 15 | +AxisMappings=(AxisName="MoveForward",Key=W,Scale=1.000000) 16 | +AxisMappings=(AxisName="MoveForward",Key=S,Scale=-1.000000) 17 | +AxisMappings=(AxisName="MoveForward",Key=Up,Scale=1.000000) 18 | +AxisMappings=(AxisName="MoveForward",Key=Down,Scale=-1.000000) 19 | +AxisMappings=(AxisName="MoveForward",Key=Gamepad_FaceButton_Bottom,Scale=1.000000) 20 | +AxisMappings=(AxisName="MoveRight",Key=A,Scale=-1.000000) 21 | +AxisMappings=(AxisName="MoveRight",Key=D,Scale=1.000000) 22 | +AxisMappings=(AxisName="MoveRight",Key=Left,Scale=-1.000000) 23 | +AxisMappings=(AxisName="MoveRight",Key=Right,Scale=1.000000) 24 | +AxisMappings=(AxisName="MoveRight",Key=Gamepad_LeftX,Scale=1.000000) 25 | +AxisMappings=(AxisName="LookUp",Key=MouseY,Scale=1.000000) 26 | +AxisMappings=(AxisName="LookRight",Key=MouseX,Scale=1.000000) 27 | +AxisMappings=(AxisName="MoveForward",Key=Gamepad_RightTriggerAxis,Scale=1.000000) 28 | +AxisMappings=(AxisName="MoveForward",Key=Gamepad_LeftTriggerAxis,Scale=-1.000000) 29 | +AxisMappings=(AxisName="LookUp",Key=Gamepad_RightY,Scale=-1.000000) 30 | +AxisMappings=(AxisName="LookRight",Key=Gamepad_RightX,Scale=1.000000) 31 | +AxisMappings=(AxisName="MoveForward",Key=Gamepad_LeftY,Scale=1.000000) 32 | +AxisMappings=(AxisName="MoveForward",Key=GenericUSBController_Axis2,Scale=-2.000000) 33 | +AxisMappings=(AxisName="MoveForward",Key=GenericUSBController_Axis3,Scale=1.000000) 34 | +AxisMappings=(AxisName="MoveRight",Key=GenericUSBController_Axis1,Scale=3.000000) 35 | DefaultTouchInterface=/Game/VehicleAdv/Vehicle/LeftVirtualJoystickOnly.LeftVirtualJoystickOnly 36 | ConsoleKey=None 37 | +ConsoleKeys=Tilde 38 | 39 | [/Script/RawInput.RawInputSettings] 40 | +DeviceConfigurations=(VendorID="0x046D",ProductID="0xC262",AxisProperties=((bEnabled=False),(Key=GenericUSBController_Axis1,Offset=-0.500000),(bEnabled=False),(Key=GenericUSBController_Axis2,bInverted=True,Offset=1.000000),(Key=GenericUSBController_Axis3,bInverted=True,Offset=1.000000)),ButtonProperties=((Key=GenericUSBController_Button1),(Key=GenericUSBController_Button2),(Key=GenericUSBController_Button3),(Key=GenericUSBController_Button4),(Key=GenericUSBController_Button5),(Key=GenericUSBController_Button6),(Key=GenericUSBController_Button7),(Key=GenericUSBController_Button8),(Key=GenericUSBController_Button9),(Key=GenericUSBController_Button10),(Key=GenericUSBController_Button11),(Key=GenericUSBController_Button12))) 41 | 42 | 43 | -------------------------------------------------------------------------------- /Content/Geometry/Meshes/1M_Cube.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/Geometry/Meshes/1M_Cube.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/1M_Cube_Chamfer.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/Geometry/Meshes/1M_Cube_Chamfer.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/CubeMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/Geometry/Meshes/CubeMaterial.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/TemplateFloor.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/Geometry/Meshes/TemplateFloor.uasset -------------------------------------------------------------------------------- /Content/PostProcess/OpticalFlowTarget.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/PostProcess/OpticalFlowTarget.uasset -------------------------------------------------------------------------------- /Content/PostProcess/OpticalFlowTarget_Mat.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/PostProcess/OpticalFlowTarget_Mat.uasset -------------------------------------------------------------------------------- /Content/PostProcess/VelocityMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/PostProcess/VelocityMaterial.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/BumpWave.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/BumpWave.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/BumpWaveSmall.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/BumpWaveSmall.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/BumpWedge.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/BumpWedge.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/CubeMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/CubeMaterial.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/LoopBig.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/LoopBig.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/LoopSmall.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/LoopSmall.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/RampLarge.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/RampLarge.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/RampTwist.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/RampTwist.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/RoadSegment_01.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/RoadSegment_01.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/StraightFull.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/StraightFull.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/StraightHalf.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/StraightHalf.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/StraightQuarter.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/StraightQuarter.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/Turn_45.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/Turn_45.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/Turn_90.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/Turn_90.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/Turn_90Large.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/Turn_90Large.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/pole.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/pole.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/ArenaMesh/turn_22andhalf.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/ArenaMesh/turn_22andhalf.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/Fixed_Template_Master.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/Fixed_Template_Master.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/Landscape.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/Landscape.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/MasterGrid.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/MasterGrid.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/MasterSolidColor.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/MasterSolidColor.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/MaterialInstances/BlackGrid.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/MaterialInstances/BlackGrid.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/MaterialInstances/LandscapeNoHole.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/MaterialInstances/LandscapeNoHole.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/MaterialInstances/RedGrid.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/MaterialInstances/RedGrid.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/MaterialInstances/SolidOrange.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/MaterialInstances/SolidOrange.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/MaterialInstances/SolidRed.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/MaterialInstances/SolidRed.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Materials/MaterialInstances/Template_BaseBlue.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Materials/MaterialInstances/Template_BaseBlue.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/PhysicsMaterials/NonSlippery.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/PhysicsMaterials/NonSlippery.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/PhysicsMaterials/Slippery.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/PhysicsMaterials/Slippery.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Sound/Engine_Loop_Cue.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Sound/Engine_Loop_Cue.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Sound/Engine_Speed_01_Loop.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Sound/Engine_Speed_01_Loop.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Sound/Engine_Speed_02_Loop.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Sound/Engine_Speed_02_Loop.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Sound/Engine_Speed_03_Loop.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Sound/Engine_Speed_03_Loop.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Sound/Engine_Speed_04_Loop.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Sound/Engine_Speed_04_Loop.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Sound/Engine_Speed_05_Loop.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Sound/Engine_Speed_05_Loop.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Sound/Engine_Speed_06_Loop.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Sound/Engine_Speed_06_Loop.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Sound/Engine_att.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Sound/Engine_att.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Textures/VehicleJoystick_BackgroundL.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Textures/VehicleJoystick_BackgroundL.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Textures/VehicleJoystick_BackgroundR.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Textures/VehicleJoystick_BackgroundR.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/LeftVirtualJoystickOnly.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/LeftVirtualJoystickOnly.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/VehicleAnimationBlueprint.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/VehicleAnimationBlueprint.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/VehicleBodyCollision.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/VehicleBodyCollision.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/VehiclePhysicsAsset.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/VehiclePhysicsAsset.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/VehicleSkeleton.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/VehicleSkeleton.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/Vehicle_SkelMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/Vehicle_SkelMesh.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/WheelData/Vehicle_BackTireConfig.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/WheelData/Vehicle_BackTireConfig.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/WheelData/Vehicle_BackTireType_TireConfig.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/WheelData/Vehicle_BackTireType_TireConfig.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/WheelData/Vehicle_FrontTireConfig.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/WheelData/Vehicle_FrontTireConfig.uasset -------------------------------------------------------------------------------- /Content/VehicleAdv/Vehicle/WheelData/Vehicle_FrontTireType_TireConfig.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdv/Vehicle/WheelData/Vehicle_FrontTireType_TireConfig.uasset -------------------------------------------------------------------------------- /Content/VehicleAdvCPP/Maps/LayerInfo/Desert_LayerInfo.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdvCPP/Maps/LayerInfo/Desert_LayerInfo.uasset -------------------------------------------------------------------------------- /Content/VehicleAdvCPP/Maps/LayerInfo/Track_LayerInfo.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdvCPP/Maps/LayerInfo/Track_LayerInfo.uasset -------------------------------------------------------------------------------- /Content/VehicleAdvCPP/Maps/VehicleAdvExampleMap.umap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProfFan/UnrealOpticalFlowDemo/00ae821c882e65bab60872877a7d88330c04e984/Content/VehicleAdvCPP/Maps/VehicleAdvExampleMap.umap -------------------------------------------------------------------------------- /OpticalFlowDemo.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "{2ED07214-D14E-C96F-94FE-349FE933C91B}", 4 | "Category": "", 5 | "Description": "", 6 | "Modules": [ 7 | { 8 | "Name": "OpticalFlowDemo", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default" 11 | } 12 | ], 13 | "Plugins": [ 14 | { 15 | "Name": "PhysXVehicles", 16 | "Enabled": true 17 | }, 18 | { 19 | "Name": "RawInput", 20 | "Enabled": true 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![DOI](https://zenodo.org/badge/144809463.svg)](https://zenodo.org/badge/latestdoi/144809463) 2 | 3 | # Optical Flow from Unreal 4 | 5 | This project demonstrates how to get optical flow information from Unreal Engine for computer vision and AI training purposes. 6 | 7 | # Usage 8 | 9 | You need to first have UE 4.20.1 source code and use `patch -p1 UE4.patch` to patch the engine. 10 | 11 | Then you can compile the engine. After a successful compilation, use the Editor to open this project. 12 | 13 | # Screen Capture 14 | 15 | ![The Optical Flow Screen](https://github.com/ProfFan/UnrealOpticalFlowDemo/raw/images/images/demo.png) 16 | 17 | # Citation 18 | 19 | If you found this work helpful in your research, please cite this repository. 20 | 21 | ``` 22 | @INPROCEEDINGS{fan_jiang_icra19, 23 | author = {Fan Jiang and Qi Hao}, 24 | booktitle = {Robotics and Automation (ICRA), 2019 IEEE International Conference on}, 25 | title = {Pavilion: Bridging Photo-Realism and Robotics}, 26 | month = may, 27 | year = 2019, 28 | } 29 | 30 | @misc{fan_jiang_2018_1345482, 31 | author = {Fan Jiang}, 32 | title = {Unreal Optical Flow Demo}, 33 | month = aug, 34 | year = 2018, 35 | doi = {10.5281/zenodo.1345482}, 36 | url = {https://doi.org/10.5281/zenodo.1345482} 37 | } 38 | ``` 39 | 40 | # LICENSE 41 | 42 | MIT 43 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo.Target.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class OpticalFlowDemoTarget : TargetRules 7 | { 8 | public OpticalFlowDemoTarget(TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Game; 11 | ExtraModuleNames.Add("OpticalFlowDemo"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemo.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class OpticalFlowDemo : ModuleRules 6 | { 7 | public OpticalFlowDemo(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "PhysXVehicles", "HeadMountedDisplay" }); 12 | 13 | PublicDefinitions.Add("HMD_MODULE_INCLUDED=1"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemo.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "OpticalFlowDemo.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, OpticalFlowDemo, "OpticalFlowDemo" ); 7 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemo.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoGameMode.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "OpticalFlowDemoGameMode.h" 4 | #include "OpticalFlowDemoPawn.h" 5 | #include "OpticalFlowDemoHud.h" 6 | 7 | AOpticalFlowDemoGameMode::AOpticalFlowDemoGameMode() 8 | { 9 | DefaultPawnClass = AOpticalFlowDemoPawn::StaticClass(); 10 | HUDClass = AOpticalFlowDemoHud::StaticClass(); 11 | } 12 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoGameMode.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/GameModeBase.h" 7 | #include "OpticalFlowDemoGameMode.generated.h" 8 | 9 | UCLASS(MinimalAPI) 10 | class AOpticalFlowDemoGameMode : public AGameModeBase 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | AOpticalFlowDemoGameMode(); 16 | }; 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoHud.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "OpticalFlowDemoHud.h" 4 | #include "OpticalFlowDemoPawn.h" 5 | #include "Engine/Canvas.h" 6 | #include "Engine/Font.h" 7 | #include "CanvasItem.h" 8 | #include "UObject/ConstructorHelpers.h" 9 | #include "Engine/Engine.h" 10 | 11 | // Needed for VR Headset 12 | #include "Engine.h" 13 | 14 | #define LOCTEXT_NAMESPACE "VehicleHUD" 15 | 16 | #ifndef HMD_MODULE_INCLUDED 17 | #define HMD_MODULE_INCLUDED 0 18 | #endif 19 | 20 | AOpticalFlowDemoHud::AOpticalFlowDemoHud() 21 | { 22 | static ConstructorHelpers::FObjectFinder Font(TEXT("/Engine/EngineFonts/RobotoDistanceField")); 23 | HUDFont = Font.Object; 24 | } 25 | 26 | void AOpticalFlowDemoHud::DrawHUD() 27 | { 28 | Super::DrawHUD(); 29 | 30 | // Calculate ratio from 720p 31 | const float HUDXRatio = Canvas->SizeX / 1280.f; 32 | const float HUDYRatio = Canvas->SizeY / 720.f; 33 | 34 | bool bHMDDeviceActive = false; 35 | 36 | // We dont want the onscreen hud when using a HMD device 37 | #if HMD_MODULE_INCLUDED 38 | bHMDDeviceActive = GEngine->IsStereoscopic3D(); 39 | #endif // HMD_MODULE_INCLUDED 40 | if( bHMDDeviceActive == false ) 41 | { 42 | // Get our vehicle so we can check if we are in car. If we are we don't want onscreen HUD 43 | AOpticalFlowDemoPawn* Vehicle = Cast(GetOwningPawn()); 44 | if ((Vehicle != nullptr) && (Vehicle->bInCarCameraActive == false)) 45 | { 46 | FVector2D ScaleVec(HUDYRatio * 1.4f, HUDYRatio * 1.4f); 47 | 48 | // Speed 49 | FCanvasTextItem SpeedTextItem(FVector2D(HUDXRatio * 805.f, HUDYRatio * 455), Vehicle->SpeedDisplayString, HUDFont, FLinearColor::White); 50 | SpeedTextItem.Scale = ScaleVec; 51 | Canvas->DrawItem(SpeedTextItem); 52 | 53 | // Gear 54 | FCanvasTextItem GearTextItem(FVector2D(HUDXRatio * 805.f, HUDYRatio * 500.f), Vehicle->GearDisplayString, HUDFont, Vehicle->bInReverseGear == false ? Vehicle->GearDisplayColor : Vehicle->GearDisplayReverseColor); 55 | GearTextItem.Scale = ScaleVec; 56 | Canvas->DrawItem(GearTextItem); 57 | } 58 | } 59 | } 60 | 61 | #undef LOCTEXT_NAMESPACE 62 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoHud.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/HUD.h" 7 | #include "OpticalFlowDemoHud.generated.h" 8 | 9 | UCLASS(config = Game) 10 | class AOpticalFlowDemoHud : public AHUD 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | AOpticalFlowDemoHud(); 16 | 17 | /** Font used to render the vehicle info */ 18 | UPROPERTY() 19 | UFont* HUDFont; 20 | 21 | // Begin AHUD interface 22 | virtual void DrawHUD() override; 23 | // End AHUD interface 24 | 25 | }; 26 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoPawn.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "OpticalFlowDemoPawn.h" 4 | #include "OpticalFlowDemoWheelFront.h" 5 | #include "OpticalFlowDemoWheelRear.h" 6 | #include "OpticalFlowDemoHud.h" 7 | #include "Components/SkeletalMeshComponent.h" 8 | #include "GameFramework/SpringArmComponent.h" 9 | #include "Camera/CameraComponent.h" 10 | #include "Components/InputComponent.h" 11 | #include "Components/TextRenderComponent.h" 12 | #include "Components/AudioComponent.h" 13 | #include "Sound/SoundCue.h" 14 | #include "PhysicalMaterials/PhysicalMaterial.h" 15 | #include "WheeledVehicleMovementComponent4W.h" 16 | #include "Engine/SkeletalMesh.h" 17 | #include "Engine/Engine.h" 18 | #include "GameFramework/Controller.h" 19 | #include "UObject/ConstructorHelpers.h" 20 | 21 | #ifndef HMD_MODULE_INCLUDED 22 | #define HMD_MODULE_INCLUDED 0 23 | #endif 24 | 25 | // Needed for VR Headset 26 | #if HMD_MODULE_INCLUDED 27 | #include "IXRTrackingSystem.h" 28 | #include "HeadMountedDisplayFunctionLibrary.h" 29 | #endif // HMD_MODULE_INCLUDED 30 | 31 | const FName AOpticalFlowDemoPawn::LookUpBinding("LookUp"); 32 | const FName AOpticalFlowDemoPawn::LookRightBinding("LookRight"); 33 | const FName AOpticalFlowDemoPawn::EngineAudioRPM("RPM"); 34 | 35 | #define LOCTEXT_NAMESPACE "VehiclePawn" 36 | 37 | AOpticalFlowDemoPawn::AOpticalFlowDemoPawn() 38 | { 39 | // Car mesh 40 | static ConstructorHelpers::FObjectFinder CarMesh(TEXT("/Game/VehicleAdv/Vehicle/Vehicle_SkelMesh.Vehicle_SkelMesh")); 41 | GetMesh()->SetSkeletalMesh(CarMesh.Object); 42 | 43 | static ConstructorHelpers::FClassFinder AnimBPClass(TEXT("/Game/VehicleAdv/Vehicle/VehicleAnimationBlueprint")); 44 | GetMesh()->SetAnimationMode(EAnimationMode::AnimationBlueprint); 45 | GetMesh()->SetAnimInstanceClass(AnimBPClass.Class); 46 | 47 | // Setup friction materials 48 | static ConstructorHelpers::FObjectFinder SlipperyMat(TEXT("/Game/VehicleAdv/PhysicsMaterials/Slippery.Slippery")); 49 | SlipperyMaterial = SlipperyMat.Object; 50 | 51 | static ConstructorHelpers::FObjectFinder NonSlipperyMat(TEXT("/Game/VehicleAdv/PhysicsMaterials/NonSlippery.NonSlippery")); 52 | NonSlipperyMaterial = NonSlipperyMat.Object; 53 | 54 | UWheeledVehicleMovementComponent4W* Vehicle4W = CastChecked(GetVehicleMovement()); 55 | 56 | check(Vehicle4W->WheelSetups.Num() == 4); 57 | 58 | // Wheels/Tyres 59 | // Setup the wheels 60 | Vehicle4W->WheelSetups[0].WheelClass = UOpticalFlowDemoWheelFront::StaticClass(); 61 | Vehicle4W->WheelSetups[0].BoneName = FName("PhysWheel_FL"); 62 | Vehicle4W->WheelSetups[0].AdditionalOffset = FVector(0.f, -8.f, 0.f); 63 | 64 | Vehicle4W->WheelSetups[1].WheelClass = UOpticalFlowDemoWheelFront::StaticClass(); 65 | Vehicle4W->WheelSetups[1].BoneName = FName("PhysWheel_FR"); 66 | Vehicle4W->WheelSetups[1].AdditionalOffset = FVector(0.f, 8.f, 0.f); 67 | 68 | Vehicle4W->WheelSetups[2].WheelClass = UOpticalFlowDemoWheelRear::StaticClass(); 69 | Vehicle4W->WheelSetups[2].BoneName = FName("PhysWheel_BL"); 70 | Vehicle4W->WheelSetups[2].AdditionalOffset = FVector(0.f, -8.f, 0.f); 71 | 72 | Vehicle4W->WheelSetups[3].WheelClass = UOpticalFlowDemoWheelRear::StaticClass(); 73 | Vehicle4W->WheelSetups[3].BoneName = FName("PhysWheel_BR"); 74 | Vehicle4W->WheelSetups[3].AdditionalOffset = FVector(0.f, 8.f, 0.f); 75 | 76 | // Adjust the tire loading 77 | Vehicle4W->MinNormalizedTireLoad = 0.0f; 78 | Vehicle4W->MinNormalizedTireLoadFiltered = 0.2f; 79 | Vehicle4W->MaxNormalizedTireLoad = 2.0f; 80 | Vehicle4W->MaxNormalizedTireLoadFiltered = 2.0f; 81 | 82 | // Engine 83 | // Torque setup 84 | Vehicle4W->MaxEngineRPM = 5700.0f; 85 | Vehicle4W->EngineSetup.TorqueCurve.GetRichCurve()->Reset(); 86 | Vehicle4W->EngineSetup.TorqueCurve.GetRichCurve()->AddKey(0.0f, 400.0f); 87 | Vehicle4W->EngineSetup.TorqueCurve.GetRichCurve()->AddKey(1890.0f, 500.0f); 88 | Vehicle4W->EngineSetup.TorqueCurve.GetRichCurve()->AddKey(5730.0f, 400.0f); 89 | 90 | // Adjust the steering 91 | Vehicle4W->SteeringCurve.GetRichCurve()->Reset(); 92 | Vehicle4W->SteeringCurve.GetRichCurve()->AddKey(0.0f, 1.0f); 93 | Vehicle4W->SteeringCurve.GetRichCurve()->AddKey(40.0f, 0.7f); 94 | Vehicle4W->SteeringCurve.GetRichCurve()->AddKey(120.0f, 0.6f); 95 | 96 | // Transmission 97 | // We want 4wd 98 | Vehicle4W->DifferentialSetup.DifferentialType = EVehicleDifferential4W::LimitedSlip_4W; 99 | 100 | // Drive the front wheels a little more than the rear 101 | Vehicle4W->DifferentialSetup.FrontRearSplit = 0.65; 102 | 103 | // Automatic gearbox 104 | Vehicle4W->TransmissionSetup.bUseGearAutoBox = true; 105 | Vehicle4W->TransmissionSetup.GearSwitchTime = 0.15f; 106 | Vehicle4W->TransmissionSetup.GearAutoBoxLatency = 1.0f; 107 | 108 | // Physics settings 109 | // Adjust the center of mass - the buggy is quite low 110 | UPrimitiveComponent* UpdatedPrimitive = Cast(Vehicle4W->UpdatedComponent); 111 | if (UpdatedPrimitive) 112 | { 113 | UpdatedPrimitive->BodyInstance.COMNudge = FVector(8.0f, 0.0f, 0.0f); 114 | } 115 | 116 | // Set the inertia scale. This controls how the mass of the vehicle is distributed. 117 | Vehicle4W->InertiaTensorScale = FVector(1.0f, 1.333f, 1.2f); 118 | 119 | // Create a spring arm component for our chase camera 120 | SpringArm = CreateDefaultSubobject(TEXT("SpringArm")); 121 | SpringArm->SetRelativeLocation(FVector(0.0f, 0.0f, 34.0f)); 122 | SpringArm->SetWorldRotation(FRotator(-20.0f, 0.0f, 0.0f)); 123 | SpringArm->SetupAttachment(RootComponent); 124 | SpringArm->TargetArmLength = 125.0f; 125 | SpringArm->bEnableCameraLag = false; 126 | SpringArm->bEnableCameraRotationLag = false; 127 | SpringArm->bInheritPitch = true; 128 | SpringArm->bInheritYaw = true; 129 | SpringArm->bInheritRoll = true; 130 | 131 | // Create the chase camera component 132 | Camera = CreateDefaultSubobject(TEXT("ChaseCamera")); 133 | Camera->SetupAttachment(SpringArm, USpringArmComponent::SocketName); 134 | Camera->SetRelativeLocation(FVector(-125.0, 0.0f, 0.0f)); 135 | Camera->SetRelativeRotation(FRotator(10.0f, 0.0f, 0.0f)); 136 | Camera->bUsePawnControlRotation = false; 137 | Camera->FieldOfView = 90.f; 138 | 139 | // Create In-Car camera component 140 | InternalCameraOrigin = FVector(-34.0f, -10.0f, 50.0f); 141 | InternalCameraBase = CreateDefaultSubobject(TEXT("InternalCameraBase")); 142 | InternalCameraBase->SetRelativeLocation(InternalCameraOrigin); 143 | InternalCameraBase->SetupAttachment(GetMesh()); 144 | 145 | InternalCamera = CreateDefaultSubobject(TEXT("InternalCamera")); 146 | InternalCamera->bUsePawnControlRotation = false; 147 | InternalCamera->FieldOfView = 90.f; 148 | InternalCamera->SetupAttachment(InternalCameraBase); 149 | 150 | // In car HUD 151 | // Create text render component for in car speed display 152 | InCarSpeed = CreateDefaultSubobject(TEXT("IncarSpeed")); 153 | InCarSpeed->SetRelativeScale3D(FVector(0.1f, 0.1f, 0.1f)); 154 | InCarSpeed->SetRelativeLocation(FVector(35.0f, -6.0f, 20.0f)); 155 | InCarSpeed->SetRelativeRotation(FRotator(0.0f, 180.0f, 0.0f)); 156 | InCarSpeed->SetupAttachment(GetMesh()); 157 | 158 | // Create text render component for in car gear display 159 | InCarGear = CreateDefaultSubobject(TEXT("IncarGear")); 160 | InCarGear->SetRelativeScale3D(FVector(0.1f, 0.1f, 0.1f)); 161 | InCarGear->SetRelativeLocation(FVector(35.0f, 5.0f, 20.0f)); 162 | InCarGear->SetRelativeRotation(FRotator(0.0f, 180.0f, 0.0f)); 163 | InCarGear->SetupAttachment(GetMesh()); 164 | 165 | // Setup the audio component and allocate it a sound cue 166 | static ConstructorHelpers::FObjectFinder SoundCue(TEXT("/Game/VehicleAdv/Sound/Engine_Loop_Cue.Engine_Loop_Cue")); 167 | EngineSoundComponent = CreateDefaultSubobject(TEXT("EngineSound")); 168 | EngineSoundComponent->SetSound(SoundCue.Object); 169 | EngineSoundComponent->SetupAttachment(GetMesh()); 170 | 171 | // Colors for the in-car gear display. One for normal one for reverse 172 | GearDisplayReverseColor = FColor(255, 0, 0, 255); 173 | GearDisplayColor = FColor(255, 255, 255, 255); 174 | 175 | bIsLowFriction = false; 176 | bInReverseGear = false; 177 | } 178 | 179 | void AOpticalFlowDemoPawn::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) 180 | { 181 | Super::SetupPlayerInputComponent(PlayerInputComponent); 182 | 183 | // set up gameplay key bindings 184 | check(PlayerInputComponent); 185 | 186 | PlayerInputComponent->BindAxis("MoveForward", this, &AOpticalFlowDemoPawn::MoveForward); 187 | PlayerInputComponent->BindAxis("MoveRight", this, &AOpticalFlowDemoPawn::MoveRight); 188 | PlayerInputComponent->BindAxis(LookUpBinding); 189 | PlayerInputComponent->BindAxis(LookRightBinding); 190 | 191 | PlayerInputComponent->BindAction("Handbrake", IE_Pressed, this, &AOpticalFlowDemoPawn::OnHandbrakePressed); 192 | PlayerInputComponent->BindAction("Handbrake", IE_Released, this, &AOpticalFlowDemoPawn::OnHandbrakeReleased); 193 | PlayerInputComponent->BindAction("SwitchCamera", IE_Pressed, this, &AOpticalFlowDemoPawn::OnToggleCamera); 194 | 195 | PlayerInputComponent->BindAction("ResetVR", IE_Pressed, this, &AOpticalFlowDemoPawn::OnResetVR); 196 | } 197 | 198 | void AOpticalFlowDemoPawn::MoveForward(float Val) 199 | { 200 | GetVehicleMovementComponent()->SetThrottleInput(Val); 201 | 202 | } 203 | 204 | void AOpticalFlowDemoPawn::MoveRight(float Val) 205 | { 206 | GetVehicleMovementComponent()->SetSteeringInput(Val); 207 | } 208 | 209 | void AOpticalFlowDemoPawn::OnHandbrakePressed() 210 | { 211 | GetVehicleMovementComponent()->SetHandbrakeInput(true); 212 | } 213 | 214 | void AOpticalFlowDemoPawn::OnHandbrakeReleased() 215 | { 216 | GetVehicleMovementComponent()->SetHandbrakeInput(false); 217 | } 218 | 219 | void AOpticalFlowDemoPawn::OnToggleCamera() 220 | { 221 | EnableIncarView(!bInCarCameraActive); 222 | } 223 | 224 | void AOpticalFlowDemoPawn::EnableIncarView(const bool bState) 225 | { 226 | if (bState != bInCarCameraActive) 227 | { 228 | bInCarCameraActive = bState; 229 | 230 | if (bState == true) 231 | { 232 | OnResetVR(); 233 | Camera->Deactivate(); 234 | InternalCamera->Activate(); 235 | } 236 | else 237 | { 238 | InternalCamera->Deactivate(); 239 | Camera->Activate(); 240 | } 241 | 242 | InCarSpeed->SetVisibility(bInCarCameraActive); 243 | InCarGear->SetVisibility(bInCarCameraActive); 244 | } 245 | } 246 | 247 | void AOpticalFlowDemoPawn::Tick(float Delta) 248 | { 249 | Super::Tick(Delta); 250 | 251 | // Setup the flag to say we are in reverse gear 252 | bInReverseGear = GetVehicleMovement()->GetCurrentGear() < 0; 253 | 254 | // Update phsyics material 255 | UpdatePhysicsMaterial(); 256 | 257 | // Update the strings used in the hud (incar and onscreen) 258 | UpdateHUDStrings(); 259 | 260 | // Set the string in the incar hud 261 | SetupInCarHUD(); 262 | 263 | bool bHMDActive = false; 264 | #if HMD_MODULE_INCLUDED 265 | if ((GEngine->XRSystem.IsValid() == true ) && ( (GEngine->XRSystem->IsHeadTrackingAllowed() == true) || (GEngine->IsStereoscopic3D() == true))) 266 | { 267 | bHMDActive = true; 268 | } 269 | #endif // HMD_MODULE_INCLUDED 270 | if( bHMDActive == false ) 271 | { 272 | if ( (InputComponent) && (bInCarCameraActive == true )) 273 | { 274 | FRotator HeadRotation = InternalCamera->RelativeRotation; 275 | HeadRotation.Pitch += InputComponent->GetAxisValue(LookUpBinding); 276 | HeadRotation.Yaw += InputComponent->GetAxisValue(LookRightBinding); 277 | InternalCamera->RelativeRotation = HeadRotation; 278 | } 279 | } 280 | 281 | // Pass the engine RPM to the sound component 282 | float RPMToAudioScale = 2500.0f / GetVehicleMovement()->GetEngineMaxRotationSpeed(); 283 | EngineSoundComponent->SetFloatParameter(EngineAudioRPM, GetVehicleMovement()->GetEngineRotationSpeed()*RPMToAudioScale); 284 | } 285 | 286 | void AOpticalFlowDemoPawn::BeginPlay() 287 | { 288 | Super::BeginPlay(); 289 | 290 | bool bWantInCar = false; 291 | // First disable both speed/gear displays 292 | bInCarCameraActive = false; 293 | InCarSpeed->SetVisibility(bInCarCameraActive); 294 | InCarGear->SetVisibility(bInCarCameraActive); 295 | 296 | // Enable in car view if HMD is attached 297 | #if HMD_MODULE_INCLUDED 298 | bWantInCar = UHeadMountedDisplayFunctionLibrary::IsHeadMountedDisplayEnabled(); 299 | #endif // HMD_MODULE_INCLUDED 300 | 301 | EnableIncarView(bWantInCar); 302 | // Start an engine sound playing 303 | EngineSoundComponent->Play(); 304 | } 305 | 306 | void AOpticalFlowDemoPawn::OnResetVR() 307 | { 308 | #if HMD_MODULE_INCLUDED 309 | if (GEngine->XRSystem.IsValid()) 310 | { 311 | GEngine->XRSystem->ResetOrientationAndPosition(); 312 | InternalCamera->SetRelativeLocation(InternalCameraOrigin); 313 | GetController()->SetControlRotation(FRotator()); 314 | } 315 | #endif // HMD_MODULE_INCLUDED 316 | } 317 | 318 | void AOpticalFlowDemoPawn::UpdateHUDStrings() 319 | { 320 | float KPH = FMath::Abs(GetVehicleMovement()->GetForwardSpeed()) * 0.036f; 321 | int32 KPH_int = FMath::FloorToInt(KPH); 322 | int32 Gear = GetVehicleMovement()->GetCurrentGear(); 323 | 324 | // Using FText because this is display text that should be localizable 325 | SpeedDisplayString = FText::Format(LOCTEXT("SpeedFormat", "{0} km/h"), FText::AsNumber(KPH_int)); 326 | 327 | 328 | if (bInReverseGear == true) 329 | { 330 | GearDisplayString = FText(LOCTEXT("ReverseGear", "R")); 331 | } 332 | else 333 | { 334 | GearDisplayString = (Gear == 0) ? LOCTEXT("N", "N") : FText::AsNumber(Gear); 335 | } 336 | 337 | } 338 | 339 | void AOpticalFlowDemoPawn::SetupInCarHUD() 340 | { 341 | APlayerController* PlayerController = Cast(GetController()); 342 | if ((PlayerController != nullptr) && (InCarSpeed != nullptr) && (InCarGear != nullptr)) 343 | { 344 | // Setup the text render component strings 345 | InCarSpeed->SetText(SpeedDisplayString); 346 | InCarGear->SetText(GearDisplayString); 347 | 348 | if (bInReverseGear == false) 349 | { 350 | InCarGear->SetTextRenderColor(GearDisplayColor); 351 | } 352 | else 353 | { 354 | InCarGear->SetTextRenderColor(GearDisplayReverseColor); 355 | } 356 | } 357 | } 358 | 359 | void AOpticalFlowDemoPawn::UpdatePhysicsMaterial() 360 | { 361 | if (GetActorUpVector().Z < 0) 362 | { 363 | if (bIsLowFriction == true) 364 | { 365 | GetMesh()->SetPhysMaterialOverride(NonSlipperyMaterial); 366 | bIsLowFriction = false; 367 | } 368 | else 369 | { 370 | GetMesh()->SetPhysMaterialOverride(SlipperyMaterial); 371 | bIsLowFriction = true; 372 | } 373 | } 374 | } 375 | 376 | #undef LOCTEXT_NAMESPACE 377 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoPawn.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WheeledVehicle.h" 7 | #include "OpticalFlowDemoPawn.generated.h" 8 | 9 | class UPhysicalMaterial; 10 | class UCameraComponent; 11 | class USpringArmComponent; 12 | class UTextRenderComponent; 13 | class UInputComponent; 14 | class UAudioComponent; 15 | 16 | UCLASS(config=Game) 17 | class AOpticalFlowDemoPawn : public AWheeledVehicle 18 | { 19 | GENERATED_BODY() 20 | 21 | /** Spring arm that will offset the camera */ 22 | UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) 23 | USpringArmComponent* SpringArm; 24 | 25 | /** Camera component that will be our viewpoint */ 26 | UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) 27 | UCameraComponent* Camera; 28 | 29 | /** SCene component for the In-Car view origin */ 30 | UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) 31 | class USceneComponent* InternalCameraBase; 32 | 33 | /** Camera component for the In-Car view */ 34 | UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) 35 | UCameraComponent* InternalCamera; 36 | 37 | /** Text component for the In-Car speed */ 38 | UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) 39 | UTextRenderComponent* InCarSpeed; 40 | 41 | /** Text component for the In-Car gear */ 42 | UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) 43 | UTextRenderComponent* InCarGear; 44 | 45 | /** Audio component for the engine sound */ 46 | UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) 47 | UAudioComponent* EngineSoundComponent; 48 | 49 | public: 50 | AOpticalFlowDemoPawn(); 51 | 52 | /** The current speed as a string eg 10 km/h */ 53 | UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly) 54 | FText SpeedDisplayString; 55 | 56 | /** The current gear as a string (R,N, 1,2 etc) */ 57 | UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly) 58 | FText GearDisplayString; 59 | 60 | UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly) 61 | /** The color of the incar gear text in forward gears */ 62 | FColor GearDisplayColor; 63 | 64 | /** The color of the incar gear text when in reverse */ 65 | UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly) 66 | FColor GearDisplayReverseColor; 67 | 68 | /** Are we using incar camera */ 69 | UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly) 70 | bool bInCarCameraActive; 71 | 72 | /** Are we in reverse gear */ 73 | UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly) 74 | bool bInReverseGear; 75 | 76 | /** Initial offset of incar camera */ 77 | FVector InternalCameraOrigin; 78 | 79 | // Begin Pawn interface 80 | virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override; 81 | // End Pawn interface 82 | 83 | // Begin Actor interface 84 | virtual void Tick(float Delta) override; 85 | protected: 86 | virtual void BeginPlay() override; 87 | 88 | public: 89 | // End Actor interface 90 | 91 | /** Handle pressing forwards */ 92 | void MoveForward(float Val); 93 | 94 | /** Setup the strings used on the hud */ 95 | void SetupInCarHUD(); 96 | 97 | /** Update the physics material used by the vehicle mesh */ 98 | void UpdatePhysicsMaterial(); 99 | 100 | /** Handle pressing right */ 101 | void MoveRight(float Val); 102 | /** Handle handbrake pressed */ 103 | void OnHandbrakePressed(); 104 | /** Handle handbrake released */ 105 | void OnHandbrakeReleased(); 106 | /** Switch between cameras */ 107 | void OnToggleCamera(); 108 | /** Handle reset VR device */ 109 | void OnResetVR(); 110 | 111 | static const FName LookUpBinding; 112 | static const FName LookRightBinding; 113 | static const FName EngineAudioRPM; 114 | 115 | private: 116 | /** 117 | * Activate In-Car camera. Enable camera and sets visibility of incar hud display 118 | * 119 | * @param bState true will enable in car view and set visibility of various 120 | */ 121 | void EnableIncarView( const bool bState ); 122 | 123 | /** Update the gear and speed strings */ 124 | void UpdateHUDStrings(); 125 | 126 | /* Are we on a 'slippery' surface */ 127 | bool bIsLowFriction; 128 | /** Slippery Material instance */ 129 | UPhysicalMaterial* SlipperyMaterial; 130 | /** Non Slippery Material instance */ 131 | UPhysicalMaterial* NonSlipperyMaterial; 132 | 133 | 134 | public: 135 | /** Returns SpringArm subobject **/ 136 | FORCEINLINE USpringArmComponent* GetSpringArm() const { return SpringArm; } 137 | /** Returns Camera subobject **/ 138 | FORCEINLINE UCameraComponent* GetCamera() const { return Camera; } 139 | /** Returns InternalCamera subobject **/ 140 | FORCEINLINE UCameraComponent* GetInternalCamera() const { return InternalCamera; } 141 | /** Returns InCarSpeed subobject **/ 142 | FORCEINLINE UTextRenderComponent* GetInCarSpeed() const { return InCarSpeed; } 143 | /** Returns InCarGear subobject **/ 144 | FORCEINLINE UTextRenderComponent* GetInCarGear() const { return InCarGear; } 145 | /** Returns EngineSoundComponent subobject **/ 146 | FORCEINLINE UAudioComponent* GetEngineSoundComponent() const { return EngineSoundComponent; } 147 | }; 148 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoWheelFront.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "OpticalFlowDemoWheelFront.h" 4 | #include "TireConfig.h" 5 | #include "UObject/ConstructorHelpers.h" 6 | 7 | UOpticalFlowDemoWheelFront::UOpticalFlowDemoWheelFront() 8 | { 9 | ShapeRadius = 18.f; 10 | ShapeWidth = 15.0f; 11 | bAffectedByHandbrake = false; 12 | SteerAngle = 40.f; 13 | 14 | // Setup suspension forces 15 | SuspensionForceOffset = -4.0f; 16 | SuspensionMaxRaise = 8.0f; 17 | SuspensionMaxDrop = 12.0f; 18 | SuspensionNaturalFrequency = 9.0f; 19 | SuspensionDampingRatio = 1.05f; 20 | 21 | // Find the tire object and set the data for it 22 | static ConstructorHelpers::FObjectFinder TireData(TEXT("/Game/VehicleAdv/Vehicle/WheelData/Vehicle_FrontTireConfig.Vehicle_FrontTireConfig")); 23 | TireConfig = TireData.Object; 24 | } 25 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoWheelFront.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "VehicleWheel.h" 7 | #include "OpticalFlowDemoWheelFront.generated.h" 8 | 9 | UCLASS() 10 | class UOpticalFlowDemoWheelFront : public UVehicleWheel 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | UOpticalFlowDemoWheelFront(); 16 | }; 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoWheelRear.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "OpticalFlowDemoWheelRear.h" 4 | #include "TireConfig.h" 5 | #include "UObject/ConstructorHelpers.h" 6 | 7 | UOpticalFlowDemoWheelRear::UOpticalFlowDemoWheelRear() 8 | { 9 | ShapeRadius = 18.0f; 10 | ShapeWidth = 15.0f; 11 | bAffectedByHandbrake = true; 12 | SteerAngle = 0.f; 13 | 14 | // Setup suspension forces 15 | SuspensionForceOffset = -4.0f; 16 | SuspensionMaxRaise = 8.0f; 17 | SuspensionMaxDrop = 12.0f; 18 | SuspensionNaturalFrequency = 9.0f; 19 | SuspensionDampingRatio = 1.05f; 20 | 21 | // Find the tire object and set the data for it 22 | static ConstructorHelpers::FObjectFinder TireData(TEXT("/Game/VehicleAdv/Vehicle/WheelData/Vehicle_BackTireConfig.Vehicle_BackTireConfig")); 23 | TireConfig = TireData.Object; 24 | } 25 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemo/OpticalFlowDemoWheelRear.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "VehicleWheel.h" 7 | #include "OpticalFlowDemoWheelRear.generated.h" 8 | 9 | UCLASS() 10 | class UOpticalFlowDemoWheelRear : public UVehicleWheel 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | UOpticalFlowDemoWheelRear(); 16 | }; 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/OpticalFlowDemoEditor.Target.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class OpticalFlowDemoEditorTarget : TargetRules 7 | { 8 | public OpticalFlowDemoEditorTarget(TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Editor; 11 | ExtraModuleNames.Add("OpticalFlowDemo"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /UE4.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Engine/Config/ConsoleVariables.ini b/Engine/Config/ConsoleVariables.ini 2 | index 73129b952a9..c8eb5209a3b 100644 3 | --- a/Engine/Config/ConsoleVariables.ini 4 | +++ b/Engine/Config/ConsoleVariables.ini 5 | @@ -33,14 +33,14 @@ 6 | 7 | 8 | ; Uncomment to get detailed logs on shader compiles and the opportunity to retry on errors 9 | -; r.ShaderDevelopmentMode=1 10 | +r.ShaderDevelopmentMode=1 11 | ; Uncomment to dump shaders in the Saved folder 12 | ; Warning: leaving this on for a while will fill your hard drive with many small files and folders 13 | -;r.DumpShaderDebugInfo=1 14 | +r.DumpShaderDebugInfo=1 15 | ; When this is enabled, dumped shader paths will get collapsed (in the cases where paths are longer than the OS's max) 16 | -;r.DumpShaderDebugShortNames=1 17 | +r.DumpShaderDebugShortNames=1 18 | ; When this is enabled, when dumping shaders an additional file to use with ShaderCompilerWorker -direct mode will be generated 19 | -;r.DumpShaderDebugWorkerCommandLine=1 20 | +r.DumpShaderDebugWorkerCommandLine=1 21 | ; Uncomment to enable parallel rendering at startup 22 | ;r.RHICmdBypass=0 23 | 24 | diff --git a/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp b/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp 25 | index 4fda27ad781..0303babd775 100644 26 | --- a/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp 27 | +++ b/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp 28 | @@ -1049,7 +1049,8 @@ static FRenderingCompositeOutputRef AddPostProcessMaterialChain( 29 | EBlendableLocation InLocation, 30 | FRenderingCompositeOutputRef SeparateTranslucency = FRenderingCompositeOutputRef(), 31 | FRenderingCompositeOutputRef PreTonemapHDRColor = FRenderingCompositeOutputRef(), 32 | - FRenderingCompositeOutputRef PostTonemapHDRColor = FRenderingCompositeOutputRef()) 33 | + FRenderingCompositeOutputRef PostTonemapHDRColor = FRenderingCompositeOutputRef(), 34 | + FRenderingCompositeOutputRef VelocityRT = FRenderingCompositeOutputRef()) 35 | { 36 | if( !Context.View.Family->EngineShowFlags.PostProcessing || 37 | !Context.View.Family->EngineShowFlags.PostProcessMaterial || 38 | @@ -1129,8 +1130,10 @@ static FRenderingCompositeOutputRef AddPostProcessMaterialChain( 39 | { 40 | Node->SetInput(ePId_Input2, PreTonemapHDRColor); 41 | Node->SetInput(ePId_Input3, PostTonemapHDRColor); 42 | - } 43 | - 44 | + } else { 45 | + Node->SetInput(ePId_Input2, VelocityRT); 46 | + } 47 | + 48 | LastestOutput = FRenderingCompositeOutputRef(Node); 49 | } 50 | 51 | @@ -1455,7 +1458,7 @@ void FPostProcessing::Process(FRHICommandListImmediate& RHICmdList, const FViewI 52 | VelocityInput = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(VelocityRT)); 53 | } 54 | 55 | - Context.FinalOutput = AddPostProcessMaterialChain(Context, BL_BeforeTranslucency, SeparateTranslucency); 56 | + Context.FinalOutput = AddPostProcessMaterialChain(Context, BL_BeforeTranslucency, SeparateTranslucency,FRenderingCompositeOutputRef(),FRenderingCompositeOutputRef(),VelocityInput); 57 | 58 | static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DepthOfFieldQuality")); 59 | check(CVar) 60 | --------------------------------------------------------------------------------