private void CreateInspectorForRow(InspectorTypes type, VarRef var, int row) { UserControl control = Inspectors.CreateInspector(type, var); switch (type) { case InspectorTypes.kMatrix4x4: Grid.SetRowSpan(control, 4); break; case InspectorTypes.kMatrix3x3: Grid.SetRowSpan(control, 3); break; } Grid.SetRow(control, row); Grid.SetColumn(control, 1); grid1.Children.Add(control); }
/** *@class sulphur.controls.inspector.Inspectors *@brief Creates an inspector user control based on an InspectorTypes type *@param[in] type (InspectorTypes) The type of inspector to create *@author Jelle de Haan */ public static UserControl CreateInspector(InspectorTypes type, VarRef var) { switch (type) { case InspectorTypes.kCheckbox: return(new CheckBoxInspector(var)); case InspectorTypes.kColor: return(new ColorInspector(var)); case InspectorTypes.kCombobox: return(new ComboBoxInspector(var)); case InspectorTypes.kImage: return(new ImageInspector(var)); case InspectorTypes.kNumber: return(new NumberInspector(var)); case InspectorTypes.kSlider: return(new SliderInspector(var)); case InspectorTypes.kVector2: return(new Vector2Inspector(var)); case InspectorTypes.kVector3: return(new Vector3Inspector(var)); case InspectorTypes.kVector4: return(new Vector4Inspector(var)); case InspectorTypes.kMatrix3x3: return(new Matrix3x3Inspector(var)); case InspectorTypes.kMatrix4x4: return(new Matrix4x4Inspector(var)); default: return(new NumberInspector(var)); } }
public void AddInspector(string label, InspectorTypes type, VarRef var) { int row = grid1.RowDefinitions.Count - 1; // There is always one row in the designer to fill the item with switch (type) { case InspectorTypes.kMatrix3x3: DefineRows(3); break; case InspectorTypes.kMatrix4x4: DefineRows(4); break; default: DefineRows(1); break; } CreateLabelForRow(label, row); CreateInspectorForRow(type, var, row); }
private void ReadMaterialData(string relative_path) { BinaryReader reader = new BinaryReader(Project.directory_path + "\\" + relative_path); if (!reader.is_ok) { return; } MaterialData material_data = new MaterialData(); material_data.Read(reader); AssetDatabase asset_database = (AssetDatabase)App.Current.Resources["asset_database"]; AssetCacheData pixel_shader_cache = asset_database.Find(material_data.pixel_shader_id, AssetType.kShader); ShaderData pixelShader = ReadShaderData(pixel_shader_cache.path); ub = new UniformBuffer(pixelShader, material_data.uniform_buffers[0].data); inspector_.ClearInspectors(); foreach (var pair in ub.name_map_) { ShaderVariable var = ub.data_map_[pair.Value]; InspectorTypes type = InspectorTypes.kNumber; switch (var.type_) { case ShaderVarType.kBool: type = InspectorTypes.kCheckbox; break; case ShaderVarType.kFloat: case ShaderVarType.kDouble: type = InspectorTypes.kSlider; break; case ShaderVarType.kUint: case ShaderVarType.kUint8: case ShaderVarType.kInt: type = InspectorTypes.kNumber; break; case ShaderVarType.kMat3: type = InspectorTypes.kMatrix3x3; break; case ShaderVarType.kMat4: type = InspectorTypes.kMatrix4x4; break; case ShaderVarType.kVec2: type = InspectorTypes.kVector2; break; case ShaderVarType.kVec3: type = InspectorTypes.kVector3; break; case ShaderVarType.kVec4: type = InspectorTypes.kVector4; break; } inspector_.AddInspector(pair.Key, type, new VarRef(() => ub.data_map_[pair.Value].data_, val => { ub.data_map_[pair.Value].Set(val); material_data.uniform_buffers[0].data = ub.ConstructDataBuffer(); StoreMaterialData(relative_path, material_data); })); } }