/// <summary> /// Gets a list of animations from the given model /// </summary> /// <param name="model">The model to get animations from</param> /// <returns>The list of animations</returns> private List <Animation> GetAllAnimations(VModel model) { var animGroupPaths = model.GetReferencedAnimationGroupNames(); var animations = model.GetEmbeddedAnimations().ToList(); // Load animations from referenced animation groups foreach (var animGroupPath in animGroupPaths) { var animGroup = VpkLoader.LoadFile(animGroupPath + "_c"); if (animGroup != default) { var data = animGroup.DataBlock is NTRO ntro ? ntro.Output as IKeyValueCollection : ((BinaryKV3)animGroup.DataBlock).Data; // Get the list of animation files var animArray = data.GetArray <string>("m_localHAnimArray").Where(a => a != null); // Get the key to decode the animations var decodeKey = data.GetSubCollection("m_decodeKey"); // Load animation files foreach (var animationFile in animArray) { var animResource = VpkLoader.LoadFile(animationFile + "_c"); // Build animation classes animations.AddRange(Animation.FromResource(animResource, decodeKey)); } } } return(animations.ToList()); }
/// <summary> /// Export a Valve VMDL to GLTF. /// </summary> /// <param name="resourceName">The name of the resource being exported.</param> /// <param name="fileName">Target file name.</param> /// <param name="model">The model resource to export.</param> public void ExportToFile(string resourceName, string fileName, VModel model) { if (FileLoader == null) { throw new InvalidOperationException(nameof(FileLoader) + " must be set first."); } DstDir = Path.GetDirectoryName(fileName); var exportedModel = CreateModelRoot(resourceName, out var scene); // Add meshes and their skeletons var meshes = LoadModelMeshes(model, resourceName); for (var i = 0; i < meshes.Length; i++) { var node = AddMeshNode(exportedModel, scene, model, meshes[i].Name, meshes[i].Mesh, model.GetSkeleton(i)); if (node == null) { continue; } // Swap Rotate upright, scale inches to meters. node.WorldMatrix = TRANSFORMSOURCETOGLTF; } WriteModelFile(exportedModel, fileName); }
/// <summary> /// Export a Valve VMDL to GLTF. /// </summary> /// <param name="resourceName">The name of the resource being exported.</param> /// <param name="fileName">Target file name.</param> /// <param name="model">The model resource to export.</param> public void ExportToFile(string resourceName, string fileName, VModel model) { var exportedModel = ModelRoot.CreateModel(); exportedModel.Asset.Generator = GENERATOR; var scene = exportedModel.UseScene(Path.GetFileName(resourceName)); var embeddedMeshIndex = 0; void AddMeshNode(string name, VMesh mesh) { var exportedMesh = CreateGltfMesh(name, mesh, exportedModel, true); // Add skeleton and skin var modelSkeleton = model.GetSkeleton(); if (modelSkeleton.AnimationTextureSize > 0) { var skeleton = scene.CreateNode(name); var joints = CreateGltfSkeleton(modelSkeleton, skeleton); scene.CreateNode(name) .WithSkinnedMesh(exportedMesh, Matrix4x4.Identity, joints); // Rotate upright, scale inches to meters. skeleton.WorldMatrix = TRANSFORMSOURCETOGLTF; } else { var meshNode = scene.CreateNode(name) .WithMesh(exportedMesh); // Rotate upright, scale inches to meters. meshNode.WorldMatrix = TRANSFORMSOURCETOGLTF; } } // Add embedded meshes foreach (var mesh in model.GetEmbeddedMeshes()) { var name = $"Embedded Mesh {++embeddedMeshIndex}"; AddMeshNode(name, mesh); } // Add external meshes foreach (var meshReference in model.GetReferencedMeshNames()) { var meshResource = GuiContext.LoadFileByAnyMeansNecessary(meshReference + "_c"); if (meshResource == null) { continue; } var nodeName = Path.GetFileNameWithoutExtension(meshReference); var mesh = new VMesh(meshResource); AddMeshNode(nodeName, mesh); } exportedModel.Save(fileName); }
public void ExportToFile(string resourceName, string fileName, VModel model) { var exportedModel = ModelRoot.CreateModel(); exportedModel.Asset.Generator = GENERATOR; var scene = exportedModel.UseScene(Path.GetFileName(resourceName)); var embeddedMeshIndex = 0; foreach (var mesh in model.GetEmbeddedMeshes()) { var name = $"Embedded Mesh {++embeddedMeshIndex}"; var exportedMesh = CreateGltfMesh(name, mesh, exportedModel); scene.CreateNode(name) .WithMesh(exportedMesh); } foreach (var meshReference in model.GetReferencedMeshNames()) { var meshResource = GuiContext.LoadFileByAnyMeansNecessary(meshReference + "_c"); if (meshResource == null) { continue; } var nodeName = Path.GetFileNameWithoutExtension(meshReference); var mesh = new VMesh(meshResource); var exportedMesh = CreateGltfMesh(nodeName, mesh, exportedModel); scene.CreateNode(nodeName) .WithMesh(exportedMesh); } exportedModel.Save(fileName); }
public async Task <bool> AddItemAsync(VModel newModel) { _db.Models.Add(newModel); var saveResult = await _db.SaveChangesAsync(); return(saveResult == 1); }
public ActionResult SaveVehicleModel(VModel modelEntity) { modelEntity.EntityVModel.Id = Guid.NewGuid(); modelEntity.EntityVModel.CountryProgrammeId = countryProg.Id; vmakeService.IsVModelSaved(modelEntity.EntityVModel); return(ViewVMake()); }
public List <VModel> GetModelsByMake(int id) { List <VModel> _vModels = new List <VModel>(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConfigurationManager.ConnectionStrings["CarDealership"].ConnectionString; SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "GetModelsByMake"; cmd.Parameters.AddWithValue("@Id", id); conn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { VModel currentRow = new VModel(); currentRow.Make = dr["Make"].ToString(); currentRow.Model = dr["Model"].ToString(); currentRow.ModelId = (int)dr["ModelId"]; _vModels.Add(currentRow); } } } return(_vModels); }
public async Task <IActionResult> Edit(int id, [Bind("MID,Model")] VModel vModel) { if (id != vModel.MID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VModelExists(vModel.MID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vModel)); }
public ActionResult Index(HttpPostedFileBase FileUpload1, HttpPostedFileBase FileUpload2) { if (FileUpload1 != null && FileUpload1.ContentLength > 0 && FileUpload2 != null && FileUpload2.ContentLength > 0) { List <string> headerFile1 = new List <string>(); List <string> headerFile2 = new List <string>(); List <string[]> dataFile1 = new List <string[]>(); List <string[]> dataFile2 = new List <string[]>(); // there's a file that needs our attention if (!(Directory.Exists(HttpContext.Server.MapPath("~/CSVFiles")))) { Directory.CreateDirectory(HttpContext.Server.MapPath("~/CSVFiles")); } string file1 = Path.Combine(HttpContext.Server.MapPath("~/CSVFiles"), "file1.csv"); FileUpload1.SaveAs(file1); string file2 = Path.Combine(HttpContext.Server.MapPath("~/CSVFiles"), "file2.csv"); FileUpload2.SaveAs(file2); using (var reader = new StreamReader(FileUpload1.InputStream)) { List <string> lines = new List <string>(); while (!reader.EndOfStream) { var line = reader.ReadLine(); lines.Add(line); } dataFile1 = (from line in lines select line.Split(',')).ToList(); if (dataFile1.Count > 0) { headerFile1 = dataFile1.FirstOrDefault().ToList(); dataFile1.RemoveAt(0); } } using (var reader = new StreamReader(FileUpload2.InputStream)) { List <string> lines = new List <string>(); while (!reader.EndOfStream) { var line = reader.ReadLine(); lines.Add(line); } dataFile2 = (from line in lines select line.Split(',')).ToList(); if (dataFile2.Count > 0) { headerFile2 = dataFile2.FirstOrDefault().ToList(); dataFile2.RemoveAt(0); } } var model = new VModel(); model.data1 = dataFile1; model.data2 = dataFile2; model.header1 = headerFile1; model.header2 = headerFile2; return(View(model)); } return(View(new VModel())); }
public ActionResult Index() { VModel vm = new VModel() { information = db.Information.Find(1) }; return(View(vm)); }
public ActionResult Index() { VModel vm = new VModel() { information = db.Information.Find(1), news = db.News.OrderByDescending(x => x.Id).ToList() }; return(View(vm)); }
public IActionResult Index() { VModel vm = new VModel { Sliders = db.Sliders, StaticSlider = db.StaticSliders }; return(View(vm)); }
public IActionResult News() { VModel vm = new VModel { StaticSlider = context.StaticSliders, OurMenus = context.OurMenus }; return(View(vm)); }
public IActionResult Contact() { VModel vm = new VModel { StaticSlider = context.StaticSliders, Contacts = context.Contacts }; return(View(vm)); }
/// <summary> /// Export a Valve VMDL to GLTF. /// </summary> /// <param name="resourceName">The name of the resource being exported.</param> /// <param name="fileName">Target file name.</param> /// <param name="model">The model resource to export.</param> public void ExportToFile(string resourceName, string fileName, VModel model) { if (FileLoader == null) { throw new NullReferenceException(nameof(FileLoader)); } var exportedModel = ModelRoot.CreateModel(); exportedModel.Asset.Generator = GENERATOR; var scene = exportedModel.UseScene(Path.GetFileName(resourceName)); void AddMeshNode(string name, VMesh mesh, Skeleton skeleton) { if (mesh.GetData().GetArray("m_sceneObjects").Length == 0) { return; } var hasJoints = skeleton.AnimationTextureSize > 0; var exportedMesh = CreateGltfMesh(name, mesh, exportedModel, hasJoints); var hasVertexJoints = exportedMesh.Primitives.All(primitive => primitive.GetVertexAccessor("JOINTS_0") != null); if (hasJoints && hasVertexJoints) { var skeletonNode = scene.CreateNode(name); var joints = CreateGltfSkeleton(skeleton, skeletonNode); scene.CreateNode(name) .WithSkinnedMesh(exportedMesh, Matrix4x4.Identity, joints); // Rotate upright, scale inches to meters. skeletonNode.WorldMatrix = TRANSFORMSOURCETOGLTF; } else { var meshNode = scene.CreateNode(name) .WithMesh(exportedMesh); // Rotate upright, scale inches to meters. meshNode.WorldMatrix = TRANSFORMSOURCETOGLTF; } } // Add meshes and their skeletons var meshes = LoadModelMeshes(model); for (var i = 0; i < meshes.Length; i++) { AddMeshNode(meshes[i].Name, meshes[i].Mesh, model.GetSkeleton(i)); } exportedModel.Save(fileName); }
public IActionResult Recipes() { VModel vm = new VModel { StaticSlider = context.StaticSliders, OurMenus = context.OurMenus, EatingTypes = context.EatingTypes }; return(View(vm)); }
public IActionResult Services(string Id) { VModel vm = new VModel { StaticSlider = context.StaticSliders, EatingTypes = context.EatingTypes.Where(et => et.Heading == Id) }; ViewBag.Id = Id; return(View(vm)); }
public ActionResult LoadVModel(Guid?modelId = null) { var model = new VModel() { EntityVModel = modelId == null ? new Model.VehicleModel() : vmakeService.GetModelById((Guid)modelId), VMakes = new SelectList(vmakeService.GetVMakes(countryProg.Id), "Id", "Name") }; ViewBag.Action = modelId == null ? "SaveVehicleModel" : "EditVehicleModel"; return(View(model)); }
public async Task <IActionResult> Create([Bind("MID,Model")] VModel vModel) { if (ModelState.IsValid) { _context.Add(vModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(vModel)); }
public IActionResult About() { VModel vm = new VModel { StaticSlider = context.StaticSliders, History = context.Histories, HistoryPics = context.Histories.Include(x => x.HistoryPics).FirstOrDefault().HistoryPics, Chefs = context.Chefs }; return(View(vm)); }
private void RemoveItemBtn_Click(object sender, RoutedEventArgs e) { // ReSharper disable once CanBeReplacedWithTryCastAndCheckForNull if (TreeView.SelectedValue is FileWrapper) { VModel.RemoveFile((FileWrapper)TreeView.SelectedValue); } else { VModel.RemoveFolder((FolderWrapper)TreeView.SelectedValue); } }
public ActionResult Delete(int id) { VModel models = new VModel(); using (var db = new PostContext()) { models.postsList = db.Post.ToList(); } models.post = models.postsList.First(s => s.Id == id); return(View(models.post)); }
public async Task <IActionResult> Upsert(VModel newItem) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } var scs = await _db.AddItemAsync(newItem); if (!scs) { return(BadRequest("Item was not added")); } return(RedirectToAction("Index")); }
private async void StartBtn_Click(object sender, RoutedEventArgs e) { if (!VModel.Ready) { return; } _manager.SetOverlayIcon(Properties.Resources.image_export, "Processing"); TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal; await VModel.Begin(); TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; _manager.SetOverlayIcon(null, ""); }
public int CheckSum() { int ret = 0; ret += VMake.CalCheckSum(); ret += VModel.CalCheckSum(); ret += VYear.CalCheckSum(); ret += VType.ToDescription().CalCheckSum(); ret += VVIN.CalCheckSum(); ret += VRegion.CalCheckSum(); ret += VLocation.CalCheckSum(); ret += VStatus.ToString().CalCheckSum(); return(ret); }
public IActionResult Index() { VModel vm = new VModel { Sliders = context.Sliders, EatingTypes = context.EatingTypes, SpecialDishes = context.SpecialDishes, OurMenus = context.OurMenus.Take(4), Testimonials = context.Testimonials, Blogs = context.Blogs }; return(View(vm)); }
public ColorDialog(VModel d) { this.InitializeComponent(); CR.MainBrush = CP.MainBrush = new SolidColorBrush(d.MainBrush.Color); //新建 First.Click += (s, e) => { d.MainBrush.Color = CR.MainBrush.Color; base.Hide(); }; //取消 Second.Click += (s, e) => { base.Hide(); }; }
public ActionResult Index() { VModel models = new VModel(); using (var db = new PostContext()) { models.postsList = db.Post.ToList(); } using (var db = new CategoryContext()) { models.categories = db.Category.ToList(); } return(View(models)); }
private static string GetSkinPathFromModel(VModel model, string skinName) { var materialGroupForSkin = model.Data.GetArray <IKeyValueCollection>("m_materialGroups") .ToList() .SingleOrDefault(m => m.GetProperty <string>("m_name") == skinName); if (materialGroupForSkin == null) { return(null); } // Given these are at the model level, and otherwise pull materials from drawcalls // on the mesh, not sure how they correlate if there's more than one here // So just take the first one and hope for the best return(materialGroupForSkin.GetArray <string>("m_materials")[0]); }
public void AddModel(VModel model) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConfigurationManager.ConnectionStrings["CarDealership"].ConnectionString; SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "AddModel"; cmd.Parameters.AddWithValue("@Make", model.MakdId); cmd.Parameters.AddWithValue("@AddedBy", model.AddedBy); cmd.Parameters.AddWithValue("@Model", model.Model); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } }