/// <summary> /// Creates controllers to skin each geometry in the collada file /// </summary> void CreateControllerList() { H1.Tags.gbxmodel_group definition = tagManager.TagDefinition as H1.Tags.gbxmodel_group; // if there are no nodes then no skinning is possible if (definition.Nodes.Count == 0) { return; } // create a controller for each geometry for (int i = 0; i < modelInfo.GetGeometryCount(); i++) { List <VertexWeight> vertex_weights = new List <VertexWeight>(); // create a list of vertex weights from all of the geometry parts foreach (var part in definition.Geometries[modelInfo.GetGeometryIndex(i)].Parts) { foreach (var vertex in part.UncompressedVertices) { VertexWeight vertex_weight = new VertexWeight(); int node1 = vertex.NodeIndex1; int node2 = vertex.NodeIndex2; // if the bone index count is 0 then the index references the main node list, // otherwise it references a local node map for this part if (part.NodeMapCount != 0) { node1 = part.NodeMap[node1]; node2 = (node2 != -1 ? part.NodeMap[node2].Value : node2); } vertex_weight.AddWeight(node1, vertex.NodeWeight1); // if the first weight is 1 the vertex is weighted to one bone only so the second weight is not needed if (vertex.NodeWeight1 != 1) { vertex_weight.AddWeight(node2, vertex.NodeWeight2); } vertex_weights.Add(vertex_weight); } } // create the controller element CreateSkinController(listGeometry[i].ID, vertex_weights); } }
/// <summary> /// Creates a controller to skin each geometry in the file /// </summary> void CreateControllerList() { H2.Tags.render_model_group definition = tagManager.TagDefinition as H2.Tags.render_model_group; // if there are no bones then skinning isnt necessary if (definition.Nodes.Count == 0) { return; } // create a controller for each geometry in modelInfo for (int i = 0; i < modelInfo.GetGeometryCount(); i++) { H2.Tags.render_model_section_block.render_model_section_data_block section_block = definition.Sections[modelInfo.GetGeometryIndex(i)].SectionData[0]; // the node map contains a list of bone indices that the section is rigged to List <int> node_map = new List <int>(); foreach (var node in section_block.NodeMap) { node_map.Add(node.NodeIndex.Value); } List <VertexWeight> vertex_weights = new List <VertexWeight>(); // create a generic list of vertex weights foreach (var vertex in section_block.Section.Value.RawVertices) { VertexWeight common_weight = new VertexWeight(); // only add the weights with valid nodes for (int weight_index = 0; (weight_index < vertex.Point.NodeIndex.Length) && (vertex.Point.NodeIndex[weight_index] != -1); weight_index++) { common_weight.AddWeight(node_map[vertex.Point.NodeIndex[weight_index]], vertex.Point.NodeWeight[weight_index]); } vertex_weights.Add(common_weight); } // create the controller element CreateSkinController(listGeometry[i].ID, vertex_weights); } }
/// <summary> /// Creates controllers to skin each geometry in the collada file /// </summary> void CreateControllerList() { H1.Tags.gbxmodel_group definition = tagManager.TagDefinition as H1.Tags.gbxmodel_group; // if there are no nodes then no skinning is possible if (definition.Nodes.Count == 0) return; // create a controller for each geometry for (int i = 0; i < modelInfo.GetGeometryCount(); i++) { List<VertexWeight> vertex_weights = new List<VertexWeight>(); // create a list of vertex weights from all of the geometry parts foreach (var part in definition.Geometries[modelInfo.GetGeometryIndex(i)].Parts) { foreach (var vertex in part.UncompressedVertices) { VertexWeight vertex_weight = new VertexWeight(); int node1 = vertex.NodeIndex1; int node2 = vertex.NodeIndex2; // if the bone index count is 0 then the index references the main node list, // otherwise it references a local node map for this part if (part.NodeMapCount != 0) { node1 = part.NodeMap[node1]; node2 = (node2 != -1 ? part.NodeMap[node2].Value : node2); } vertex_weight.AddWeight(node1, vertex.NodeWeight1); // if the first weight is 1 the vertex is weighted to one bone only so the second weight is not needed if(vertex.NodeWeight1 != 1) vertex_weight.AddWeight(node2, vertex.NodeWeight2); vertex_weights.Add(vertex_weight); } } // create the controller element CreateSkinController(listGeometry[i].ID, vertex_weights); } }
/// <summary> /// Creates a controller to skin each geometry in the file /// </summary> void CreateControllerList() { H2.Tags.render_model_group definition = tagManager.TagDefinition as H2.Tags.render_model_group; // if there are no bones then skinning isnt necessary if (definition.Nodes.Count == 0) return; // create a controller for each geometry in modelInfo for (int i = 0; i < modelInfo.GetGeometryCount(); i++) { H2.Tags.render_model_section_block.render_model_section_data_block section_block = definition.Sections[modelInfo.GetGeometryIndex(i)].SectionData[0]; // the node map contains a list of bone indices that the section is rigged to List<int> node_map = new List<int>(); foreach (var node in section_block.NodeMap) node_map.Add(node.NodeIndex.Value); List<VertexWeight> vertex_weights = new List<VertexWeight>(); // create a generic list of vertex weights foreach(var vertex in section_block.Section.Value.RawVertices) { VertexWeight common_weight = new VertexWeight(); // only add the weights with valid nodes for(int weight_index = 0; (weight_index < vertex.Point.NodeIndex.Length) && (vertex.Point.NodeIndex[weight_index] != -1); weight_index++) common_weight.AddWeight(node_map[vertex.Point.NodeIndex[weight_index]], vertex.Point.NodeWeight[weight_index]); vertex_weights.Add(common_weight); } // create the controller element CreateSkinController(listGeometry[i].ID, vertex_weights); } }