protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(Resource.Layout.locate_anchors); this.arFragment = (ArFragment)this.SupportFragmentManager.FindFragmentById(Resource.Id.ux_fragment); this.sceneView = this.arFragment.ArSceneView; Scene scene = this.sceneView.Scene; scene.Update += (_, args) => { // Pass frames to Spatial Anchors for processing. this.cloudAnchorManager?.Update(this.sceneView.ArFrame); }; this.exitButton = (Button)this.FindViewById(Resource.Id.backButton); this.exitButton.Click += this.OnExitDemoClicked; this.locateButton = (Button)this.FindViewById(Resource.Id.locateButton); this.locateButton.Click += this.OnLocateButtonClicked; this.textView = (TextView)this.FindViewById(Resource.Id.statusText); this.textView.Visibility = ViewStates.Visible; this.anchorNumInput = (EditText)this.FindViewById(Resource.Id.anchorNumText); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Purple)).GetAsync().ContinueWith(materialTask => { readyColor = (Material)materialTask.Result; foundColor = readyColor; }); }
private void MergeButton_Click(object sender, EventArgs e) { if (MergePanel.Visible) { Panel_Main.Visible = true; MergePanel.Visible = false; for (int i = 0; i < NewMatListBox.CheckedItems.Count; i++) { var mat = (NewMatListBox.CheckedItems[i] as IMaterial); if (mat.GetMTLVersion() != mtl.Version) { mat = MaterialFactory.ConvertMaterial(mtl.Version, mat); } mtl.Materials.Add(mat.GetMaterialHash(), mat); } for (int i = 0; i < OverwriteListBox.CheckedItems.Count; i++) { var mat = (OverwriteListBox.CheckedItems[i] as IMaterial); if (mat.GetMTLVersion() != mtl.Version) { mat = MaterialFactory.ConvertMaterial(mtl.Version, mat); } mtl.Materials[mat.GetMaterialHash()] = mat; } OverwriteListBox.Items.Clear(); NewMatListBox.Items.Clear(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_shared); arFragment = (ArFragment)SupportFragmentManager.FindFragmentById(Resource.Id.ux_fragment); arFragment.TapArPlane += (s, e) => onTapArPlaneListener(e.HitResult, e.Plane, e.MotionEvent); sceneView = arFragment.ArSceneView; textView = FindViewById <TextView>(Resource.Id.textView); textView.Visibility = ViewStates.Visible; locateButton = FindViewById <Button>(Resource.Id.locateButton); createButton = FindViewById <Button>(Resource.Id.createButton); anchorNumInput = FindViewById <EditText>(Resource.Id.anchorNumText); editTextInfo = FindViewById <TextView>(Resource.Id.editTextInfo); enableCorrectUIControls(); Scene scene = sceneView.Scene; scene.Update += (s, e) => { if (cloudAnchorManager != null) { // Pass frames to Spatial Anchors for processing. cloudAnchorManager.Update(sceneView.ArFrame); } }; MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Red)).GetAsync().ContinueWith(t => failedColor = (Material)t.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Green)).GetAsync().ContinueWith(t => savedColor = (Material)t.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Yellow)).GetAsync().ContinueWith(t => readyColor = foundColor = (Material)t.Result); }
public override void Dispose() { MaterialFactory.DeleteMaterial(materialIdx); Physics.DestroyBody(PhysicsId); mesh.Destroy(); mesh = null; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_anchors); basicDemo = Intent.GetBooleanExtra("BasicDemo", true); arFragment = (ArFragment)SupportFragmentManager.FindFragmentById(Resource.Id.ux_fragment); arFragment.TapArPlane += (s, e) => onTapArPlaneListener(e.HitResult, e.Plane, e.MotionEvent); sceneView = arFragment.ArSceneView; Scene scene = sceneView.Scene; scene.Update += (s, e) => { if (cloudAnchorManager != null) { // Pass frames to Spatial Anchors for processing. cloudAnchorManager.Update(sceneView.ArFrame); } ; }; backButton = FindViewById <Button>(Resource.Id.backButton); statusText = FindViewById <TextView>(Resource.Id.statusText); scanProgressText = FindViewById <TextView>(Resource.Id.scanProgressText); actionButton = FindViewById <Button>(Resource.Id.actionButton); actionButton.Click += (s, e) => advanceDemo(); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Red)).GetAsync().ContinueWith(t => failedColor = (Material)t.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Green)).GetAsync().ContinueWith(t => savedColor = (Material)t.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Yellow)).GetAsync().ContinueWith(t => readyColor = foundColor = (Material)t.Result); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(Resource.Layout.create_anchors); this.arFragment = (ArFragment)this.SupportFragmentManager.FindFragmentById(Resource.Id.ux_fragment); this.arFragment.TapArPlane += (sender, args) => this.OnTapArPlaneListener(args.HitResult, args.Plane, args.MotionEvent); this.sceneView = this.arFragment.ArSceneView; Scene scene = this.sceneView.Scene; scene.Update += (_, args) => { // Pass frames to Spatial Anchors for processing. this.cloudAnchorManager?.Update(this.sceneView.ArFrame); }; this.exitButton = (Button)this.FindViewById(Resource.Id.backButton); this.exitButton.Click += this.OnExitDemoClicked; this.textView = (TextView)this.FindViewById(Resource.Id.statusText); this.textView.Visibility = ViewStates.Visible; this.scanProgressText = (TextView)this.FindViewById(Resource.Id.scanProgressText); // Initialize the colors. MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Red)).GetAsync().ContinueWith(materialTask => failedColor = (Material)materialTask.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Green)).GetAsync().ContinueWith(materialTask => savedColor = (Material)materialTask.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Yellow)).GetAsync().ContinueWith(materialTask => { readyColor = (Material)materialTask.Result; foundColor = readyColor; }); }
/// <summary> /// This method creates a new instance of class <see cref="Beam{TProfile}"/>. /// This is a step to create the input fot finite element analysis. /// </summary> /// <param name="request"></param> /// <param name="degreesOfFreedom"></param> /// <returns>A new instance of class <see cref="Beam{TProfile}"/>.</returns> public override async Task <Beam <TProfile> > BuildBeam(BeamRequest <TProfile> request, uint degreesOfFreedom) { GeometricProperty geometricProperty = new GeometricProperty(); if (request.Profile.Area != null && request.Profile.MomentOfInertia != null) { geometricProperty.Area = await ArrayFactory.CreateVectorAsync(request.Profile.Area.Value, request.NumberOfElements).ConfigureAwait(false); geometricProperty.MomentOfInertia = await ArrayFactory.CreateVectorAsync(request.Profile.MomentOfInertia.Value, request.NumberOfElements).ConfigureAwait(false); } else { geometricProperty.Area = await this._geometricProperty.CalculateArea(request.Profile, request.NumberOfElements).ConfigureAwait(false); geometricProperty.MomentOfInertia = await this._geometricProperty.CalculateMomentOfInertia(request.Profile, request.NumberOfElements).ConfigureAwait(false); } var beam = new Beam <TProfile>() { Fastenings = await this._mappingResolver.BuildFastenings(request.Fastenings).ConfigureAwait(false), Forces = await this._mappingResolver.BuildForceVector(request.Forces, degreesOfFreedom).ConfigureAwait(false), GeometricProperty = geometricProperty, Length = request.Length, Material = MaterialFactory.Create(request.Material), NumberOfElements = request.NumberOfElements, Profile = request.Profile }; return(beam); }
private void AddMaterial(object sender, EventArgs e) { if (!Panel_Main.Visible) { return; } // Ask user for material name. NewObjectForm form = new NewObjectForm(true); form.SetLabel(Language.GetString("$QUESTION_NAME_OF_MAT")); form.LoadOption(new MaterialAddOption()); if (form.ShowDialog() == DialogResult.OK) { if (mtl.Materials.ContainsKey(FNV64.Hash(form.GetInputText()))) { MessageBox.Show("Found duplicate material. Will not be adding new material!", "Toolkit"); return; } // Create material with new name. IMaterial mat = MaterialFactory.ConstructMaterial(mtl.Version); mat.SetName(form.GetInputText()); mtl.Materials.Add(mat.GetMaterialHash(), mat); dataGridView1.Rows.Add(BuildRowData(mat)); } // Cleanup and reload. form.Dispose(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(Resource.Layout.activity_shared); this.arFragment = (ArFragment)this.SupportFragmentManager.FindFragmentById(Resource.Id.ux_fragment); this.sceneView = this.arFragment.ArSceneView; this.exitButton = (Button)this.FindViewById(Resource.Id.mainMenu); this.exitButton.Click += this.OnExitDemoClicked; this.textView = (TextView)this.FindViewById(Resource.Id.textView); this.textView.Visibility = ViewStates.Visible; this.locateButton = (Button)this.FindViewById(Resource.Id.locateButton); this.locateButton.Click += this.OnLocateButtonClicked; this.anchorNumInput = (EditText)this.FindViewById(Resource.Id.anchorNumText); this.editTextInfo = (TextView)this.FindViewById(Resource.Id.editTextInfo); this.EnableCorrectUIControls(); Scene scene = this.sceneView.Scene; scene.Update += (_, args) => { // Pass frames to Spatial Anchors for processing. this.cloudAnchorManager?.Update(this.sceneView.ArFrame); }; // Initialize the colors. MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Blue)).GetAsync().ContinueWith(materialTask => failedColor = (Material)materialTask.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Green)).GetAsync().ContinueWith(materialTask => savedColor = (Material)materialTask.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Blue)).GetAsync().ContinueWith(materialTask => { readyColor = (Material)materialTask.Result; foundColor = readyColor; }); }
private static Material AssembleMaterial(ParticleSystem ps, Dictionary <int, object> resource) { string texName = (resource[ps.TexId] as Texture3D).Name; ps.UnityResourceParam.MaterialPath = SceneFileCopy.GetRelativeMaterialDir(ps.RootFileName) + ps.Name + ".mat"; Material mtl = MaterialFactory.createMaterial(ps); mtl.SetTexture("_MainTex", UnityEditor.AssetDatabase.LoadAssetAtPath(ps.UnityResourceParam.Texture2DPath, typeof(Texture2D)) as Texture2D); float baseTilingX = 1f; float baseTilingY = 1f; float baseOffsetX = 0f; float baseOffsetY = 0f; mtl.SetTextureScale("_MainTex", new Vector2(baseTilingX, baseTilingY)); mtl.SetTextureOffset("_MainTex", new Vector2(baseOffsetX, baseOffsetY)); uint color = 0xFFFFFFFF; mtl.SetColor("_Color", new Color(((color >> 16) & 0xFF) / 255.0f, ((color >> 8) & 0xFF) / 255.0f, (color & 0xFF) / 255.0f, ((color >> 24) & 0xFF) / 255.0f)); UnityEditor.AssetDatabase.CreateAsset(mtl, ps.UnityResourceParam.MaterialPath); UnityEditor.AssetDatabase.Refresh(); return(mtl); }
public override void AcceptVisit(IVisitor visitor) { visitor.StartVisit <ISimpleFixture>(this); MaterialFactory.AcceptVisit(visitor); ShapeFactory.AcceptVisit(visitor); visitor.EndVisit <ISimpleFixture>(this); }
public void Start(EngineStartParameters parameters) { graphicsHost.CreateWindow(new Vector2(1600, 900)); var mapPath = parameters.LoadPathOverride ?? @"D:\H2vMaps\lockout.map"; var configPath = Environment.GetEnvironmentVariable(ConfigurationConstants.ConfigPathOverrideEnvironmentVariable); if (configPath != null) { configPath = Path.GetFullPath(configPath); } else { configPath = Environment.CurrentDirectory + "/Configs"; } var matFactory = new MaterialFactory(configPath); var factory = new MapFactory(Path.GetDirectoryName(mapPath)); matFactory.AddListener(() => { LoadMap(factory, mapPath, matFactory); }); world = new RealtimeWorld(gameWindowGetter(), audioHost.GetAudioAdapter(), graphicsHost); LoadMap(factory, mapPath, matFactory); gameLoop.RegisterCallbacks(world.Update, world.Render); gameLoop.Start(60, 60); }
public static async Task <Material> CreateAsync(IAwaitCaller awaitCaller, GltfParser parser, int m_index, glTF_VRM_Material vrmMaterial, GetTextureAsyncFunc getTexture) { var item = vrmMaterial; var shaderName = item.shader; var shader = Shader.Find(shaderName); if (shader == null) { // // no shader // if (VRM_SHADER_NAMES.Contains(shaderName)) { Debug.LogErrorFormat("shader {0} not found. set Assets/VRM/Shaders/VRMShaders to Edit - project setting - Graphics - preloaded shaders", shaderName); } else { // #if VRM_DEVELOP // Debug.LogWarningFormat("unknown shader {0}.", shaderName); // #endif } return(await MaterialFactory.DefaultCreateMaterialAsync(awaitCaller, parser, m_index, getTexture)); } // // restore VRM material // var material = new Material(shader); // use material.name, because material name may renamed in GltfParser. material.name = parser.GLTF.materials[m_index].name; material.renderQueue = item.renderQueue; foreach (var kv in item.floatProperties) { material.SetFloat(kv.Key, kv.Value); } var offsetScaleMap = new Dictionary <string, float[]>(); foreach (var kv in item.vectorProperties) { if (item.textureProperties.ContainsKey(kv.Key)) { // texture offset & scale offsetScaleMap.Add(kv.Key, kv.Value); } else { // vector4 var v = new Vector4(kv.Value[0], kv.Value[1], kv.Value[2], kv.Value[3]); material.SetVector(kv.Key, v); } } foreach (var kv in item.textureProperties) { var(offset, scale) = (Vector2.zero, Vector2.one); if (offsetScaleMap.TryGetValue(kv.Key, out float[] value))
public static void ConvertColourGradingViaLUT(PostProcessProfile ppp, ColorGradingModel oldColorGradingSettings, PostProcessingProfile oldPPP) { var materialFactory = new MaterialFactory(); var uberShader = materialFactory.Get("Hidden/Post FX/Uber Shader"); uberShader.shaderKeywords = new string[0]; var cgc = new ColorGradingComponent(); cgc.Init(new PostProcessingContext { materialFactory = materialFactory }, oldColorGradingSettings); cgc.context.profile = oldPPP; cgc.Prepare(uberShader); var cg = ppp.AddSettings <ColorGrading>(); cg.gradingMode.value = GradingMode.LowDefinitionRange; cg.gradingMode.overrideState = true; var lut = cgc.model.bakedLut; /* * var textureFormat = TextureFormat.RGBAHalf; * if (!SystemInfo.SupportsTextureFormat(textureFormat)) * textureFormat = TextureFormat.ARGB32; * * var lutAsT2D = lut.GrabTexture(dontUseCopyTexture: true, format: textureFormat).GetPixels(); * * for (int i = 0; i < lutAsT2D.Length; i++) * { * lutAsT2D[i] = lutAsT2D[i].gamma; * } * * var newLut = new Texture2D(lut.width, lut.height, textureFormat, false, true); * newLut.SetPixels(lutAsT2D); * newLut.Apply(true, false); */ cg.ldrLut.value = lut;//newLut;//TextureCompositor.GPUDegamma(newLut, null, true); cg.ldrLut.overrideState = true; cg.ldrLutContribution.value = 1.0f; cg.ldrLutContribution.overrideState = true; var exposure = ppp.AddSettings <AutoExposure>(); exposure.eyeAdaptation.value = EyeAdaptation.Fixed; exposure.eyeAdaptation.overrideState = true; exposure.keyValue.value = 1.0f; exposure.keyValue.overrideState = true; }
public PostProcessingContext Reset() { profile = null; camera = null; materialFactory = null; renderTextureFactory = null; interrupted = false; return(this); }
public PostProcessingContext Reset() { profile = null; camera = null; materialFactory = null; renderTextureFactory = null; interrupted = false; return this; }
public static Material TeamIdToLogo(int teamId) { if (TeamIdToLogoMaster.ContainsKey(teamId)) { return(TeamIdToLogoMaster[teamId]); } return(MaterialFactory.GetDefaultMaterial()); }
public Task <Material> CreateMaterialAsync(IAwaitCaller awaitCaller, glTF gltf, int i, GetTextureAsyncFunc getTexture) { if (i == 0 && m_materials.Count == 0) { // dummy return(MaterialFactory.DefaultCreateMaterialAsync(awaitCaller, gltf, i, getTexture)); } return(MToonMaterialItem.CreateAsync(awaitCaller, gltf, i, m_materials[i], getTexture)); }
protected override void OnProcessOutputSchema(MutableObject newSchema) { if (SchemaMaterial == null) { SchemaMaterial = GameObject.Instantiate(MaterialFactory.GetDefaultMaterial()); } MaterialTarget.SetValue(SchemaMaterial, newSchema); Router.TransmitAllSchema(newSchema); }
public void SetColor(Context context, int rgb) { lock (this) { if (!solidColorMaterialCache.ContainsKey(rgb)) { solidColorMaterialCache[rgb] = MaterialFactory.MakeOpaqueWithColor(context, new Color(rgb)); } CompletableFuture loadMaterial = solidColorMaterialCache[rgb]; loadMaterial.ThenAccept(new FutureResultConsumer <Material>(SetMaterial)); } }
public Material() { this.Created_At = DateTime.Now; this.Updated_At = DateTime.Now; MaterialFactory theFactory = new MaterialFactory(); _repository = theFactory.createRepository(); if (_repository == null) { throw new NotImplementedException(); } }
private GameObject AddTestModel(string model, string materialName) { GameObject gameObject = new GameObject(); gameObject.AddComponent(new ModelComponent(SystemCore.ContentManager.Load <Model>(model))); MaterialFactory.ApplyMaterialComponent(gameObject, materialName); gameObject.AddComponent(new ShadowCasterComponent()); //gameObject.AddComponent(new RotatorComponent(Vector3.Up, 0.001f)); gameObject.AddComponent(new SquareParticleSystem()); SystemCore.GameObjectManager.AddAndInitialiseGameObject(gameObject); return(gameObject); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_shared); arFragment = (ArFragment)SupportFragmentManager.FindFragmentById(Resource.Id.ux_fragment); arFragment.TapArPlane += (sender, args) => OnTapArPlaneListener(args.HitResult, args.Plane, args.MotionEvent); sceneView = arFragment.ArSceneView; exitButton = (Button)FindViewById(Resource.Id.mainMenu); exitButton.Click += OnExitDemoClicked; exitButton.Visibility = ViewStates.Gone; textView = (TextView)FindViewById(Resource.Id.textView); textView.Visibility = ViewStates.Visible; locateButton = (Button)FindViewById(Resource.Id.locateButton); locateButton.Click += OnLocateButtonClicked; createButton = (Button)FindViewById(Resource.Id.createButton); createButton.Click += OnCreateButtonClicked; anchorNumInput = (EditText)FindViewById(Resource.Id.anchorNumText); editTextInfo = (TextView)FindViewById(Resource.Id.editTextInfo); backingPlateTwo = (LinearLayout)FindViewById(Resource.Id.backingplateTwo); currentStep = DemoStep.MindrStart; EnableCorrectUIControls(); Scene scene = sceneView.Scene; scene.Update += (_, args) => { // Pass frames to Spatial Anchors for processing. cloudAnchorManager?.Update(sceneView.ArFrame); }; // Initialize the colors. MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Red)).GetAsync().ContinueWith(materialTask => failedColor = (Material)materialTask.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Green)).GetAsync().ContinueWith(materialTask => savedColor = (Material)materialTask.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.DarkBlue)).GetAsync().ContinueWith(materialTask => selectedColor = (Material)materialTask.Result); MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Orange)).GetAsync().ContinueWith(materialTask => { readyColor = (Material)materialTask.Result; foundColor = readyColor; }); // HAX LocateAllAnchors(); }
/// <summary> /// This method creates a new instance of class <see cref="BeamWithDva{TProfile}"/>. /// This is a step to create the input fot finite element analysis. /// </summary> /// <param name="request"></param> /// <param name="degreesOfFreedom"></param> /// <returns>A new instance of class <see cref="Beam{TProfile}"/>.</returns> public override async Task <BeamWithDva <TProfile> > BuildBeam(BeamWithDvaRequest <TProfile> request, uint degreesOfFreedom) { double[] dvaMasses = new double[request.Dvas.Count]; double[] dvaStiffnesses = new double[request.Dvas.Count]; uint[] dvaNodePositions = new uint[request.Dvas.Count]; int i = 0; foreach (DynamicVibrationAbsorber dva in request.Dvas) { dvaMasses[i] = dva.Mass; dvaStiffnesses[i] = dva.Stiffness; dvaNodePositions[i] = dva.NodePosition; i += 1; } GeometricProperty geometricProperty = new GeometricProperty(); if (request.Profile.Area != 0 && request.Profile.MomentOfInertia != 0) { geometricProperty.Area = await ArrayFactory.CreateVectorAsync(request.Profile.Area.Value, request.NumberOfElements).ConfigureAwait(false); geometricProperty.MomentOfInertia = await ArrayFactory.CreateVectorAsync(request.Profile.MomentOfInertia.Value, request.NumberOfElements).ConfigureAwait(false); } else { geometricProperty.Area = await this._geometricProperty.CalculateArea(request.Profile, request.NumberOfElements).ConfigureAwait(false); geometricProperty.MomentOfInertia = await this._geometricProperty.CalculateMomentOfInertia(request.Profile, request.NumberOfElements).ConfigureAwait(false); } var beam = new BeamWithDva <TProfile>() { DvaMasses = dvaMasses, DvaNodePositions = dvaNodePositions, DvaStiffnesses = dvaStiffnesses, Fastenings = await this._mappingResolver.BuildFastenings(request.Fastenings).ConfigureAwait(false), Forces = await this._mappingResolver.BuildForceVector(request.Forces, degreesOfFreedom + (uint)request.Dvas.Count).ConfigureAwait(false), GeometricProperty = geometricProperty, Length = request.Length, Material = MaterialFactory.Create(request.Material), NumberOfElements = request.NumberOfElements, Profile = request.Profile }; return(beam); }
public void CreateCategoria() { var factory = MaterialFactory.Create(); Categoria categoria = factory.getCategoria(); categoria.Descricao = "Componente para ser usado em computador"; categoria.Nome = "Teclado"; categoria.Status = "AT"; MaterialContexto materialContexto = factory.getContexto(); materialContexto.Categoria.Add(categoria); int retorno = materialContexto.SaveChanges(); Assert.AreEqual(retorno, 1); }
public VRMMetaObject ReadMeta(bool createThumbnail = false) { var meta = ScriptableObject.CreateInstance <VRMMetaObject>(); meta.name = "Meta"; meta.ExporterVersion = VRM.exporterVersion; var gltfMeta = VRM.meta; meta.Version = gltfMeta.version; // model version meta.Author = gltfMeta.author; meta.ContactInformation = gltfMeta.contactInformation; meta.Reference = gltfMeta.reference; meta.Title = gltfMeta.title; var thumbnail = MaterialFactory.GetTexture(gltfMeta.texture); if (thumbnail != null) { // ロード済み meta.Thumbnail = thumbnail.Texture; } else if (createThumbnail) { // 作成する(先行ロード用) if (gltfMeta.texture >= 0 && gltfMeta.texture < GLTF.textures.Count) { var t = new TextureItem(gltfMeta.texture, MaterialFactory.CreateTextureLoader(gltfMeta.texture)); t.Process(GLTF, Storage); meta.Thumbnail = t.Texture; } } meta.AllowedUser = gltfMeta.allowedUser; meta.ViolentUssage = gltfMeta.violentUssage; meta.SexualUssage = gltfMeta.sexualUssage; meta.CommercialUssage = gltfMeta.commercialUssage; meta.OtherPermissionUrl = gltfMeta.otherPermissionUrl; meta.LicenseType = gltfMeta.licenseType; meta.OtherLicenseUrl = gltfMeta.otherLicenseUrl; return(meta); }
void OnEnable() { m_CommandBuffers = new Dictionary <Type, KeyValuePair <CameraEvent, CommandBuffer> >(); m_MaterialFactory = new MaterialFactory(); m_RenderTextureFactory = new RenderTextureFactory(); m_Context = new PostProcessingContext(); // Keep a list of all post-fx for automation purposes m_Components = new List <PostProcessingComponentBase>(); // Component list m_DebugViews = AddComponent(new BuiltinDebugViewsComponent()); m_AmbientOcclusion = AddComponent(new AmbientOcclusionComponent()); m_ScreenSpaceReflection = AddComponent(new ScreenSpaceReflectionComponent()); m_FogComponent = AddComponent(new FogComponent()); m_MotionBlur = AddComponent(new MotionBlurComponent()); m_Taa = AddComponent(new TaaComponent()); m_EyeAdaptation = AddComponent(new EyeAdaptationComponent()); m_DepthOfField = AddComponent(new DepthOfFieldComponent()); m_Bloom = AddComponent(new BloomComponent()); m_ChromaticAberration = AddComponent(new ChromaticAberrationComponent()); m_ColorGrading = AddComponent(new ColorGradingComponent()); m_UserLut = AddComponent(new UserLutComponent()); m_Grain = AddComponent(new GrainComponent()); m_Vignette = AddComponent(new VignetteComponent()); m_Dithering = AddComponent(new DitheringComponent()); m_Fxaa = AddComponent(new FxaaComponent()); // Prepare state observers m_ComponentStates = new Dictionary <PostProcessingComponentBase, bool>(); foreach (var component in m_Components) { m_ComponentStates.Add(component, false); } useGUILayout = false; }
public void LoadScenario(string path) { foreach (var c in childWindows) { c.Close(); } childWindows.Clear(); if (string.IsNullOrEmpty(path)) { prefManager.StoreAppPreferences(prefs); return; } var matfac = new MaterialFactory(Environment.CurrentDirectory + "/Configs"); var factory = new MapFactory(Path.GetDirectoryName(path)); var scene = factory.Load(Path.GetFileName(path)); var vm = new ScenarioViewModel(scene, prefs.DiscoveryMode); DataCtx.LoadedScenario = vm; DataCtx.SelectedEntry = vm.TreeRoots[0]; loadedMap = path; this.Title = $"OpenH2 Scenario Explorer - {Path.GetFileName(path)} {(prefs.DiscoveryMode ? "[Discovery Mode]" : "")}"; prefs.LastBrowseLocation = Path.GetDirectoryName(path); var list = prefs.RecentFiles.ToList(); list.Insert(0, path); prefs.RecentFiles = list.Take(5).Distinct().ToArray(); prefManager.StoreAppPreferences(prefs); }
static Program() { m_SettingsFilepath = FindFilepath("EditorSettings.xml"); m_TextureManager = new TextureManager(); m_MaterialFactory = new MaterialFactory(m_TextureManager); }
void OnEnable() { matFactory = new MaterialFactory(); }
public static async Task <Material> CreateAsync(IAwaitCaller awaitCaller, glTF gltf, int m_index, glTF_VRM_Material vrmMaterial, GetTextureAsyncFunc getTexture) { var item = vrmMaterial; var shaderName = item.shader; var shader = Shader.Find(shaderName); if (shader == null) { // // no shader // if (VRM_SHADER_NAMES.Contains(shaderName)) { Debug.LogErrorFormat("shader {0} not found. set Assets/VRM/Shaders/VRMShaders to Edit - project setting - Graphics - preloaded shaders", shaderName); } else { // #if VRM_DEVELOP // Debug.LogWarningFormat("unknown shader {0}.", shaderName); // #endif } return(await MaterialFactory.DefaultCreateMaterialAsync(awaitCaller, gltf, m_index, getTexture)); } // // restore VRM material // var material = new Material(shader); // use material.name, because material name may renamed in GltfParser. material.name = gltf.materials[m_index].name; material.renderQueue = item.renderQueue; foreach (var kv in item.floatProperties) { material.SetFloat(kv.Key, kv.Value); } foreach (var kv in item.vectorProperties) { if (item.textureProperties.ContainsKey(kv.Key)) { // texture offset & scale material.SetTextureOffset(kv.Key, new Vector2(kv.Value[0], kv.Value[1])); material.SetTextureScale(kv.Key, new Vector2(kv.Value[2], kv.Value[3])); } else { // vector4 var v = new Vector4(kv.Value[0], kv.Value[1], kv.Value[2], kv.Value[3]); material.SetVector(kv.Key, v); } } foreach (var kv in item.textureProperties) { var param = GetTextureParam.Create(gltf, kv.Value, kv.Key, 1, 1); var texture = await getTexture(awaitCaller, gltf, param); if (texture != null) { material.SetTexture(kv.Key, texture); } } foreach (var kv in item.keywordMap) { if (kv.Value) { material.EnableKeyword(kv.Key); } else { material.DisableKeyword(kv.Key); } } foreach (var kv in item.tagMap) { material.SetOverrideTag(kv.Key, kv.Value); } if (shaderName == MToon.Utils.ShaderName) { // TODO: Material拡張にMToonの項目が追加されたら旧バージョンのshaderPropから変換をかける // インポート時にUniVRMに含まれるMToonのバージョンに上書きする material.SetFloat(MToon.Utils.PropVersion, MToon.Utils.VersionNumber); } return(material); }
private void LoadTextures() { //mesh.SetShadowCast(true, true); var lightMode = LightMode.Managed; for (var i = 0; i < mesh.GetGroupCount(); i++) { var textureInfo = TextureFactory.GetTextureInfo(mesh.GetTexture(i)); // Skip if there is no texture. if (textureInfo.Filename.Equals(textureInfo.Name)) { break; } var normalTexture = string.Empty; var normalTextureName = string.Empty; var specularTexture = string.Empty; var specularTextureName = string.Empty; var heightTexture = string.Empty; var heightTextureName = string.Empty; var texture = textureInfo.Filename; var fileInfo = new FileInfo(textureInfo.Filename); normalTextureName = fileInfo.Name.Replace(fileInfo.Extension, Constants.TextureNormalSuffix + fileInfo.Extension); normalTexture = Directory.GetParent(textureInfo.Filename) + @"\" + normalTextureName; heightTextureName = fileInfo.Name.Replace(fileInfo.Extension, Constants.TextureHeightSuffix + fileInfo.Extension); heightTexture = Directory.GetParent(textureInfo.Filename) + @"\" + heightTextureName; specularTextureName = fileInfo.Name.Replace(fileInfo.Extension, Constants.TextureSpecularSuffix + fileInfo.Extension); specularTexture = Directory.GetParent(textureInfo.Filename) + @"\" + specularTextureName; //mesh.SetTextureEx((int)CONST_TV_LAYER.TV_LAYER_BASETEXTURE, Globals.GetTex(textureInfo.Name), i); if (File.Exists(normalTexture)) { var normalId = TextureFactory.LoadTexture(normalTexture, normalTextureName); mesh.SetTextureEx((int)CONST_TV_LAYER.TV_LAYER_NORMALMAP, normalId, i); if (lightMode != LightMode.Offset) { lightMode = LightMode.Normal; } if (File.Exists(specularTexture)) { var alphaId = TextureFactory.LoadTexture(specularTexture); var specularId = TextureFactory.AddAlphaChannel(normalId, alphaId, specularTexture); mesh.SetTextureEx((int)CONST_TV_LAYER.TV_LAYER_SPECULARMAP, specularId, i); } } if (File.Exists(heightTexture)) { var heightId = TextureFactory.LoadTexture(heightTexture); mesh.SetTextureEx((int)CONST_TV_LAYER.TV_LAYER_HEIGHTMAP, heightId, i); lightMode = LightMode.Offset; } } switch (lightMode) { case LightMode.Normal: mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_BUMPMAPPING_TANGENTSPACE); break; case LightMode.Offset: mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_OFFSETBUMPMAPPING_TANGENTSPACE); break; case LightMode.Managed: mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); break; default: mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_NONE); break; } // Setup material TV_COLOR ambient = new TV_COLOR(0.25f, 0.25f, 0.25f, 1f); TV_COLOR diffuse = new TV_COLOR(1f, 1f, 1f, 1f); TV_COLOR specular = new TV_COLOR(0.35f, 0.35f, 0.35f, 1f); TV_COLOR emissive = new TV_COLOR(1f, 1f, 1f, 1f); float power = 100; materialIdx = MaterialFactory.CreateMaterial(); MaterialFactory.SetAmbient(materialIdx, ambient.r, ambient.g, ambient.b, ambient.a); MaterialFactory.SetDiffuse(materialIdx, diffuse.r, diffuse.g, diffuse.b, diffuse.a); MaterialFactory.SetSpecular(materialIdx, specular.r, specular.g, specular.b, specular.a); MaterialFactory.SetEmissive(materialIdx, emissive.r, emissive.g, emissive.b, emissive.a); MaterialFactory.SetPower(materialIdx, power); mesh.SetMaterial(materialIdx); }