/// <summary> /// Creates geometry elements for all of the included geometry blocks /// </summary> void CreateGeometryList() { H1.Tags.gbxmodel_group definition = tagManager.TagDefinition as H1.Tags.gbxmodel_group; // create a list contining the names of all the shaders being used List <string> shader_names = new List <string>(); foreach (var shader in definition.Shaders) { shader_names.Add(Path.GetFileNameWithoutExtension(shader.Shader.ToString())); } for (int i = 0; i < modelInfo.GetGeometryCount(); i++) { string name = ColladaUtilities.FormatName(modelInfo.GetGeometryName(i), " ", "_"); List <Vertex> common_vertices = new List <Vertex>(); H1.Tags.gbxmodel_group.model_geometry_block geometry = definition.Geometries[modelInfo.GetGeometryIndex(i)]; // collect the vertices for all of the geometries parts foreach (var part in geometry.Parts) { foreach (var vertex in part.UncompressedVertices) { Vertex common_vertex = new Vertex(vertex.Position.ToPoint3D(100), vertex.Normal.ToVector3D(), vertex.Binormal.ToVector3D(), vertex.Tangent.ToVector3D()); // if the texture coordinate scale is 0.0, default to 1.0 float u_scale = (definition.BaseMapUScale.Value == 0.0f ? 1.0f : definition.BaseMapUScale.Value); float v_scale = (definition.BaseMapVScale.Value == 0.0f ? 1.0f : definition.BaseMapVScale.Value); // add the texture coordinate data common_vertex.AddTexcoord(new LowLevel.Math.real_point2d( vertex.TextureCoords.X * u_scale, ((vertex.TextureCoords.Y * v_scale) * -1) + 1)); common_vertices.Add(common_vertex); } } List <Part> common_parts = new List <Part>(); // create a new Part for each geometry part int index_offset = 0; foreach (var part in geometry.Parts) { Part common_part = new Part(shader_names[part.ShaderIndex]); common_part.AddIndices(CreateIndicesModel(part, index_offset)); index_offset += part.UncompressedVertices.Count; common_parts.Add(common_part); } // create the geometry element CreateGeometry(name, 1, VertexComponent.POSITION | VertexComponent.NORMAL | VertexComponent.BINORMAL | VertexComponent.TANGENT | VertexComponent.TEXCOORD, common_vertices, common_parts); } }