public override object TransfomSpawn(object createInstance) { if (AutoHide) { var propertyInfos = Type.GetHighestProperties().Select(i => i.PropertyInfo); var shouldHave = AttributeMappings.Select(i => i.PropertyInfo).Where(i => i != null).ToList(); foreach (var prop in propertyInfos) { if (shouldHave.Any(i => i.Name == prop.Name)) { continue; } { if (AttributeMappings.Any(i => i.PropertyInfo?.Name == prop.Name)) { continue; } AttributeMappings.Add(new AttributeMap(this) { Attributes = new Expression <Func <Attribute> >[] { () => new FieldAttribute { IsVisible = false } }, PropertyInfo = prop }); } } } return(base.TransfomSpawn(createInstance)); }
private void InitializeMappings() { attributeMappings.Add("_position", VertexUsage.Position, 0, 3); attributeMappings.Add("_normal", VertexUsage.Normal, 0, 3); attributeMappings.Add("_polygon_normal", VertexUsage.Normal, 1, 3); attributeMappings.Add("_normal_smooth", VertexUsage.Normal, 2, 3); attributeMappings.Add("_tangent", VertexUsage.Tangent, 0, 3); attributeMappings.Add("_texcoord", VertexUsage.TexCoord, 0, 2); attributeMappings.Add("_color", VertexUsage.Color, 0, 4); /* name in shader uniform */ UniformMappings.Add("_model_to_world_matrix", LogicalUniform.ModelToWorld); UniformMappings.Add("_world_to_model_matrix", LogicalUniform.WorldToModel); UniformMappings.Add("_model_to_clip_matrix", LogicalUniform.ModelToClip); UniformMappings.Add("_clip_to_model_matrix", LogicalUniform.ClipToModel); UniformMappings.Add("_model_to_view_matrix", LogicalUniform.ModelToView); UniformMappings.Add("_view_to_model_matrix", LogicalUniform.ViewToModel); UniformMappings.Add("_world_to_clip_matrix", LogicalUniform.WorldToClip); UniformMappings.Add("_clip_to_world_matrix", LogicalUniform.ClipToWorld); UniformMappings.Add("_view_to_world_matrix", LogicalUniform.ViewToWorld); UniformMappings.Add("_world_to_view_matrix", LogicalUniform.WorldToView); UniformMappings.Add("_view_to_clip_matrix", LogicalUniform.ViewToClip); UniformMappings.Add("_clip_to_view_matrix", LogicalUniform.ClipToView); UniformMappings.Add("_viewport", LogicalUniform.Viewport); UniformMappings.Add("_near_far", LogicalUniform.NearFar); /* name in shader parameter name */ /* lighting */ UniformMappings.Add <Floats> ("_ambient_light_color", "ambient_light_color"); UniformMappings.Add <Floats> ("_light_direction", "light_direction"); UniformMappings.Add <Floats> ("_light_radiance", "light_radiance"); UniformMappings.Add <Floats> ("_light_color", "light_color"); UniformMappings.Add <Floats> ("_exposure", "exposure"); /* material, surface */ UniformMappings.Add <Floats> ("_surface_color", "surface_color"); UniformMappings.Add <Floats> ("_surface_rim_color", "surface_rim_color"); UniformMappings.Add <Floats> ("_surface_diffuse_reflectance_color", "surface_diffuse_reflectance_color"); UniformMappings.Add <Floats> ("_surface_specular_reflectance_color", "surface_specular_reflectance_color"); UniformMappings.Add <Floats> ("_surface_specular_reflectance_exponent", "surface_specular_reflectance_exponent"); UniformMappings.Add <Texture>("_texture", "texture"); UniformMappings.Add <Floats> ("_grid_size", "grid_size"); UniformMappings.Add <Floats> ("_surface_roughness", "surface_roughness"); UniformMappings.Add <Floats> ("_surface_isotropy", "surface_isotropy"); UniformMappings.Add <Floats> ("_alpha", "alpha"); UniformMappings.Add <Floats> ("_global_add_color", "global_add_color"); /* ui */ UniformMappings.Add <Floats> ("_slider_t", "slider_t"); }
protected override void OnLoad(System.EventArgs e) { mesh = new GeometryMesh( new ColladaGeometry("cube.dae"), NormalStyle.CornerNormals ).GetMesh; viewport = new Viewport(base.Width, base.Height); modelFrame.LocalToParent.Set( Matrix4.CreateTranslation(0.0f, 0.0f, 0.0f) ); camera.Frame.LocalToParent.Set( Matrix4.CreateLookAt( new Vector3(0.0f, 0.0f, -4.0f), // camera location new Vector3(0.0f, 0.0f, 0.0f), // aim point new Vector3(0.0f, 1.0f, 0.0f) // up vector ) ); camera.FovYRadians = RenderStack.Math.Conversions.DegreesToRadians(60.0f); camera.ProjectionType = ProjectionType.PerspectiveVertical; program = new Program(vs, fs); attributeMappings.Add("_position", VertexUsage.Position, 0, 3); attributeMappings.Add("_normal", VertexUsage.Normal, 0, 3); program.AttributeMappings = attributeMappings; /* name in shader uniform */ UniformMappings.Add("_model_to_world_matrix", LogicalUniform.ModelToWorld); UniformMappings.Add("_world_to_model_matrix", LogicalUniform.WorldToModel); UniformMappings.Add("_model_to_clip_matrix", LogicalUniform.ModelToClip); UniformMappings.Add("_clip_to_model_matrix", LogicalUniform.ClipToModel); UniformMappings.Add("_world_to_clip_matrix", LogicalUniform.WorldToClip); UniformMappings.Add("_clip_to_world_matrix", LogicalUniform.ClipToWorld); UniformMappings.Add("_view_position_in_world", LogicalUniform.ViewPositionInWorld); /* type name in shader parameter name */ UniformMappings.Add <Floats>("_light_direction", "light_direction"); UniformMappings.Add <Floats>("_light_color", "light_color"); UniformMappings.Add <Floats>("_surface_color", "surface_color"); parameters["surface_color"] = new Floats(1.0f, 1.0f, 1.0f); parameters["light_direction"] = new Floats(0.0f, 1.0f, 0.0f); parameters["light_color"] = new Floats(1.0f, 1.0f, 1.0f); program.Bind(camera); program.Bind(parameters); // Setup initial GL state { // Since we only use one program, we don't // need to touch this after. program.Use(); program.ApplyUniforms(); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); GL.ClearColor(0.5f, 0.5f, 0.5f, 1.0f); // Since we only use one mesh, we don't // need to change this after mesh.ApplyAttributes(program, meshMode); } Resize += new EventHandler <EventArgs>(Application_Resize); Unload += new EventHandler <EventArgs>(Application_Unload); }
public void UpdateViewModel(object dataModel, CatfishDbContext db) { CFEntityType model = dataModel as CFEntityType; Id = model.Id; Name = model.Name; if (!string.IsNullOrEmpty(Name)) { ErrorMessage = ""; } Description = model.Description; // TargetType = model.TargetType.ToString(); foreach (var tt in model.TargetTypesList) //MR jan 15 2018 { TargetType[(int)tt] = true; } CFTypeLabelAttribute att = Attribute.GetCustomAttribute(model.GetType(), typeof(CFTypeLabelAttribute)) as CFTypeLabelAttribute; TypeLabel = att == null?model.GetType().ToString() : att.Name; //populating the available metadata sets array MetadataService srv = new MetadataService(db); var metadataSets = srv.GetMetadataSets(); AvailableMetadataSets.Clear(); AvailableMetadataSets.Add(new MetadataSetListItem(0, "")); foreach (var ms in metadataSets) { if (!string.IsNullOrEmpty(ms.Name)) { AvailableMetadataSets.Add(new MetadataSetListItem(ms.Id, ms.Name)); List <string> addList = new List <string>(); addList.Add(""); addList = addList.Concat((ms.Fields.Select(f => f.Name).ToList())).ToList(); if (!MetadataSetFields.ContainsKey(ms.Id.ToString())) { MetadataSetFields.Add(ms.Id.ToString(), addList); } } } //populating the associated metadata sets array AssociatedMetadataSets.Clear(); foreach (var ms in model.MetadataSets) { AssociatedMetadataSets.Add(new MetadataSetListItem(ms.Id, ms.Name)); } AttributeMappings.Clear(); if (model.AttributeMappings.Count > 0) { foreach (CFEntityTypeAttributeMapping map in model.AttributeMappings) { if (map.Name.Equals("Name Mapping"))// || map.Name.Equals("Description Mapping")) { map.Deletable = false; } AttributeMappings.Add(new AttributeMapping { Id = map.Id, Name = map.Name, Field = map.FieldName, MetadataSetFieldId = map.MetadataSetId, Label = map.Label, Deletable = map.Deletable }); } } else { AttributeMappings.Add(new AttributeMapping { Id = 0, Name = "Name Mapping", Deletable = false }); AttributeMappings.Add(new AttributeMapping { Id = 0, Name = "Description Mapping", Deletable = true, ErrorMessage = "" }); } }
protected override void OnLoad(System.EventArgs e) { // Check GL version and feature capabilities RenderStack.Graphics.Configuration.Initialize(); if (RenderStack.Graphics.Configuration.canUseFramebufferObject == false) { throw new System.PlatformNotSupportedException( "GL version 3.0 or GL_ARB_framebuffer_object extension is needed. Neither was found." ); } if (RenderStack.Graphics.Configuration.canUseBaseVertex == false) { throw new System.PlatformNotSupportedException( "GL version 3.2 or GL_ARB_draw_elements_base_vertex extension is needed. Neither was found." ); } sphereMesh = new GeometryMesh(new Sphere(2.00f, 20, 20), NormalStyle.PointNormals).GetMesh; quadMesh = new GeometryMesh(new QuadXY(1.0f, 1.0f, 0.0f), NormalStyle.PolygonNormals).GetMesh; // Initialize shared resources attributeMappings.Add("_position", VertexUsage.Position, 0, 3); attributeMappings.Add("_normal", VertexUsage.Normal, 0, 3); attributeMappings.Add("_texcoord", VertexUsage.TexCoord, 0, 2); UniformMappings.Add("_model_to_world_matrix", LogicalUniform.ModelToWorld); UniformMappings.Add("_world_to_model_matrix", LogicalUniform.WorldToModel); UniformMappings.Add("_model_to_clip_matrix", LogicalUniform.ModelToClip); UniformMappings.Add("_clip_to_model_matrix", LogicalUniform.ClipToModel); UniformMappings.Add("_world_to_clip_matrix", LogicalUniform.WorldToClip); UniformMappings.Add("_clip_to_world_matrix", LogicalUniform.ClipToWorld); UniformMappings.Add("_view_position_in_world", LogicalUniform.ViewPositionInWorld); UniformMappings.Add <Floats>("_light_direction", "light_direction"); UniformMappings.Add <Floats>("_light_color", "light_color"); UniformMappings.Add <Floats>("_surface_color", "surface_color"); UniformMappings.Add <Texture>("_texture", "texture"); UniformMappings.Add <Floats> ("_t", "t"); parameters["surface_color"] = new Floats(1.0f, 1.0f, 1.0f); parameters["light_direction"] = new Floats(0.0f, 1.0f, 0.0f); parameters["light_color"] = new Floats(1.0f, 1.0f, 1.0f); parameters["t"] = new Floats(0.5f); // Initialize resources used by the first pass (render to texture) framebuffer = new Framebuffer(128, 128); framebuffer.AttachTexture(FramebufferAttachment.ColorAttachment0, PixelFormat.Rgb, PixelInternalFormat.Rgb8); framebuffer.AttachRenderBuffer(FramebufferAttachment.DepthAttachment, PixelFormat.DepthComponent, RenderbufferStorage.DepthComponent32, 0); framebuffer.Begin(); framebuffer.Check(); framebuffer.End(); cameraOne.Frame.LocalToParent.Set( Matrix4.CreateLookAt( new Vector3(0.0f, 0.0f, -4.0f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f) ) ); cameraOne.FovYRadians = RenderStack.Math.Conversions.DegreesToRadians(60.0f); cameraOne.ProjectionType = ProjectionType.PerspectiveVertical; ulong updateSerial = 1; cameraOne.Frame.UpdateHierarchical(updateSerial); quadFrame.UpdateHierarchical(updateSerial); cameraOne.UpdateFrame(); cameraOne.UpdateViewport(framebuffer); cameraOne.UpdateModelFrame(quadFrame); if (RenderStack.Graphics.Configuration.glslVersion >= 330) { diffuseProgram = new ProgramDeprecated(vsDiffuse330, fsDiffuse330); } else { diffuseProgram = new ProgramDeprecated(vsDiffuse120, fsDiffuse120); } diffuseProgram.AttributeMappings = attributeMappings; diffuseProgram.Bind(cameraOne); diffuseProgram.Bind(parameters); // Initialize resources used by the second pass (render to screen, using texture) windowViewport = new Viewport(base.Width, base.Height); cameraTwo.Frame.LocalToParent.Set( Matrix4.CreateLookAt( new Vector3(0.0f, 0.0f, -2.0f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f) ) ); cameraTwo.FovYRadians = RenderStack.Math.Conversions.DegreesToRadians(60.0f); cameraTwo.ProjectionType = ProjectionType.PerspectiveVertical; cameraTwo.Frame.UpdateHierarchical(updateSerial); sphereFrame.UpdateHierarchical(updateSerial); cameraTwo.UpdateFrame(); cameraTwo.UpdateViewport(windowViewport); cameraTwo.UpdateModelFrame(sphereFrame); parameters["texture"] = framebuffer[FramebufferAttachment.ColorAttachment0]; if (RenderStack.Graphics.Configuration.glslVersion >= 330) { texturedProgram = new ProgramDeprecated(vsTextured330, fsTextured330); } else { texturedProgram = new ProgramDeprecated(vsTextured120, fsTextured120); } texturedProgram.AttributeMappings = attributeMappings; texturedProgram.Bind(cameraTwo); texturedProgram.Bind(parameters); diffuseProgram.Use(); diffuseProgram.ApplyUniforms(); texturedProgram.Use(); texturedProgram.ApplyUniforms(); EnsureUploaded(sphereMesh); EnsureUploaded(quadMesh); // Setup some GL state GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); Resize += new EventHandler <EventArgs>(Application_Resize); Unload += new EventHandler <EventArgs>(Application_Unload); GL.ClearColor(0.5f, 0.5f, 0.5f, 1.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); SwapBuffers(); Visible = true; }