├── .gitattributes ├── .github ├── issue_template.md ├── pull_request_template.md └── workflows │ └── activation.yml ├── .gitignore ├── .vsconfig ├── Assets ├── .gitignore ├── NightDriveryUnity.meta ├── NightDriveryUnity │ ├── Scenes.meta │ ├── Scenes │ │ ├── Simple Pacman Demo.unity │ │ ├── Simple Pacman Demo.unity.meta │ │ ├── Simple YouTube Demo.unity │ │ └── Simple YouTube Demo.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── Adler32.cs │ │ ├── Adler32.cs.meta │ │ ├── FastLEDInterop.cs │ │ ├── FastLEDInterop.cs.meta │ │ ├── Graphics.cs │ │ ├── Graphics.cs.meta │ │ ├── LEDControllerChannel.cs │ │ ├── LEDControllerChannel.cs.meta │ │ ├── LEDSignController.cs │ │ ├── LEDSignController.cs.meta │ │ ├── ZLIBStream.cs │ │ ├── ZLIBStream.cs.meta │ │ ├── ZLibHeader.cs │ │ └── ZLibHeader.cs.meta │ ├── Videos.meta │ └── Videos │ │ ├── Pacman Chase Wide.mov │ │ ├── Pacman Chase Wide.mov.meta │ │ ├── Road - 1101.mp4 │ │ ├── Road - 1101.mp4.meta │ │ ├── swcrawl.mp4 │ │ └── swcrawl.mp4.meta ├── Simple Demo.unity └── Simple Demo.unity.meta ├── CONTRIBUTING.md ├── COPYING.txt └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | # Unity files 4 | *.meta -text merge=unityyamlmerge diff 5 | *.unity -text merge=unityyamlmerge diff 6 | *.asset -text merge=unityyamlmerge diff 7 | *.prefab -text merge=unityyamlmerge diff 8 | *.mat -text merge=unityyamlmerge diff 9 | *.anim -text merge=unityyamlmerge diff 10 | *.controller -text merge=unityyamlmerge diff 11 | *.overrideController -text merge=unityyamlmerge diff 12 | *.physicMaterial -text merge=unityyamlmerge diff 13 | *.physicsMaterial2D -text merge=unityyamlmerge diff 14 | *.playable -text merge=unityyamlmerge diff 15 | *.mask -text merge=unityyamlmerge diff 16 | *.brush -text merge=unityyamlmerge diff 17 | *.flare -text merge=unityyamlmerge diff 18 | *.fontsettings -text merge=unityyamlmerge diff 19 | *.guiskin -text merge=unityyamlmerge diff 20 | *.giparams -text merge=unityyamlmerge diff 21 | *.renderTexture -text merge=unityyamlmerge diff 22 | *.spriteatlas -text merge=unityyamlmerge diff 23 | *.terrainlayer -text merge=unityyamlmerge diff 24 | *.mixer -text merge=unityyamlmerge diff 25 | *.shadervariants -text merge=unityyamlmerge diff 26 | 27 | # Image formats 28 | *.psd filter=lfs diff=lfs merge=lfs -text 29 | *.jpg filter=lfs diff=lfs merge=lfs -text 30 | *.png filter=lfs diff=lfs merge=lfs -text 31 | *.gif filter=lfs diff=lfs merge=lfs -text 32 | *.bmp filter=lfs diff=lfs merge=lfs -text 33 | *.tga filter=lfs diff=lfs merge=lfs -text 34 | *.tiff filter=lfs diff=lfs merge=lfs -text 35 | *.tif filter=lfs diff=lfs merge=lfs -text 36 | *.iff filter=lfs diff=lfs merge=lfs -text 37 | *.pict filter=lfs diff=lfs merge=lfs -text 38 | *.dds filter=lfs diff=lfs merge=lfs -text 39 | *.xcf filter=lfs diff=lfs merge=lfs -text 40 | 41 | # Audio formats 42 | *.mp3 filter=lfs diff=lfs merge=lfs -text 43 | *.ogg filter=lfs diff=lfs merge=lfs -text 44 | *.wav filter=lfs diff=lfs merge=lfs -text 45 | *.aiff filter=lfs diff=lfs merge=lfs -text 46 | *.aif filter=lfs diff=lfs merge=lfs -text 47 | *.mod filter=lfs diff=lfs merge=lfs -text 48 | *.it filter=lfs diff=lfs merge=lfs -text 49 | *.s3m filter=lfs diff=lfs merge=lfs -text 50 | *.xm filter=lfs diff=lfs merge=lfs -text 51 | 52 | # Video formats 53 | *.mov filter=lfs diff=lfs merge=lfs -text 54 | *.avi filter=lfs diff=lfs merge=lfs -text 55 | *.asf filter=lfs diff=lfs merge=lfs -text 56 | *.mpg filter=lfs diff=lfs merge=lfs -text 57 | *.mpeg filter=lfs diff=lfs merge=lfs -text 58 | *.mp4 filter=lfs diff=lfs merge=lfs -text 59 | 60 | # 3D formats 61 | *.fbx filter=lfs diff=lfs merge=lfs -text 62 | *.obj filter=lfs diff=lfs merge=lfs -text 63 | *.max filter=lfs diff=lfs merge=lfs -text 64 | *.blend filter=lfs diff=lfs merge=lfs -text 65 | *.dae filter=lfs diff=lfs merge=lfs -text 66 | *.mb filter=lfs diff=lfs merge=lfs -text 67 | *.ma filter=lfs diff=lfs merge=lfs -text 68 | *.3ds filter=lfs diff=lfs merge=lfs -text 69 | *.dfx filter=lfs diff=lfs merge=lfs -text 70 | *.c4d filter=lfs diff=lfs merge=lfs -text 71 | *.lwo filter=lfs diff=lfs merge=lfs -text 72 | *.lwo2 filter=lfs diff=lfs merge=lfs -text 73 | *.abc filter=lfs diff=lfs merge=lfs -text 74 | *.3dm filter=lfs diff=lfs merge=lfs -text 75 | 76 | # Build 77 | *.dll filter=lfs diff=lfs merge=lfs -text 78 | *.pdb filter=lfs diff=lfs merge=lfs -text 79 | *.mdb filter=lfs diff=lfs merge=lfs -text 80 | 81 | # Packaging 82 | *.zip filter=lfs diff=lfs merge=lfs -text 83 | *.7z filter=lfs diff=lfs merge=lfs -text 84 | *.gz filter=lfs diff=lfs merge=lfs -text 85 | *.rar filter=lfs diff=lfs merge=lfs -text 86 | *.tar filter=lfs diff=lfs merge=lfs -text 87 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Bug report 4 | 5 | 6 | **Problem** 7 | 8 | 9 | **Steps** 10 | 11 | 1. 12 | 2. 13 | 3. 14 | 15 | **Example** 16 | 17 | 18 | **Notes** 19 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | 4 | ## Contributing requirements 5 | 6 | 7 | 12 | * [ ] I read the contribution guidelines in [CONTRIBUTING.md](http://github.com/PlummersSoftwareLLC/NightDriverUnity/blob/main/CONTRIBUTING.md). 13 | * [ ] I selected `main` as the target branch. 14 | * [ ] All code herein is subjected to the license terms in [COPYING.txt](http://github.com/PlummersSoftwareLLC/NightDriverUnity/blob/main/COPYING.txt). -------------------------------------------------------------------------------- /.github/workflows/activation.yml: -------------------------------------------------------------------------------- 1 | name: Acquire activation file 2 | on: 3 | workflow_dispatch: {} 4 | jobs: 5 | activation: 6 | name: Request manual activation file 🔑 7 | runs-on: ubuntu-latest 8 | steps: 9 | # Request manual activation file 10 | - name: Request manual activation file 11 | id: getManualLicenseFile 12 | uses: game-ci/unity-request-activation-file@v2 13 | # Upload artifact (Unity_v20XX.X.XXXX.alf) 14 | - name: Expose as artifact 15 | uses: actions/upload-artifact@v2 16 | with: 17 | name: ${{ steps.getManualLicenseFile.outputs.filePath }} 18 | path: ${{ steps.getManualLicenseFile.outputs.filePath }} 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | [Ll]ogs/ 7 | 8 | # Uncomment this line if you wish to ignore the asset store tools plugin 9 | # [Aa]ssets/AssetStoreTools* 10 | 11 | # Visual Studio cache directory 12 | .vs/ 13 | 14 | # Gradle cache directory 15 | .gradle/ 16 | 17 | # Autogenerated VS/MD/Consulo solution and project files 18 | ExportedObj/ 19 | .consulo/ 20 | *.csproj 21 | *.unityproj 22 | *.sln 23 | *.suo 24 | *.tmp 25 | *.user 26 | *.userprefs 27 | *.pidb 28 | *.booproj 29 | *.svd 30 | *.pdb 31 | *.mdb 32 | *.opendb 33 | *.VC.db 34 | 35 | # Unity3D generated meta files 36 | *.pidb.meta 37 | *.pdb.meta 38 | *.mdb.meta 39 | 40 | # Unity3D generated file on crash reports 41 | sysinfo.txt 42 | 43 | # Builds 44 | *.apk 45 | *.unitypackage 46 | 47 | # Crashlytics generated file 48 | crashlytics-build.properties 49 | -------------------------------------------------------------------------------- /.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Workload.ManagedGame" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Assets/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlummersSoftwareLLC/NightDriverUnity/e69d3cbd1ac7016ac70dee42f2b68870a17fb8f0/Assets/.gitignore -------------------------------------------------------------------------------- /Assets/NightDriveryUnity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25e41caf209526b48813f6a399a74b51 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3e2fe1b553882645a3eca762b46c889 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scenes/Simple Pacman Demo.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 3 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 0 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 512 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 256 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 1 83 | m_PVRDenoiserTypeDirect: 1 84 | m_PVRDenoiserTypeIndirect: 1 85 | m_PVRDenoiserTypeAO: 1 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 1 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_UseShadowmask: 1 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | debug: 122 | m_Flags: 0 123 | m_NavMeshData: {fileID: 0} 124 | --- !u!1 &23841965 125 | GameObject: 126 | m_ObjectHideFlags: 0 127 | m_CorrespondingSourceObject: {fileID: 0} 128 | m_PrefabInstance: {fileID: 0} 129 | m_PrefabAsset: {fileID: 0} 130 | serializedVersion: 6 131 | m_Component: 132 | - component: {fileID: 23841967} 133 | - component: {fileID: 23841966} 134 | - component: {fileID: 23841968} 135 | m_Layer: 0 136 | m_Name: GameObject 137 | m_TagString: Untagged 138 | m_Icon: {fileID: 0} 139 | m_NavMeshLayer: 0 140 | m_StaticEditorFlags: 0 141 | m_IsActive: 1 142 | --- !u!328 &23841966 143 | VideoPlayer: 144 | m_ObjectHideFlags: 0 145 | m_CorrespondingSourceObject: {fileID: 0} 146 | m_PrefabInstance: {fileID: 0} 147 | m_PrefabAsset: {fileID: 0} 148 | m_GameObject: {fileID: 23841965} 149 | m_Enabled: 1 150 | m_VideoClip: {fileID: 32900000, guid: d535eb95f4dea4b27af31e8b955997c8, type: 3} 151 | m_TargetCameraAlpha: 1 152 | m_TargetCamera3DLayout: 0 153 | m_TargetCamera: {fileID: 123536681} 154 | m_TargetTexture: {fileID: 0} 155 | m_TimeReference: 0 156 | m_TargetMaterialRenderer: {fileID: 0} 157 | m_TargetMaterialProperty: _MainTex 158 | m_RenderMode: 1 159 | m_AspectRatio: 2 160 | m_DataSource: 0 161 | m_PlaybackSpeed: 1 162 | m_AudioOutputMode: 2 163 | m_TargetAudioSources: [] 164 | m_DirectAudioVolumes: [] 165 | m_Url: 166 | m_EnabledAudioTracks: 167 | m_DirectAudioMutes: 168 | m_ControlledAudioTrackCount: 0 169 | m_PlayOnAwake: 1 170 | m_SkipOnDrop: 1 171 | m_Looping: 1 172 | m_WaitForFirstFrame: 1 173 | m_FrameReadyEventEnabled: 0 174 | --- !u!4 &23841967 175 | Transform: 176 | m_ObjectHideFlags: 0 177 | m_CorrespondingSourceObject: {fileID: 0} 178 | m_PrefabInstance: {fileID: 0} 179 | m_PrefabAsset: {fileID: 0} 180 | m_GameObject: {fileID: 23841965} 181 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 182 | m_LocalPosition: {x: -166.95186, y: 85.481, z: -5031.5} 183 | m_LocalScale: {x: 1, y: 1, z: 1} 184 | m_Children: 185 | - {fileID: 1253871086} 186 | m_Father: {fileID: 0} 187 | m_RootOrder: 1 188 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 189 | --- !u!114 &23841968 190 | MonoBehaviour: 191 | m_ObjectHideFlags: 0 192 | m_CorrespondingSourceObject: {fileID: 0} 193 | m_PrefabInstance: {fileID: 0} 194 | m_PrefabAsset: {fileID: 0} 195 | m_GameObject: {fileID: 23841965} 196 | m_Enabled: 1 197 | m_EditorHideFlags: 0 198 | m_Script: {fileID: 11500000, guid: 615918ee99cb44f23ad88aa3c3c7a429, type: 3} 199 | m_Name: 200 | m_EditorClassIdentifier: 201 | HostName: 192.168.8.198 202 | FriendlyName: RGMatrix 203 | CompressData: 0 204 | Channel: 0 205 | Brightness: 1 206 | Connects: 0 207 | Watts: 0 208 | Width: 48 209 | Height: 16 210 | FramesPerSecond: 24 211 | RedGreenSwap: 0 212 | AntiAliasing: 8 213 | CaptureCamera: {fileID: 123536681} 214 | --- !u!1 &123536679 215 | GameObject: 216 | m_ObjectHideFlags: 0 217 | m_CorrespondingSourceObject: {fileID: 0} 218 | m_PrefabInstance: {fileID: 0} 219 | m_PrefabAsset: {fileID: 0} 220 | serializedVersion: 6 221 | m_Component: 222 | - component: {fileID: 123536682} 223 | - component: {fileID: 123536681} 224 | - component: {fileID: 123536680} 225 | m_Layer: 0 226 | m_Name: Main Camera 227 | m_TagString: MainCamera 228 | m_Icon: {fileID: 0} 229 | m_NavMeshLayer: 0 230 | m_StaticEditorFlags: 0 231 | m_IsActive: 1 232 | --- !u!81 &123536680 233 | AudioListener: 234 | m_ObjectHideFlags: 0 235 | m_CorrespondingSourceObject: {fileID: 0} 236 | m_PrefabInstance: {fileID: 0} 237 | m_PrefabAsset: {fileID: 0} 238 | m_GameObject: {fileID: 123536679} 239 | m_Enabled: 1 240 | --- !u!20 &123536681 241 | Camera: 242 | m_ObjectHideFlags: 0 243 | m_CorrespondingSourceObject: {fileID: 0} 244 | m_PrefabInstance: {fileID: 0} 245 | m_PrefabAsset: {fileID: 0} 246 | m_GameObject: {fileID: 123536679} 247 | m_Enabled: 1 248 | serializedVersion: 2 249 | m_ClearFlags: 1 250 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 251 | m_projectionMatrixMode: 1 252 | m_GateFitMode: 2 253 | m_FOVAxisMode: 0 254 | m_SensorSize: {x: 36, y: 24} 255 | m_LensShift: {x: 0, y: 0} 256 | m_FocalLength: 50 257 | m_NormalizedViewPortRect: 258 | serializedVersion: 2 259 | x: 0 260 | y: 0 261 | width: 1 262 | height: 1 263 | near clip plane: 0.3 264 | far clip plane: 1000 265 | field of view: 60 266 | orthographic: 1 267 | orthographic size: 5 268 | m_Depth: -1 269 | m_CullingMask: 270 | serializedVersion: 2 271 | m_Bits: 4294967295 272 | m_RenderingPath: -1 273 | m_TargetTexture: {fileID: 0} 274 | m_TargetDisplay: 0 275 | m_TargetEye: 3 276 | m_HDR: 1 277 | m_AllowMSAA: 1 278 | m_AllowDynamicResolution: 0 279 | m_ForceIntoRT: 0 280 | m_OcclusionCulling: 1 281 | m_StereoConvergence: 10 282 | m_StereoSeparation: 0.022 283 | --- !u!4 &123536682 284 | Transform: 285 | m_ObjectHideFlags: 0 286 | m_CorrespondingSourceObject: {fileID: 0} 287 | m_PrefabInstance: {fileID: 0} 288 | m_PrefabAsset: {fileID: 0} 289 | m_GameObject: {fileID: 123536679} 290 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 291 | m_LocalPosition: {x: 0, y: 0, z: -10} 292 | m_LocalScale: {x: 1, y: 1, z: 1} 293 | m_Children: [] 294 | m_Father: {fileID: 0} 295 | m_RootOrder: 0 296 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 297 | --- !u!1 &1253871085 298 | GameObject: 299 | m_ObjectHideFlags: 0 300 | m_CorrespondingSourceObject: {fileID: 0} 301 | m_PrefabInstance: {fileID: 0} 302 | m_PrefabAsset: {fileID: 0} 303 | serializedVersion: 6 304 | m_Component: 305 | - component: {fileID: 1253871086} 306 | - component: {fileID: 1253871089} 307 | - component: {fileID: 1253871088} 308 | - component: {fileID: 1253871087} 309 | - component: {fileID: 1253871090} 310 | m_Layer: 0 311 | m_Name: Canvas 312 | m_TagString: Untagged 313 | m_Icon: {fileID: 0} 314 | m_NavMeshLayer: 0 315 | m_StaticEditorFlags: 0 316 | m_IsActive: 1 317 | --- !u!224 &1253871086 318 | RectTransform: 319 | m_ObjectHideFlags: 0 320 | m_CorrespondingSourceObject: {fileID: 0} 321 | m_PrefabInstance: {fileID: 0} 322 | m_PrefabAsset: {fileID: 0} 323 | m_GameObject: {fileID: 1253871085} 324 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 325 | m_LocalPosition: {x: 0, y: 0, z: 5121.5} 326 | m_LocalScale: {x: 0.0295858, y: 0.0295858, z: 0.0295858} 327 | m_Children: [] 328 | m_Father: {fileID: 23841967} 329 | m_RootOrder: 0 330 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 331 | m_AnchorMin: {x: 0, y: 0} 332 | m_AnchorMax: {x: 0, y: 0} 333 | m_AnchoredPosition: {x: 166.95186, y: -85.481} 334 | m_SizeDelta: {x: 868.99994, y: 0} 335 | m_Pivot: {x: 0.5, y: 0.5} 336 | --- !u!114 &1253871087 337 | MonoBehaviour: 338 | m_ObjectHideFlags: 0 339 | m_CorrespondingSourceObject: {fileID: 0} 340 | m_PrefabInstance: {fileID: 0} 341 | m_PrefabAsset: {fileID: 0} 342 | m_GameObject: {fileID: 1253871085} 343 | m_Enabled: 0 344 | m_EditorHideFlags: 0 345 | m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} 346 | m_Name: 347 | m_EditorClassIdentifier: 348 | m_IgnoreReversedGraphics: 1 349 | m_BlockingObjects: 0 350 | m_BlockingMask: 351 | serializedVersion: 2 352 | m_Bits: 4294967295 353 | --- !u!114 &1253871088 354 | MonoBehaviour: 355 | m_ObjectHideFlags: 0 356 | m_CorrespondingSourceObject: {fileID: 0} 357 | m_PrefabInstance: {fileID: 0} 358 | m_PrefabAsset: {fileID: 0} 359 | m_GameObject: {fileID: 1253871085} 360 | m_Enabled: 1 361 | m_EditorHideFlags: 0 362 | m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} 363 | m_Name: 364 | m_EditorClassIdentifier: 365 | m_UiScaleMode: 0 366 | m_ReferencePixelsPerUnit: 100 367 | m_ScaleFactor: 1 368 | m_ReferenceResolution: {x: 800, y: 600} 369 | m_ScreenMatchMode: 0 370 | m_MatchWidthOrHeight: 0 371 | m_PhysicalUnit: 3 372 | m_FallbackScreenDPI: 96 373 | m_DefaultSpriteDPI: 96 374 | m_DynamicPixelsPerUnit: 1 375 | --- !u!223 &1253871089 376 | Canvas: 377 | m_ObjectHideFlags: 0 378 | m_CorrespondingSourceObject: {fileID: 0} 379 | m_PrefabInstance: {fileID: 0} 380 | m_PrefabAsset: {fileID: 0} 381 | m_GameObject: {fileID: 1253871085} 382 | m_Enabled: 1 383 | serializedVersion: 3 384 | m_RenderMode: 1 385 | m_Camera: {fileID: 123536681} 386 | m_PlaneDistance: 100 387 | m_PixelPerfect: 0 388 | m_ReceivesEvents: 1 389 | m_OverrideSorting: 0 390 | m_OverridePixelPerfect: 0 391 | m_SortingBucketNormalizedSize: 0 392 | m_AdditionalShaderChannelsFlag: 0 393 | m_SortingLayerID: 0 394 | m_SortingOrder: 0 395 | m_TargetDisplay: 1 396 | --- !u!114 &1253871090 397 | MonoBehaviour: 398 | m_ObjectHideFlags: 0 399 | m_CorrespondingSourceObject: {fileID: 0} 400 | m_PrefabInstance: {fileID: 0} 401 | m_PrefabAsset: {fileID: 0} 402 | m_GameObject: {fileID: 1253871085} 403 | m_Enabled: 1 404 | m_EditorHideFlags: 0 405 | m_Script: {fileID: 11500000, guid: 86710e43de46f6f4bac7c8e50813a599, type: 3} 406 | m_Name: 407 | m_EditorClassIdentifier: 408 | m_AspectMode: 1 409 | m_AspectRatio: 2 410 | --- !u!1 &1347277838 411 | GameObject: 412 | m_ObjectHideFlags: 0 413 | m_CorrespondingSourceObject: {fileID: 0} 414 | m_PrefabInstance: {fileID: 0} 415 | m_PrefabAsset: {fileID: 0} 416 | serializedVersion: 6 417 | m_Component: 418 | - component: {fileID: 1347277841} 419 | - component: {fileID: 1347277840} 420 | - component: {fileID: 1347277839} 421 | m_Layer: 0 422 | m_Name: EventSystem 423 | m_TagString: Untagged 424 | m_Icon: {fileID: 0} 425 | m_NavMeshLayer: 0 426 | m_StaticEditorFlags: 0 427 | m_IsActive: 1 428 | --- !u!114 &1347277839 429 | MonoBehaviour: 430 | m_ObjectHideFlags: 0 431 | m_CorrespondingSourceObject: {fileID: 0} 432 | m_PrefabInstance: {fileID: 0} 433 | m_PrefabAsset: {fileID: 0} 434 | m_GameObject: {fileID: 1347277838} 435 | m_Enabled: 1 436 | m_EditorHideFlags: 0 437 | m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} 438 | m_Name: 439 | m_EditorClassIdentifier: 440 | m_HorizontalAxis: Horizontal 441 | m_VerticalAxis: Vertical 442 | m_SubmitButton: Submit 443 | m_CancelButton: Cancel 444 | m_InputActionsPerSecond: 10 445 | m_RepeatDelay: 0.5 446 | m_ForceModuleActive: 0 447 | --- !u!114 &1347277840 448 | MonoBehaviour: 449 | m_ObjectHideFlags: 0 450 | m_CorrespondingSourceObject: {fileID: 0} 451 | m_PrefabInstance: {fileID: 0} 452 | m_PrefabAsset: {fileID: 0} 453 | m_GameObject: {fileID: 1347277838} 454 | m_Enabled: 1 455 | m_EditorHideFlags: 0 456 | m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} 457 | m_Name: 458 | m_EditorClassIdentifier: 459 | m_FirstSelected: {fileID: 0} 460 | m_sendNavigationEvents: 1 461 | m_DragThreshold: 10 462 | --- !u!4 &1347277841 463 | Transform: 464 | m_ObjectHideFlags: 0 465 | m_CorrespondingSourceObject: {fileID: 0} 466 | m_PrefabInstance: {fileID: 0} 467 | m_PrefabAsset: {fileID: 0} 468 | m_GameObject: {fileID: 1347277838} 469 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 470 | m_LocalPosition: {x: 0, y: 0, z: 0} 471 | m_LocalScale: {x: 1, y: 1, z: 1} 472 | m_Children: [] 473 | m_Father: {fileID: 0} 474 | m_RootOrder: 2 475 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 476 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scenes/Simple Pacman Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90fc8c32e04e54df0b6ec2947e3cd66a 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scenes/Simple YouTube Demo.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 3 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 0 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 512 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 256 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 1 83 | m_PVRDenoiserTypeDirect: 1 84 | m_PVRDenoiserTypeIndirect: 1 85 | m_PVRDenoiserTypeAO: 1 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 1 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_UseShadowmask: 1 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | debug: 122 | m_Flags: 0 123 | m_NavMeshData: {fileID: 0} 124 | --- !u!1 &23841965 125 | GameObject: 126 | m_ObjectHideFlags: 0 127 | m_CorrespondingSourceObject: {fileID: 0} 128 | m_PrefabInstance: {fileID: 0} 129 | m_PrefabAsset: {fileID: 0} 130 | serializedVersion: 6 131 | m_Component: 132 | - component: {fileID: 23841967} 133 | - component: {fileID: 23841966} 134 | - component: {fileID: 23841968} 135 | m_Layer: 0 136 | m_Name: GameObject 137 | m_TagString: Untagged 138 | m_Icon: {fileID: 0} 139 | m_NavMeshLayer: 0 140 | m_StaticEditorFlags: 0 141 | m_IsActive: 1 142 | --- !u!328 &23841966 143 | VideoPlayer: 144 | m_ObjectHideFlags: 0 145 | m_CorrespondingSourceObject: {fileID: 0} 146 | m_PrefabInstance: {fileID: 0} 147 | m_PrefabAsset: {fileID: 0} 148 | m_GameObject: {fileID: 23841965} 149 | m_Enabled: 1 150 | m_VideoClip: {fileID: 32900000, guid: d535eb95f4dea4b27af31e8b955997c8, type: 3} 151 | m_TargetCameraAlpha: 1 152 | m_TargetCamera3DLayout: 0 153 | m_TargetCamera: {fileID: 123536681} 154 | m_TargetTexture: {fileID: 0} 155 | m_TimeReference: 0 156 | m_TargetMaterialRenderer: {fileID: 0} 157 | m_TargetMaterialProperty: _MainTex 158 | m_RenderMode: 1 159 | m_AspectRatio: 2 160 | m_DataSource: 0 161 | m_PlaybackSpeed: 1 162 | m_AudioOutputMode: 2 163 | m_TargetAudioSources: [] 164 | m_DirectAudioVolumes: [] 165 | m_Url: 166 | m_EnabledAudioTracks: 167 | m_DirectAudioMutes: 168 | m_ControlledAudioTrackCount: 0 169 | m_PlayOnAwake: 1 170 | m_SkipOnDrop: 1 171 | m_Looping: 1 172 | m_WaitForFirstFrame: 1 173 | m_FrameReadyEventEnabled: 0 174 | --- !u!4 &23841967 175 | Transform: 176 | m_ObjectHideFlags: 0 177 | m_CorrespondingSourceObject: {fileID: 0} 178 | m_PrefabInstance: {fileID: 0} 179 | m_PrefabAsset: {fileID: 0} 180 | m_GameObject: {fileID: 23841965} 181 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 182 | m_LocalPosition: {x: -166.95186, y: 85.481, z: -5031.5} 183 | m_LocalScale: {x: 1, y: 1, z: 1} 184 | m_Children: 185 | - {fileID: 1253871086} 186 | m_Father: {fileID: 0} 187 | m_RootOrder: 1 188 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 189 | --- !u!114 &23841968 190 | MonoBehaviour: 191 | m_ObjectHideFlags: 0 192 | m_CorrespondingSourceObject: {fileID: 0} 193 | m_PrefabInstance: {fileID: 0} 194 | m_PrefabAsset: {fileID: 0} 195 | m_GameObject: {fileID: 23841965} 196 | m_Enabled: 1 197 | m_EditorHideFlags: 0 198 | m_Script: {fileID: 11500000, guid: 615918ee99cb44f23ad88aa3c3c7a429, type: 3} 199 | m_Name: 200 | m_EditorClassIdentifier: 201 | HostName: 192.168.8.198 202 | FriendlyName: RGMatrix 203 | CompressData: 1 204 | Channel: 0 205 | Brightness: 1 206 | Connects: 0 207 | Watts: 0 208 | Width: 48 209 | Height: 16 210 | FramesPerSecond: 24 211 | RedGreenSwap: 0 212 | AntiAliasing: 8 213 | CaptureCamera: {fileID: 123536681} 214 | --- !u!1 &123536679 215 | GameObject: 216 | m_ObjectHideFlags: 0 217 | m_CorrespondingSourceObject: {fileID: 0} 218 | m_PrefabInstance: {fileID: 0} 219 | m_PrefabAsset: {fileID: 0} 220 | serializedVersion: 6 221 | m_Component: 222 | - component: {fileID: 123536682} 223 | - component: {fileID: 123536681} 224 | - component: {fileID: 123536680} 225 | m_Layer: 0 226 | m_Name: Main Camera 227 | m_TagString: MainCamera 228 | m_Icon: {fileID: 0} 229 | m_NavMeshLayer: 0 230 | m_StaticEditorFlags: 0 231 | m_IsActive: 1 232 | --- !u!81 &123536680 233 | AudioListener: 234 | m_ObjectHideFlags: 0 235 | m_CorrespondingSourceObject: {fileID: 0} 236 | m_PrefabInstance: {fileID: 0} 237 | m_PrefabAsset: {fileID: 0} 238 | m_GameObject: {fileID: 123536679} 239 | m_Enabled: 1 240 | --- !u!20 &123536681 241 | Camera: 242 | m_ObjectHideFlags: 0 243 | m_CorrespondingSourceObject: {fileID: 0} 244 | m_PrefabInstance: {fileID: 0} 245 | m_PrefabAsset: {fileID: 0} 246 | m_GameObject: {fileID: 123536679} 247 | m_Enabled: 1 248 | serializedVersion: 2 249 | m_ClearFlags: 1 250 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 251 | m_projectionMatrixMode: 1 252 | m_GateFitMode: 2 253 | m_FOVAxisMode: 0 254 | m_SensorSize: {x: 36, y: 24} 255 | m_LensShift: {x: 0, y: 0} 256 | m_FocalLength: 50 257 | m_NormalizedViewPortRect: 258 | serializedVersion: 2 259 | x: 0 260 | y: 0 261 | width: 1 262 | height: 1 263 | near clip plane: 0.3 264 | far clip plane: 1000 265 | field of view: 60 266 | orthographic: 1 267 | orthographic size: 5 268 | m_Depth: -1 269 | m_CullingMask: 270 | serializedVersion: 2 271 | m_Bits: 4294967295 272 | m_RenderingPath: -1 273 | m_TargetTexture: {fileID: 0} 274 | m_TargetDisplay: 0 275 | m_TargetEye: 3 276 | m_HDR: 1 277 | m_AllowMSAA: 1 278 | m_AllowDynamicResolution: 0 279 | m_ForceIntoRT: 0 280 | m_OcclusionCulling: 1 281 | m_StereoConvergence: 10 282 | m_StereoSeparation: 0.022 283 | --- !u!4 &123536682 284 | Transform: 285 | m_ObjectHideFlags: 0 286 | m_CorrespondingSourceObject: {fileID: 0} 287 | m_PrefabInstance: {fileID: 0} 288 | m_PrefabAsset: {fileID: 0} 289 | m_GameObject: {fileID: 123536679} 290 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 291 | m_LocalPosition: {x: 0, y: 0, z: -10} 292 | m_LocalScale: {x: 1, y: 1, z: 1} 293 | m_Children: [] 294 | m_Father: {fileID: 0} 295 | m_RootOrder: 0 296 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 297 | --- !u!1 &1253871085 298 | GameObject: 299 | m_ObjectHideFlags: 0 300 | m_CorrespondingSourceObject: {fileID: 0} 301 | m_PrefabInstance: {fileID: 0} 302 | m_PrefabAsset: {fileID: 0} 303 | serializedVersion: 6 304 | m_Component: 305 | - component: {fileID: 1253871086} 306 | - component: {fileID: 1253871089} 307 | - component: {fileID: 1253871088} 308 | - component: {fileID: 1253871087} 309 | - component: {fileID: 1253871090} 310 | m_Layer: 0 311 | m_Name: Canvas 312 | m_TagString: Untagged 313 | m_Icon: {fileID: 0} 314 | m_NavMeshLayer: 0 315 | m_StaticEditorFlags: 0 316 | m_IsActive: 1 317 | --- !u!224 &1253871086 318 | RectTransform: 319 | m_ObjectHideFlags: 0 320 | m_CorrespondingSourceObject: {fileID: 0} 321 | m_PrefabInstance: {fileID: 0} 322 | m_PrefabAsset: {fileID: 0} 323 | m_GameObject: {fileID: 1253871085} 324 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 325 | m_LocalPosition: {x: 0, y: 0, z: 5121.5} 326 | m_LocalScale: {x: 0.0295858, y: 0.0295858, z: 0.0295858} 327 | m_Children: [] 328 | m_Father: {fileID: 23841967} 329 | m_RootOrder: 0 330 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 331 | m_AnchorMin: {x: 0, y: 0} 332 | m_AnchorMax: {x: 0, y: 0} 333 | m_AnchoredPosition: {x: 166.95186, y: -85.481} 334 | m_SizeDelta: {x: 868.99994, y: 0} 335 | m_Pivot: {x: 0.5, y: 0.5} 336 | --- !u!114 &1253871087 337 | MonoBehaviour: 338 | m_ObjectHideFlags: 0 339 | m_CorrespondingSourceObject: {fileID: 0} 340 | m_PrefabInstance: {fileID: 0} 341 | m_PrefabAsset: {fileID: 0} 342 | m_GameObject: {fileID: 1253871085} 343 | m_Enabled: 0 344 | m_EditorHideFlags: 0 345 | m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} 346 | m_Name: 347 | m_EditorClassIdentifier: 348 | m_IgnoreReversedGraphics: 1 349 | m_BlockingObjects: 0 350 | m_BlockingMask: 351 | serializedVersion: 2 352 | m_Bits: 4294967295 353 | --- !u!114 &1253871088 354 | MonoBehaviour: 355 | m_ObjectHideFlags: 0 356 | m_CorrespondingSourceObject: {fileID: 0} 357 | m_PrefabInstance: {fileID: 0} 358 | m_PrefabAsset: {fileID: 0} 359 | m_GameObject: {fileID: 1253871085} 360 | m_Enabled: 1 361 | m_EditorHideFlags: 0 362 | m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} 363 | m_Name: 364 | m_EditorClassIdentifier: 365 | m_UiScaleMode: 0 366 | m_ReferencePixelsPerUnit: 100 367 | m_ScaleFactor: 1 368 | m_ReferenceResolution: {x: 800, y: 600} 369 | m_ScreenMatchMode: 0 370 | m_MatchWidthOrHeight: 0 371 | m_PhysicalUnit: 3 372 | m_FallbackScreenDPI: 96 373 | m_DefaultSpriteDPI: 96 374 | m_DynamicPixelsPerUnit: 1 375 | --- !u!223 &1253871089 376 | Canvas: 377 | m_ObjectHideFlags: 0 378 | m_CorrespondingSourceObject: {fileID: 0} 379 | m_PrefabInstance: {fileID: 0} 380 | m_PrefabAsset: {fileID: 0} 381 | m_GameObject: {fileID: 1253871085} 382 | m_Enabled: 1 383 | serializedVersion: 3 384 | m_RenderMode: 1 385 | m_Camera: {fileID: 123536681} 386 | m_PlaneDistance: 100 387 | m_PixelPerfect: 0 388 | m_ReceivesEvents: 1 389 | m_OverrideSorting: 0 390 | m_OverridePixelPerfect: 0 391 | m_SortingBucketNormalizedSize: 0 392 | m_AdditionalShaderChannelsFlag: 0 393 | m_SortingLayerID: 0 394 | m_SortingOrder: 0 395 | m_TargetDisplay: 1 396 | --- !u!114 &1253871090 397 | MonoBehaviour: 398 | m_ObjectHideFlags: 0 399 | m_CorrespondingSourceObject: {fileID: 0} 400 | m_PrefabInstance: {fileID: 0} 401 | m_PrefabAsset: {fileID: 0} 402 | m_GameObject: {fileID: 1253871085} 403 | m_Enabled: 1 404 | m_EditorHideFlags: 0 405 | m_Script: {fileID: 11500000, guid: 86710e43de46f6f4bac7c8e50813a599, type: 3} 406 | m_Name: 407 | m_EditorClassIdentifier: 408 | m_AspectMode: 1 409 | m_AspectRatio: 2 410 | --- !u!1 &1347277838 411 | GameObject: 412 | m_ObjectHideFlags: 0 413 | m_CorrespondingSourceObject: {fileID: 0} 414 | m_PrefabInstance: {fileID: 0} 415 | m_PrefabAsset: {fileID: 0} 416 | serializedVersion: 6 417 | m_Component: 418 | - component: {fileID: 1347277841} 419 | - component: {fileID: 1347277840} 420 | - component: {fileID: 1347277839} 421 | m_Layer: 0 422 | m_Name: EventSystem 423 | m_TagString: Untagged 424 | m_Icon: {fileID: 0} 425 | m_NavMeshLayer: 0 426 | m_StaticEditorFlags: 0 427 | m_IsActive: 1 428 | --- !u!114 &1347277839 429 | MonoBehaviour: 430 | m_ObjectHideFlags: 0 431 | m_CorrespondingSourceObject: {fileID: 0} 432 | m_PrefabInstance: {fileID: 0} 433 | m_PrefabAsset: {fileID: 0} 434 | m_GameObject: {fileID: 1347277838} 435 | m_Enabled: 1 436 | m_EditorHideFlags: 0 437 | m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} 438 | m_Name: 439 | m_EditorClassIdentifier: 440 | m_HorizontalAxis: Horizontal 441 | m_VerticalAxis: Vertical 442 | m_SubmitButton: Submit 443 | m_CancelButton: Cancel 444 | m_InputActionsPerSecond: 10 445 | m_RepeatDelay: 0.5 446 | m_ForceModuleActive: 0 447 | --- !u!114 &1347277840 448 | MonoBehaviour: 449 | m_ObjectHideFlags: 0 450 | m_CorrespondingSourceObject: {fileID: 0} 451 | m_PrefabInstance: {fileID: 0} 452 | m_PrefabAsset: {fileID: 0} 453 | m_GameObject: {fileID: 1347277838} 454 | m_Enabled: 1 455 | m_EditorHideFlags: 0 456 | m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} 457 | m_Name: 458 | m_EditorClassIdentifier: 459 | m_FirstSelected: {fileID: 0} 460 | m_sendNavigationEvents: 1 461 | m_DragThreshold: 10 462 | --- !u!4 &1347277841 463 | Transform: 464 | m_ObjectHideFlags: 0 465 | m_CorrespondingSourceObject: {fileID: 0} 466 | m_PrefabInstance: {fileID: 0} 467 | m_PrefabAsset: {fileID: 0} 468 | m_GameObject: {fileID: 1347277838} 469 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 470 | m_LocalPosition: {x: 0, y: 0, z: 0} 471 | m_LocalScale: {x: 1, y: 1, z: 1} 472 | m_Children: [] 473 | m_Father: {fileID: 0} 474 | m_RootOrder: 2 475 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 476 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scenes/Simple YouTube Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c011c8dd3f2b4074ab93b5001658339 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7ae410da350a814581baa2a6ce81e85 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/Adler32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ZLIB 4 | { 5 | public class Adler32 6 | { 7 | #region "Variables globales" 8 | private UInt32 a = 1; 9 | private UInt32 b = 0; 10 | private const int _base = 65521; 11 | private const int _nmax = 5550; 12 | private int pend = 0; 13 | #endregion 14 | #region "Metodos publicos" 15 | public void Update(byte data) 16 | { 17 | if (pend >= _nmax) updateModulus(); 18 | a += data; 19 | b += a; 20 | pend++; 21 | } 22 | public void Update(byte[] data) 23 | { 24 | Update(data, 0, data.Length); 25 | } 26 | public void Update(byte[] data, int offset, int length) 27 | { 28 | int nextJToComputeModulus = _nmax - pend; 29 | for (int j = 0; j < length; j++) { 30 | if (j == nextJToComputeModulus) { 31 | updateModulus(); 32 | nextJToComputeModulus = j + _nmax; 33 | } 34 | unchecked { 35 | a += data[j + offset]; 36 | } 37 | b += a; 38 | pend++; 39 | } 40 | } 41 | public void Reset() 42 | { 43 | a = 1; 44 | b = 0; 45 | pend = 0; 46 | } 47 | private void updateModulus() 48 | { 49 | a %= _base; 50 | b %= _base; 51 | pend = 0; 52 | } 53 | public UInt32 GetValue() 54 | { 55 | if (pend > 0) updateModulus(); 56 | return (b << 16) | a; 57 | } 58 | #endregion 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/Adler32.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e226a8c13e3a94b7ab35683f2ce23004 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/FastLEDInterop.cs: -------------------------------------------------------------------------------- 1 | //+-------------------------------------------------------------------------- 2 | // 3 | // File: FastLEDInterop.h 4 | // 5 | // NightDriverUnity - (c) 2021 Plummer's Software LLC. All Rights Reserved. 6 | // 7 | // This file is part of the NightDriver software project. 8 | // 9 | // NightDriver is free software: you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License as published by 11 | // the Free Software Foundation, either version 3 of the License, or 12 | // (at your option) any later version. 13 | // 14 | // NightDriver is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | // GNU General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with Nightdriver. It is normally found in copying.txt 21 | // If not, see . 22 | // 23 | // Description: 24 | // 25 | // Scripts to allow Unity to display vides on LED strip arrays. This 26 | // file provides LEDInterop such as compression, converting bytestream 27 | // to and from long integral values, etc. Utilities, basically, to make 28 | // it easier to manage color streams created by FastLED. 29 | // 30 | // History: Oct-10-2021 Davepl Created from NightDriverServer 31 | //--------------------------------------------------------------------------- 32 | 33 | using System; 34 | using System.IO; 35 | using ZLIB; 36 | using System.Linq; 37 | using System.Collections.Generic; 38 | using System.Collections.Concurrent; 39 | 40 | namespace NightDriver 41 | { 42 | public static class QueueExtensions 43 | { 44 | public static IEnumerable DequeueChunk(this ConcurrentQueue queue, int chunkSize) 45 | { 46 | for (int i = 0; i < chunkSize && queue.Count > 0; i++) 47 | { 48 | T result; 49 | if (false == queue.TryDequeue(out result)) 50 | throw new Exception("Unable to Dequeue the data!"); 51 | yield return result; 52 | } 53 | } 54 | } 55 | 56 | // LEDInterop 57 | // 58 | // Functions fdor working directly with the color data in an LED string 59 | 60 | public static class LEDInterop 61 | { 62 | // scale8 - Given a value i, scales it down by scale/256th 63 | 64 | public static byte scale8(byte i, byte scale) 65 | { 66 | return (byte)(((ushort)i * (ushort)(scale)) >> 8); 67 | } 68 | 69 | public static byte scale8_video(byte i, byte scale) 70 | { 71 | byte j = (byte)((((int)i * (int)scale) >> 8) + ((i != 0 && scale != 0) ? 1 : 0)); 72 | return j; 73 | } 74 | 75 | // fill_solid - fills a rnage of LEDs with a given color value 76 | 77 | public static void fill_solid(CRGB[] leds, CRGB color) 78 | { 79 | for (int i = 0; i < leds.Length; i++) 80 | leds[i] = color; 81 | } 82 | 83 | // fill_rainbow - fills a range of LEDs rotating through a hue wheel 84 | 85 | public static void fill_rainbow(CRGB[] leds, byte initialHue, float deltaHue) 86 | { 87 | float hue = initialHue; 88 | for (int i = 0; i < leds.Length; i++, hue += deltaHue) 89 | leds[i].HSV2RGB((byte)hue, 255, 255); 90 | } 91 | 92 | // GetColorBytes - get the color data as a packaged up array of bytes 93 | 94 | public static byte[] GetColorBytes(CRGB[] leds) 95 | { 96 | byte[] data = new byte[leds.Length * 3]; 97 | for (int i = 0; i < leds.Length; i++) 98 | { 99 | data[i * 3] = leds[i].r; 100 | data[i * 3 + 1] = leds[i].g; 101 | data[i * 3 + 2] = leds[i].b; 102 | } 103 | return data; 104 | } 105 | 106 | public static byte[] ULONGToBytes(UInt64 input) 107 | { 108 | return new byte[] 109 | { 110 | (byte)((input ) & 0xff), 111 | (byte)((input >> 8) & 0xff), 112 | (byte)((input >> 16) & 0xff), 113 | (byte)((input >> 24) & 0xff), 114 | (byte)((input >> 32) & 0xff), 115 | (byte)((input >> 40) & 0xff), 116 | (byte)((input >> 48) & 0xff), 117 | (byte)((input >> 56) & 0xff), 118 | }; 119 | } 120 | 121 | // DWORD and WORD to Bytes - Flatten 16 and 32 bit values to memory 122 | 123 | public static byte[] DWORDToBytes(UInt32 input) 124 | { 125 | return new byte[] 126 | { 127 | (byte)((input ) & 0xff), 128 | (byte)((input >> 8) & 0xff), 129 | (byte)((input >> 16) & 0xff), 130 | (byte)((input >> 24) & 0xff), 131 | }; 132 | } 133 | 134 | public static byte[] WORDToBytes(UInt16 input) 135 | { 136 | return new byte[] 137 | { 138 | (byte)((input ) & 0xff), 139 | (byte)((input >> 8) & 0xff), 140 | }; 141 | } 142 | 143 | // CombineByteArrays - Combine N arrays and returns them as one new big new one 144 | 145 | public static byte[] CombineByteArrays(params byte[][] arrays) 146 | { 147 | byte[] rv = new byte[arrays.Sum(a => a.Length)]; 148 | int offset = 0; 149 | foreach (byte[] array in arrays) 150 | { 151 | System.Buffer.BlockCopy(array, 0, rv, offset, array.Length); 152 | offset += array.Length; 153 | } 154 | return rv; 155 | } 156 | 157 | // CompressMemory 158 | // 159 | // Compress a buffer using ZLIB, return the compressed version of it as a ZLIB stream 160 | 161 | public static byte[] Compress(byte[] data) 162 | { 163 | using (var compressedStream = new MemoryStream()) 164 | using (var zipStream = new ZLIBStream(compressedStream, System.IO.Compression.CompressionLevel.Optimal)) 165 | { 166 | zipStream.Write(data, 0, data.Length); 167 | zipStream.Close(); 168 | return compressedStream.ToArray(); 169 | } 170 | } 171 | 172 | // DecompressMemory 173 | // 174 | // Expands a buffer using ZLib, returns the uncompressed version of it 175 | 176 | public static byte[] Decompress(byte[] input) 177 | { 178 | using (var inStream = new MemoryStream(input)) 179 | using (var bigStream = new ZLIBStream(inStream, System.IO.Compression.CompressionMode.Decompress)) 180 | using (var bigStreamOut = new MemoryStream()) 181 | { 182 | bigStream.CopyTo(bigStreamOut); 183 | return bigStreamOut.ToArray(); 184 | } 185 | } 186 | } 187 | } 188 | 189 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/FastLEDInterop.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4cbf7191494e240ba907342000f938f3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/Graphics.cs: -------------------------------------------------------------------------------- 1 | //+-------------------------------------------------------------------------- 2 | // 3 | // File: FastLEDInterop.h 4 | // 5 | // NightDriverUnity - (c) 2021 Plummer's Software LLC. All Rights Reserved. 6 | // 7 | // This file is part of the NightDriver software project. 8 | // 9 | // NightDriver is free software: you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License as published by 11 | // the Free Software Foundation, either version 3 of the License, or 12 | // (at your option) any later version. 13 | // 14 | // NightDriver is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | // GNU General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with Nightdriver. It is normally found in copying.txt 21 | // If not, see . 22 | // 23 | // Description: 24 | // 25 | // FastLED Interop. Provides some of the basics of the Arduino 26 | // project known as FastLED by bringing it into C# so that the 27 | // Unity code can more easily interact with FastLED colors streams. 28 | // 29 | // History: Oct-10-2021 Davepl Created from NightDriverServer 30 | //--------------------------------------------------------------------------- 31 | 32 | 33 | using System; 34 | using uint16_t = System.UInt16; 35 | using int16_t = System.Int16; // Nice C# feature allowing to use same Arduino/C type 36 | using uint8_t = System.Byte; 37 | using System.Drawing; 38 | using UnityEngine; 39 | using System.Threading; 40 | using NightDriver; 41 | 42 | namespace NightDriver 43 | { 44 | // Utilities 45 | // 46 | // Helpers and extension methods of general use throughout 47 | 48 | public static class Utilities 49 | { 50 | public static float constrain(this float value, float inclusiveMinimum, float inclusiveMaximum) 51 | { 52 | if (value < inclusiveMinimum) { return inclusiveMinimum; } 53 | if (value > inclusiveMaximum) { return inclusiveMaximum; } 54 | return value; 55 | } 56 | 57 | public static byte RandomByte() 58 | { 59 | return (byte)UnityEngine.Random.Range(0, 256); 60 | } 61 | } 62 | 63 | // CRGB 64 | // 65 | // A class that represents 24 bits of color, no alpha. This class is similar to the CRGB class in FastLED 66 | 67 | public class CRGB 68 | { 69 | public byte r; 70 | public byte g; 71 | public byte b; 72 | 73 | public CRGB() 74 | { 75 | r = 0; 76 | g = 0; 77 | b = 0; 78 | } 79 | 80 | public CRGB(byte red, byte green, byte blue) 81 | { 82 | r = red; 83 | g = green; 84 | b = blue; 85 | } 86 | 87 | public CRGB(UInt32 input) 88 | { 89 | r = (byte)((input >> 16) & 0xFF); 90 | g = (byte)((input >> 8) & 0xFF); 91 | b = (byte)((input) & 0xFF); 92 | } 93 | 94 | public CRGB(CRGB other) 95 | { 96 | r = other.r; 97 | g = other.g; 98 | b = other.b; 99 | } 100 | 101 | public static CRGB RandomSaturatedColor 102 | { 103 | get 104 | { 105 | CRGB c = new CRGB(); 106 | c.HSV2RGB((byte)UnityEngine.Random.Range(0, 256), 255, 255); 107 | return c; 108 | } 109 | 110 | } 111 | 112 | public CRGB Blend(CRGB with, float ratio = 0.5f) 113 | { 114 | Color32 c1 = new Color32(this.r, this.g, this.b, 255); 115 | Color32 c2 = new Color32(with.r, with.g, with.b, 255); 116 | Color32 c3 = Color32.Lerp(c1, c2, ratio); 117 | return new CRGB(c3.r, c3.g, c3.b); 118 | } 119 | 120 | public static CRGB Black { get { return new CRGB(0,0,0); } } 121 | public static CRGB White { get { return new CRGB(255,255,255); } } 122 | public static CRGB Grey { get { return new CRGB(160,160,160); } } 123 | 124 | public static CRGB Red { get { return new CRGB(255, 0, 0); } } 125 | public static CRGB Maroon { get { return new CRGB(255, 0, 128); } } 126 | public static CRGB Blue { get { return new CRGB(0, 0, 255); } } 127 | public static CRGB Cyan { get { return new CRGB(0, 255, 255); } } 128 | public static CRGB Green { get { return new CRGB(0, 255, 0); } } 129 | public static CRGB Yellow { get { return new CRGB(255, 255, 0); } } 130 | public static CRGB Purple { get { return new CRGB(255, 0, 255); } } 131 | public static CRGB Pink { get { return new CRGB(255, 0, 128); } } 132 | public static CRGB Orange { get { return new CRGB(255, 128, 0); } } 133 | 134 | public UInt32 ColorValueAsInt() 135 | { 136 | return (uint)(r << 16) + (uint)(g << 8) + (uint)b; 137 | } 138 | 139 | public CRGB setRGB(byte red, byte green, byte blue) 140 | { 141 | r = red; 142 | g = green; 143 | b = blue; 144 | return this; 145 | } 146 | 147 | public CRGB HSV2RGB(double h, double s = 1.0, double v = 1.0) 148 | { 149 | h %= 360; 150 | 151 | double hh, p, q, t, ff; 152 | long i; 153 | CRGB outval = new CRGB(); 154 | 155 | if (s <= 0.0) // No saturaturation, return a greyscale 156 | { 157 | outval.r = (byte)(v * 255); 158 | outval.g = (byte)(v * 255); 159 | outval.b = (byte)(v * 255); 160 | return outval; 161 | } 162 | 163 | hh = h; 164 | if (hh >= 360.0) 165 | hh = 0.0; 166 | hh /= 60.0; 167 | i = (long)hh; 168 | ff = hh - i; 169 | p = v * (1.0 - s); 170 | q = v * (1.0 - (s * ff)); 171 | t = v * (1.0 - (s * (1.0 - ff))); 172 | 173 | switch (i) 174 | { 175 | case 0: 176 | outval.r = (byte)(255 * v); 177 | outval.g = (byte)(255 * t); 178 | outval.b = (byte)(255 * p); 179 | break; 180 | 181 | case 1: 182 | outval.r = (byte)(255 * q); 183 | outval.g = (byte)(255 * v); 184 | outval.b = (byte)(255 * p); 185 | break; 186 | 187 | case 2: 188 | outval.r = (byte)(255 * p); 189 | outval.g = (byte)(255 * v); 190 | outval.b = (byte)(255 * t); 191 | break; 192 | 193 | case 3: 194 | outval.r = (byte)(255 * p); 195 | outval.g = (byte)(255 * q); 196 | outval.b = (byte)(255 * v); 197 | break; 198 | 199 | case 4: 200 | outval.r = (byte)(255 * t); 201 | outval.g = (byte)(255 * p); 202 | outval.b = (byte)(255 * v); 203 | break; 204 | 205 | case 5: 206 | default: 207 | outval.r = (byte)(255 * v); 208 | outval.g = (byte)(255 * p); 209 | outval.b = (byte)(255 * q); 210 | break; 211 | } 212 | 213 | return outval; 214 | } 215 | 216 | public CRGB HSV2RGB(byte hue, byte sat = 255, byte val = 255) 217 | { 218 | #pragma warning disable CS0162 // Unreachable code detected 219 | const byte K255 = 255; 220 | const byte K171 = 171; 221 | const byte K170 = 170; 222 | const byte K85 = 85; 223 | 224 | // Yellow has a higher inherent brightness than 225 | // any other color; 'pure' yellow is perceived to 226 | // be 93% as bright as white. In order to make 227 | // yellow appear the correct relative brightness, 228 | // it has to be rendered brighter than all other 229 | // colors. 230 | // Level Y1 is a moderate boost, the default. 231 | // Level Y2 is a strong boost. 232 | 233 | const byte Y1 = 1; 234 | const byte Y2 = 0; 235 | 236 | // G2: Whether to divide all greens by two. 237 | // Depends GREATLY on your particular LEDs 238 | const byte G2 = 0; 239 | 240 | // Gscale: what to scale green down by. 241 | // Depends GREATLY on your particular LEDs 242 | const byte Gscale = 0; 243 | 244 | byte offset = (byte)(hue & 0x1F); // 0..31 245 | 246 | // offset8 = offset * 8 247 | byte offset8 = offset; 248 | offset8 <<= 3; 249 | 250 | byte third = LEDInterop.scale8(offset8, (256 / 3)); // max = 85 251 | 252 | if (0 == (hue & 0x80)) 253 | { 254 | // 0XX 255 | if (0 == (hue & 0x40)) 256 | { 257 | // 00X 258 | //section 0-1 259 | if (0 == (hue & 0x20)) 260 | { 261 | // 000 262 | //case 0: // R -> O 263 | r = (byte)(K255 - third); 264 | g = third; 265 | b = 0; 266 | } 267 | else 268 | { 269 | // 001 270 | //case 1: // O -> Y 271 | if (0 != Y1) 272 | { 273 | r = K171; 274 | g = (byte)(K85 + third); 275 | b = 0; 276 | } 277 | if (0 != Y2) 278 | { 279 | r = (byte)(K170 + third); 280 | //byte twothirds = (third << 1); 281 | byte twothirds = LEDInterop.scale8(offset8, ((256 * 2) / 3)); // max=170 282 | g = (byte)(K85 + twothirds); 283 | b = 0; 284 | } 285 | } 286 | } 287 | else 288 | { 289 | //01X 290 | // section 2-3 291 | if (0 == (hue & 0x20)) 292 | { 293 | // 010 294 | //case 2: // Y -> G 295 | if (0 != Y1) 296 | { 297 | //byte twothirds = (third << 1); 298 | byte twothirds = LEDInterop.scale8(offset8, ((256 * 2) / 3)); // max=170 299 | r = (byte)(K171 - twothirds); 300 | g = (byte)(K170 + third); 301 | b = 0; 302 | } 303 | if (0 != Y2) 304 | { 305 | r = (byte)(K255 - offset8); 306 | g = K255; 307 | b = 0; 308 | } 309 | } 310 | else 311 | { 312 | // 011 313 | // case 3: // G -> A 314 | r = 0; 315 | g = (byte)(K255 - third); 316 | b = third; 317 | } 318 | } 319 | } 320 | else 321 | { 322 | // section 4-7 323 | // 1XX 324 | if (0 == (hue & 0x40)) 325 | { 326 | // 10X 327 | if (0 == (hue & 0x20)) 328 | { 329 | // 100 330 | //case 4: // A -> B 331 | r = 0; 332 | //byte twothirds = (third << 1); 333 | byte twothirds = LEDInterop.scale8(offset8, ((256 * 2) / 3)); // max=170 334 | g = (byte)(K171 - twothirds); //K170? 335 | b = (byte)(K85 + twothirds); 336 | } 337 | else 338 | { 339 | // 101 340 | //case 5: // B -> P 341 | r = third; 342 | g = 0; 343 | b = (byte)(K255 - third); 344 | } 345 | } 346 | else 347 | { 348 | if (0 == (hue & 0x20)) 349 | { 350 | // 110 351 | //case 6: // P -- K 352 | r = (byte)(K85 + third); 353 | g = 0; 354 | b = (byte)(K171 - third); 355 | } 356 | else 357 | { 358 | // 111 359 | //case 7: // K -> R 360 | r = (byte)(K170 + third); 361 | g = 0; 362 | b = (byte)(K85 - third); 363 | } 364 | } 365 | } 366 | 367 | // Debug.Log("Midpoint -> r=" + r + ", g=" + g + ", b=" + b); 368 | 369 | // This is one of the good places to scale the green down, 370 | // although the client can scale green down as well. 371 | if (0 != G2) 372 | g = (byte)(g >> 1); 373 | if (0 != Gscale) 374 | g = LEDInterop.scale8_video(g, Gscale); 375 | 376 | // Scale down colors if we're desaturated at all 377 | // and add the brightness_floor to r, g, and b. 378 | if (sat != 255) 379 | { 380 | if (sat == 0) 381 | { 382 | r = 255; b = 255; g = 255; 383 | } 384 | else 385 | { 386 | //nscale8x3_video( r, g, b, sat); 387 | if (0 != r) 388 | r = (byte)(LEDInterop.scale8(r, sat) + 1); 389 | if (0 != g) 390 | g = (byte)(LEDInterop.scale8(g, sat) + 1); 391 | if (0 != b) 392 | b = (byte)(LEDInterop.scale8(b, sat) + 1); 393 | 394 | byte desat = (byte)(255 - sat); 395 | desat = LEDInterop.scale8(desat, desat); 396 | 397 | byte brightness_floor = desat; 398 | r += brightness_floor; 399 | g += brightness_floor; 400 | b += brightness_floor; 401 | } 402 | } 403 | 404 | // Now scale everything down if we're at value < 255. 405 | if (val != 255) 406 | { 407 | val = LEDInterop.scale8_video(val, val); 408 | if (val == 0) 409 | { 410 | r = 0; 411 | g = 0; 412 | b = 0; 413 | } 414 | else 415 | { 416 | // nscale8x3_video( r, g, b, val); 417 | if (0 != r) 418 | r = (byte)(LEDInterop.scale8(r, val) + 1); 419 | if (0 != g) 420 | g = (byte)(LEDInterop.scale8(g, val) + 1); 421 | if (0 != b) 422 | b = (byte)(LEDInterop.scale8(b, val) + 1); 423 | } 424 | } 425 | #pragma warning disable CS0162 // Unreachable code detected 426 | return this; 427 | } 428 | 429 | private CRGB scaleColorsDownTo(float amount) 430 | { 431 | r = (byte)(r * amount); 432 | g = (byte)(g * amount); 433 | b = (byte)(b * amount); 434 | return this; 435 | } 436 | 437 | public CRGB fadeToBlackBy(float amt) 438 | { 439 | CRGB copy = new CRGB(this); 440 | float amountToFade = Utilities.constrain(amt, 0.0f, 1.0f); 441 | copy.scaleColorsDownTo(1.0f - amountToFade); 442 | return copy; 443 | } 444 | 445 | public CRGB blendWith(CRGB other, float amount) 446 | { 447 | r = (byte)(r * amount + other.r * (1.0f - amount)); 448 | g = (byte)(g * amount + other.g * (1.0f - amount)); 449 | b = (byte)(b * amount + other.b * (1.0f - amount)); 450 | return this; 451 | } 452 | 453 | public static CRGB GetBlackbodyHeatColor(float temp) 454 | { 455 | temp = Math.Min(1.0f, temp); 456 | byte temperature = (byte)(255 * temp); 457 | byte t192 = (byte) Math.Round((temperature/255.0f) * 191); 458 | 459 | byte heatramp = (byte)(t192 & 0x3F); 460 | heatramp <<=2; 461 | 462 | if (t192 > 0x80) 463 | return new CRGB(255, 255, heatramp); 464 | else if (t192 > 0x40) 465 | return new CRGB(255, heatramp, 0); 466 | else 467 | return new CRGB(heatramp, 0, 0); 468 | } 469 | 470 | } 471 | 472 | public interface ILEDGraphics 473 | { 474 | void DrawCircleHelper(uint x0, uint y0, uint r, uint cornername, CRGB color); 475 | void DrawCircle(uint x0, uint y0, uint r, bool color); 476 | void DrawCircle(uint x0, uint y0, uint r, CRGB color); 477 | void DrawRect(uint x, uint y, uint w, uint h, bool color); 478 | void DrawRect(uint x, uint y, uint w, uint h, CRGB color); 479 | void DrawFastVLine(uint x, uint y, uint h, CRGB color); 480 | void DrawFastHLine(uint x, uint y, uint w, CRGB color); 481 | void DrawRoundRect(uint x, uint y, uint w, uint h, uint r, CRGB color); 482 | void DrawLine(uint x0, uint y0, uint x1, uint y1, bool color); 483 | void DrawLine(uint x0, uint y0, uint x1, uint y1, CRGB color); 484 | void FillSolid(CRGB color); 485 | void FillRainbow(float startHue = 0.0f, float deltaHue = 5.0f); 486 | 487 | /* These are here for integration with the DotMatrix component 488 | void DrawText(string text, 489 | TextCommand.Fonts font, 490 | CRGB color, 491 | float startX, 492 | float startY, 493 | bool bBold = false, 494 | TextAlignment alignment = TextAlignment.Left, 495 | bool bClear = false); 496 | void DrawText(string text, 497 | TextCommand.Fonts font, 498 | CRGB color, 499 | int startX, 500 | int startY, 501 | bool bBold = false, 502 | TextAlignment alignment = TextAlignment.Left, 503 | bool bClear = false); 504 | void DrawTextShadow(string text, 505 | TextCommand.Fonts font, 506 | CRGB color, 507 | uint x, 508 | uint y, 509 | bool bBold = false, 510 | TextAlignment alignment = TextAlignment.Left); 511 | */ 512 | 513 | void DrawPixel(uint x, uint y, CRGB color); 514 | void DrawPixels(float fPos, uint count, CRGB color); 515 | void DrawPixel(uint x, CRGB color); 516 | void BlendPixel(uint x, CRGB color); 517 | uint DotCount { get; } 518 | uint Width { get; } 519 | uint Height { get; } 520 | }; 521 | 522 | 523 | 524 | abstract public class GraphicsBase : MonoBehaviour, ILEDGraphics 525 | { 526 | public virtual void Awake() 527 | { 528 | } 529 | 530 | private static bool IsSet(byte b, int pos) 531 | { 532 | return (b & (1 << pos)) != 0; 533 | } 534 | 535 | public virtual uint DotCount 536 | { 537 | get { return Width * Height ;} 538 | } 539 | 540 | protected int16_t abs(int v) 541 | { 542 | return (int16_t)System.Math.Abs(v); 543 | } 544 | 545 | protected int16_t abs(int16_t v) 546 | { 547 | return System.Math.Abs(v); 548 | } 549 | 550 | protected void Swap(ref uint v1, ref uint v2) 551 | { 552 | uint v = v1; 553 | v1 = v2; 554 | v2 = v; 555 | } 556 | 557 | public void DrawCircleHelper(uint x0, uint y0, uint r, uint cornername, CRGB color) 558 | { 559 | int16_t f = (int16_t)(1 - r); 560 | int16_t ddF_x = 1; 561 | int16_t ddF_y = (int16_t)(-2 * r); 562 | int16_t x = 0; 563 | int16_t y = (int16_t) r; 564 | 565 | while (x < y) 566 | { 567 | if (f >= 0) 568 | { 569 | y--; 570 | ddF_y += 2; 571 | f += ddF_y; 572 | } 573 | x++; 574 | ddF_x += 2; 575 | f += ddF_x; 576 | if (IsSet((byte)cornername, 0x4)) 577 | { 578 | 579 | DrawPixel((uint)(x0 + x), (uint)(y0 + y), color); 580 | DrawPixel((uint)(x0 + y), (uint)(y0 + x), color); 581 | } 582 | if (IsSet((byte)cornername, 0x2)) 583 | { 584 | DrawPixel((uint)(x0 + x), (uint)(y0 - y), color); 585 | DrawPixel((uint)(x0 + y), (uint)(y0 - x), color); 586 | } 587 | if (IsSet((byte)cornername, 0x8)) 588 | { 589 | DrawPixel((uint)(x0 - y), (uint)(y0 + x), color); 590 | DrawPixel((uint)(x0 - x), (uint)(y0 + y), color); 591 | } 592 | if (IsSet((byte)cornername, 0x1)) 593 | { 594 | DrawPixel((uint)(x0 - y), (uint)(y0 - x), color); 595 | DrawPixel((uint)(x0 - x), (uint)(y0 - y), color); 596 | } 597 | } 598 | } 599 | 600 | public void DrawCircle(uint x0, uint y0, uint r, bool b) 601 | { 602 | DrawCircle(x0, y0, r, b ? CRGB.Green : CRGB.Black); 603 | } 604 | 605 | // Draw a circle outline 606 | public void DrawCircle(uint x0, uint y0, uint r, CRGB color) 607 | { 608 | int16_t f = (int16_t)(1 - r); 609 | int16_t ddF_x = 1; 610 | int16_t ddF_y = (int16_t)(-2 * r); 611 | int16_t x = 0; 612 | int16_t y = (int16_t) r; 613 | 614 | DrawPixel(x0, (y0 + r), color); 615 | DrawPixel(x0, (y0 - r), color); 616 | DrawPixel((x0 + r), y0, color); 617 | DrawPixel((x0 - r), y0, color); 618 | 619 | while (x < y) 620 | { 621 | if (f >= 0) 622 | { 623 | y--; 624 | ddF_y += 2; 625 | f += ddF_y; 626 | } 627 | x++; 628 | ddF_x += 2; 629 | f += ddF_x; 630 | 631 | DrawPixel((uint)(x0 + x), (uint)(y0 + y), color); 632 | DrawPixel((uint)(x0 - x), (uint)(y0 + y), color); 633 | DrawPixel((uint)(x0 + x), (uint)(y0 - y), color); 634 | DrawPixel((uint)(x0 - x), (uint)(y0 - y), color); 635 | DrawPixel((uint)(x0 + y), (uint)(y0 + x), color); 636 | DrawPixel((uint)(x0 - y), (uint)(y0 + x), color); 637 | DrawPixel((uint)(x0 + y), (uint)(y0 - x), color); 638 | DrawPixel((uint)(x0 - y), (uint)(y0 - x), color); 639 | } 640 | } 641 | 642 | public void DrawRect(uint x, uint y, uint w, uint h, CRGB color) 643 | { 644 | DrawFastHLine(x, y, w, color); 645 | DrawFastHLine(x, (y + h - 1), w, color); 646 | DrawFastVLine(x, y, h, color); 647 | DrawFastVLine((x + w - 1), y, h, color); 648 | } 649 | 650 | public void DrawRect(uint x, uint y, uint w, uint h, bool b) 651 | { 652 | DrawRect(x, y, w, h, b ? CRGB.Green : CRGB.Black); 653 | } 654 | 655 | public void DrawFastVLine(uint x, uint y, uint h, CRGB color) 656 | { 657 | DrawLine(x, y, x, (y + h - 1), color); 658 | } 659 | 660 | public void DrawFastHLine(uint x, uint y, uint w, CRGB color) 661 | { 662 | // Update in subclasses if desired! 663 | DrawLine(x, y, (x + w - 1), y, color); 664 | } 665 | public void DrawRoundRect(uint x, uint y, uint w, uint h, uint r, CRGB color) 666 | { 667 | // smarter version 668 | DrawFastHLine(x + r, y, w - 2 * r, color); // Top 669 | DrawFastHLine(x + r, y + h - 1, w - 2 * r, color); // Bottom 670 | DrawFastVLine(x, y + r, h - 2 * r, color); // Left 671 | DrawFastVLine(x + w - 1, y + r, h - 2 * r, color); // Right 672 | // draw four corners 673 | DrawCircleHelper(x + r, y + r, r, 1, color); 674 | DrawCircleHelper(x + w - r - 1, y + r, r, 2, color); 675 | DrawCircleHelper(x + w - r - 1, y + h - r - 1, r, 4, color); 676 | DrawCircleHelper(x + r, y + h - r - 1, r, 8, color); 677 | } 678 | 679 | public void DrawLine(uint x0, uint y0, uint x1, uint y1, bool color) 680 | { 681 | this.DrawLine(x0, y0, x1, y1, (CRGB)(color ? new CRGB(0xFFFFFF) : new CRGB(0x000000))); 682 | } 683 | 684 | // Bresenham's algorithm - thx wikpedia 685 | public void DrawLine(uint x0, uint y0, uint x1, uint y1, CRGB color) 686 | { 687 | bool steep = abs((int)y1 - (int)y0) > abs((int)x1 - (int)x0); 688 | if (steep) 689 | { 690 | Swap(ref x0, ref y0); 691 | Swap(ref x1, ref y1); 692 | } 693 | 694 | if (x0 > x1) 695 | { 696 | Swap(ref x0, ref x1); 697 | Swap(ref y0, ref y1); 698 | } 699 | 700 | int16_t dx, dy; 701 | dx = (int16_t)(x1 - x0); 702 | dy = (int16_t)(abs((int)y1 - (int)y0)); 703 | 704 | int16_t err = (int16_t)(dx / 2); 705 | int16_t ystep; 706 | 707 | if (y0 < y1) 708 | { 709 | ystep = 1; 710 | } 711 | else 712 | { 713 | ystep = -1; 714 | } 715 | 716 | for (; x0 <= x1; x0++) 717 | { 718 | if (steep) 719 | { 720 | DrawPixel(y0, x0, color); 721 | } 722 | else 723 | { 724 | DrawPixel(x0, y0, color); 725 | } 726 | err -= dy; 727 | if (err < 0) 728 | { 729 | y0 += (uint) ystep; 730 | err += dx; 731 | } 732 | } 733 | } 734 | 735 | public void FillSolid(CRGB color) 736 | { 737 | for (uint x = 0; x < Width; x++) 738 | for (uint y = 0; y < Height; y++) 739 | DrawPixel(x, y, color); 740 | } 741 | 742 | public void FillRainbow(float startHue = 0.0f, float deltaHue = 5.0f) 743 | { 744 | float hue = startHue; 745 | for (uint y = 0; y < Height; y++) 746 | { 747 | for (uint x = 0; x < Width; x++) 748 | { 749 | CRGB color = new CRGB(); 750 | color.HSV2RGB((byte)hue); 751 | DrawPixel(x, y, color); 752 | hue += deltaHue; 753 | } 754 | } 755 | } 756 | 757 | /* 758 | public void DrawText(string text, 759 | TextCommand.Fonts font, 760 | CRGB color, 761 | float startX, 762 | float startY, 763 | bool bBold = false, 764 | TextAlignment alignment = TextAlignment.Left, 765 | bool bClear = false) 766 | { 767 | DrawText(text, font, color, (startX * Width), (startY * Height), bBold, alignment, bClear); 768 | } 769 | 770 | public void DrawText(string text, 771 | TextCommand.Fonts font, 772 | CRGB color, 773 | int startX, 774 | int startY, 775 | bool bBold = false, 776 | TextAlignment alignment = TextAlignment.Left, 777 | bool bClear = false) 778 | { 779 | int[,] textContent = TextToCont 780 | ent.getContent(text, font, true, bBold, 1); 781 | int height = textContent.GetLength(0); 782 | int width = textContent.GetLength(1); 783 | 784 | if (alignment == TextAlignment.Left) 785 | startX += 0; 786 | else if (alignment == TextAlignment.Center) 787 | startX -= width / 2; 788 | else if (alignment == TextAlignment.Right) 789 | startX -= width; 790 | 791 | 792 | for (uint y = 0; y < Height; y++) 793 | { 794 | for (uint x = 0; x < Width; x++) 795 | { 796 | if (x >= startX && x < startX + width && y >= startY && y < startY + height) 797 | { 798 | var content = textContent[y - startY, x - startX]; 799 | if (content != 0) 800 | DrawPixel(x, y, color); 801 | else if (bClear) 802 | DrawPixel(x, y, CRGB.Black); 803 | } 804 | } 805 | } 806 | } 807 | 808 | public void DrawTextShadow(string text, 809 | TextCommand.Fonts font, 810 | CRGB color, 811 | uint x, 812 | uint y, 813 | bool bBold = false, 814 | TextAlignment alignment = TextAlignment.Left) 815 | { 816 | DrawText(text, font, color, x - 1, y - 1, bBold, TextAlignment.Center); 817 | DrawText(text, font, color, x + 1, y + 1, bBold, TextAlignment.Center); 818 | DrawText(text, font, color, x - 1, y + 1, bBold, TextAlignment.Center); 819 | DrawText(text, font, color, x + 1, y - 1, bBold, TextAlignment.Center); 820 | } 821 | */ 822 | 823 | // Your implementation class must provide these, the actual writing of pixels 824 | 825 | public abstract void DrawPixel(uint x, uint y, CRGB color); 826 | public abstract void DrawPixels(float fPos, uint count, CRGB color); 827 | public abstract void DrawPixel(uint x, CRGB color); 828 | public abstract void BlendPixel(uint x, CRGB color); 829 | 830 | public abstract uint Width 831 | { 832 | get; 833 | } 834 | 835 | public abstract uint Height 836 | { 837 | get; 838 | } 839 | 840 | public abstract uint LEDCount 841 | { 842 | get; 843 | } 844 | 845 | } 846 | } -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/Graphics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8ef0fe282b0443bbb71883535bda42d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/LEDControllerChannel.cs: -------------------------------------------------------------------------------- 1 | //+-------------------------------------------------------------------------- 2 | // 3 | // NightDriver.Net - (c) 2019 Dave Plummer. All Rights Reserved. 4 | // 5 | // File: LEDControllerChannel.cs 6 | // 7 | // NightDriverUnity - (c) 2021 Plummer's Software LLC. All Rights Reserved. 8 | // 9 | // This file is part of the NightDriver software project. 10 | // 11 | // NightDriver is free software: you can redistribute it and/or modify 12 | // it under the terms of the GNU General Public License as published by 13 | // the Free Software Foundation, either version 3 of the License, or 14 | // (at your option) any later version. 15 | // 16 | // NightDriver is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU General Public License 22 | // along with Nightdriver. It is normally found in copying.txt 23 | // If not, see . 24 | // Description: 25 | // 26 | // Represents a specific channel on a particular strip and exposes the 27 | // GraphicsBase class for drawing directly on it. 28 | // 29 | // Each instance has a worker thread that manages keeping the socket 30 | // connected and sending it the data that has been queued up for it. 31 | // 32 | // History: Jun-15-2019 Davepl Created 33 | // 34 | //--------------------------------------------------------------------------- 35 | 36 | using System; 37 | using System.Collections.Concurrent; 38 | using System.Net; 39 | using System.Net.Sockets; 40 | using System.Linq; 41 | using System.Threading; 42 | using System.Collections.Generic; 43 | using UnityEngine; 44 | 45 | 46 | // LEDControllerChannel 47 | // 48 | // Exposes ILEDGraphics via the GraphicsBase baseclass 49 | // Abstract until deriving class implements GetDataFrame() 50 | 51 | namespace NightDriver 52 | { 53 | public abstract class LEDControllerChannel : MonoBehaviour 54 | { 55 | public string HostName; 56 | public string FriendlyName; 57 | public bool CompressData = true; 58 | public byte Channel = 0; 59 | public double Brightness = 1.0f; 60 | public uint Connects = 0; 61 | public uint Watts = 0; 62 | public uint Width = 64; 63 | public uint Height = 32; 64 | public uint FramesPerSecond = 20; 65 | public bool RedGreenSwap = false; 66 | public int AntiAliasing = 8; 67 | //public RenderTexture CameraRenderTexture; 68 | public Camera CaptureCamera; 69 | 70 | public const int BatchSize = 1; 71 | public const double BatchTimeout = 0.5; 72 | 73 | private ConcurrentQueue DataQueue = new ConcurrentQueue(); 74 | 75 | private Thread _SendWorker; 76 | private Thread _DrawWorker; 77 | 78 | CRGB[] MainLEDs; 79 | 80 | public void Start() 81 | { 82 | Debug.Log("LEDControllerChannel started"); 83 | 84 | MainLEDs = new CRGB[Width * Height]; 85 | for (int i = 0; i < Width * Height; i++) 86 | MainLEDs[i] = new CRGB(0,0,255); 87 | 88 | if (Application.isPlaying) 89 | { 90 | Debug.Log("LEDControllerChannel Creating Workers"); 91 | _SendWorker = new Thread(WorkerConnectAndSendLoop); 92 | _SendWorker.IsBackground = true; 93 | _SendWorker.Priority = System.Threading.ThreadPriority.Normal; 94 | _SendWorker.Start(); 95 | 96 | _DrawWorker = new Thread(DrawLoop); 97 | _DrawWorker.IsBackground = true; 98 | _DrawWorker.Priority = System.Threading.ThreadPriority.Normal; 99 | _DrawWorker.Start(); 100 | } 101 | } 102 | 103 | public void OnDestroy() 104 | { 105 | if (Application.isPlaying) 106 | { 107 | _SendWorker.Abort(); 108 | _DrawWorker.Abort(); 109 | } 110 | Debug.Log("LEDControllerChannel exiting, terminating workers"); 111 | } 112 | 113 | public Texture2D GetRTPixels(RenderTexture rt) 114 | { 115 | 116 | // Remember currently active render texture 117 | RenderTexture currentActiveRT = RenderTexture.active; 118 | 119 | // Set the supplied RenderTexture as the active one 120 | RenderTexture.active = rt; 121 | 122 | CaptureCamera.Render(); 123 | 124 | // Create a new Texture2D and read the RenderTexture image into it 125 | 126 | Texture2D tex = new Texture2D((int)Width, (int)Height, TextureFormat.RGB24, false); 127 | tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0); 128 | tex.Apply(); 129 | 130 | // Restorie previously active render texture 131 | RenderTexture.active = currentActiveRT; 132 | return tex; 133 | } 134 | 135 | public Texture2D GetCamPic() 136 | { 137 | int resWidth = (int)Width; 138 | int resHeight = (int)Height; 139 | 140 | RenderTexture rt = new RenderTexture(resWidth, resHeight, 24); 141 | rt.antiAliasing = AntiAliasing; 142 | CaptureCamera.targetTexture = rt; //Create new renderTexture and assign to camera 143 | Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false); //Create new texture 144 | 145 | CaptureCamera.Render(); 146 | 147 | RenderTexture.active = rt; 148 | screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0); //Apply pixels from camera onto Texture2D 149 | 150 | CaptureCamera.targetTexture = null; 151 | RenderTexture.active = null; //Clean 152 | Destroy(rt); //Free memory 153 | 154 | return screenShot; 155 | } 156 | 157 | public void Update() 158 | { 159 | Texture2D newTexture = GetCamPic(); 160 | 161 | for (int x = 0; x < Width; x++) 162 | { 163 | for (int y = 0; y < Height; y++) 164 | { 165 | Color color = newTexture.GetPixel(x, y); 166 | CRGB crgb = new CRGB(); 167 | crgb.setRGB((byte)(color.r * 255), (byte)(color.g * 255), (byte)(color.b * 255)); 168 | long i = (Height - 1 - y) * Width + x; 169 | MainLEDs[i] = crgb; 170 | } 171 | } 172 | } 173 | 174 | public int QueueDepth 175 | { 176 | get 177 | { 178 | return DataQueue.Count; 179 | } 180 | } 181 | 182 | public bool HasSocket // Is there a socket at all yet? 183 | { 184 | get 185 | { 186 | ControllerSocket controllerSocket = ControllerSocketForHost(HostName); 187 | if (null == controllerSocket || controllerSocket._socket == null) 188 | return false; 189 | return true; 190 | } 191 | } 192 | 193 | public bool ReadyForData // Is there a socket and is it connected to the chip? 194 | { 195 | get 196 | { 197 | ControllerSocket controllerSocket = ControllerSocketForHost(HostName); 198 | if (null == controllerSocket || controllerSocket._socket == null || !controllerSocket._socket.Connected) 199 | return false; 200 | return true; 201 | } 202 | } 203 | 204 | public bool NeedsClockStream 205 | { 206 | get; 207 | set; 208 | } = true; 209 | 210 | public bool Supports64BitClock 211 | { 212 | get; 213 | set; 214 | } = true; 215 | 216 | 217 | public uint MinimumSpareTime => (uint)_HostControllerSockets.Min(controller => controller.Value.BytesPerSecond); 218 | 219 | public uint BytesPerSecond 220 | { 221 | get 222 | { 223 | ControllerSocket controllerSocket = ControllerSocketForHost(HostName); 224 | if (null == controllerSocket || controllerSocket._socket == null) 225 | return 0; 226 | return controllerSocket.BytesPerSecond; 227 | } 228 | } 229 | 230 | public uint TotalBytesPerSecond => (uint)_HostControllerSockets.Sum(controller => controller.Value.BytesPerSecond); 231 | 232 | public ControllerSocket ControllerSocket 233 | { 234 | get 235 | { 236 | return ControllerSocketForHost(HostName); 237 | } 238 | } 239 | 240 | public static ControllerSocket ControllerSocketForHost(string host) 241 | { 242 | if (_HostControllerSockets.ContainsKey(host)) 243 | { 244 | _HostControllerSockets.TryGetValue(host, out ControllerSocket controller); 245 | return controller; 246 | } 247 | return null; 248 | } 249 | 250 | protected abstract byte[] GetDataFrame(CRGB[] MainLEDs, DateTime timeStart); 251 | 252 | protected virtual byte[] GetClockFrame(DateTime timeStart) 253 | { 254 | // The timeOffset is how far in the future frames are generated for. If the chips have a 2 second buffer, you could 255 | // go up to 2 seconds, but I shoot for the middle of the buffer depth. 256 | 257 | double epoch = (timeStart.Ticks - 621355968000000000) / (double)TimeSpan.TicksPerSecond; 258 | UInt64 seconds = (UInt64)epoch; // Whole part of time number (left of the decimal point) 259 | UInt64 uSeconds = (UInt64)((epoch - (UInt64)epoch) * 1000000); // Fractional part of time (right of the decimal point) 260 | return LEDInterop.CombineByteArrays(LEDInterop.WORDToBytes((UInt16)2), // Command, which is 2 for us 261 | LEDInterop.WORDToBytes((UInt16)0), // LED channel on ESP32 262 | LEDInterop.ULONGToBytes(seconds), // Number of LEDs 263 | LEDInterop.ULONGToBytes(uSeconds) // Timestamp seconds 264 | ); // Color Data 265 | } 266 | 267 | byte[] CompressFrame(byte[] data) 268 | { 269 | const int COMPRESSED_HEADER_TAG = 0x44415645; // Magic "DAVE" tag for compressed data - replaces size field 270 | byte[] compressedData = LEDInterop.Compress(data); 271 | byte[] compressedFrame = LEDInterop.CombineByteArrays(LEDInterop.DWORDToBytes((uint)COMPRESSED_HEADER_TAG), 272 | LEDInterop.DWORDToBytes((uint)compressedData.Length), 273 | LEDInterop.DWORDToBytes((uint)data.Length), 274 | LEDInterop.DWORDToBytes(0x12345678), 275 | compressedData); 276 | return compressedFrame; 277 | } 278 | 279 | DateTime _timeLastSend = DateTime.UtcNow; 280 | DateTime _lastBatchTime = DateTime.UtcNow; 281 | 282 | // _HostSockets 283 | // 284 | // We can only have one socket open per ESP32 chip per channel, so this concurrent dictionary keeps track of which sockets are 285 | // open to what chips so that the socket can be reused. 286 | 287 | static ConcurrentDictionary _HostControllerSockets = new ConcurrentDictionary(); 288 | 289 | private int _iPacketCount = 0; 290 | 291 | // https://files.sexyandfunny.com/mp4/usr_506ef5a36788d.mp4 292 | // https://www.youtube.com/watch?v=G3HUp7LH5ig 293 | 294 | public void DrawLoop() 295 | { 296 | for(;;) 297 | { 298 | DateTime timeStart = DateTime.UtcNow; 299 | 300 | CompressAndEnqueueData(MainLEDs, timeStart); 301 | 302 | uint ms = (uint)(1000 * (1.0f / FramesPerSecond)); 303 | TimeSpan alreadyElapsed = (DateTime.UtcNow - timeStart); 304 | TimeSpan delay = TimeSpan.FromMilliseconds(ms) - alreadyElapsed; 305 | if (delay.TotalMilliseconds > 0) 306 | Thread.Sleep((int) delay.TotalMilliseconds); 307 | } 308 | } 309 | 310 | public void CompressAndEnqueueData(CRGB[] MainLEDs, DateTime timeStart) 311 | { 312 | if (DataQueue.Count > 20) 313 | { 314 | // ConsoleApp.Stats.WriteLine("Queue full so dicarding frame for " + HostName); 315 | return; 316 | } 317 | 318 | // If there is already a socket open, we will use that; otherwise, a new connection will be opened and if successful 319 | // it will be placed into the _HostSockets concurrent dictionary 320 | 321 | if (_HostControllerSockets.ContainsKey(HostName) == false && (DateTime.UtcNow - _timeLastSend).TotalSeconds < 2) 322 | { 323 | //ConsoleApp.Stats.WriteLine("Too early to retry for " + HostName); 324 | return; 325 | } 326 | _timeLastSend = DateTime.UtcNow; 327 | 328 | ControllerSocket controllerSocket = ControllerSocketForHost(HostName); 329 | if (null == controllerSocket) 330 | _HostControllerSockets[HostName] = controllerSocket; 331 | 332 | 333 | if (_iPacketCount % 100 == 0 && NeedsClockStream) 334 | { 335 | byte[] msgclock = GetClockFrame(timeStart); 336 | DataQueue.Enqueue(msgclock); 337 | } 338 | 339 | // Optionally compress the data, but when we do, if the compressed is larger, we send the original 340 | 341 | byte[] msgraw = GetDataFrame(MainLEDs, timeStart); 342 | byte[] msg = CompressData ? CompressFrame(msgraw) : msgraw; 343 | if (msg.Length >= msgraw.Length) 344 | { 345 | msg = msgraw; 346 | } 347 | 348 | DataQueue.Enqueue(msg); 349 | _iPacketCount++; 350 | 351 | } 352 | 353 | public bool ShouldSendBatch 354 | { 355 | get 356 | { 357 | if (DataQueue.Any()) 358 | if ((DateTime.UtcNow - _lastBatchTime).TotalSeconds > BatchTimeout) 359 | return true; 360 | 361 | if (DataQueue.Count() > BatchSize) 362 | return true; 363 | 364 | return false; 365 | } 366 | } 367 | 368 | // WorkerConnectAndSendLoop 369 | // 370 | // Every controller has a worker thread that sits and spins in a thread loop doing the work of connecting to 371 | // the chips, pulling data from the queues, and sending it off 372 | 373 | void WorkerConnectAndSendLoop() 374 | { 375 | // We delay-start a random fraction of a quarter second to stagger the workload so that the WiFi is a little more balanced 376 | 377 | Thread.Sleep((int)(new System.Random().NextDouble() * 250)); 378 | 379 | for (; ; ) 380 | { 381 | ControllerSocket controllerSocket 382 | = _HostControllerSockets.GetOrAdd(HostName, (hostname) => 383 | { 384 | Connects++; 385 | Debug.Log("Connecting to " + HostName); 386 | return new ControllerSocket(hostname); 387 | }); 388 | 389 | 390 | if (false == controllerSocket.EnsureConnected()) 391 | { 392 | if (controllerSocket.IsDead) 393 | { 394 | Debug.Log("Closing disconnected socket: " + HostName); 395 | ControllerSocket oldSocket; 396 | _HostControllerSockets.TryRemove(HostName, out oldSocket); 397 | } 398 | Thread.Sleep(10); 399 | continue; 400 | } 401 | 402 | // Compose a message which is a binary block of N (where N is up to Count) dequeue packets all 403 | // in a row, which is how the chips can actually process them 404 | 405 | if (ShouldSendBatch) 406 | { 407 | _lastBatchTime = DateTime.UtcNow; 408 | 409 | byte[] msg = LEDInterop.CombineByteArrays(DataQueue.DequeueChunk(DataQueue.Count()).ToArray()); 410 | if (msg.Length > 0) 411 | { 412 | try 413 | { 414 | uint bytesSent = 0; 415 | if (!controllerSocket.IsDead) 416 | bytesSent = controllerSocket.SendData(msg); 417 | if (bytesSent != msg.Length) 418 | { 419 | Debug.Log("Could not write all bytes so closing socket for " + HostName); 420 | ControllerSocket oldSocket; 421 | _HostControllerSockets.TryRemove(HostName, out oldSocket); 422 | } 423 | else 424 | { 425 | //Debug.Log("Sent " + bytesSent + " to " + HostName); 426 | double framesPerSecond = (double)((DateTime.UtcNow - _timeLastSend).TotalSeconds); 427 | } 428 | } 429 | catch (SocketException ex) 430 | { 431 | Debug.Log("Exception writing to socket for " + HostName + ": " + ex.Message); 432 | ControllerSocket oldSocket; 433 | _HostControllerSockets.TryRemove(HostName, out oldSocket); 434 | } 435 | } 436 | } 437 | 438 | Thread.Sleep(10); 439 | } 440 | } 441 | } 442 | 443 | // ControllerSocket 444 | // 445 | // Wrapper for .Net Socket so that we can track the number of bytes sent and so on 446 | 447 | public class ControllerSocket 448 | { 449 | public Socket _socket; 450 | private IPAddress _ipAddress; 451 | private IPEndPoint _remoteEP; 452 | 453 | private DateTime LastDataFrameTime; 454 | 455 | private uint BytesSentSinceFrame = 0; 456 | 457 | public string HostName; 458 | 459 | public bool IsDead { get; protected set; } = false; 460 | 461 | public uint BytesPerSecond 462 | { 463 | get 464 | { 465 | double d = (DateTime.UtcNow - LastDataFrameTime).TotalSeconds; 466 | if (d < 0.001) 467 | return 0; 468 | 469 | return (uint)(BytesSentSinceFrame / d); 470 | } 471 | } 472 | 473 | public ControllerSocket(string hostname) 474 | { 475 | HostName = hostname; 476 | //ConsoleApp.Stats.WriteLine("Constructor for " + hostname); 477 | _remoteEP = null; 478 | Dns.BeginGetHostAddresses(HostName, OnDnsGetHostAddressesComplete, this); 479 | } 480 | 481 | private void OnDnsGetHostAddressesComplete(IAsyncResult result) 482 | { 483 | var This = (ControllerSocket)result.AsyncState; 484 | 485 | try 486 | { 487 | This._ipAddress = Dns.EndGetHostAddresses(result)[0]; 488 | This._remoteEP = new IPEndPoint(_ipAddress, 49152); 489 | Debug.Log("Got IP of " + _remoteEP.Address.ToString() + " for " + This.HostName); 490 | } 491 | catch (Exception) 492 | { 493 | Debug.Log("DNS Exception: " + HostName); 494 | IsDead = true; 495 | } 496 | } 497 | 498 | // EnsureConnected 499 | // 500 | // If not already connected, initiates the connection so that perhaps next time we will ideally be connected 501 | 502 | public bool EnsureConnected() 503 | { 504 | if (IsDead == true) 505 | return false; 506 | 507 | if (_remoteEP == null) 508 | return false; 509 | 510 | if (_socket != null && _socket.Connected) 511 | return true; 512 | 513 | try 514 | { 515 | if (DateTime.UtcNow - LastDataFrameTime < TimeSpan.FromSeconds(1)) 516 | { 517 | //ConsoleApp.Stats.WriteLine("Bailing connection as too early!"); 518 | return false; 519 | } 520 | LastDataFrameTime = DateTime.UtcNow; 521 | _socket = new Socket(_ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); 522 | 523 | _socket.Connect(_remoteEP); 524 | 525 | BytesSentSinceFrame = 0; 526 | Debug.Log("Connected to " + _remoteEP); 527 | 528 | return true; 529 | } 530 | catch (SocketException) 531 | { 532 | IsDead = true; 533 | return false; 534 | } 535 | } 536 | 537 | public uint SendData(byte[] data) 538 | { 539 | uint result = (uint)_socket.Send(data); 540 | 541 | TimeSpan timeSinceLastSend = DateTime.UtcNow - LastDataFrameTime; 542 | if (timeSinceLastSend > TimeSpan.FromSeconds(10.0)) 543 | { 544 | LastDataFrameTime = DateTime.UtcNow; 545 | BytesSentSinceFrame = 0; 546 | } 547 | else 548 | { 549 | BytesSentSinceFrame += result; 550 | } 551 | return result; 552 | } 553 | } 554 | } 555 | 556 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/LEDControllerChannel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70a9b4bb2d8a94978bf10947de5357fd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/LEDSignController.cs: -------------------------------------------------------------------------------- 1 | //+-------------------------------------------------------------------------- 2 | // 3 | // NightDriver.Net - (c) 2019 Dave Plummer. All Rights Reserved. 4 | // 5 | // File: LEDSignController.cs 6 | // 7 | // NightDriverUnity - (c) 2021 Plummer's Software LLC. All Rights Reserved. 8 | // 9 | // This file is part of the NightDriver software project. 10 | // 11 | // NightDriver is free software: you can redistribute it and/or modify 12 | // it under the terms of the GNU General Public License as published by 13 | // the Free Software Foundation, either version 3 of the License, or 14 | // (at your option) any later version. 15 | // 16 | // NightDriver is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU General Public License 22 | // along with Nightdriver. It is normally found in copying.txt 23 | // If not, see . 24 | // 25 | // Description: 26 | // 27 | // Represents a specific channel on a particular strip and exposes the 28 | // GraphicsBase class for drawing directly on it. 29 | // 30 | // Each instance has a worker thread that manages keeping the socket 31 | // connected and sending it the data that has been queued up for it. 32 | // 33 | // History: Jun-15-2019 Davepl Created 34 | // 35 | //--------------------------------------------------------------------------- 36 | 37 | using System; 38 | using System.Threading; 39 | using NightDriver; 40 | using UnityEngine; 41 | 42 | public class LEDSignController : LEDControllerChannel 43 | { 44 | // BUGBUG(davepl) Once upon a time I protected this with a lock, and it might not be a good or bad idea, 45 | // but I can't prove it either way. 46 | 47 | private byte[] GetPixelData(CRGB[] MainLEDs) 48 | { 49 | return LEDInterop.GetColorBytes(MainLEDs); 50 | } 51 | 52 | public const uint FramesPerBuffer = 40; // How many buffer frames the chips have 53 | public const double PercentBufferUse = 0.80; // How much of the buffer we should use up 54 | 55 | public double TimeOffset 56 | { 57 | get 58 | { 59 | if (0 == FramesPerSecond) // No speed indication yet, can't guess at offset, assume 1 second for now 60 | return 1.0; 61 | 62 | if (!Supports64BitClock) // Old V001 flash is locked at 22 fps 63 | return 1.0; 64 | else 65 | return (double)FramesPerBuffer / FramesPerSecond * PercentBufferUse; 66 | } 67 | } 68 | 69 | const UInt16 WIFI_COMMAND_PIXELDATA = 0; 70 | const UInt16 WIFI_COMMAND_VU = 1; 71 | const UInt16 WIFI_COMMAND_CLOCK = 2; 72 | const UInt16 WIFI_COMMAND_PIXELDATA64 = 3; 73 | 74 | ulong foo = 0; 75 | 76 | protected override byte[] GetDataFrame(CRGB [] MainLEDs, DateTime timeStart) 77 | { 78 | // The old original code truncated 64 bit values down to 32, and we need to fix that, so it's a in a packet called PIXELDATA64 79 | // and is only sent to newer flashes taht support it. Otherwise we send the old original foramt. 80 | 81 | if (false == Supports64BitClock) 82 | { 83 | // The timeOffset is how far in the future frames are generated for. If the chips have a 2 second buffer, you could 84 | // go up to 2 seconds, but I shoot for the middle of the buffer depth. Right now it's calculated as using 85 | 86 | 87 | double epoch = (timeStart.Ticks - 621355968000000000 + (0.5 * TimeSpan.TicksPerSecond)) / (double)TimeSpan.TicksPerSecond; 88 | double fraction = epoch - (Int64)epoch; 89 | 90 | ulong seconds = (ulong)epoch; // Whole part of time number (left of the decimal point) 91 | ulong uSeconds = (ulong)(fraction * 1000000); // Fractional part of time (right of the decimal point) 92 | 93 | var data = GetPixelData(MainLEDs); 94 | 95 | // Debug.Log("Old Seconds: " + seconds + "uSec: " + uSeconds); 96 | 97 | return LEDInterop.CombineByteArrays(LEDInterop.WORDToBytes(WIFI_COMMAND_PIXELDATA), // Offset, always zero for us 98 | LEDInterop.WORDToBytes((UInt16)Channel), // LED channel on ESP32 99 | LEDInterop.DWORDToBytes((UInt32)data.Length / 3), // Number of LEDs 100 | LEDInterop.DWORDToBytes((UInt32)seconds), // Timestamp seconds (32 bit truncation) 101 | LEDInterop.DWORDToBytes((UInt32)uSeconds), // Timestmap microseconds (32 bit truncation) 102 | data); // Color Data 103 | } 104 | else 105 | { 106 | // The timeOffset is how far in the future frames are generated for. If the chips have a 2 second buffer, you could 107 | // go up to 2 seconds, but I shoot for the middle of the buffer depth. Right now it's calculated as using 108 | 109 | double epoch = (timeStart.Ticks - 621355968000000000 + (1.0 * TimeSpan.TicksPerSecond)) / (double)TimeSpan.TicksPerSecond; 110 | double fraction = epoch - (Int64)epoch; 111 | 112 | ulong seconds = (ulong)epoch; // Whole part of time number (left of the decimal point) 113 | ulong uSeconds = (ulong)(fraction * 1000000); // Fractional part of time (right of the decimal point) 114 | 115 | // Debug.Log("New Seconds: " + seconds + "uSec: " + uSeconds); 116 | 117 | var data = GetPixelData(MainLEDs); 118 | return LEDInterop.CombineByteArrays(LEDInterop.WORDToBytes(WIFI_COMMAND_PIXELDATA64), // Offset, always zero for us 119 | LEDInterop.WORDToBytes((UInt16)Channel), // LED channel on ESP32 120 | LEDInterop.DWORDToBytes((UInt32)data.Length / 3), // Number of LEDs 121 | LEDInterop.ULONGToBytes(seconds), // Timestamp seconds (64 bit) 122 | LEDInterop.ULONGToBytes(uSeconds), // Timestmap microseconds (64 bit) 123 | data); // Color Data 124 | 125 | } 126 | } 127 | 128 | }; 129 | 130 | 131 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/LEDSignController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 615918ee99cb44f23ad88aa3c3c7a429 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/ZLIBStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.IO.Compression; 4 | 5 | namespace ZLIB 6 | { 7 | public sealed class ZLIBStream : Stream 8 | { 9 | #region "Variables globales" 10 | private CompressionMode mCompressionMode = CompressionMode.Compress; 11 | private CompressionLevel mCompressionLevel = CompressionLevel.NoCompression; 12 | private bool mLeaveOpen = false; 13 | private Adler32 adler32 = new Adler32(); 14 | private DeflateStream mDeflateStream; 15 | private Stream mRawStream; 16 | private bool mClosed = false; 17 | private byte[] mCRC = null; 18 | #endregion 19 | #region "Constructores" 20 | /// 21 | /// Inicializa una nueva instancia de la clase ZLIBStream usando la secuencia y nivel de compresión especificados. 22 | /// 23 | /// Secuencia que se va a comprimir 24 | /// Nivel de compresión 25 | public ZLIBStream(Stream stream, CompressionLevel compressionLevel) : this(stream, compressionLevel, false) 26 | { 27 | } 28 | /// 29 | /// Inicializa una nueva instancia de la clase ZLIBStream usando la secuencia y modo de compresión especificados. 30 | /// 31 | /// Secuencia que se va a comprimir o descomprimir 32 | /// Modo de compresión 33 | public ZLIBStream(Stream stream, CompressionMode compressionMode) : this(stream, compressionMode, false) 34 | { 35 | } 36 | /// 37 | /// Inicializa una nueva instancia de la clase ZLIBStream usando la secuencia y nivel de compresión especificados y, opcionalmente, deja la secuencia abierta. 38 | /// 39 | /// Secuencia que se va a comprimir 40 | /// Nivel de compresión 41 | /// Indica si se debe de dejar la secuencia abierta después de comprimir la secuencia 42 | public ZLIBStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen) 43 | { 44 | this.mCompressionMode = CompressionMode.Compress; 45 | this.mCompressionLevel = compressionLevel; 46 | this.mLeaveOpen = leaveOpen; 47 | this.mRawStream = stream; 48 | this.InicializarStream(); 49 | } 50 | /// 51 | /// Inicializa una nueva instancia de la clase ZLIBStream usando la secuencia y modo de compresión especificados y, opcionalmente, deja la secuencia abierta. 52 | /// 53 | /// Secuencia que se va a comprimir o descomprimir 54 | /// Modo de compresión 55 | /// Indica si se debe de dejar la secuencia abierta después de comprimir o descomprimir la secuencia 56 | public ZLIBStream(Stream stream, CompressionMode compressionMode, bool leaveOpen) 57 | { 58 | this.mCompressionMode = compressionMode; 59 | this.mCompressionLevel = CompressionLevel.Fastest; 60 | this.mLeaveOpen = leaveOpen; 61 | this.mRawStream = stream; 62 | this.InicializarStream(); 63 | } 64 | #endregion 65 | #region "Propiedades sobreescritas" 66 | public override bool CanRead 67 | { 68 | get 69 | { 70 | return ((this.mCompressionMode == CompressionMode.Decompress) && (this.mClosed != true)); 71 | } 72 | } 73 | public override bool CanWrite 74 | { 75 | get 76 | { 77 | return ((this.mCompressionMode == CompressionMode.Compress) && (this.mClosed != true)); 78 | } 79 | } 80 | public override bool CanSeek 81 | { 82 | get 83 | { 84 | return false; 85 | } 86 | } 87 | public override long Length 88 | { 89 | get 90 | { 91 | throw new NotImplementedException(); 92 | } 93 | } 94 | public override long Position 95 | { 96 | get 97 | { 98 | throw new NotImplementedException(); 99 | } 100 | set 101 | { 102 | throw new NotImplementedException(); 103 | } 104 | } 105 | #endregion 106 | #region "Metodos sobreescritos" 107 | public override int ReadByte() 108 | { 109 | int result = 0; 110 | 111 | if (this.CanRead == true) 112 | { 113 | result = this.mDeflateStream.ReadByte(); 114 | 115 | //Comprobamos si se ha llegado al final del stream 116 | if (result == -1) 117 | { 118 | this.ReadCRC(); 119 | } 120 | else 121 | { 122 | this.adler32.Update(Convert.ToByte(result)); 123 | } 124 | } 125 | else 126 | { 127 | throw new InvalidOperationException(); 128 | } 129 | 130 | return result; 131 | } 132 | 133 | public override int Read(byte[] buffer, int offset, int count) 134 | { 135 | int result = 0; 136 | 137 | if (this.CanRead == true) 138 | { 139 | result = this.mDeflateStream.Read(buffer, offset, count); 140 | 141 | //Comprobamos si hemos llegado al final del stream 142 | if ((result < 1) && (count > 0)) 143 | { 144 | this.ReadCRC(); 145 | } 146 | else 147 | { 148 | this.adler32.Update(buffer, offset, result); 149 | } 150 | } 151 | else 152 | { 153 | throw new InvalidOperationException(); 154 | } 155 | 156 | return result; 157 | } 158 | 159 | public override void WriteByte(byte value) 160 | { 161 | if (this.CanWrite == true) 162 | { 163 | this.mDeflateStream.WriteByte(value); 164 | this.adler32.Update(value); 165 | } 166 | else 167 | { 168 | throw new InvalidOperationException(); 169 | } 170 | } 171 | 172 | public override void Write(byte[] buffer, int offset, int count) 173 | { 174 | if (this.CanWrite == true) 175 | { 176 | this.mDeflateStream.Write(buffer, offset, count); 177 | this.adler32.Update(buffer, offset, count); 178 | } 179 | else 180 | { 181 | throw new InvalidOperationException(); 182 | } 183 | } 184 | 185 | public override void Close() 186 | { 187 | if (this.mClosed == false) 188 | { 189 | this.mClosed = true; 190 | if (this.mCompressionMode == CompressionMode.Compress) 191 | { 192 | this.Flush(); 193 | this.mDeflateStream.Close(); 194 | 195 | this.mCRC = BitConverter.GetBytes(adler32.GetValue()); 196 | 197 | if (BitConverter.IsLittleEndian == true) 198 | { 199 | Array.Reverse(this.mCRC); 200 | } 201 | 202 | this.mRawStream.Write(this.mCRC, 0, this.mCRC.Length); 203 | } 204 | else 205 | { 206 | this.mDeflateStream.Close(); 207 | if (this.mCRC == null) 208 | { 209 | this.ReadCRC(); 210 | } 211 | } 212 | 213 | if (this.mLeaveOpen == false) 214 | { 215 | this.mRawStream.Close(); 216 | } 217 | } 218 | else 219 | { 220 | //throw new InvalidOperationException("Stream already closed"); 221 | } 222 | } 223 | 224 | public override void Flush() 225 | { 226 | if (this.mDeflateStream != null) 227 | { 228 | this.mDeflateStream.Flush(); 229 | } 230 | } 231 | 232 | public override long Seek(long offset, SeekOrigin origin) 233 | { 234 | throw new NotImplementedException(); 235 | } 236 | 237 | public override void SetLength(long value) 238 | { 239 | throw new NotImplementedException(); 240 | } 241 | #endregion 242 | #region "Metodos publicos" 243 | /// 244 | /// Comprueba si el stream esta en formato ZLib 245 | /// 246 | /// Stream a comprobar 247 | /// Retorna True en caso de que el stream sea en formato ZLib y False en caso contrario u error 248 | public static bool IsZLibStream(Stream stream) 249 | { 250 | bool bResult = false; 251 | int CMF = 0; 252 | int Flag = 0; 253 | ZLibHeader header; 254 | 255 | //Comprobamos si la secuencia esta en la posición 0, de no ser así, lanzamos una excepción 256 | if (stream.Position != 0) 257 | { 258 | throw new ArgumentOutOfRangeException("Sequence must be at position 0"); 259 | } 260 | 261 | //Comprobamos si podemos realizar la lectura de los dos bytes que conforman la cabecera 262 | if (stream.CanRead == true) 263 | { 264 | CMF = stream.ReadByte(); 265 | Flag = stream.ReadByte(); 266 | try 267 | { 268 | header = ZLibHeader.DecodeHeader(CMF, Flag); 269 | bResult = header.IsSupportedZLibStream; 270 | } 271 | catch 272 | { 273 | //Nada 274 | } 275 | } 276 | 277 | return bResult; 278 | } 279 | /// 280 | /// Lee los últimos 4 bytes del stream ya que es donde está el CRC 281 | /// 282 | private void ReadCRC() 283 | { 284 | this.mCRC = new byte[4]; 285 | this.mRawStream.Seek(-4, SeekOrigin.End); 286 | if (this.mRawStream.Read(this.mCRC, 0, 4) < 4) 287 | { 288 | throw new EndOfStreamException(); 289 | } 290 | 291 | if (BitConverter.IsLittleEndian == true) 292 | { 293 | Array.Reverse(this.mCRC); 294 | } 295 | 296 | uint crcAdler = this.adler32.GetValue(); 297 | uint crcStream = BitConverter.ToUInt32(this.mCRC, 0); 298 | 299 | if (crcStream != crcAdler) 300 | { 301 | throw new Exception("CRC mismatch"); 302 | } 303 | } 304 | #endregion 305 | #region "Metodos privados" 306 | /// 307 | /// Inicializa el stream 308 | /// 309 | private void InicializarStream() 310 | { 311 | switch (this.mCompressionMode) 312 | { 313 | case CompressionMode.Compress: 314 | { 315 | this.InicializarZLibHeader(); 316 | this.mDeflateStream = new DeflateStream(this.mRawStream, this.mCompressionLevel, true); 317 | break; 318 | } 319 | case CompressionMode.Decompress: 320 | { 321 | if (ZLIBStream.IsZLibStream(this.mRawStream) == false) 322 | { 323 | throw new InvalidDataException(); 324 | } 325 | this.mDeflateStream = new DeflateStream(this.mRawStream, CompressionMode.Decompress, true); 326 | break; 327 | } 328 | } 329 | } 330 | /// 331 | /// Inicializa el encabezado del stream en formato ZLib 332 | /// 333 | private void InicializarZLibHeader() 334 | { 335 | byte[] bytesHeader; 336 | 337 | //Establecemos la configuración de la cabecera 338 | ZLibHeader header = new ZLibHeader(); 339 | 340 | header.CompressionMethod = 8; //Deflate 341 | header.CompressionInfo = 7; 342 | 343 | header.FDict = false; //Sin diccionario 344 | switch (this.mCompressionLevel) 345 | { 346 | case CompressionLevel.NoCompression: 347 | { 348 | header.FLevel = FLevel.Faster; 349 | break; 350 | } 351 | case CompressionLevel.Fastest: 352 | { 353 | header.FLevel = FLevel.Default; 354 | break; 355 | } 356 | case CompressionLevel.Optimal: 357 | { 358 | header.FLevel = FLevel.Optimal; 359 | break; 360 | } 361 | } 362 | 363 | bytesHeader = header.EncodeZlibHeader(); 364 | 365 | this.mRawStream.WriteByte(bytesHeader[0]); 366 | this.mRawStream.WriteByte(bytesHeader[1]); 367 | } 368 | #endregion 369 | } 370 | } 371 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/ZLIBStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfd9257c5140043d386e90fcdb9c5f8c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/ZLibHeader.cs: -------------------------------------------------------------------------------- 1 | // I can't find any source for this code! The variables don't hit on Google even. 2 | // If you can ID the source, please advise. 3 | 4 | using System; 5 | 6 | namespace ZLIB 7 | { 8 | public enum FLevel 9 | { 10 | Faster = 0, 11 | Fast = 1, 12 | Default = 2, 13 | Optimal = 3, 14 | } 15 | 16 | public sealed class ZLibHeader 17 | { 18 | #region "Variables globales" 19 | private bool mIsSupportedZLibStream; 20 | private byte mCompressionMethod; //CMF 0-3 21 | private byte mCompressionInfo; //CMF 4-7 22 | private byte mFCheck; //Flag 0-4 (Check bits for CMF and FLG) 23 | private bool mFDict; //Flag 5 (Preset dictionary) 24 | private FLevel mFLevel; //Flag 6-7 (Compression level) 25 | #endregion 26 | #region "Propiedades" 27 | public bool IsSupportedZLibStream 28 | { 29 | get 30 | { 31 | return this.mIsSupportedZLibStream; 32 | } 33 | set 34 | { 35 | this.mIsSupportedZLibStream = value; 36 | } 37 | } 38 | public byte CompressionMethod 39 | { 40 | get 41 | { 42 | return this.mCompressionMethod; 43 | } 44 | set 45 | { 46 | if (value > 15) 47 | { 48 | throw new ArgumentOutOfRangeException("Argument cannot be greater than 15"); 49 | } 50 | this.mCompressionMethod = value; 51 | } 52 | } 53 | public byte CompressionInfo 54 | { 55 | get 56 | { 57 | return this.mCompressionInfo; 58 | } 59 | set 60 | { 61 | if (value > 15) 62 | { 63 | throw new ArgumentOutOfRangeException("Argument cannot be greater than 15"); 64 | } 65 | this.mCompressionInfo = value; 66 | } 67 | } 68 | public byte FCheck 69 | { 70 | get 71 | { 72 | return this.mFCheck; 73 | } 74 | set 75 | { 76 | if (value > 31) 77 | { 78 | throw new ArgumentOutOfRangeException("Argument cannot be greater than 31"); 79 | } 80 | this.mFCheck = value; 81 | } 82 | } 83 | public bool FDict 84 | { 85 | get 86 | { 87 | return this.mFDict; 88 | } 89 | set 90 | { 91 | this.mFDict = value; 92 | } 93 | } 94 | public FLevel FLevel 95 | { 96 | get 97 | { 98 | return this.mFLevel; 99 | } 100 | set 101 | { 102 | this.mFLevel = value; 103 | } 104 | } 105 | #endregion 106 | #region "Constructor" 107 | public ZLibHeader() 108 | { 109 | 110 | } 111 | #endregion 112 | #region "Metodos privados" 113 | private void RefreshFCheck() 114 | { 115 | byte byteFLG = 0x00; 116 | 117 | byteFLG = (byte)(Convert.ToByte(this.FLevel) << 1); 118 | byteFLG |= Convert.ToByte(this.FDict); 119 | 120 | this.FCheck = Convert.ToByte(31 - Convert.ToByte((this.GetCMF() * 256 + byteFLG) % 31)); 121 | } 122 | private byte GetCMF() 123 | { 124 | byte byteCMF = 0x00; 125 | 126 | byteCMF = (byte)(this.CompressionInfo << 4); 127 | byteCMF |= (byte)(this.CompressionMethod); 128 | 129 | return byteCMF; 130 | } 131 | private byte GetFLG() 132 | { 133 | byte byteFLG = 0x00; 134 | 135 | byteFLG = (byte)(Convert.ToByte(this.FLevel) << 6); 136 | byteFLG |= (byte)(Convert.ToByte(this.FDict) << 5); 137 | byteFLG |= this.FCheck; 138 | 139 | return byteFLG; 140 | } 141 | #endregion 142 | #region "Metodos publicos" 143 | public byte[] EncodeZlibHeader() 144 | { 145 | byte[] result = new byte[2]; 146 | 147 | this.RefreshFCheck(); 148 | 149 | result[0] = this.GetCMF(); 150 | result[1] = this.GetFLG(); 151 | 152 | return result; 153 | } 154 | #endregion 155 | #region "Metodos estáticos" 156 | public static ZLibHeader DecodeHeader(int pCMF, int pFlag) 157 | { 158 | ZLibHeader result = new ZLibHeader(); 159 | 160 | //Ensure that parameters are bytes 161 | pCMF = pCMF & 0x0FF; 162 | pFlag = pFlag & 0x0FF; 163 | 164 | //Decode bytes 165 | result.CompressionInfo = Convert.ToByte((pCMF & 0xF0) >> 4); 166 | result.CompressionMethod = Convert.ToByte(pCMF & 0x0F); 167 | 168 | result.FCheck = Convert.ToByte(pFlag & 0x1F); 169 | result.FDict = Convert.ToBoolean(Convert.ToByte((pFlag & 0x20) >> 5)); 170 | result.FLevel = (FLevel)Convert.ToByte((pFlag & 0xC0) >> 6); 171 | 172 | result.IsSupportedZLibStream = (result.CompressionMethod == 8) && (result.CompressionInfo == 7) && (((pCMF * 256 + pFlag) % 31 == 0)) && (result.FDict == false); 173 | 174 | return result; 175 | } 176 | #endregion 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Scripts/ZLibHeader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2222abef5cddd473c8d92be1eb53bb4e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Videos.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afae8d9c501ebc649935ef2387316154 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Videos/Pacman Chase Wide.mov: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:842d22791e880d7c467a8a39e546ff7c39951daac7bc75856eb47cc4fcb455e9 3 | size 568542 4 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Videos/Pacman Chase Wide.mov.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d535eb95f4dea4b27af31e8b955997c8 3 | VideoClipImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | frameRange: 0 7 | startFrame: -1 8 | endFrame: -1 9 | colorSpace: 0 10 | deinterlace: 0 11 | encodeAlpha: 0 12 | flipVertical: 0 13 | flipHorizontal: 0 14 | importAudio: 1 15 | targetSettings: {} 16 | userData: 17 | assetBundleName: 18 | assetBundleVariant: 19 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Videos/Road - 1101.mp4: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7b71237c818eca5eb58a78139de65791e1ddccd2714b02c97bcf7793e2cfb690 3 | size 2504741 4 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Videos/Road - 1101.mp4.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc916c6b8092a4e5db003394af4154f8 3 | VideoClipImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | frameRange: 0 7 | startFrame: -1 8 | endFrame: -1 9 | colorSpace: 0 10 | deinterlace: 0 11 | encodeAlpha: 0 12 | flipVertical: 0 13 | flipHorizontal: 0 14 | importAudio: 1 15 | targetSettings: {} 16 | userData: 17 | assetBundleName: 18 | assetBundleVariant: 19 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Videos/swcrawl.mp4: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fba1f945fa6201bc38c2718a15d313c6ed9eed1642b707946f6c6f7b9539bde6 3 | size 1056260 4 | -------------------------------------------------------------------------------- /Assets/NightDriveryUnity/Videos/swcrawl.mp4.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91257a12080fa403aa519b7bd0a9db4d 3 | VideoClipImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | frameRange: 0 7 | startFrame: -1 8 | endFrame: -1 9 | colorSpace: 0 10 | deinterlace: 0 11 | encodeAlpha: 0 12 | flipVertical: 0 13 | flipHorizontal: 0 14 | importAudio: 1 15 | targetSettings: {} 16 | userData: 17 | assetBundleName: 18 | assetBundleVariant: 19 | -------------------------------------------------------------------------------- /Assets/Simple Demo.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 3 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 0 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 512 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 256 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 1 83 | m_PVRDenoiserTypeDirect: 1 84 | m_PVRDenoiserTypeIndirect: 1 85 | m_PVRDenoiserTypeAO: 1 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 1 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_UseShadowmask: 1 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | debug: 122 | m_Flags: 0 123 | m_NavMeshData: {fileID: 0} 124 | --- !u!1 &23841965 125 | GameObject: 126 | m_ObjectHideFlags: 0 127 | m_CorrespondingSourceObject: {fileID: 0} 128 | m_PrefabInstance: {fileID: 0} 129 | m_PrefabAsset: {fileID: 0} 130 | serializedVersion: 6 131 | m_Component: 132 | - component: {fileID: 23841967} 133 | - component: {fileID: 23841966} 134 | - component: {fileID: 23841968} 135 | m_Layer: 0 136 | m_Name: GameObject 137 | m_TagString: Untagged 138 | m_Icon: {fileID: 0} 139 | m_NavMeshLayer: 0 140 | m_StaticEditorFlags: 0 141 | m_IsActive: 1 142 | --- !u!328 &23841966 143 | VideoPlayer: 144 | m_ObjectHideFlags: 0 145 | m_CorrespondingSourceObject: {fileID: 0} 146 | m_PrefabInstance: {fileID: 0} 147 | m_PrefabAsset: {fileID: 0} 148 | m_GameObject: {fileID: 23841965} 149 | m_Enabled: 1 150 | m_VideoClip: {fileID: 32900000, guid: d535eb95f4dea4b27af31e8b955997c8, type: 3} 151 | m_TargetCameraAlpha: 1 152 | m_TargetCamera3DLayout: 0 153 | m_TargetCamera: {fileID: 123536681} 154 | m_TargetTexture: {fileID: 0} 155 | m_TimeReference: 0 156 | m_TargetMaterialRenderer: {fileID: 0} 157 | m_TargetMaterialProperty: _MainTex 158 | m_RenderMode: 1 159 | m_AspectRatio: 2 160 | m_DataSource: 0 161 | m_PlaybackSpeed: 1 162 | m_AudioOutputMode: 2 163 | m_TargetAudioSources: [] 164 | m_DirectAudioVolumes: [] 165 | m_Url: 166 | m_EnabledAudioTracks: 167 | m_DirectAudioMutes: 168 | m_ControlledAudioTrackCount: 0 169 | m_PlayOnAwake: 1 170 | m_SkipOnDrop: 1 171 | m_Looping: 1 172 | m_WaitForFirstFrame: 1 173 | m_FrameReadyEventEnabled: 0 174 | --- !u!4 &23841967 175 | Transform: 176 | m_ObjectHideFlags: 0 177 | m_CorrespondingSourceObject: {fileID: 0} 178 | m_PrefabInstance: {fileID: 0} 179 | m_PrefabAsset: {fileID: 0} 180 | m_GameObject: {fileID: 23841965} 181 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 182 | m_LocalPosition: {x: -166.95186, y: 85.481, z: -5031.5} 183 | m_LocalScale: {x: 1, y: 1, z: 1} 184 | m_Children: 185 | - {fileID: 1253871086} 186 | m_Father: {fileID: 0} 187 | m_RootOrder: 1 188 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 189 | --- !u!114 &23841968 190 | MonoBehaviour: 191 | m_ObjectHideFlags: 0 192 | m_CorrespondingSourceObject: {fileID: 0} 193 | m_PrefabInstance: {fileID: 0} 194 | m_PrefabAsset: {fileID: 0} 195 | m_GameObject: {fileID: 23841965} 196 | m_Enabled: 1 197 | m_EditorHideFlags: 0 198 | m_Script: {fileID: 11500000, guid: 615918ee99cb44f23ad88aa3c3c7a429, type: 3} 199 | m_Name: 200 | m_EditorClassIdentifier: 201 | HostName: 192.168.8.198 202 | FriendlyName: RGMatrix 203 | CompressData: 0 204 | Channel: 0 205 | Brightness: 1 206 | Connects: 0 207 | Watts: 0 208 | Width: 48 209 | Height: 16 210 | FramesPerSecond: 24 211 | RedGreenSwap: 0 212 | AntiAliasing: 8 213 | CaptureCamera: {fileID: 123536681} 214 | --- !u!1 &123536679 215 | GameObject: 216 | m_ObjectHideFlags: 0 217 | m_CorrespondingSourceObject: {fileID: 0} 218 | m_PrefabInstance: {fileID: 0} 219 | m_PrefabAsset: {fileID: 0} 220 | serializedVersion: 6 221 | m_Component: 222 | - component: {fileID: 123536682} 223 | - component: {fileID: 123536681} 224 | - component: {fileID: 123536680} 225 | m_Layer: 0 226 | m_Name: Main Camera 227 | m_TagString: MainCamera 228 | m_Icon: {fileID: 0} 229 | m_NavMeshLayer: 0 230 | m_StaticEditorFlags: 0 231 | m_IsActive: 1 232 | --- !u!81 &123536680 233 | AudioListener: 234 | m_ObjectHideFlags: 0 235 | m_CorrespondingSourceObject: {fileID: 0} 236 | m_PrefabInstance: {fileID: 0} 237 | m_PrefabAsset: {fileID: 0} 238 | m_GameObject: {fileID: 123536679} 239 | m_Enabled: 1 240 | --- !u!20 &123536681 241 | Camera: 242 | m_ObjectHideFlags: 0 243 | m_CorrespondingSourceObject: {fileID: 0} 244 | m_PrefabInstance: {fileID: 0} 245 | m_PrefabAsset: {fileID: 0} 246 | m_GameObject: {fileID: 123536679} 247 | m_Enabled: 1 248 | serializedVersion: 2 249 | m_ClearFlags: 1 250 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 251 | m_projectionMatrixMode: 1 252 | m_GateFitMode: 2 253 | m_FOVAxisMode: 0 254 | m_SensorSize: {x: 36, y: 24} 255 | m_LensShift: {x: 0, y: 0} 256 | m_FocalLength: 50 257 | m_NormalizedViewPortRect: 258 | serializedVersion: 2 259 | x: 0 260 | y: 0 261 | width: 1 262 | height: 1 263 | near clip plane: 0.3 264 | far clip plane: 1000 265 | field of view: 60 266 | orthographic: 1 267 | orthographic size: 5 268 | m_Depth: -1 269 | m_CullingMask: 270 | serializedVersion: 2 271 | m_Bits: 4294967295 272 | m_RenderingPath: -1 273 | m_TargetTexture: {fileID: 0} 274 | m_TargetDisplay: 0 275 | m_TargetEye: 3 276 | m_HDR: 1 277 | m_AllowMSAA: 1 278 | m_AllowDynamicResolution: 0 279 | m_ForceIntoRT: 0 280 | m_OcclusionCulling: 1 281 | m_StereoConvergence: 10 282 | m_StereoSeparation: 0.022 283 | --- !u!4 &123536682 284 | Transform: 285 | m_ObjectHideFlags: 0 286 | m_CorrespondingSourceObject: {fileID: 0} 287 | m_PrefabInstance: {fileID: 0} 288 | m_PrefabAsset: {fileID: 0} 289 | m_GameObject: {fileID: 123536679} 290 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 291 | m_LocalPosition: {x: 0, y: 0, z: -10} 292 | m_LocalScale: {x: 1, y: 1, z: 1} 293 | m_Children: [] 294 | m_Father: {fileID: 0} 295 | m_RootOrder: 0 296 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 297 | --- !u!1 &1253871085 298 | GameObject: 299 | m_ObjectHideFlags: 0 300 | m_CorrespondingSourceObject: {fileID: 0} 301 | m_PrefabInstance: {fileID: 0} 302 | m_PrefabAsset: {fileID: 0} 303 | serializedVersion: 6 304 | m_Component: 305 | - component: {fileID: 1253871086} 306 | - component: {fileID: 1253871089} 307 | - component: {fileID: 1253871088} 308 | - component: {fileID: 1253871087} 309 | - component: {fileID: 1253871090} 310 | m_Layer: 0 311 | m_Name: Canvas 312 | m_TagString: Untagged 313 | m_Icon: {fileID: 0} 314 | m_NavMeshLayer: 0 315 | m_StaticEditorFlags: 0 316 | m_IsActive: 1 317 | --- !u!224 &1253871086 318 | RectTransform: 319 | m_ObjectHideFlags: 0 320 | m_CorrespondingSourceObject: {fileID: 0} 321 | m_PrefabInstance: {fileID: 0} 322 | m_PrefabAsset: {fileID: 0} 323 | m_GameObject: {fileID: 1253871085} 324 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 325 | m_LocalPosition: {x: 0, y: 0, z: 5121.5} 326 | m_LocalScale: {x: 0.0295858, y: 0.0295858, z: 0.0295858} 327 | m_Children: [] 328 | m_Father: {fileID: 23841967} 329 | m_RootOrder: 0 330 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 331 | m_AnchorMin: {x: 0, y: 0} 332 | m_AnchorMax: {x: 0, y: 0} 333 | m_AnchoredPosition: {x: 166.95186, y: -85.481} 334 | m_SizeDelta: {x: 868.99994, y: 0} 335 | m_Pivot: {x: 0.5, y: 0.5} 336 | --- !u!114 &1253871087 337 | MonoBehaviour: 338 | m_ObjectHideFlags: 0 339 | m_CorrespondingSourceObject: {fileID: 0} 340 | m_PrefabInstance: {fileID: 0} 341 | m_PrefabAsset: {fileID: 0} 342 | m_GameObject: {fileID: 1253871085} 343 | m_Enabled: 0 344 | m_EditorHideFlags: 0 345 | m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} 346 | m_Name: 347 | m_EditorClassIdentifier: 348 | m_IgnoreReversedGraphics: 1 349 | m_BlockingObjects: 0 350 | m_BlockingMask: 351 | serializedVersion: 2 352 | m_Bits: 4294967295 353 | --- !u!114 &1253871088 354 | MonoBehaviour: 355 | m_ObjectHideFlags: 0 356 | m_CorrespondingSourceObject: {fileID: 0} 357 | m_PrefabInstance: {fileID: 0} 358 | m_PrefabAsset: {fileID: 0} 359 | m_GameObject: {fileID: 1253871085} 360 | m_Enabled: 1 361 | m_EditorHideFlags: 0 362 | m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} 363 | m_Name: 364 | m_EditorClassIdentifier: 365 | m_UiScaleMode: 0 366 | m_ReferencePixelsPerUnit: 100 367 | m_ScaleFactor: 1 368 | m_ReferenceResolution: {x: 800, y: 600} 369 | m_ScreenMatchMode: 0 370 | m_MatchWidthOrHeight: 0 371 | m_PhysicalUnit: 3 372 | m_FallbackScreenDPI: 96 373 | m_DefaultSpriteDPI: 96 374 | m_DynamicPixelsPerUnit: 1 375 | --- !u!223 &1253871089 376 | Canvas: 377 | m_ObjectHideFlags: 0 378 | m_CorrespondingSourceObject: {fileID: 0} 379 | m_PrefabInstance: {fileID: 0} 380 | m_PrefabAsset: {fileID: 0} 381 | m_GameObject: {fileID: 1253871085} 382 | m_Enabled: 1 383 | serializedVersion: 3 384 | m_RenderMode: 1 385 | m_Camera: {fileID: 123536681} 386 | m_PlaneDistance: 100 387 | m_PixelPerfect: 0 388 | m_ReceivesEvents: 1 389 | m_OverrideSorting: 0 390 | m_OverridePixelPerfect: 0 391 | m_SortingBucketNormalizedSize: 0 392 | m_AdditionalShaderChannelsFlag: 0 393 | m_SortingLayerID: 0 394 | m_SortingOrder: 0 395 | m_TargetDisplay: 1 396 | --- !u!114 &1253871090 397 | MonoBehaviour: 398 | m_ObjectHideFlags: 0 399 | m_CorrespondingSourceObject: {fileID: 0} 400 | m_PrefabInstance: {fileID: 0} 401 | m_PrefabAsset: {fileID: 0} 402 | m_GameObject: {fileID: 1253871085} 403 | m_Enabled: 1 404 | m_EditorHideFlags: 0 405 | m_Script: {fileID: 11500000, guid: 86710e43de46f6f4bac7c8e50813a599, type: 3} 406 | m_Name: 407 | m_EditorClassIdentifier: 408 | m_AspectMode: 1 409 | m_AspectRatio: 2 410 | --- !u!1 &1347277838 411 | GameObject: 412 | m_ObjectHideFlags: 0 413 | m_CorrespondingSourceObject: {fileID: 0} 414 | m_PrefabInstance: {fileID: 0} 415 | m_PrefabAsset: {fileID: 0} 416 | serializedVersion: 6 417 | m_Component: 418 | - component: {fileID: 1347277841} 419 | - component: {fileID: 1347277840} 420 | - component: {fileID: 1347277839} 421 | m_Layer: 0 422 | m_Name: EventSystem 423 | m_TagString: Untagged 424 | m_Icon: {fileID: 0} 425 | m_NavMeshLayer: 0 426 | m_StaticEditorFlags: 0 427 | m_IsActive: 1 428 | --- !u!114 &1347277839 429 | MonoBehaviour: 430 | m_ObjectHideFlags: 0 431 | m_CorrespondingSourceObject: {fileID: 0} 432 | m_PrefabInstance: {fileID: 0} 433 | m_PrefabAsset: {fileID: 0} 434 | m_GameObject: {fileID: 1347277838} 435 | m_Enabled: 1 436 | m_EditorHideFlags: 0 437 | m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} 438 | m_Name: 439 | m_EditorClassIdentifier: 440 | m_HorizontalAxis: Horizontal 441 | m_VerticalAxis: Vertical 442 | m_SubmitButton: Submit 443 | m_CancelButton: Cancel 444 | m_InputActionsPerSecond: 10 445 | m_RepeatDelay: 0.5 446 | m_ForceModuleActive: 0 447 | --- !u!114 &1347277840 448 | MonoBehaviour: 449 | m_ObjectHideFlags: 0 450 | m_CorrespondingSourceObject: {fileID: 0} 451 | m_PrefabInstance: {fileID: 0} 452 | m_PrefabAsset: {fileID: 0} 453 | m_GameObject: {fileID: 1347277838} 454 | m_Enabled: 1 455 | m_EditorHideFlags: 0 456 | m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} 457 | m_Name: 458 | m_EditorClassIdentifier: 459 | m_FirstSelected: {fileID: 0} 460 | m_sendNavigationEvents: 1 461 | m_DragThreshold: 10 462 | --- !u!4 &1347277841 463 | Transform: 464 | m_ObjectHideFlags: 0 465 | m_CorrespondingSourceObject: {fileID: 0} 466 | m_PrefabInstance: {fileID: 0} 467 | m_PrefabAsset: {fileID: 0} 468 | m_GameObject: {fileID: 1347277838} 469 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 470 | m_LocalPosition: {x: 0, y: 0, z: 0} 471 | m_LocalScale: {x: 1, y: 1, z: 1} 472 | m_Children: [] 473 | m_Father: {fileID: 0} 474 | m_RootOrder: 2 475 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 476 | -------------------------------------------------------------------------------- /Assets/Simple Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aba02fdd321d8614eba42a30603300b2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | NightDriverUnity 2 | ================ 3 | 4 | The NightDriveUnity project is really a "demo" of how to create a server application, in this case using C# and Unity, to drive [NightDriverStrip](https://github.com/PlummersSoftwareLLC/NightDriverStrip) instances remotely by WiFi. 5 | 6 | You are welcome and encouraged to party and adapt this code as needed. My hope for this little project is that it can grow into something useful for people, enabling them to write LED control code in Unity rather than more complex environments. 7 | 8 | Adding more demos of how to do things (signs, candles, flames, etc) would be a great way to flesh this project out further. 9 | 10 | The one issue I've run into with Unity is that when it does not have the focus, your app will not run reliably in the background. I would be very indebted to anyone who can figure that one out! 11 | 12 | -------------------------------------------------------------------------------- /COPYING.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NightDriverUnity 2 | Davepl, 9/19/2021 3 | 4 | See [Discussions](https://github.com/PlummersSoftwareLLC/NightDriverUnity/discussions) for questions and comments. 5 | See source code and [COPYING.txt](COPYING.txt) for detailed technical and licensing information including versions. 6 | 7 | ## What NightDriverUnity is: 8 | NightDriverUnity is a set of scripts for Unity that you can attach to a standard `VideoPlayer` object. You then set the IP address, dimensions, and framerate and when you press play the video in question will be streamed to the [NightDriverStrip](https://github.com/PlummersSoftwareLLC/NightDriverStrip) located at that IP address. 9 | 10 | To create a suitable client for sending data, use the NightDriverStrip's SPECTRUM config, with the following changes: 11 | ```cpp 12 | #define ENABLE_WIFI 1 // Connect to WiFi 13 | #define INCOMING_WIFI_ENABLED 1 // Accepting incoming color data and commands 14 | #define WAIT_FOR_WIFI 1 // Hold in setup until we have WiFi - for strips without effects 15 | #define TIME_BEFORE_LOCAL 2 // How many seconds before the lamp times out and shows local content 16 | #define ENABLE_WEBSERVER 1 // Turn on the internal webserver 17 | #define ENABLE_NTP 1 // Set the clock from the web 18 | #define ENABLE_OTA 0 // Accept over the air flash updates 19 | #define ENABLE_REMOTE 1 // IR Remote Control 20 | #define ENABLE_AUDIO 1 // Listen for audio from the microphone and process it 21 | ``` 22 | I also recommmend that you set 23 | ```cpp 24 | #define INCOMING_CORE 0 25 | #define MAX_BUFFERS 30 26 | ``` 27 | 28 | Construct a display consisting of three 16x16 matrixes in series, and connect them to PIN5 of an M5 ESP32 stick. Set your WiFi credentials in `globals.h`, and when run, the client should get (and display) an IP address. Use this IP in Unity on the `LEDSignController` object. With that set you should be able to click Play and have PACMAN scroll across your LED display. 29 | 30 | Open the Unity project (likely in a 2019 version of Unity or later) and open the Simple Demo scene. Right next to Main Camera is a Game Object to which is attached the Video Player and the LED Sign Controller that you are concerned with. 31 | 32 | Good luck! 33 | --------------------------------------------------------------------------------