public void SetSoundMaterial(uint index, SurfaceTypes soundMaterial) { if (index == 0u) { this.mSurfaceType = soundMaterial; } }
public StandingsItem() { driver = new DriverInfo(); laps = new List <LapInfo>(); fastestlap = 0; lapsled = 0; classlapsled = 0; currentTrackSurface = prevTrackSurface = SurfaceTypes.NotInWorld; trackpct = 0; prevtrackpct = 0; prevtrackpctupdate = 0; speed = 0; prevspeed = 0; position = 0; currentlap = new LapInfo(); sector = 0; sectorbegin = 0; pitstops = 0; pitstoptime = 0; pitstorbegin = DateTime.MinValue; begin = 0; finished = false; offtracksince = 0; positionlive = 0; }
public StandingsItem() { driver = new DriverInfo(); laps = new List<LapInfo>(); fastestlap = 0; lapsled = 0; classlapsled = 0; currentTrackSurface = prevTrackSurface = SurfaceTypes.NotInWorld; trackpct = 0; prevtrackpct = 0; prevtrackpctupdate = 0; speed = 0; prevspeed = 0; position = 0; currentlap = new LapInfo(); sector = 0; sectorbegin = 0; pitstops = 0; pitstoptime = 0; pitstorbegin = DateTime.MinValue; begin = 0; finished = false; offtracksince = 0; positionlive = 0; }
public static Material GetMaterial( ShapeDescriptor shapeDescriptor, short transferMode, bool isOpaqueSurface, SurfaceTypes surfaceType, bool incrementUsageCounter) { if (!shapeDescriptor.IsEmpty()) { if (TextureUsageCounter.ContainsKey(shapeDescriptor)) { if (incrementUsageCounter) { TextureUsageCounter[shapeDescriptor]++; } } else { TextureUsageCounter[shapeDescriptor] = 1; } var landscapeTransferMode = transferMode == 9 || shapeDescriptor.UsesLandscapeCollection(); return(GetTrackedMaterial(shapeDescriptor, landscapeTransferMode, isOpaqueSurface, surfaceType)); } else { return(UnassignedMaterial); } }
public static int GetTextureArrayIndex( ShapeDescriptor shapeDescriptor, short transferMode, bool isOpaqueSurface, SurfaceTypes surfaceType) { if (shapeDescriptor.IsEmpty()) { return(0); } var landscapeTransferMode = transferMode == 9 || shapeDescriptor.UsesLandscapeCollection(); var collectionKey = GetTexture2DArrayKeyDictionary( shapeDescriptor, landscapeTransferMode: landscapeTransferMode, isOpaqueSurface: isOpaqueSurface, surfaceType) [shapeDescriptor]; var collection = Texture2DArrays[collectionKey]; return(collection.GetBitmapIndex(shapeDescriptor)); }
private Scene GetSceneAsync(Scene previousScene) { Scene scene = null; if (Application.isEditor && ShouldLoadFromFile) { if (sceneBytes == null) { Debug.LogError("sceneBytes is null!"); } // Move onto a background thread for the expensive scene loading stuff if (UsePersistentObjects && previousScene != null) { scene = Scene.Deserialize(sceneBytes, previousScene); } else { // This happens first time through as we have no history yet scene = Scene.Deserialize(sceneBytes); } } else { SceneQuerySettings sceneQuerySettings = new SceneQuerySettings() { EnableSceneObjectQuads = RequestPlaneData, EnableSceneObjectMeshes = RequestMeshData, EnableOnlyObservedSceneObjects = !InferRegions, EnableWorldMesh = SurfaceTypes.HasFlag(SpatialAwarenessSurfaceTypes.World), RequestedMeshLevelOfDetail = LevelOfDetailToMeshLOD(WorldMeshLevelOfDetail) }; // Ideally you'd call SceneObserver.ComputeAsync() like this: // scene = await SceneObserver.ComputeAsync(...); // however this has has been problematic (buggy?) // For the time being we force it to be synchronous with the ...GetAwaiter().GetResult() pattern if (UsePersistentObjects) { if (previousScene != null) { scene = SceneObserver.ComputeAsync(sceneQuerySettings, QueryRadius, previousScene).GetAwaiter().GetResult(); } else { // first time through, we have no history scene = SceneObserver.ComputeAsync(sceneQuerySettings, QueryRadius).GetAwaiter().GetResult(); } } else { scene = SceneObserver.ComputeAsync(sceneQuerySettings, QueryRadius).GetAwaiter().GetResult(); } } return(scene); }
public SurfaceSettings GetSurfaceSettings(SurfaceTypes type) { if (database == null) { Initialize(); } return(database[type]); }
public void Clear() { name = ""; surfaceType = SurfaceTypes.Blank; constructionName = ""; outsideBoundary = OutsideBoundary.Blank; zoneName = ""; sunExposureVar = ""; windExposureVar = ""; numVertices = 0; SurfaceCoords.Clear(); }
public Sprite GetSurface(string tagName, SurfaceTypes type) { // Loop through the collection of the specified type. for (int i = 0; i < this._surface[(int)type].Count; i++) { // If the surface tag name is equal to the tag name specified, return the surface. if (this._surface[(int)type][i].Tag == tagName?.ToLower()) { return(this._surface[(int)type][i].Sprite); } } // Return null if we couldn't find a surface with the tag specified. return(null); }
private int GetSurfaceIndex(string tagName, SurfaceTypes type) { // Loop through the collection of the specified type. for (int i = 0; i < this._surface[(int)type].Count; i++) { // If the surface tag name is equal to the tag name specified, return the surface. if (this._surface[(int)type][i].Tag == tagName.ToLower()) { return(i); } } // Return -1 if we couldn't find a surface with the tag specified. return(-1); }
private List <SceneObject> FilterSelectedSurfaceTypes(IReadOnlyList <SceneObject> newObjects) { filteredSelectedSurfaceTypesResult.Clear(); int count = newObjects.Count; for (int i = 0; i < count; ++i) { if (!SurfaceTypes.HasFlag(SpatialAwarenessSurfaceType(newObjects[i].Kind))) { continue; } filteredSelectedSurfaceTypesResult.Add(newObjects[i]); } return(filteredSelectedSurfaceTypesResult); }
public MemorySafe_Surface(string name, int multiplier, SurfaceTypes surfaceType, string constName, OutsideBoundary ob, string zoneName, string outsideBC, string sunExp, string windExp, double vF, int numVert, List <Vector.MemorySafe_CartCoord> sC, double tilt, double az) { _name = name; _multiplier = multiplier; _surfaceType = surfaceType; _constructioName = constName; _outsideBoundary = ob; _zoneName = zoneName; _outsideBoundaryCondition = outsideBC; _sunExposureVar = sunExp; _windExposureVar = windExp; _viewFactor = vF; _numVertices = numVert; _SurfaceCoords = sC; _tilt = tilt; _azimuth = az; }
private void CheckTextureIsReadable() { _isReadable = true; if (_material == null) { return; } #if !UNITY_2017_3_OR_NEWER if (_material is ProceduralMaterial) { _type = SurfaceTypes.Substance; } else { _type = SurfaceTypes.Material; } if (_type == SurfaceTypes.Substance) { return; } #endif #if UNITY_EDITOR Texture texture = material.mainTexture; if (texture == null) { _isReadable = false; return; } string texturePath = UnityEditor.AssetDatabase.GetAssetPath(texture); UnityEditor.TextureImporter textureImporter = (UnityEditor.TextureImporter)UnityEditor.AssetImporter.GetAtPath(texturePath); if (textureImporter == null) { _isReadable = false; return; } if (!textureImporter.isReadable) { _isReadable = false; } #endif }
private static Dictionary <ShapeDescriptor, Texture2DArrayCollectionKey> GetTexture2DArrayKeyDictionary( ShapeDescriptor shapeDescriptor, bool landscapeTransferMode, bool isOpaqueSurface, SurfaceTypes surfaceType) { // TODO: where textures are -first- loaded, populate a Dictionary<ShapeDescriptor, TextureFormat> // so this can be looked up without loading a texture (important for NO_EDITING) var textureToUse = GetTexture(shapeDescriptor, returnPlaceholderIfNotFound: true); if (surfaceType == SurfaceTypes.Media) { return(MediaTexture2DArrayKeys); } else if (landscapeTransferMode) { return(LandscapeTexture2DArrayKeys); } else { if (isOpaqueSurface || textureToUse.format != TextureFormat.ARGB32) { return(Texture2DArrayKeys); } else { if (surfaceType == SurfaceTypes.LayeredTransparentOuter) { return(TransparentLayeredOuterTexture2DArrayKeys); } else { return(TransparentTexture2DArrayKeys); } } } }
private void ReportCollision(Collision collision) { if (NetGame.isClient || ReplayRecorder.isPlaying || collision.contacts.Length == 0) { return; } float time = Time.time; if (nextSoundTime > time || collision.relativeVelocity.magnitude < CollisionAudioEngine.instance.minVelocity || collision.impulse.magnitude < CollisionAudioEngine.instance.minImpulse) { return; } collision.Analyze(out Vector3 pos, out float impulse, out float normalVelocity, out float tangentVelocity, out PhysicMaterial mat, out PhysicMaterial mat2, out int id, out float volume, out float pitch); if (this.id < id) { SurfaceType surf = SurfaceTypes.Resolve(mat); SurfaceType surf2 = SurfaceTypes.Resolve(mat2); if (ReportCollision(surf, surf2, pos, impulse, normalVelocity, tangentVelocity, this.volume * volume, this.pitch * pitch)) { nextSoundTime = time + Random.Range(0.5f, 1.5f) * CollisionAudioEngine.instance.hitDelay; } } }
public void Clear() { name = ""; surfaceType = SurfaceTypes.Blank; constructionName = ""; outsideBoundary = OutsideBoundary.Blank; zoneName = ""; sunExposureVar = ""; windExposureVar = ""; numVertices = 0; SurfaceCoords.Clear(); }
public MemorySafe_Surface(string name, int multiplier, SurfaceTypes surfaceType, string constName, OutsideBoundary ob, string zoneName, string outsideBC, string sunExp, string windExp, double vF, int numVert, List<MemorySafe_CartCoord> sC, double tilt, double az) { _name = name; _multiplier = multiplier; _surfaceType = surfaceType; _constructioName = constName; _outsideBoundary = ob; _zoneName = zoneName; _outsideBoundaryCondition = outsideBC; _sunExposureVar = sunExp; _windExposureVar = windExp; _viewFactor = vF; _numVertices = numVert; _SurfaceCoords = sC; _tilt = tilt; _azimuth = az; }
private static Material GetTrackedMaterial( ShapeDescriptor shapeDescriptor, bool landscapeTransferMode, bool isOpaqueSurface, SurfaceTypes surfaceType) { #if USE_TEXTURE_ARRAYS var collectionKeyDictionary = GetTexture2DArrayKeyDictionary( shapeDescriptor, landscapeTransferMode: landscapeTransferMode, isOpaqueSurface: isOpaqueSurface, surfaceType); if (collectionKeyDictionary.ContainsKey(shapeDescriptor)) { var collectionKey = collectionKeyDictionary[shapeDescriptor]; var texture2DArrayCollection = Texture2DArrays[collectionKey]; return(texture2DArrayCollection.SharedMaterial); } var texture2DArrayCollectionKey = new Texture2DArrayCollectionKey(shapeDescriptor, surfaceType == SurfaceTypes.Media); collectionKeyDictionary[shapeDescriptor] = texture2DArrayCollectionKey; if (Texture2DArrays.ContainsKey(texture2DArrayCollectionKey)) { var texture2DArrayCollection = Texture2DArrays[texture2DArrayCollectionKey]; texture2DArrayCollection.AddBitmap(shapeDescriptor); return(texture2DArrayCollection.SharedMaterial); } #endif var textureToUse = GetTexture(shapeDescriptor, returnPlaceholderIfNotFound: true); Material material; if (surfaceType == SurfaceTypes.Media) { #if USE_TEXTURE_ARRAYS material = new Material(MediaShader); #else material = GetTrackedMaterial(shapeDescriptor, textureToUse, MediaShader, MediaMaterials); #endif } else if (landscapeTransferMode) { #if USE_TEXTURE_ARRAYS material = new Material(OpaqueLandscapeShader); #else material = GetTrackedMaterial(shapeDescriptor, textureToUse, OpaqueLandscapeShader, LandscapeMaterials); #endif } else { if (isOpaqueSurface || textureToUse.format != TextureFormat.ARGB32) { #if USE_TEXTURE_ARRAYS material = new Material(OpaqueWithAlphaAlphaNormalShader); #else material = GetTrackedMaterial(shapeDescriptor, textureToUse, OpaqueWithAlphaAlphaNormalShader, Materials); #endif } else { if (surfaceType == SurfaceTypes.LayeredTransparentOuter) { #if USE_TEXTURE_ARRAYS material = new Material(TransparentNormalLayeredOuterShader); #else material = GetTrackedMaterial(shapeDescriptor, textureToUse, TransparentNormalLayeredOuterShader, TransparentLayeredOuterMaterials); #endif } else { #if USE_TEXTURE_ARRAYS material = new Material(TransparentNormalShader); #else material = GetTrackedMaterial(shapeDescriptor, textureToUse, TransparentNormalShader, TransparentMaterials); #endif } } } #if USE_TEXTURE_ARRAYS material.name = $"Collection({shapeDescriptor.Collection}) Bitmap({shapeDescriptor.Bitmap})"; material.enableInstancing = true; var newTexture2DArrayCollection = new Texture2DArrayCollection( shapeDescriptor, material, textureToUse.width, textureToUse.height, textureToUse.format, textureToUse.mipmapCount > 0); Texture2DArrays[texture2DArrayCollectionKey] = newTexture2DArrayCollection; #endif return(material); }
/// <summary> /// Exports the given asset from this pool /// </summary> public HydraStatus Export(GameAsset asset, HydraInstance instance) { var header = instance.Reader.ReadStruct <MaterialAsset>(asset.HeaderAddress); if (asset.Name != Path.GetFileNameWithoutExtension(instance.Reader.ReadNullTerminatedString(header.NamePointer).Split('|')[0])) { return(HydraStatus.MemoryChanged); } // We need the techset for buffer info var techset = instance.Reader.ReadStruct <MaterialTechniqueSet>(header.TechniquePointer); var mtlType = Path.GetFileNameWithoutExtension(instance.Reader.ReadNullTerminatedString(instance.Reader.ReadInt64(header.TechniquePointer)).Split('#')[0]); if (!instance.TechniqueSetCache.TryGetValue(mtlType, out var set)) { throw new ArgumentException("Unknown material type.", mtlType); } // Add base stuffs // Create asset var gdtAsset = new GameDataTable.Asset(asset.Name, "material"); // Set Default Properties gdtAsset.Properties.Add("surfaceType", SurfaceTypes.TryGetValue(BitConverter.ToUInt32(header.FlagsAndSettings, 28), out var surfaceType) ? surfaceType : "<none>"); gdtAsset.Properties.Add("template", "material.template"); gdtAsset.Properties.Add("materialCategory", set.Category); gdtAsset.Properties.Add("materialType", mtlType); gdtAsset.Properties.Add("textureAtlasRowCount", header.FlagsAndSettings[6].ToString()); gdtAsset.Properties.Add("textureAtlasColumnCount", header.FlagsAndSettings[7].ToString()); gdtAsset.Properties.Add("usage", "<not in editor>"); for (int i = 0; i < header.SettingsPointers.Length; i++) { if (header.SettingsPointers[i].SettingsPointer == 0) { continue; } var technique = instance.Reader.ReadStruct <MaterialTechnique>(techset.TechniquePointers[i]); var pass = instance.Reader.ReadStruct <MaterialTechniquePass>(technique.PassPointer); var settings = ParseDXBC(instance.Reader.ReadBytes(pass.ShaderPointer, pass.ShaderSize)); if (settings == null) { throw new ArgumentException("Failed to find $Globals in DirectX Byte Code RDEF part", "settings"); } var settingsInfo = instance.Reader.ReadStruct <MaterialSettingBuffer>(header.SettingsPointers[i].SettingsPointer); var settingsBuffer = instance.Reader.ReadBytes(settingsInfo.BufferPointer, (int)settingsInfo.Size); foreach (var setting in settings) { if (set.Settings.TryGetValue(setting.Key, out var gdtInfo)) { switch (gdtInfo.DataType) { case SettingDataType.Boolean: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { gdtAsset[gdtInfo.GDTSlotNames[0]] = (int)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor); } break; } case SettingDataType.UInt1: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { gdtAsset[gdtInfo.GDTSlotNames[0]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor); } break; } case SettingDataType.UInt2: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { gdtAsset[gdtInfo.GDTSlotNames[0]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[1])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 04), gdtInfo.PostProcessor); } break; } case SettingDataType.UInt3: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { gdtAsset[gdtInfo.GDTSlotNames[0]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[1])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 04), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[2])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 08), gdtInfo.PostProcessor); } break; } case SettingDataType.UInt4: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { gdtAsset[gdtInfo.GDTSlotNames[0]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[1])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 04), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[2])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 08), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[3])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = (uint)PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 12), gdtInfo.PostProcessor); } break; } case SettingDataType.Float1: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { gdtAsset[gdtInfo.GDTSlotNames[0]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor); } break; } case SettingDataType.Float2: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { gdtAsset[gdtInfo.GDTSlotNames[0]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[1])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 04), gdtInfo.PostProcessor); } break; } case SettingDataType.Float3: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { gdtAsset[gdtInfo.GDTSlotNames[0]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[1])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 04), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[2])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 08), gdtInfo.PostProcessor); } break; } case SettingDataType.Float4: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { gdtAsset[gdtInfo.GDTSlotNames[0]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[1])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 04), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[2])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 08), gdtInfo.PostProcessor); } if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[3])) { gdtAsset[gdtInfo.GDTSlotNames[1]] = PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 12), gdtInfo.PostProcessor); } break; } case SettingDataType.Color: { if (!gdtAsset.Properties.ContainsKey(gdtInfo.GDTSlotNames[0])) { var r = MathUtilities.Clamp(PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 00), gdtInfo.PostProcessor), 1.0, 0.0); var g = MathUtilities.Clamp(PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 04), gdtInfo.PostProcessor), 1.0, 0.0); var b = MathUtilities.Clamp(PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 08), gdtInfo.PostProcessor), 1.0, 0.0); var a = MathUtilities.Clamp(PerformPostProcess(BitConverter.ToSingle(settingsBuffer, setting.Value + 12), gdtInfo.PostProcessor), 1.0, 0.0); gdtAsset[gdtInfo.GDTSlotNames[0]] = string.Format("{0:0.000000} {1:0.000000} {2:0.000000} {3:0.000000}", r, g, b, a); } break; } } } } } for (int j = 0; j < header.Counts[0]; j++) { var materialImage = instance.Reader.ReadStruct <MaterialImage>(header.ImageTablePointer + (j * 0x20)); if (set.ImageSlots.TryGetValue(materialImage.SemanticHash, out string slot)) { gdtAsset.Properties[slot] = instance.Reader.ReadNullTerminatedString(instance.Reader.ReadInt64(materialImage.ImagePointer + 0xF8)); } } instance.GDTs["Misc"][asset.Name] = gdtAsset; return(HydraStatus.Success); }