public bool Update(Cloth cloth, bool warning) { Cloth clothToUpdate = this.Get(cloth.Id); Cloth name = this.context.Cloths.SingleOrDefault(c => c.Name == cloth.Name); //Checking if name of the cloth already exists if (name == null || name.Name == clothToUpdate.Name) { clothToUpdate.Name = cloth.Name; clothToUpdate.Type = cloth.Type; clothToUpdate.Price = cloth.Price; if (!warning) { clothToUpdate.ImagePath = cloth.ImagePath; } this.context.SaveChanges(); return(true); } else { return(false); } }
public override void Setup(Component c) { var target = c as SkinnedMeshRenderer; m_target = target; var mesh = target.sharedMesh; if (mesh == null) { return; } abcObject = parent.abcObject.NewPolyMesh(target.name, timeSamplingIndex); if (recorder.Settings.MeshSubmeshes) { m_mbuf.SetupSubmeshes(abcObject, mesh); } m_meshSrc = target.sharedMesh; m_cloth = m_target.GetComponent <Cloth>(); if (m_cloth != null) { m_cbuf = new ClothBuffer(); m_cbuf.rootBone = m_target.rootBone != null ? m_target.rootBone : m_target.GetComponent <Transform>(); var tc = parent as TransformCapturer; if (tc != null) { tc.capturePosition = false; tc.captureRotation = false; tc.captureScale = false; } } }
public ActionResult AdminEdit(Cloth model, HttpPostedFileBase image1, HttpPostedFileBase image2) { Cloth clothes = new Cloth(); clothes.Gender = model.Gender; clothes.Name = model.Name; clothes.Details = model.Details; clothes.Color = model.Color; clothes.Brand = model.Brand; clothes.BrandInfo = model.BrandInfo; clothes.About = model.About; clothes.LookAfter = model.LookAfter; clothes.MoreDetails = model.MoreDetails; clothes.Image = new byte[image1.ContentLength]; image1.InputStream.Read(clothes.Image, 0, image1.ContentLength); clothes.ExtraImage = new byte[image2.ContentLength]; image2.InputStream.Read(clothes.ExtraImage, 0, image2.ContentLength); //clothes.ExtraImage = model.ExtraImage; clothes.Price = model.Price; clothes.CategoryId = model.CategoryId; //shoppingEntities.Clothes.Attach(clothes); shoppingEntities.Entry(clothes).State = System.Data.Entity.EntityState.Modified; shoppingEntities.SaveChanges(); return(RedirectToAction("AdminList")); }
public int Delete(int id) { Cloth clothToDelete = this.Get(id); this.context.Cloths.Remove(clothToDelete); return(this.context.SaveChanges()); }
public JsonResult Index(int Id, string Size) { BagViewModel objShoppingCartModel = new BagViewModel(); Cloth objItem = shoppingEntities.Clothes.Single(model => model.Id == Id); if (Session["CartCounter"] != null) { listOfShoppingCartModels = Session["CartItem"] as List <BagViewModel>; } if (listOfShoppingCartModels.Any(m => m.Id == Id && m.Size == Size)) { objShoppingCartModel = listOfShoppingCartModels.Single(m => m.Id == Id && m.Size == Size); objShoppingCartModel.Quantity = objShoppingCartModel.Quantity + 1; objShoppingCartModel.Total = objShoppingCartModel.Quantity * objShoppingCartModel.UnitPrice; } else { objShoppingCartModel.Id = Id; objShoppingCartModel.Image = objItem.Image; objShoppingCartModel.ItemName = objItem.Name; objShoppingCartModel.Size = Size; objShoppingCartModel.Quantity = 1; objShoppingCartModel.Total = objItem.Price; objShoppingCartModel.UnitPrice = objItem.Price; listOfShoppingCartModels.Add(objShoppingCartModel); } Session["CartCounter"] = listOfShoppingCartModels.Count; Session["CartItem"] = listOfShoppingCartModels; return(Json(new { Success = true, Counter = listOfShoppingCartModels.Count }, JsonRequestBehavior.AllowGet)); }
/////////////////////////////edit clothes public ActionResult EditClothes(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Cloth data = db.Clothes.Find(id); if (data == null) { return(HttpNotFound()); } AddClothes PassedData = new AddClothes(); PassedData.productID = data.ProductID; PassedData.name = data.name; PassedData.color = data.color; PassedData.Brand = data.Brand; PassedData.Price = data.Price; PassedData.sale = data.sale; PassedData.Size = data.Size; PassedData.img = data.img; Admon.name = Adminloggedin.name; Admon.password = Adminloggedin.password; Admon.Type = Adminloggedin.type; ViewBag.Message = Admon; return(View(PassedData)); }
void ClearAllExcept(Component comp) { if (!typeof(Collider).IsAssignableFrom(comp.GetType())) { collider = null; } if (!typeof(Cloth).IsAssignableFrom(comp.GetType())) { cloth = null; } if (!typeof(LODGroup).IsAssignableFrom(comp.GetType())) { lodGroup = null; } if (!typeof(Renderer).IsAssignableFrom(comp.GetType())) { renderer = null; } if (!typeof(Behaviour).IsAssignableFrom(comp.GetType())) { behaviour = null; } }
public AddPicWin(Cloth keyCloth) { colorItems = ViewHelper.NewColorItems; shapeItems = ViewHelper.NewShapeItems; this.Resources.Add("colorItems", colorItems); this.Resources.Add("shapeItems", shapeItems); InitializeComponent(); txtAddName.Text = "自动"; txtAddName.IsEnabled = false; this.keyCloth = keyCloth; if (null == keyCloth || String.IsNullOrEmpty(this.keyCloth.Path)) { btnAddImportKeyPic.IsEnabled = false; } btnAddFileSave.IsEnabled = false; // It should be done by dependency injection here!! clothLibService = new ClothLibService(); // initialize OpenFileDialog dlgOpenPic = new OpenFileDialog(); dlgOpenPic.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); dlgOpenPic.Title = "请选择新增的图片"; dlgOpenPic.Filter = "jpeg (*.jpg;*.jpeg;*.jpe;*.jfif)|*.jpg;*.jpeg;*.jpe;*.jfif|所有支持的图片文件 (JPG;BMP;PNG;TIF;...)|*.jpg;*.jpeg;*.jpe;*.jfif;*.png;*.bmp;*.dib;*.tif;*.tiff"; dlgOpenPic.FilterIndex = 2; // begin from 1 }
public ActionResult AddClothes(AddClothes addClothes) { if (ModelState.IsValid) { Cloth clothesData = new Cloth(); clothesData.img = new byte[addClothes.file.ContentLength]; MemoryStream target = new MemoryStream(); addClothes.file.InputStream.CopyTo(target); clothesData.img = target.ToArray(); clothesData.name = addClothes.name; clothesData.Size = addClothes.Size; clothesData.Brand = addClothes.Brand; clothesData.Price = addClothes.Price; clothesData.sale = addClothes.sale; clothesData.color = addClothes.color; db.Clothes.Add(clothesData); db.SaveChanges(); return(RedirectToAction("DashBoard")); } Admon.name = Adminloggedin.name; Admon.password = Adminloggedin.password; Admon.Type = Adminloggedin.type; ViewBag.Message = Admon; return(View(addClothes)); }
void Roaming() { if (roam) { //print("monster is changing course"); target = transform.position; target.x += Random.Range(1.0f, 30.0f) * 10.0f * ((Random.Range(1, 3) * 2) - 3); target.z += Random.Range(1.0f, 30.0f) * 10.0f * ((Random.Range(1, 3) * 2) - 3); //print("target x: " + target.x); //print("target y: " + target.x); if (Random.Range(0, 10) == 0) { print("enemy is jumping to new position"); Cloth cloth = transform.GetChild(0).GetComponent <Cloth>(); Cloth veil = transform.GetChild(1).GetComponent <Cloth>(); cloth.worldAccelerationScale = 0.0f; cloth.worldVelocityScale = 0.0f; veil.worldAccelerationScale = 0.0f; veil.worldVelocityScale = 0.0f; do { transform.position = new Vector3(Random.Range(0.0f, 500.0f), 22.0f, Random.Range(0.0f, 500.0f)); distance = Mathf.Abs((playerTransform.position - transform.position).magnitude); } while (distance < 80.0f || distance > 120.0f); cloth.worldAccelerationScale = 0.5f; cloth.worldVelocityScale = 0.5f; veil.worldAccelerationScale = 0.5f; veil.worldVelocityScale = 0.5f; } } }
protected GameObject GetOrCreateObject(string name, Cloth cloth) { GameObject obj = null; bool found = false; if (parentObj == null) { throw new ArgumentNullException("parentObj cannot be null"); } foreach (Transform child in parentObj.transform) { if (child.name == name) { //Debug.Log("Child exists"); obj = child.gameObject; found = true; } } // If hatSprite is null, we couldn't find it. Time to create it. if (!found) { obj = CreateGameObjectForSprite(name, cloth, parentObj); Debug.Log("Created \"" + name + "\""); } return(obj); // Should never be null.. }
public void ItCanPlaceClaimsOnTheMap() { var map = new HashSet<string>[8,8]; map[1,3] = new HashSet<string> { "1" }; map[1,4] = new HashSet<string> { "1" }; map[1,5] = new HashSet<string> { "1" }; map[1,6] = new HashSet<string> { "1" }; map[2,3] = new HashSet<string> { "1" }; map[2,4] = new HashSet<string> { "1" }; map[2,5] = new HashSet<string> { "1" }; map[2,6] = new HashSet<string> { "1" }; map[3,3] = new HashSet<string> { "1" }; map[3,4] = new HashSet<string> { "1" }; map[3,5] = new HashSet<string> { "1" }; map[3,6] = new HashSet<string> { "1" }; map[4,3] = new HashSet<string> { "1" }; map[4,4] = new HashSet<string> { "1" }; map[4,5] = new HashSet<string> { "1" }; map[4,6] = new HashSet<string> { "1" }; var c = new Claim("1", new Point(1, 3), new Area(4, 4)); var cloth = new Cloth(8, 8); cloth.Place(c); Assert.Equal(map, cloth.Map); }
public void ItCanPlaceMultipleClaimsOnTheMap() { var map = new HashSet<string>[4,4]; map[1, 1] = new HashSet<string> { "1" }; map[1, 2] = new HashSet<string> { "1", "3" }; map[2, 1] = new HashSet<string> { "1" }; map[2, 2] = new HashSet<string> { "1", "2", "3" }; map[2, 3] = new HashSet<string> { "2", "3" }; map[3, 2] = new HashSet<string> { "2" }; map[3, 3] = new HashSet<string> { "2" }; map[1, 3] = new HashSet<string> { "3" }; var c = new Claim("1", new Point(1, 1), new Area(2, 2)); var d = new Claim("2", new Point(2, 2), new Area(2, 2)); var e = new Claim("3", new Point(1, 2), new Area(2, 2)); var cloth = new Cloth(4,4); cloth.Place(c); cloth.Place(d); cloth.Place(e); Assert.Equal(map, cloth.Map); }
private void ShowDefaultShoe() { Cloth defaultCloth = SpriteLoader.defaultClothes[2]; ChangeInThreeScenes(InventorySlotMgt.ShoeImages, defaultCloth, 2); InventorySlotMgt.wearingNonDefualtClothes[2] = false; }
public void ChangeWorkCloth() { if (FinalCameraController.isTutorial) { // FinalCameraController.TutorialManager.tutorialNumber = 13; FinalCameraController.TutorialManager.kararaText.text = "Workwear No"; return; } HideTopBottom(); Cloth workingCloth = SpriteLoader.ClothDic["work"]; ChangeInThreeScenes(InventorySlotMgt.EverythingImages, workingCloth, 3); if (InventorySlotMgt.wearingNonDefualtClothes[3]) { InventorySlotMgt.wearingSlots[3].GetComponent <ClothChanging>().isWearing = false; } isWearing = true; InventorySlotMgt.wearingSlots[3] = this.transform.gameObject; InventorySlotMgt.isWorkingCloth = true; }
private void ShowDefaultBottom() { Cloth defaultCloth = SpriteLoader.defaultClothes[1]; ChangeInThreeScenes(InventorySlotMgt.BottomImages, defaultCloth, 1); InventorySlotMgt.wearingNonDefualtClothes[1] = false; }
private void ShowDefaultTop() { Cloth defaultCloth = SpriteLoader.defaultClothes[0]; ChangeInThreeScenes(InventorySlotMgt.TopImages, defaultCloth, 0); InventorySlotMgt.wearingNonDefualtClothes[0] = false; }
private Cloth getClothFromResponse(Response response) ///get cloth object from response object { string clothString = response.data; Cloth cloth = JsonConvert.DeserializeObject <Cloth>(clothString); return(cloth); }
public ActionResult Add(ShoppingViewModel model, HttpPostedFileBase image1, HttpPostedFileBase image2) { Cloth clothes = new Cloth(); clothes.Gender = model.Gender; clothes.Name = model.Name; clothes.Details = model.Details; clothes.Color = model.Color; clothes.Brand = model.Brand; clothes.BrandInfo = model.BrandInfo; clothes.About = model.About; clothes.LookAfter = model.LookAfter; clothes.MoreDetails = model.MoreDetails; clothes.Image = new byte[image1.ContentLength]; image1.InputStream.Read(clothes.Image, 0, image1.ContentLength); clothes.ExtraImage = new byte[image2.ContentLength]; image2.InputStream.Read(clothes.ExtraImage, 0, image2.ContentLength); //clothes.ExtraImage = model.ExtraImage; clothes.Price = model.Price; clothes.CategoryId = int.Parse(model.Category); shoppingEntities.Clothes.Add(clothes); shoppingEntities.SaveChanges(); return(RedirectToAction("AdminList")); }
/// <summary> /// methode qui genere un vetement aleatoire /// </summary> public void RandomObject() { Random rnd = new Random(); int RandInt = rnd.Next(Cloth.list.Count <Cloth>()); randomCloth = Cloth.list[RandInt]; }
void OnGUI() { EditorGUILayout.LabelField("Please Set Target Cloth"); obj = (Cloth)EditorGUILayout.ObjectField(obj, typeof(Cloth), true); offset = EditorGUILayout.FloatField(offset); maxClothDistance = EditorGUILayout.FloatField(maxClothDistance); try { if (GUILayout.Button("自動でウェイト設定_Smooth", GUILayout.Width(256), GUILayout.Height(32))) // ボタンの大きさを Width と Height を指定. { obj.coefficients = SetAutoWeight(obj, 0); } if (GUILayout.Button("自動でウェイト設定_Inverse", GUILayout.Width(256), GUILayout.Height(32))) // ボタンの大きさを Width と Height を指定. { obj.coefficients = SetAutoWeight(obj, 1); } if (GUILayout.Button("自動でウェイト設定_Liner", GUILayout.Width(256), GUILayout.Height(32))) // ボタンの大きさを Width と Height を指定. { obj.coefficients = SetAutoWeight(obj, 2); } } catch { Debug.Log("Err"); } }
private void importClothPicThread(Object obj) { ImportThreadArgus argus = (ImportThreadArgus)obj; List <Cloth> clothes = new List <Cloth>(argus.Step); while (!argus.StopImport()) { String picName = dequeuePicName(argus.PicNameQueue); if (picName == null) { break; } Cloth cloth = ClothUtil.GenerateClothObject(picName, argus.isGabor); clothes.Add(cloth); if (clothes.Count % argus.Step == 0) { InsertAll(clothes); argus.StepDel(clothes.Count); clothes.Clear(); } } if (clothes.Count > 0) { InsertAll(clothes); argus.StepDel(clothes.Count); } }
public void CreateFlag() { var clothGrid = new ClothTestGrid(10, 10); using (var physics = CreatePhysicsAndScene()) { using (var cooking = physics.Physics.CreateCooking()) { var clothMeshDesc = new ClothMeshDesc() { Points = clothGrid.Points, Triangles = ArrayUtil.ToByteArray(clothGrid.Indices) }; MemoryStream stream = new MemoryStream(); cooking.CookClothFabric(clothMeshDesc, new Vector3(0, -9.81f, 0), stream); // After cooking the fabric, we must put the position of the written stream back to 0 // so that it can be read from the beginning in the CreateClothFabric method stream.Position = 0; ClothFabric clothFabric = physics.Physics.CreateClothFabric(stream); ClothParticle[] particles = clothGrid.Points.Select(p => new ClothParticle(p, 2)).ToArray(); Cloth cloth = physics.Physics.CreateCloth(Matrix4x4.Identity, clothFabric, particles, 0); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Mark,Size,Colour,Type,Description,Price,Price_RL,Agreement_Id,Sold")] Cloth cloth) { if (id != cloth.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cloth); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClothExists(cloth.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Agreement_Id"] = new SelectList(_context.Agreements, "Id", "Name", cloth.Agreement_Id); return(View(cloth)); }
public void UpdateClothAcceleration() { if (avatar == null) { return; } if (xSlider == null || ySlider == null || zSlider == null) { return; } if (m_Cloth == null) { m_Cloth = avatar.GetComponentInChildren <Cloth>(); if (m_Cloth == null) { return; } } acceleration.x = xSlider.value; acceleration.y = ySlider.value; acceleration.z = zSlider.value; m_Cloth.externalAcceleration = acceleration; }
public ActionResult Details(int id) { var _cloth = _uow.Clothes.Get(id); Cloth cloth = (Cloth)_cloth; return(View(cloth)); }
public static void CaptureMesh(AbcAPI.aeObject abc, Mesh mesh, Cloth cloth, MeshBuffer dst_buf) { dst_buf.indices = mesh.triangles; dst_buf.uvs = mesh.uv; if (cloth == null) { dst_buf.vertices = mesh.vertices; dst_buf.normals = mesh.normals; } else { dst_buf.vertices = cloth.vertices; dst_buf.normals = cloth.normals; } var data = new AbcAPI.aePolyMeshData(); data.indices = GetArrayPtr(dst_buf.indices); data.positions = GetArrayPtr(dst_buf.vertices); if (dst_buf.normals != null) { data.normals = GetArrayPtr(dst_buf.normals); } if (dst_buf.uvs != null) { data.uvs = GetArrayPtr(dst_buf.uvs); } data.positionCount = dst_buf.vertices.Length; data.indexCount = dst_buf.indices.Length; AbcAPI.aePolyMeshWriteSample(abc, ref data); }
// GET: Clother/Edit/5 public ActionResult Edit(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Cloth clother = _clotherService.GetClothById(id); if (clother == null) { return(HttpNotFound()); } return(View(new ClothCreateViewModel { ClothTypes = _clotherService.GetAllClothTypes().ToSelectList("Id", "Name", clother.ClothTypeId), Brands = _clotherService.GetAllBrands().ToSelectList("Id", "Name", clother.BrandId), Form = new ClothCreateForm { Id = clother.Id, Name = clother.Name, BrandId = clother.BrandId, ClothTypeId = clother.ClothTypeId, Pictures = clother.Pictures }, UploadPictureForm = new UploadPictureForm { ClothId = clother.Id } })); }
public List <Cloth> SearchTest4(Cloth keyCloth) { ClothUtil.ExtractFeaturesNecessary(keyCloth, false); return(new HLSColorSearcher(new PicParam(keyCloth.HLSColorVector, keyCloth.ColorNum), float.MaxValue, ClothUtil.CalcManhattanDistance, clothDao, 100).Search()); //return new DaubechiesWaveletSearcher(new PicParam(keyCloth.DaubechiesWaveletVector, keyCloth.ColorNum), float.MaxValue, ClothUtil.CalcManhattanDistance, // new HLSColorSearcher(new PicParam(keyCloth.HLSColorVector, keyCloth.ColorNum), float.MaxValue, ClothUtil.CalcManhattanDistance, clothDao, 100), 200).Search(); }
public void CreateFlag() { var clothGrid = new ClothTestGrid(10, 10); using (var physics = CreatePhysicsAndScene()) { Cooking cooking = physics.Physics.CreateCooking(); ClothMeshDesc clothMeshDesc = new ClothMeshDesc() { Points = clothGrid.Points, Triangles = clothGrid.Indices }; MemoryStream stream = new MemoryStream(); bool result = cooking.CookClothFabric(clothMeshDesc, new Vector3(0, -9.81f, 0), stream); ClothFabric clothFabric = physics.Physics.CreateClothFabric(stream); ClothParticle[] particles = clothGrid.Points.Select(p => new ClothParticle(p, 2)).ToArray(); ClothCollisionData collision = new ClothCollisionData(); Cloth cloth = physics.Physics.CreateCloth(Matrix.Identity, clothFabric, particles, collision, 0); } }
protected override void LoadPhysics(Scene scene) { var poleActor = CreateFlagPole(); _flag = CreateCloth(scene, poleActor); // Visualize the cloth scene.SetVisualizationParameter(VisualizationParameter.ClothVertical, true); scene.SetVisualizationParameter(VisualizationParameter.ClothHorizontal, true); }
/// <summary> /// 向数据库中添加装备数据 /// </summary> /// <param name="userId"></param> /// <param name="clothType"></param> /// <param name="gridId"></param> public Cloth add(int userId,int clothType,int gridId) { Cloth cloth = new Cloth(); ClothData data = FinalData.Instance().GetCloth(clothType); cloth.user_id = userId; cloth.type = clothType; cloth.grid_id = gridId; cloth.defend = data.defend; cloth.magic = data.magic; cloth.hp = data.hp; cloth.ap = data.ap; cloth.Add(); userCloth[userId].Add ( cloth.id, cloth ); return cloth; }
/* * Add Net Collision * @param Cloth _net */ public void AddNetCollision(Cloth _net) { net = _net; CapsuleCollider[] newColliders = net.capsuleColliders; // Go through the nets capsule colliders and find an empty space for(int i = 0; i < net.capsuleColliders.Length; i++) { if(newColliders[i] == null) { newColliders[i] = netCollision; break; } } net.capsuleColliders = newColliders; }
protected override void LoadPhysics(Scene scene) { int w = 26; int h = 26; float hw = w / 2.0f; float hh = h / 2.0f; Vector3 p = new Vector3(0, h + 1, 0); // Create a Grid of Points int vertices, indices; ClothMesh clothMesh; { var grid = VertexGrid.CreateGrid(w, h); vertices = grid.Points.Length; indices = grid.Indices.Length; ClothMeshDescription clothMeshDesc = new ClothMeshDescription(); clothMeshDesc.AllocateVertices<Vector3>(vertices); clothMeshDesc.AllocateTriangles<int>(indices / 3); clothMeshDesc.VertexCount = vertices; clothMeshDesc.TriangleCount = indices / 3; clothMeshDesc.VerticesStream.SetData(grid.Points); clothMeshDesc.TriangleStream.SetData(grid.Indices); // We are using 32 bit integers for our indices, so make sure the 16 bit flag is removed. // 32 bits are the default, so this isn't technically needed, but it's good to show in a sample clothMeshDesc.Flags &= ~MeshFlag.Indices16Bit; clothMeshDesc.Flags |= (MeshFlag)((int)clothMeshDesc.Flags | (int)ClothMeshFlag.Tearable); //var elements = new[] //{ //new SlimDX.Direct3D10.InputElement("Position", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 0, 0), //new SlimDX.Direct3D10.InputElement("Color", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 16, 0) //}; //mesh = new SlimDX.Direct3D10.Mesh(Engine.GraphicsDevice, elements, "Position", vertices, indices / 3, SlimDX.Direct3D10.MeshFlags.Has32BitIndices); // Write the cooked data to memory using (var memoryStream = new MemoryStream()) { Cooking.InitializeCooking(); Cooking.CookClothMesh(clothMeshDesc, memoryStream); Cooking.CloseCooking(); // Need to reset the position of the stream to the beginning memoryStream.Position = 0; clothMesh = Engine.Core.CreateClothMesh(memoryStream); } } // int j = vertices * 2; int k = indices * 3; var clothDesc = new ClothDescription() { ClothMesh = clothMesh, GlobalPose = Matrix.RotationX((float)Math.PI / 2.0F) * Matrix.Translation(-w - 1, 0, 0) * Matrix.Translation(p), Flags = ClothFlag.Gravity | ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization, BendingStiffness = 0.1f, TearFactor = 1.5f, WindAcceleration = new Vector3(windX, windY, windZ) }; clothDesc.MeshData.AllocatePositions<Vector3>(j); clothDesc.MeshData.AllocateIndices<int>(k); clothDesc.MeshData.AllocateNormals<Vector3>(j); clothDesc.MeshData.MaximumVertices = j; clothDesc.MeshData.MaximumIndices = k; clothDesc.MeshData.NumberOfVertices = vertices; clothDesc.MeshData.NumberOfIndices = indices; _clothL = scene.CreateCloth(clothDesc); var clothDesc2 = new ClothDescription() { ClothMesh = clothMesh, GlobalPose = Matrix.RotationX((float)Math.PI / 2.0F) * Matrix.Translation(1, 0, 0) * Matrix.Translation(p), Flags = ClothFlag.Gravity | ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization, BendingStiffness = 0.1f, TearFactor = 1.5f, WindAcceleration = new Vector3(windX, windY, windZ) }; clothDesc2.MeshData.AllocatePositions<Vector3>(j); clothDesc2.MeshData.AllocateIndices<int>(k); clothDesc2.MeshData.AllocateNormals<Vector3>(j); clothDesc2.MeshData.MaximumVertices = j; clothDesc2.MeshData.MaximumIndices = k; clothDesc2.MeshData.NumberOfVertices = vertices; clothDesc2.MeshData.NumberOfIndices = indices; _clothR = scene.CreateCloth(clothDesc2); // for (int i = 0; i <= w; i += 2) { var actorDesc = new ActorDescription() { GlobalPose = Matrix.Translation(new Vector3(i - w - 1, 0, 0) + p), Shapes = { new SphereShapeDescription(0.3F) }, BodyDescription = new BodyDescription(3) }; var actor = scene.CreateActor(actorDesc); AnchorActorsL.Add(actor); _clothL.AttachToShape(actor.Shapes.First(), (ClothAttachmentFlag)0); } for (int i = 0; i <= w; i += 2) { var actorDesc = new ActorDescription() { GlobalPose = Matrix.Translation(new Vector3(-i + w + 1, 0, 0) + p), Shapes = { new SphereShapeDescription(0.3F) }, BodyDescription = new BodyDescription(3) }; var actor = scene.CreateActor(actorDesc); AnchorActorsR.Add(actor); _clothR.AttachToShape(actor.Shapes.First(), (ClothAttachmentFlag)0); } for (int i = 0; i <= 1; i++) { var actorDesc = new ActorDescription() { GlobalPose = Matrix.Translation(new Vector3(0, -1, 0.2F * (float)Math.Pow(-1, i)) + p), Shapes = { new BoxShapeDescription(new Vector3(2 * w + 4, 0.001F, 0.1F)) } }; scene.CreateActor(actorDesc); } for (int i = 0; i <= 1; i++) { var actorDesc = new ActorDescription() { GlobalPose = Matrix.Translation(new Vector3(0, -1, 0.4F * (float)Math.Pow(-1, i)) + p), Shapes = { new BoxShapeDescription(new Vector3(2 * w + 4, 1, 0.1F)) } }; scene.CreateActor(actorDesc); } for (int i = 0; i <= 1; i++) { var actorDesc = new ActorDescription() { GlobalPose = Matrix.Translation(new Vector3((w + 2.1F) * (float)Math.Pow(-1, i), -1, 0) + p), Shapes = { new BoxShapeDescription(new Vector3(0.1F, 1, 1)) } }; scene.CreateActor(actorDesc); } }
protected override void LoadPhysics(Scene scene) { int w = 25; int h = 25; float hw = w / 2.0f; float hh = h / 2.0f; Vector3 p = new Vector3(0, 20, 0); // Create a Grid of Points int vertices, indices; ClothMesh clothMesh; { var grid = VertexGrid.CreateGrid(w, h); vertices = grid.Points.Length; indices = grid.Indices.Length; ClothMeshDescription clothMeshDesc = new ClothMeshDescription(); clothMeshDesc.AllocateVertices<Vector3>(vertices); clothMeshDesc.AllocateTriangles<int>(indices / 3); clothMeshDesc.VertexCount = vertices; clothMeshDesc.TriangleCount = indices / 3; clothMeshDesc.VerticesStream.SetData(grid.Points); clothMeshDesc.TriangleStream.SetData(grid.Indices); // We are using 32 bit integers for our indices, so make sure the 16 bit flag is removed. // 32 bits are the default, so this isn't technically needed, but it's good to show in a sample clothMeshDesc.Flags &= ~MeshFlag.Indices16Bit; clothMeshDesc.Flags |= (MeshFlag)((int)clothMeshDesc.Flags | (int)ClothMeshFlag.Tearable); // Write the cooked data to memory using (var memoryStream = new MemoryStream()) { Cooking.InitializeCooking(); Cooking.CookClothMesh(clothMeshDesc, memoryStream); Cooking.CloseCooking(); // Need to reset the position of the stream to the beginning memoryStream.Position = 0; clothMesh = Engine.Core.CreateClothMesh(memoryStream); } } // int j = vertices * 2; int k = indices * 3; var clothDesc = new ClothDescription() { ClothMesh = clothMesh, GlobalPose = Matrix.Translation(-hw, 0, -hh) * Matrix.Translation(p), Flags = ClothFlag.Gravity | ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization | ClothFlag.Tearable, BendingStiffness = 0.1f, TearFactor = 1.5f }; clothDesc.MeshData.AllocatePositions<Vector3>(j); clothDesc.MeshData.AllocateIndices<int>(k); clothDesc.MeshData.AllocateNormals<Vector3>(j); clothDesc.MeshData.MaximumVertices = j; clothDesc.MeshData.MaximumIndices = k; clothDesc.MeshData.NumberOfVertices = vertices; clothDesc.MeshData.NumberOfIndices = indices; _cloth = scene.CreateCloth(clothDesc); // // Four corner boxes to hold it in place var positions = new[] { new Vector3(0, 0, -hh), // Back new Vector3(0, 0, hh), // Front new Vector3(-hw, 0, 0), // Left new Vector3(hw, 0, 0), // Right }; var sizes = new[] { new Vector3(w, 1, 1), // Back new Vector3(w, 1, 1), // Front new Vector3(1, 1, h), // Left new Vector3(1, 1, h), //Right }; for (int i = 0; i < 4; i++) { var actorDesc = new ActorDescription() { GlobalPose = Matrix.Translation(positions[i] + p), Shapes = { new BoxShapeDescription(sizes[i]) } }; var actor = scene.CreateActor(actorDesc); _cloth.AttachToShape(actor.Shapes.First(), (ClothAttachmentFlag)0); } // // Something to drop on it { var actorDesc = new ActorDescription() { GlobalPose = Matrix.Translation(0, 100, 0), Shapes = { new SphereShapeDescription(2) }, BodyDescription = new BodyDescription(50) }; var actor = scene.CreateActor(actorDesc); } }
// Use this for initialization void Start() { CapsuleCollider horn = GameObject.FindGameObjectWithTag("Horn").GetComponent<CapsuleCollider>(); cl = GetComponent<Cloth>(); cl.capsuleColliders.SetValue(horn, 0); }
// Use this for initialization void Start() { wind = GameObject.Find("GameController").GetComponent<Wind>(); cloth = gameObject.GetComponent<Cloth>(); }
static int _CreateCloth(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { Cloth obj = new Cloth(); LuaScriptMgr.Push(L, obj); return 1; } else { LuaDLL.luaL_error(L, "invalid arguments to method: Cloth.New"); } return 0; }
// Use this for initialization void Start() { cloth = GetComponentsInChildren<Cloth>()[0]; }
void Start() { cloth=(Cloth)GetComponent<InteractiveCloth>(); }