//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Adds the scenarios objects as child jobs. </summary> /// /// <param name="scenarioData"> Information describing the scenario. </param> /// <param name="objectType"> Type of the object. </param> private void AddChildJobs(ScenarioData scenarioData, TypeEnums.ObjectType objectType) { foreach (var scenarioObjectType in scenarioData.ScenarioObjectLists[objectType]) { // Get the model tag if (!BlamLib.Managers.TagIndex.IsValid(scenarioObjectType.ObjectTagDatum)) { mMessageHandler.SendMessage("Failed to open {0}, child job not added", Path.GetFileName(scenarioObjectType.ObjectTagPath)); continue; } var objectData = new ObjectData(); objectData.CollectData(TagIndex, TagIndex[scenarioObjectType.ObjectTagDatum]); // If no model was set don't continue if (objectData.Model.IsNull) { continue; } if (!BlamLib.Managers.TagIndex.IsValid(objectData.Model)) { mMessageHandler.SendMessage("Failed to open model tag for {0}, child job not added", Path.GetFileName(scenarioObjectType.ObjectTagPath)); continue; } // Add an extraction job for the model tag var modelTagManager = TagIndex[objectData.Model]; var modelFile = Path.Combine(mModelExtractionData.TagsDirectory.Root , mModelExtractionData.TagsDirectory.EndFolder , modelTagManager.Name); modelFile = Path.ChangeExtension(modelFile, "gbxmodel"); mModelExtractionData.JobInterface.AddJob(modelFile, mExtractionData); } }
private List <string> GetNodeReferences(ScenarioData.ScenarioObject objectType, string permutation) { var nodeIds = new List <string>(); // Add geometry instances to the node if (!TagIndex.IsValid(objectType.ObjectTagDatum)) { throw new ColladaException("Failed to load the object type tag {0}", objectType.ObjectTagPath); } var objectName = Path.GetFileNameWithoutExtension(objectType.ObjectTagPath); objectName += "-perm" + permutation; // Collect data about the object var objectData = new ObjectData(); objectData.CollectData(mTagIndex, mTagIndex[objectType.ObjectTagDatum]); if (!TagIndex.IsValid(objectData.Model)) { return(nodeIds); } if (COLLADAFile.LibraryNodes == null) { AddLibraryNodes(); } // Collect data about the model var modelData = new ModelData(); modelData.CollectData(mTagIndex, mTagIndex[objectData.Model]); // Get all of the geometries that make up the permutation at the highest lod var geometryList = modelData.GetGeometries(permutation, Blam.Halo1.TypeEnums.LevelOfDetailEnum.SuperHigh); // Add geometry instances for all geometries foreach (var geometrySet in geometryList) { var name = objectName + "-" + geometrySet.Name; ColladaNCName nodeName = name; ColladaID <ColladaNode> nodeId = name; nodeIds.Add(nodeId); if (COLLADAFile.LibraryNodes.Node.Exists(node => node.ID == nodeId.ToString())) { break; } // Create shader references for all shaders used by the geometry var materialReferences = new MaterialReferenceList(); foreach (var shader in geometrySet.Shaders) { ColladaNCName symbolName = shader.MaterialName; ColladaID <Fx.ColladaMaterial> shaderName = shader.MaterialName; var url = ColladaUtilities.BuildExternalReference(modelData, colladaSettings.RootDirectory, shaderName); materialReferences.Add(new MaterialReference(shaderName, url, symbolName)); } // Build the geometry reference URL and add the geometry instance string geometryURL = ColladaUtilities.BuildExternalReference(modelData, colladaSettings.RootDirectory, new ColladaID <Core.ColladaGeometry>(geometrySet.Name)); var nodeType = CreateNode(nodeName, "", nodeId, Enums.ColladaNodeType.NODE); nodeType.Add(CreateInstanceGeometry(geometryURL, geometrySet.Name, materialReferences)); COLLADAFile.LibraryNodes.Node.Add(nodeType); } return(nodeIds); }
private List<string> GetNodeReferences(ScenarioData.ScenarioObject objectType, string permutation) { var nodeIds = new List<string>(); // Add geometry instances to the node if (!TagIndex.IsValid(objectType.ObjectTagDatum)) { throw new ColladaException("Failed to load the object type tag {0}", objectType.ObjectTagPath); } var objectName = Path.GetFileNameWithoutExtension(objectType.ObjectTagPath); objectName += "-perm" + permutation; // Collect data about the object var objectData = new ObjectData(); objectData.CollectData(mTagIndex, mTagIndex[objectType.ObjectTagDatum]); if (!TagIndex.IsValid(objectData.Model)) { return nodeIds; } if(COLLADAFile.LibraryNodes == null) { AddLibraryNodes(); } // Collect data about the model var modelData = new ModelData(); modelData.CollectData(mTagIndex, mTagIndex[objectData.Model]); // Get all of the geometries that make up the permutation at the highest lod var geometryList = modelData.GetGeometries(permutation, Blam.Halo1.TypeEnums.LevelOfDetailEnum.SuperHigh); // Add geometry instances for all geometries foreach(var geometrySet in geometryList) { var name = objectName + "-" + geometrySet.Name; ColladaNCName nodeName = name; ColladaID<ColladaNode> nodeId = name; nodeIds.Add(nodeId); if (COLLADAFile.LibraryNodes.Node.Exists(node => node.ID == nodeId.ToString())) { break; } // Create shader references for all shaders used by the geometry var materialReferences = new MaterialReferenceList(); foreach (var shader in geometrySet.Shaders) { ColladaNCName symbolName = shader.MaterialName; ColladaID<Fx.ColladaMaterial> shaderName = shader.MaterialName; var url = ColladaUtilities.BuildExternalReference(modelData, colladaSettings.RootDirectory, shaderName); materialReferences.Add(new MaterialReference(shaderName, url, symbolName)); } // Build the geometry reference URL and add the geometry instance string geometryURL = ColladaUtilities.BuildExternalReference(modelData, colladaSettings.RootDirectory, new ColladaID<Core.ColladaGeometry>(geometrySet.Name)); var nodeType = CreateNode(nodeName, "", nodeId, Enums.ColladaNodeType.NODE); nodeType.Add(CreateInstanceGeometry(geometryURL, geometrySet.Name, materialReferences)); COLLADAFile.LibraryNodes.Node.Add(nodeType); } return nodeIds; }