public static JsonWrappers.AdvancedDownloadPreviewSettings ViewButton_Click(string PID, bool bConvert, bool bConvertTextures, bool bResizeTextures, bool bReducePolys, string NewModelFormat, string NewTextureFormat, int NewTextureSize, float PolygonThresh, bool Smoothing, bool IgnoreBoundry, float MaxError, float MaxEdgeLength, string mode) { if (!bConvert) { NewModelFormat = ".dae"; } Utility_3D.ConverterOptions opts = new Utility_3D.ConverterOptions(); if (bConvertTextures) { opts.EnableTextureConversion(NewTextureFormat); } if (bResizeTextures) { opts.EnableScaleTextures(NewTextureSize); } if (bReducePolys) { opts.EnablePolygonReduction(PolygonThresh); } opts.SetPolygonReductionSmoothing(Smoothing); opts.SetPolygonReductionMaxLength(MaxEdgeLength); opts.SetPolygonReductionMaxError(MaxError); if (mode == "Simple") { opts.SetPolygonReductionModeSimple(); } else { opts.SetPolygonReductionModeComplex(); } HttpContext.Current.Session["options"] = opts; HttpContext.Current.Session["format"] = NewModelFormat; // string PID = HttpContext.Current.Request.QueryString["ContentObjectID"]; DataAccessFactory factory = new vwarDAL.DataAccessFactory(); vwarDAL.IDataRepository vd = factory.CreateDataRepositorProxy(); ContentObject co = vd.GetContentObjectById(PID, false, false); JsonWrappers.AdvancedDownloadPreviewSettings jsReturnParams = new JsonWrappers.AdvancedDownloadPreviewSettings(); jsReturnParams.FlashLocation = co.Location; Utils.FileStatus currentStatus = new Utils.FileStatus("", Utils.FormatType.UNRECOGNIZED); //tempFedoraCO.DisplayFile = currentStatus.filename.Replace("zip", "o3d").Replace("skp", "o3d"); currentStatus.filename = co.Location; currentStatus.hashname = co.Location; jsReturnParams.IsViewable = true; jsReturnParams.BasePath = "../Public/"; jsReturnParams.BaseContentUrl = "Model.ashx?temp=true&file="; jsReturnParams.O3DLocation = currentStatus.hashname.ToLower().Replace("zip", "o3d").Replace("skp", "o3d"); jsReturnParams.FlashLocation = currentStatus.hashname; jsReturnParams.ShowScreenshot = true; jsReturnParams.UpAxis = co.UpAxis; jsReturnParams.UnitScale = co.UnitScale; string optionalPath = (co.Location.LastIndexOf("o3d", StringComparison.CurrentCultureIgnoreCase) != -1) ? "viewerTemp/" : "converterTemp/"; string pathToTempFile = "~/App_Data/" + optionalPath + co.Location; using (FileStream stream = new FileStream(HttpContext.Current.Server.MapPath(pathToTempFile), FileMode.Create, FileAccess.Write)) { Utility_3D.ConvertedModel model = GetAndConvertModel(PID); byte[] data = model.data; Utility_3D.ConvertedModel model2 = (new Utility_3D.Model_Packager()).Convert(new MemoryStream(model.data), "test.zip"); jsReturnParams.Polygons = model2._ModelData.VertexCount.Polys; stream.Write(data, 0, data.Length); stream.Close(); } HttpContext.Current.Session["contentObject"] = co; vd.Dispose(); return(jsReturnParams); // HttpContext.Current.Response.BinaryWrite(GetAndConvertModel().data); }
public static JsonWrappers.AdvancedDownloadPreviewSettings ViewButton_Click(string PID, bool bConvert, bool bConvertTextures, bool bResizeTextures, bool bReducePolys, string NewModelFormat, string NewTextureFormat, int NewTextureSize, float PolygonThresh, bool Smoothing, bool IgnoreBoundry, float MaxError, float MaxEdgeLength, string mode) { if (!bConvert) NewModelFormat = ".dae"; Utility_3D.ConverterOptions opts = new Utility_3D.ConverterOptions(); if (bConvertTextures) opts.EnableTextureConversion(NewTextureFormat); if (bResizeTextures) opts.EnableScaleTextures(NewTextureSize); if (bReducePolys) opts.EnablePolygonReduction(PolygonThresh); opts.SetPolygonReductionSmoothing(Smoothing); opts.SetPolygonReductionMaxLength(MaxEdgeLength); opts.SetPolygonReductionMaxError(MaxError); if (mode == "Simple") opts.SetPolygonReductionModeSimple(); else opts.SetPolygonReductionModeComplex(); HttpContext.Current.Session["options"] = opts; HttpContext.Current.Session["format"] = NewModelFormat; // string PID = HttpContext.Current.Request.QueryString["ContentObjectID"]; DataAccessFactory factory = new vwarDAL.DataAccessFactory(); vwarDAL.IDataRepository vd = factory.CreateDataRepositorProxy(); ContentObject co = vd.GetContentObjectById(PID, false, false); JsonWrappers.AdvancedDownloadPreviewSettings jsReturnParams = new JsonWrappers.AdvancedDownloadPreviewSettings(); jsReturnParams.FlashLocation = co.Location; Utils.FileStatus currentStatus = new Utils.FileStatus("", Utils.FormatType.UNRECOGNIZED); //tempFedoraCO.DisplayFile = currentStatus.filename.Replace("zip", "o3d").Replace("skp", "o3d"); currentStatus.filename = co.Location; currentStatus.hashname = co.Location; jsReturnParams.IsViewable = true; jsReturnParams.BasePath = "../Public/"; jsReturnParams.BaseContentUrl = "Model.ashx?temp=true&file="; jsReturnParams.O3DLocation = currentStatus.hashname.ToLower().Replace("zip", "o3d").Replace("skp", "o3d"); jsReturnParams.FlashLocation = currentStatus.hashname; jsReturnParams.ShowScreenshot = true; jsReturnParams.UpAxis = co.UpAxis; jsReturnParams.UnitScale = co.UnitScale; string optionalPath = (co.Location.LastIndexOf("o3d", StringComparison.CurrentCultureIgnoreCase) != -1) ? "viewerTemp/" : "converterTemp/"; string pathToTempFile = "~/App_Data/" + optionalPath + co.Location; using (FileStream stream = new FileStream(HttpContext.Current.Server.MapPath(pathToTempFile), FileMode.Create, FileAccess.Write)) { Utility_3D.ConvertedModel model = GetAndConvertModel(PID); byte[] data = model.data; Utility_3D.ConvertedModel model2 = (new Utility_3D.Model_Packager()).Convert(new MemoryStream(model.data), "test.zip"); jsReturnParams.Polygons = model2._ModelData.VertexCount.Polys; stream.Write(data, 0, data.Length); stream.Close(); } HttpContext.Current.Session["contentObject"] = co; vd.Dispose(); return jsReturnParams; // HttpContext.Current.Response.BinaryWrite(GetAndConvertModel().data); }