public void LoadRawAsset() { if (this.RawRes != null || !File.Exists(this.AssetPath)) { return; } switch (this.ResourceType) { case EResoucresTypes.TextureType: RawRes = new TextureAttribute(this); break; case EResoucresTypes.MatrialType: RawRes = new MaterialAttribute(this); break; case EResoucresTypes.ShaderType: RawRes = new ShaderAttribute(this); break; case EResoucresTypes.MeshType: RawRes = new MeshAttribute(this); break; } }
public async Task <ActionResult> Save(MaterialAttributeViewModel model) { using (MaterialAttributeServiceClient client = new MaterialAttributeServiceClient()) { MaterialAttribute obj = new MaterialAttribute() { Key = new MaterialAttributeKey() { MaterialCode = model.MaterialCode, AttributeName = model.AttributeName }, Value = model.Value, Editor = User.Identity.Name, EditTime = DateTime.Now, }; MethodReturnResult rst = await client.AddAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(FMMResources.StringResource.MaterialAttribute_Save_Success , obj.Key); } return(Json(rst)); } }
public bool UpdateMaterialAttributes(List <MaterialAttribute> lMaterialAttributes) { bool isUpdate = true; try { foreach (MaterialAttribute itemMaterialAttribute in lMaterialAttributes) { var materialAttributes = jmdc.MaterialAttributes.Where(p => p.MaterialId == itemMaterialAttribute.MaterialId && p.AttributeId == itemMaterialAttribute.AttributeId).Select(p => p); if (materialAttributes.Any() == false) { jmdc.MaterialAttributes.InsertOnSubmit(itemMaterialAttribute); jmdc.SubmitChanges(); } else { MaterialAttribute selectedMaterialAttribute = materialAttributes.FirstOrDefault(); selectedMaterialAttribute.MaterialId = itemMaterialAttribute.MaterialId; selectedMaterialAttribute.AttributeId = itemMaterialAttribute.AttributeId; selectedMaterialAttribute.SortOder = itemMaterialAttribute.SortOder; selectedMaterialAttribute.IsRequired = itemMaterialAttribute.IsRequired; jmdc.SubmitChanges(); } } } catch (Exception) { isUpdate = false; return(isUpdate); } return(isUpdate); }
void cb_Click(object sender, RoutedEventArgs e) { CheckBox cb = ((CheckBox)sender); MaterialAttribute r = (MaterialAttribute)Enum.Parse(typeof(MaterialAttribute), cb.Name); if (objectToEdit != null && objectToEdit is Material) { ((Material)objectToEdit).setAttribute(r, cb.IsChecked.HasValue && cb.IsChecked.Value); } }
public RayTracingObject() { o_type = ObjectType.none; l_type = LightType.none; m_type = MaterialType.none; pos = Vector3.zero; rot = Vector3.zero; scale = Vector3.one; whrInfo = Vector3.zero; yminmax = Vector2.zero; mattr = new MaterialAttribute(); lightColor = Vector3.zero; nsample = 0; }
public JsonResult UpdateAttribute([FromBody] MaterialAttribute obj) { var msg = new JMessage { Title = "", Error = false }; try { _context.MaterialAttributes.Update(obj); _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_UPDATE_SUCCESS"), CommonUtil.ResourceValue("MLP_MSG_PROPETIES_ADD")); } catch { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_UPDATE_FAILED"), CommonUtil.ResourceValue("MLP_MSG_PROPETIES_ADD")); } return(Json(msg)); }
private void WriteMaterialAttribute(uint version, MaterialAttribute attribute) { WriteUInt(attribute.RawFlags); switch (attribute.Type) { case MaterialAttributeType.Type0: WriteMaterialAttributeType0(version, ( MaterialAttributeType0 )attribute); break; case MaterialAttributeType.Type1: WriteMaterialAttributeType1(version, ( MaterialAttributeType1 )attribute); break; case MaterialAttributeType.Type2: WriteMaterialAttributeType2(( MaterialAttributeType2 )attribute); break; case MaterialAttributeType.Type3: WriteMaterialAttributeType3(( MaterialAttributeType3 )attribute); break; case MaterialAttributeType.Type4: WriteMaterialAttributeType4(( MaterialAttributeType4 )attribute); break; case MaterialAttributeType.Type5: WriteMaterialAttributeType5(( MaterialAttributeType5 )attribute); break; case MaterialAttributeType.Type6: WriteMaterialAttributeType6(( MaterialAttributeType6 )attribute); break; case MaterialAttributeType.Type7: // no data break; default: throw new Exception($"Unknown material attribute type { attribute.Type } "); } }
public bool DeleteAttributeFromMaterial(int MaterialId, int AttributeId) { bool isResult = true; try { MaterialAttribute objMaterialAttribute = jmdc.MaterialAttributes.Where(p => p.MaterialId == MaterialId && p.AttributeId == AttributeId).Select(p => p).FirstOrDefault(); if (objMaterialAttribute != null) { jmdc.MaterialAttributes.DeleteOnSubmit(objMaterialAttribute); jmdc.SubmitChanges(); } } catch (Exception) { isResult = false; throw; } return(isResult); }
private void bSave_Click(object sender, RoutedEventArgs e) { int iMaterialId = Convert.ToInt32(dMaterials.SelectedValue); if (iMaterialId != 0) { Material objSelectedMaterial = new Material(); objSelectedMaterial.Id = Convert.ToInt32(dMaterials.SelectedValue); objSelectedMaterial.Name = dMaterials.Text; objSelectedMaterial.TypeId = Convert.ToInt32(dMaterialType.SelectedValue); objSelectedMaterial.IsActive = Convert.ToBoolean(cIsEnable.IsChecked); List <MaterialGridAttribute> objSelectedMaterialGridAttribute = (List <MaterialGridAttribute>)dSelectedAttributes.ItemsSource; List <MaterialAttribute> lSelectedMaterialAttributes = new List <MaterialAttribute>(); for (int i = 1; i <= objSelectedMaterialGridAttribute.Count(); i++) { MaterialAttribute objMaterialAttribute = new MaterialAttribute(); objMaterialAttribute.MaterialId = objSelectedMaterial.Id; objMaterialAttribute.AttributeId = objSelectedMaterialGridAttribute[i - 1].Attribute.AttributeId; objMaterialAttribute.SortOder = i; objMaterialAttribute.IsRequired = true; lSelectedMaterialAttributes.Add(objMaterialAttribute); } bool isMaterialUpdate = objDataAccess.UpdateMaterial(objSelectedMaterial); if (isMaterialUpdate) { bool isMaterialAttributeUpdate = objDataAccess.UpdateMaterialAttributes(lSelectedMaterialAttributes); if (isMaterialAttributeUpdate) { MessageBox.Show("Material Saved successfully"); } } else { MessageBox.Show("Material Failed to Save"); } // For existing material save } else { // For New Material save Material objNewMaterial = new Material(); objNewMaterial.Name = dMaterials.Text; objNewMaterial.IsActive = Convert.ToBoolean(cIsEnable.IsChecked); objNewMaterial.TypeId = Convert.ToInt32(dMaterialType.SelectedValue); bool isSuccesss = objDataAccess.AddMaterial(objNewMaterial); List <MaterialGridAttribute> objSelectedMaterialGridAttribute = (List <MaterialGridAttribute>)dSelectedAttributes.ItemsSource; if (objSelectedMaterialGridAttribute != null) { List <MaterialAttribute> lSelectedMaterialAttributes = new List <MaterialAttribute>(); for (int i = 1; i <= objSelectedMaterialGridAttribute.Count(); i++) { MaterialAttribute objMaterialAttribute = new MaterialAttribute(); objMaterialAttribute.MaterialId = objNewMaterial.Id; objMaterialAttribute.AttributeId = objSelectedMaterialGridAttribute[i - 1].Attribute.AttributeId; objMaterialAttribute.SortOder = i; objMaterialAttribute.IsRequired = true; lSelectedMaterialAttributes.Add(objMaterialAttribute); } if (isSuccesss) { bool isMaterialAttributeUpdate = objDataAccess.UpdateMaterialAttributes(lSelectedMaterialAttributes); if (isMaterialAttributeUpdate) { MessageBox.Show("Material Saved successfully"); } } else { MessageBox.Show("Material Failed to Save"); } } else { MessageBox.Show("Material cannot be saved without selecting selected attribute"); } } ClearScreen(); }
protected override void InitializeCore() { RegisterExportHandler <Stream>(path => MaterialAttribute.Save(Data, path)); RegisterReplaceHandler <Stream>(Resource.Load <MaterialAttributeType7>); }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (objectToEdit == null) { objectToEdit = new Material(); } Material obj = objectToEdit as Material; obj.BaseObjectId = txtBaseObjectId.Text; obj.BaseObjectName = txtBaseObjectName.Text; obj.MaterialIndex = int.Parse(txtMaterialIndex.Text); //custom code obj.Emissive = (float)Emissive.Value; obj.Reflectivity = (float)Reflectivity.Value; obj.ReflectionSmoothness = (float)ReflectionSmoothness.Value; obj.SpecularIntensity = (float)specularIntensity.Value; obj.SpecularPower = (int)specularPower.Value; obj.Roughness = (float)roughness.Value; obj.RefAtNormIncidence = (float)refAtNormIncidence.Value; obj.Smoothness = (float)smoothness.Value; obj.Metalness = (float)metalness.Value; obj.AnisotropicRoughnessX = (float)anisotropicRoughnessX.Value; obj.AnisotropicRoughnessY = (float)anisotropicRoughnessY.Value; if (ddlLightingModel.SelectedItem != null) { obj.LightModel = (LightingModel)Enum.Parse(typeof(LightingModel), ((ComboBoxItem)ddlLightingModel.SelectedItem).Name); } foreach (CheckBox cb in divAttributes.Children) { MaterialAttribute r = (MaterialAttribute)Enum.Parse(typeof(MaterialAttribute), cb.Name); obj.setAttribute(r, cb.IsChecked.HasValue && cb.IsChecked.Value); } String cubTexName = cubeMapToLoad.Content != null?cubeMapToLoad.Content.ToString() : ""; if (string.IsNullOrEmpty(cubTexName)) { obj.CubeMapSRV = null; obj.CubeMapTextureName = null; } else { obj.CubeMapSRV = TextureLoader.LoadCubeTexture("fx/" + cubTexName); obj.CubeMapTextureName = cubTexName; } String detailTexName = detailMapToLoad.Content != null?detailMapToLoad.Content.ToString() : ""; if (string.IsNullOrEmpty(detailTexName)) { obj.DetailMapSRV = null; obj.DetailMapTextureName = null; } else { obj.DetailMapSRV = TextureLoader.LoadTexture("detail/" + detailTexName); obj.DetailMapTextureName = detailTexName; } //custom code end obj.Category = objCategory; bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj); if (!success) { MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel); } else { this.Close(); if (parentWindow != null) { parentWindow.Refresh(); } } }
public void setAttribute(MaterialAttribute r, bool val) { initAttributes(); attributes[r] = val; }
public bool getAttribute(MaterialAttribute r) { initAttributes(); return(attributes.ContainsKey(r) ? attributes[r] : false); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // constructors // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Creates a new instance of this class.</summary> /// <param name="t">Type.</param> public __Entity(Type t) { EntityAttribute tattr = (EntityAttribute)t.GetCustomAttribute(typeof(EntityAttribute)); if (tattr == null) { MaterialAttribute mattr = (MaterialAttribute)t.GetCustomAttribute(typeof(MaterialAttribute)); if (mattr != null) { TableName = mattr.TableName; SubsetQuery = mattr.SubsetQuery; IsMaterial = true; } } else { TableName = tattr.TableName; SubsetQuery = tattr.SubsetQuery; ChildKey = tattr.ChildKey; } if (string.IsNullOrWhiteSpace(TableName)) { TableName = t.Name.ToUpper(); } Member = t; List <__Field> fields = new List <__Field>(); foreach (PropertyInfo i in t.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { if ((IgnoreAttribute)i.GetCustomAttribute(typeof(IgnoreAttribute)) != null) { continue; } __Field field = new __Field(this); FieldAttribute fattr = (FieldAttribute)i.GetCustomAttribute(typeof(FieldAttribute)); if (fattr != null) { if (fattr is PrimaryKeyAttribute) { PrimaryKey = field; field.IsPrimaryKey = true; } field.ColumnName = (fattr?.ColumnName ?? i.Name); field.ColumnType = (fattr?.ColumnType ?? i.PropertyType); field.IsNullable = fattr.Nullable; if (field.IsForeignKey = (fattr is ForeignKeyAttribute)) { field.IsExternal = typeof(IEnumerable).IsAssignableFrom(i.PropertyType); field.AssignmentTable = ((ForeignKeyAttribute)fattr).AssignmentTable; field.RemoteColumnName = ((ForeignKeyAttribute)fattr).RemoteColumnName; field.IsManyToMany = (!string.IsNullOrWhiteSpace(field.AssignmentTable)); } } else { if ((i.GetGetMethod() == null) || (!i.GetGetMethod().IsPublic)) { continue; } field.ColumnName = i.Name; field.ColumnType = i.PropertyType; } field.Member = i; fields.Add(field); } Fields = fields.ToArray(); Internals = fields.Where(m => (!m.IsExternal)).ToArray(); Externals = fields.Where(m => m.IsExternal).ToArray(); }