/// <summary> /// Parses the mesh data from the current data segment. /// </summary> /// <param name="dataSegment"> /// Contains the data to be parsed. /// </param> protected void ParseMeshData(DataReader3DS dataSegment) { string name = dataSegment.GetString(); // mesh object name DataReader3DS subSegment = dataSegment.GetNextSubSegment(); // working subsegment this.currentMeshData = new MeshData3DS(); this.currentMeshData.Name = name; while (subSegment != null) { switch (subSegment.Tag) { case 0x4100: // Current subsegment contains the polygonal information this.ParsePolygonalData(subSegment); break; default: // Ignore all other subsegment types break; } subSegment = dataSegment.GetNextSubSegment(); } while (this.meshDataStore.ContainsKey(this.currentMeshData.Name)) { this.currentMeshData.Name += "X"; } this.meshDataStore.Add(this.currentMeshData.Name, this.currentMeshData); }
/// <summary> /// Parses the material data from the current data segment. /// </summary> /// <param name="dataSegment"> /// Contains the data to be parsed. /// </param> protected void ParseMaterialData(DataReader3DS dataSegment) { DataReader3DS subSegment = dataSegment.GetNextSubSegment(); this.currentMaterialData = new MaterialData3DS(); while (subSegment != null) { switch (subSegment.Tag) { case 0xa000: // Subsegment holds material name this.currentMaterialData.name = subSegment.GetString(); Console.WriteLine("Material is named: " + this.currentMaterialData.name); break; case 0xa010: // Subsegment holds ambient color this.currentMaterialData.ambient = this.ParseColorData(subSegment.GetNextSubSegment()); break; case 0xa020: // Subsegment holds diffuse color (this is iffy...) this.currentMaterialData.diffuse = this.ParseColorData(subSegment.GetNextSubSegment()); break; case 0xa200: // Subsegment holds texture map info this.ParseTextureWeight(subSegment.GetNextSubSegment()); this.currentMaterialData.textureName = subSegment.GetNextSubSegment().GetString(); break; default: // Ignore all other subsegment types break; } subSegment = dataSegment.GetNextSubSegment(); } // Store newly created material in data store and change name if another exists with its name while (this.materialDataStore.ContainsKey(this.currentMaterialData.name)) { this.currentMaterialData.name += "X"; } this.materialDataStore.Add(this.currentMaterialData.name, this.currentMaterialData); }
/// <summary> /// Parses the mesh data from the current data segment. /// </summary> /// <param name="dataSegment"> /// Contains the data to be parsed. /// </param> protected void ParseMeshData(DataReader3DS dataSegment) { string name = dataSegment.GetString(); // mesh object name DataReader3DS subSegment = dataSegment.GetNextSubSegment(); // working subsegment this.currentMeshData = new MeshData3DS(); this.currentMeshData.Name = name; while (subSegment != null) { switch (subSegment.Tag) { case 0x4100: // Current subsegment contains the polygonal information this.ParsePolygonalData(subSegment); break; default: // Ignore all other subsegment types break; } subSegment = dataSegment.GetNextSubSegment(); } while (this.meshDataStore.ContainsKey(this.currentMeshData.Name)) { this.currentMeshData.Name += "X"; } this.meshDataStore.Add(this.currentMeshData.Name, this.currentMeshData); }