void LoadModel(string fileName) { Cursor = Cursors.WaitCursor; // Unload any existing model. modelViewerControl1.Model = null; contentManager.Unload(); // Tell the ContentBuilder what to build. contentBuilder.Clear(); contentBuilder.Add(fileName, "Model", null, "ModelProcessor"); // Build this new model data. string buildError = contentBuilder.Build(); if (string.IsNullOrEmpty(buildError)) { // If the build succeeded, use the ContentManager to // load the temporary .xnb file that we just created. modelViewerControl1.Model = contentManager.Load <Model>("Model"); } else { // If the build failed, display an error message. MessageBox.Show(buildError, "Error"); } Cursor = Cursors.Arrow; }
public IBuilderWithResource Append(ResourceId resourceId, ContentBuilderHandler contentHandler, object key = null) { var builder = new ContentBuilder(resourceId); contentHandler(builder); Add(builder.Build(), key); return(this); }
private bool CloseFile(string message = "Do you really want to close?") { if (builder.IsBuilding) { if (MessageBox.Show("Your Project is currently Building." + message, "Close file", MessageBoxButtons.YesNo) == DialogResult.No) { return(false); } builder.Build(); } currentFile = null; CurrentProject = null; RecalcTreeView(); return(true); }
void BuildMenuItem_Click(object sender, EventArgs e) { if (!SaveFirst()) { return; } txtLog.Text = ""; builder.Build(); }
static void Main(string[] args) { try { ServiceContainer Services = new ServiceContainer(); Builder = new ContentBuilder(); ContentExternal = new ContentManager(Services, "../Content/"); string[] Files; #region Ressources building #region Units map icons Files = Directory.GetFiles("../Content/Units", "*.png", SearchOption.AllDirectories); // Tell the ContentBuilder what to build. for (int F = 0; F < Files.Count(); F++) { if (!File.Exists(Path.ChangeExtension(Files[F], ".xnb"))) { Builder.Add(Path.GetFullPath(Files[F]), Files[F].Substring(0, Files[F].Length - 4).Remove(0, 11), "TextureImporter", "TextureProcessor"); } } #endregion #region Map tilesets Files = Directory.GetFiles("../Content/Maps/Tilesets", "*.png", SearchOption.AllDirectories); // Tell the ContentBuilder what to build. for (int F = 0; F < Files.Count(); F++) { if (!File.Exists(Path.ChangeExtension(Files[F], ".xnb"))) { Builder.Add(Path.GetFullPath(Files[F]), Files[F].Substring(0, Files[F].Length - 4).Remove(0, 11), "TextureImporter", "TextureProcessor"); } } #endregion // Build this new model data. string buildError = Builder.Build(); if (!string.IsNullOrEmpty(buildError)) { throw new Exception(buildError); } #endregion } catch (Exception ex) { Console.WriteLine(ex.Message); Console.Read(); } }
public void GenerateBabylonFile(string file, string outputFile, bool skinned) { if (OnImportProgressChanged != null) { OnImportProgressChanged(0); } var scene = new BabylonScene(Path.GetDirectoryName(outputFile)); var services = new ServiceContainer(); // Create a graphics device var form = new Form(); services.AddService <IGraphicsDeviceService>(BabylonExport.Core.Exporters.FBX.GraphicsDeviceService.AddRef(form.Handle, 1, 1)); var contentBuilder = new ContentBuilder(); var contentManager = new ContentManager(services, contentBuilder.OutputDirectory); // Tell the ContentBuilder what to build. contentBuilder.Clear(); contentBuilder.Add(Path.GetFullPath(file), "Model", null, skinned ? "SkinnedModelProcessor" : "ModelProcessor"); // Build this new model data. string buildError = contentBuilder.Build(); if (string.IsNullOrEmpty(buildError)) { var model = contentManager.Load <Model>("Model"); ParseModel(model, scene); } else { throw new Exception(buildError); } // Output scene.Prepare(); using (var outputStream = new FileStream(outputFile, FileMode.Create, FileAccess.Write)) { var ser = new DataContractJsonSerializer(typeof(BabylonScene)); ser.WriteObject(outputStream, scene); } // Cleaning foreach (var path in exportedTexturesFilename.Values) { File.Delete(path); } if (OnImportProgressChanged != null) { OnImportProgressChanged(100); } }
public IBuilderWithResource AddContent(ResourceId resourceId, long id, ContentBuilderHandler contentHandler) { var builder = new ContentBuilder(resourceId, id); contentHandler(builder); if (!content.ContainsKey(resourceId)) { content[resourceId] = new List <Contents>(); } content[resourceId].Add(builder.Build()); return(this); }
public void GenerateBabylonFile(string file, string outputFile, bool skinned, bool rightToLeft) { if (OnImportProgressChanged != null) OnImportProgressChanged(0); var scene = new BabylonScene(Path.GetDirectoryName(outputFile)); var services = new ServiceContainer(); // Create a graphics device var form = new Form(); services.AddService<IGraphicsDeviceService>(GraphicsDeviceService.AddRef(form.Handle, 1, 1)); var contentBuilder = new ContentBuilder(ExtraPipelineAssemblies); var contentManager = new ContentManager(services, contentBuilder.OutputDirectory); // Tell the ContentBuilder what to build. contentBuilder.Clear(); contentBuilder.Add(Path.GetFullPath(file), "Model", Importer, skinned ? "SkinnedModelProcessor" : "ModelProcessor"); // Build this new model data. string buildError = contentBuilder.Build(); if (string.IsNullOrEmpty(buildError)) { var model = contentManager.Load<Model>("Model"); ParseModel(model, scene, rightToLeft); } else { throw new Exception(buildError); } // Output scene.Prepare(); using (var outputStream = new FileStream(outputFile, FileMode.Create, FileAccess.Write)) { var ser = new DataContractJsonSerializer(typeof(BabylonScene)); ser.WriteObject(outputStream, scene); } // Cleaning foreach (var path in exportedTexturesFilename.Values) { File.Delete(path); } if (OnImportProgressChanged != null) OnImportProgressChanged(100); }
private bool CompileAssets() { foreach (EntityType at in AssetTypesByName.Values) { foreach (EntityConfig ac in at.PrototypeAssets.Values) { //<<<<<<< HEAD CheckPart(ac.Parts); } } //======= // { // if (NeedsCompiling(ac)) // contentBuilder.Add(ac.fbxModelFilepath, ac.AssetName, "FbxImporter", "ModelProcessor"); // else // Debug.WriteLine("Skipping compilation of asset \"" + ac.AssetName + "\""); // } // } //>>>>>>> 2dbeb8655797c9cd196612178f8ddca744fa620c if (!contentBuilder.hasContent) { return(true); } // kick-off the build string error = contentBuilder.Build(); if (!String.IsNullOrEmpty(error)) { MessageBox.Show(error); return(false); } // move the output from the temp directory to the destination directory string tempPath = contentBuilder.OutputDirectory; if (!Directory.Exists(processedModelDirectory)) { Directory.CreateDirectory(processedModelDirectory); } string[] files = Directory.GetFiles(tempPath, "*.xnb"); foreach (string file in files) { System.IO.File.Copy(file, Path.Combine(processedModelDirectory, Path.GetFileName(file)), true); } MessageBox.Show("Files compiled successfully."); return(true); }
private void CreateInternalTexture(String fileName) { if (!textureLoaded.ContainsKey(fileName)) { ContentBuilder.Clear(); String iname = "Texture" + StaticRandom.Random(); ContentBuilder.Add(fileName, iname, null, "TextureProcessor"); String buildError = ContentBuilder.Build(); if (string.IsNullOrEmpty(buildError)) { if (!Directory.Exists(Directory.GetCurrentDirectory() + "/Content/Loaded")) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/Content/Loaded"); } MakeCopy(ContentBuilder.OutputDirectory, Directory.GetCurrentDirectory() + "/Content/Loaded/"); textureLoaded.Add(fileName, iname); } else { throw new Exception(buildError); } } }
public void ImportHeightMapAndGridMap(string heightmapFile, string gridmapFile = null) { if (File.Exists(heightmapFile)) { heightmapContent = new ContentManager(graphicsDeviceControl1.Services, contentBuilder.OutputDirectory); contentBuilder.Add(heightmapFile, "heightmap", null, "TextureProcessor"); bool gridmapFileExists = !string.IsNullOrEmpty(gridmapFile) && File.Exists(gridmapFile); if (gridmapFileExists) { contentBuilder.Add(gridmapFile, "gridmap", null, "TextureProcessor"); } contentBuilder.Build(); camera.Detach(Terrain.TerrainIndexer); Terrain = new Terrain(GraphicsDevice, camera, heightmapContent.Load <Texture2D>("heightmap"), heightmapFile, effectFile, terrainTextureFile); Terrain.Texture = grassTexture; terrainBrush.Terrain = Terrain; if (gridmapFileExists) { List <string> assets = Grid.RoadAssetFiles; Grid = new Grid(Terrain, 8, camera, GraphicsDevice, basicEffect); Grid.RoadModel = contentManager.Load <Model>("jalan_raya"); Grid.RoadModel_belok = contentManager.Load <Model>("jalan_raya_belok"); Grid.GridMapFile = gridmapFile; Grid.GridMap = heightmapContent.Load <Texture2D>("gridmap"); Grid.ImportGridMap(); Grid.RoadAssetFiles = assets; gridPointer = new GridPointer(Grid); gridPointers = new List <GridPointer>(); } camera.Attach(Terrain.TerrainIndexer); camera.Notify(); } }
static void Main(string[] args) { if (args.Length == 0) { ShowHelp(); return; } if (args[0] == "/html" && args.Length == 3) { var contentBuilder = new ContentBuilder(args[1]); var formContent = contentBuilder.Build(); var htmlGen = new HtmlGenerator(formContent, GetFullOutDir(args[2])); htmlGen.Do(); var calcGen = new CalcGenerator(formContent, GetFullOutDir(args[2])); calcGen.Do(); return; } ShowHelp(); }
public void Load() { // Create our Builder ContentBuilder builder = new ContentBuilder(@"C:\Build\Output"); // Add our Build Files builder.Add(@"C:\Build\Original\Stadium1.fbx", "Stadium1", null, "ModelProcessor"); // Build our content string result = builder.Build(); // Display Results if (string.IsNullOrEmpty(result)) { Console.WriteLine("Success ok to load model!"); } else { Console.WriteLine(result); } }
private void button1_Click(object sender, RoutedEventArgs e) { OpenFileDialog OpenFileDialog = new OpenFileDialog(); OpenFileDialog.Filter = "X Files (*.x)|*.x"; OpenFileDialog.ShowDialog(); String fileName = OpenFileDialog.FileName; if (String.IsNullOrEmpty(fileName)) { return; } ContentBuilder.Add(fileName, "Model", null, "ModelProcessor"); String buildError = ContentBuilder.Build(); if (string.IsNullOrEmpty(buildError)) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/Content/Loaded"); MakeCopy(ContentBuilder.OutputDirectory, Directory.GetCurrentDirectory() + "/Content/Loaded/"); SimpleModel simpleModel = new SimpleModel(EditorTestScreen.GraphicFactory, "Loaded/Model"); ///Physic info (position, rotation and scale are set here) TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Microsoft.Xna.Framework.Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ///Shader info (must be a deferred type) DeferredNormalShader shader = new DeferredNormalShader(); ///Material info (must be a deferred type also) DeferredMaterial fmaterial = new DeferredMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, tmesh); ///Add to the world EditorTestScreen.World.AddObject(obj); } else { // If the build failed, display an error message. MessageBox.Show(buildError, "Error"); } }
private void Editor_Load(object sender, EventArgs e) { string errorBuild = ""; try { mapModel = new EditorModel.MapModel(); mouseMoving = false; mouseEventArgs = null; tempMouseX = tempMouseY = -1; text = ""; basicEffect = new BasicEffect(graphicsDeviceControl1.GraphicsDevice); contentBuilder = ContentBuilder.Instance; contentManager = new ContentManager(graphicsDeviceControl1.Services, contentBuilder.OutputDirectory); heightmapContent = new ContentManager(graphicsDeviceControl1.Services, contentBuilder.OutputDirectory); spriteBatch = new SpriteBatch(graphicsDeviceControl1.GraphicsDevice); //MessageBox.Show(GraphicsDevice.Adapter.Description); effectFile = AssemblyDirectory + "\\Assets\\effects.fx"; terrainTextureFile = AssemblyDirectory + "\\Assets\\Textures\\grass.dds"; //importer reference: http://msdn.microsoft.com/en-us/library/bb447762%28v=xnagamestudio.20%29.aspx contentBuilder.Add(AssemblyDirectory + "\\Assets\\SegoeUI.spritefont", "SegoeUI.spritefont", null, "FontDescriptionProcessor"); contentBuilder.Add(effectFile, "effects", null, "EffectProcessor"); contentBuilder.Add(AssemblyDirectory + "\\Assets\\brush.bmp", "brush", null, "TextureProcessor"); contentBuilder.Add(terrainTextureFile, "grass", null, "TextureProcessor"); contentBuilder.Add(AssemblyDirectory + "\\Assets\\video_camera.png", "video_camera", null, "TextureProcessor"); contentBuilder.Add(AssemblyDirectory + "\\Assets\\Roads\\jalan_raya.fbx", "jalan_raya", null, "ModelProcessor"); contentBuilder.Add(AssemblyDirectory + "\\Assets\\Roads\\jalan_raya_belok.fbx", "jalan_raya_belok", null, "ModelProcessor"); contentBuilder.Add(AssemblyDirectory + "\\Assets\\heightmap2.png", "heightmap", null, "TextureProcessor"); string error = contentBuilder.Build(); if (!string.IsNullOrEmpty(error)) { throw new Exception(error); } errorBuild = contentBuilder.Build(); spriteFont = contentManager.Load <SpriteFont>("SegoeUI.spritefont"); terrainEffect = contentManager.Load <Effect>("effects"); brushHeightMap = contentManager.Load <Texture2D>("brush"); grassTexture = contentManager.Load <Texture2D>("grass"); camera = new Camera(GraphicsDevice); camera.Position = new Vector3(0, 50, 0); camera.AspectRatio = graphicsDeviceControl1.GraphicsDevice.Viewport.AspectRatio; camera.Rotate(20, 45, 0); camera.Attach(this); CheckIsOrthographic(); string heightMapFile = AssemblyDirectory + "\\test_HeightMap.png"; Terrain = new Terrain(GraphicsDevice, camera, heightMapFile, effectFile, terrainTextureFile, 128, 128); Terrain.Texture = grassTexture; //heightmapContent = new ContentManager(graphicsDeviceControl1.Services, contentBuilder.OutputDirectory); //quadTreeTerrain = new QuadTree(Vector3.Zero, 1025, 1025, camera, GraphicsDevice, 1); //quadTreeTerrain.Effect.Texture = grassTexture; editorMode = new EditorMode_Select(this); Selected = null; selectedBoundingBox = new ModelBoundingBox(graphicsDeviceControl1.GraphicsDevice, camera, false); selectedBoundingBox.SpriteBatch = spriteBatch; selectedBoundingBox.SpriteFont = spriteFont; CheckActiveTransformMode(); terrainBrush = new TerrainBrush(GraphicsDevice, Terrain, brushHeightMap); terrainBrush.BasicEffect = basicEffect; Grid = new Grid(Terrain, 8, camera, GraphicsDevice, basicEffect); Grid.RoadModel = contentManager.Load <Model>("jalan_raya"); Grid.RoadModel_belok = contentManager.Load <Model>("jalan_raya_belok"); Grid.GridMapFile = AssemblyDirectory + "\\Assets\\gridmap.png"; Grid.ExportGridMap(); Grid.RoadAssetFiles.Add(AssemblyDirectory + "\\Assets\\Roads\\jalan_raya.fbx"); Grid.RoadAssetFiles.Add(AssemblyDirectory + "\\Assets\\Roads\\jalan_raya_belok.fbx"); Grid.RoadAssetFiles.Add(AssemblyDirectory + "\\Assets\\Roads\\texture_jalan_raya.png"); Grid.RoadAssetFiles.Add(AssemblyDirectory + "\\Assets\\Roads\\texture_jalan_raya_belok.png"); gridPointer = new GridPointer(Grid); gridPointers = new List <GridPointer>(); mapModel.MainCamera.Texture = contentManager.Load <Texture2D>("video_camera"); mapModel.MainCamera.GraphicsDevice = GraphicsDevice; mapModel.MainCamera.Camera = camera; mapModel.MainCamera.BasicEffect = basicEffect; timer = new System.Threading.Timer((c) => SetGravity(), null, Timeout.Infinite, Timeout.Infinite); camera.Notify(); } catch (Exception ex) { if (!DesignMode) { if (mainUserControl != null && mainUserControl.StatusStrip1 != null) { mainUserControl.StatusStrip1.Text = ex.Message + "\r\n" + ex.StackTrace; } else { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } } } }
public static int Main(string[] args) { Arguments = new Arguments(); Arguments.ParseArguments(args); if (Arguments.Hidden) { ContentBuilder builder = new ContentBuilder(ContentProject.Load(Arguments.ContentProject)); if (Arguments.Configuration.HasValue) { builder.Project.Configuration = Arguments.Configuration.Value; } if (Arguments.OutputDirectory != null) { builder.Project.OutputDir = Arguments.OutputDirectory; } builder.BuildMessage += (sender, e) => { if (e.MessageType == engenious.Content.Pipeline.BuildMessageEventArgs.BuildMessageType.Error) { Console.Error.WriteLine(Program.MakePathRelative(e.FileName) + e.Message); } else { Console.WriteLine(Program.MakePathRelative(e.FileName) + e.Message); } }; builder.BuildStatusChanged += (sender, buildStep) => { string message = (buildStep & (BuildStep.Build | BuildStep.Clean)).ToString() + " "; bool error = false; if (buildStep.HasFlag(Builder.BuildStep.Abort)) { message += "aborted!"; error = true; } else if (buildStep.HasFlag(Builder.BuildStep.Finished)) { message += "finished!"; if (builder.FailedBuilds != 0) { message += " " + builder.FailedBuilds.ToString() + " files failed to build!"; error = true; } } if (error) { Console.Error.WriteLine(message); } else { Console.WriteLine(message); } }; builder.ItemProgress += (sender, e) => { string message = e.Item + " " + (e.BuildStep & (BuildStep.Build | BuildStep.Clean)).ToString().ToLower() + "ing "; bool error = false; if (e.BuildStep.HasFlag(Builder.BuildStep.Abort)) { message += "failed!"; error = true; } else if (e.BuildStep.HasFlag(Builder.BuildStep.Finished)) { message += "finished!"; } if (error) { Console.Error.WriteLine(message); } else { Console.WriteLine(message); } }; builder.Build(); builder.Join(); if (builder.FailedBuilds != 0) { return(-1); } } else { System.Windows.Forms.Application.EnableVisualStyles(); using (frmMain mainForm = new frmMain()) { System.Windows.Forms.Application.Run(mainForm); } } return(0); }
/// <summary> /// Loads a new XNA asset file into the ModelViewerControl. /// </summary> public AssetType LoadFile(string fileName, XnaBuildProperties buildProperties) { if (!_loaded) { return(AssetType.None); } // Unload any existing content. graphicsDeviceControl.AssetRenderer = null; AssetHandler assetHandler = _assetHandlers.GetAssetHandler(fileName); assetHandler.ResetRenderer(); windowsFormsHost.Visibility = Visibility.Collapsed; txtInfo.Text = "Loading..."; txtInfo.Visibility = Visibility.Visible; // Load asynchronously. var ui = TaskScheduler.FromCurrentSynchronizationContext(); Task <string> loadTask = new Task <string>(() => { _contentManager.Unload(); // Tell the ContentBuilder what to build. _contentBuilder.Clear(); _contentBuilder.SetReferences(buildProperties.ProjectReferences); string assetName = fileName; foreach (char c in Path.GetInvalidFileNameChars()) { assetName = assetName.Replace(c.ToString(), string.Empty); } assetName = Path.GetFileNameWithoutExtension(assetName); _contentBuilder.Add(fileName, assetName, buildProperties.Importer, buildProperties.Processor ?? assetHandler.ProcessorName, buildProperties.ProcessorParameters); // Build this new model data. string buildErrorInternal = _contentBuilder.Build(); if (string.IsNullOrEmpty(buildErrorInternal)) { // If the build succeeded, use the ContentManager to // load the temporary .xnb file that we just created. assetHandler.LoadContent(assetName); graphicsDeviceControl.AssetRenderer = assetHandler.Renderer; } return(buildErrorInternal); }); loadTask.ContinueWith(t => { string buildError = t.Result; if (!string.IsNullOrEmpty(buildError)) { // If the build failed, display an error message. txtInfo.Text = "Uh-oh. Something went wrong. Check the Output window for details."; XBuilderWindowPane.WriteLine(buildError); } else { windowsFormsHost.Visibility = Visibility.Visible; txtInfo.Visibility = Visibility.Hidden; } }, ui); loadTask.Start(); return(_assetHandlers.GetAssetType(fileName)); }
public void saveTexture() { // try // { if (!String.IsNullOrEmpty(sourcePath) && !String.IsNullOrEmpty(_AnimationDefinition["Texture"])) { ContentBuilder contentBuilder = new ContentBuilder(); //create a combo item for the texture compiledTextures = new ComboItem[textureSheetCount]; if (textureSheetCount > 0) { for (int i = 0; i < textureSheetCount; i++) { string indexKey = (i == 0) ? "" : i.ToString(); string multiSheetPath = System.IO.Path.Combine(Settings.projectDirectory, Settings.animationSheetDir, _AnimationDefinition["Texture Path"].Split('/', '\\').Last() + indexKey + ".png"); //create the list items compiledTextures[i] = new ComboItem(_AnimationDefinition["Texture"] + indexKey, multiSheetPath); contentBuilder.Add(compiledTextures[i]); } } else { compiledTextures = new ComboItem[1]; compiledTextures[0] = new ComboItem(_AnimationDefinition["Texture"], sourcePath); contentBuilder.Add(compiledTextures[0]); } //Compile String error = contentBuilder.Build(); if (!String.IsNullOrEmpty(error)) { MessageBox.Show(error); return; } //Copy files to the output directory string tempPath = contentBuilder.OutputDirectory; outputFiles = Directory.GetFiles(tempPath, "*.xnb"); tProcessBuildOutput = new Thread(new ParameterizedThreadStart(processBuildOutput)); tProcessBuildOutput.Start(); tProcessBuildOutput.Join(); StreamWriter outStream = null; try { outStream = new StreamWriter(System.IO.Path.Combine(Settings.projectDirectory, Settings.textureDir, Settings.texturesFile)); foreach (KeyValuePair <string, string> kvp in MainWindow.textures) { outStream.WriteLine(kvp.Key + "," + kvp.Value); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (outStream != null) { outStream.Close(); } } checkTextureName(textureName.Text); } // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } }
internal static int Main(string[] args) { int argCount = args.Length; string inputFileName = string.Empty; string outputDirectory = string.Empty; string importerName = null; string processorName = string.Empty; string contentType = string.Empty; GraphicsProfile graphicsProfile = GraphicsProfile.HiDef; print(" Troya Engine - DirectX Binary Content Builder v" + AssemblyInfo.Version); string[] plugins = getAvailableXNBPlugins( ); if (argCount > 1) { for (int i = 0; i < argCount; i++) { string arg = args[i]; string val = string.Empty; if (i + 1 < argCount) { val = args[i + 1]; } switch (arg) { // Source file: case "/source": inputFileName = val; break; // Content type: case "/type": contentType = val.ToUpper( ); break; // Profile: case "/profile": switch (val.ToUpper( )) { case "HIDEF": graphicsProfile = GraphicsProfile.HiDef; break; case "REACH": graphicsProfile = GraphicsProfile.Reach; break; } break; // Output directory: case "/outdir": string dirPath = Path.GetFullPath(val); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } outputDirectory = dirPath; break; } } if (!string.IsNullOrEmpty(inputFileName) && !string.IsNullOrEmpty(contentType)) { string contentSourceFile = string.Empty; switch (contentType) { case "MODEL": if (inputFileName.EndsWith(".fbx") || inputFileName.EndsWith(".x")) { contentSourceFile = Path.GetFullPath(inputFileName); processorName = "ModelProcessor"; } else if (inputFileName.EndsWith(".obj")) { contentSourceFile = Path.GetFullPath(inputFileName); importerName = "ObjModelImporter"; processorName = "ModelProcessor"; } else { print("Error: File format does not supported! Supported formats are: *.fbx *.x *.obj", true); return(MSG_ERROR); } break; case "STUDIOMODEL": if (inputFileName.EndsWith(".fbx") || inputFileName.EndsWith(".x")) { contentSourceFile = Path.GetFullPath(inputFileName); processorName = "StudioModelProcessor"; } else if (inputFileName.EndsWith(".obj")) { contentSourceFile = Path.GetFullPath(inputFileName); importerName = "ObjModelImporter"; processorName = "StudioModelProcessor"; } else { print("Error: File format does not supported! Supported formats are: *.fbx *.x *.obj", true); return(MSG_ERROR); } break; case "GAMEMODEL": if (inputFileName.EndsWith(".fbx") || inputFileName.EndsWith(".x")) { contentSourceFile = Path.GetFullPath(inputFileName); processorName = "GameModelProcessor"; } else if (inputFileName.EndsWith(".obj")) { contentSourceFile = Path.GetFullPath(inputFileName); importerName = "ObjModelImporter"; processorName = "GameModelProcessor"; } else { print("Error: File format does not supported! Supported formats are: *.fbx *.x *.obj", true); return(MSG_ERROR); } break; case "TEXTURE": if (inputFileName.EndsWith(".bmp") || inputFileName.EndsWith(".dds") || inputFileName.EndsWith(".dib") || inputFileName.EndsWith(".hdr") || inputFileName.EndsWith(".jpg") || inputFileName.EndsWith(".pfm") || inputFileName.EndsWith(".png") || inputFileName.EndsWith(".ppm") || inputFileName.EndsWith(".tga")) { contentSourceFile = Path.GetFullPath(inputFileName); processorName = "TextureProcessor"; } else { print("Error: File format does not supported! Supported formats are: *.bmp *.dds *.dib *.hdr *.jpg *.pfm *.png *.ppm *.tga", true); return(MSG_ERROR); } break; case "FONT": if (inputFileName.EndsWith(".bmp")) { contentSourceFile = Path.GetFullPath(inputFileName); processorName = "FontTextureProcessor"; } else if (inputFileName.EndsWith(".spritefont")) { contentSourceFile = Path.GetFullPath(inputFileName); processorName = "FontDescriptionProcessor"; } else { print("Error: File format does not supported! Supported formats are: *.bmp *.spritefont", true); return(MSG_ERROR); } break; case "SOUND": if (inputFileName.EndsWith(".wav")) { contentSourceFile = Path.GetFullPath(inputFileName); processorName = "SoundEffectProcessor"; } else { print("Error: File format does not supported! Supported formats are: *.wav", true); return(MSG_ERROR); } break; } if (!File.Exists(contentSourceFile)) { print("Error: File does not exists! " + contentSourceFile, true); return(MSG_ERROR); } string outputFile = (Path.GetFileNameWithoutExtension(contentSourceFile) + ".xnb"); if (string.IsNullOrEmpty(outputDirectory)) { string filePath = Path.GetFullPath(contentSourceFile); string fileName = Path.GetFileName(contentSourceFile); string path = filePath.Replace(fileName, string.Empty); outputDirectory = Path.GetFullPath(path); } print(" Source File: " + contentSourceFile); print(" Output File: " + outputFile); print(" Destination: " + outputDirectory); print(" Content Type: " + contentType); print(" Profile: " + graphicsProfile); if (importerName != null) { print(" Importer: " + importerName); } print(" Processor: " + processorName); try { ContentBuilder builder = new ContentBuilder( ); builder.GraphicsProfile = graphicsProfile; for (int i = 0; i < plugins.Length; i++) { builder.RegisterAssembly(plugins[i], true); } builder.Create( ); builder.AddItem(contentSourceFile, Path.GetFileNameWithoutExtension(contentSourceFile), importerName, processorName); bool result = builder.Build(outputDirectory); if (result) { if (processorName == "GameModelProcessor") { // Erase autogenerated "log" file [game_0.xnb]: File.Delete(Path.Combine(outputDirectory, "game_0.xnb")); } print("Content built!\r\n"); return(MSG_SUCCESS); } print("Error:", true); print(builder.ErrorLogger.Errors.ToArray( ), true, true); return(MSG_ERROR); } catch (Exception ex) { print(ex.Message); return(MSG_ERROR); } } else { print("Error: Missing arguments. Check README.txt\r\n", true); return(MSG_ERROR); } } return(MSG_NOP); }
public static void Execute(ContentItem selectedItem, ContentBuilder builder) { builder.Build(selectedItem); }