public void Draw(Matrix4 model, Geometry geometry, ComponentMaterial mat) { GL.UseProgram(m_PBR_Shader.GetProgramId); GL.Uniform1(m_PBR_Shader.GetUniformColourTex, 0); GL.Uniform1(m_PBR_Shader.GetUniformHeightTex, 1); GL.Uniform1(m_PBR_Shader.GetUniformMetalicTex, 2); GL.Uniform1(m_PBR_Shader.GetUniformNormalTex, 3); GL.Uniform1(m_PBR_Shader.GetUniformRoughnessTex, 4); mat.SetActiveTextues(); Matrix4 worldViewProjection = model * MyGame.gameInstance.view * MyGame.gameInstance.projection; Vector3 eyePos = MyGame.gameInstance.view.ExtractTranslation(); Vector4 h = new Vector4(eyePos.X, eyePos.Y, eyePos.Z, 1); GL.Uniform4(m_PBR_Shader.Get_EyePosition, h); GL.Uniform4(m_PBR_Shader.Get_Lightposiytion, MyGame.gameInstance.lightPosition); GL.UniformMatrix4(m_PBR_Shader.GetuniforMVP_Matrix, false, ref worldViewProjection); GL.UniformMatrix4(m_PBR_Shader.Get_uniform_ModelMatrix, false, ref model); GL.UniformMatrix4(m_PBR_Shader.Get_uniform_ViewMatrix, false, ref MyGame.gameInstance.view); GL.UniformMatrix4(m_PBR_Shader.Get_uniform_ProjectionMatrix, false, ref MyGame.gameInstance.projection); geometry.Render(); GL.BindVertexArray(0); GL.UseProgram(0); }
public void SaveComponentMaterial(Sender sender, ComponentMaterial obj) { try { using (ObjectProxy op = new ObjectProxy(true)) { if (op.LoadComponentMaterial(obj) == 0) { obj.Created = DateTime.Now; obj.CreatedBy = sender.UserCode + "." + sender.UserName; obj.Modified = DateTime.Now; obj.ModifiedBy = sender.UserCode + "." + sender.UserName; op.InsertComponentMaterial(obj); } else { obj.Modified = DateTime.Now; obj.ModifiedBy = sender.UserCode + "." + sender.UserName; op.UpdateComponentMaterialByID(obj); } op.CommitTransaction(); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
public List <ComponentMaterial> GetComponentMaterialByID(Sender sender, Int32 ID) { try { using (ObjectProxy op = new ObjectProxy()) { ComponentMaterial obj = new ComponentMaterial(); obj.ID = ID; return(op.LoadComponentMaterialByID(obj)); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
public Drone(string name, List <Vector3> route, int startIndex, Player player) : base(name) { this.route = route; this.player = player; this.startIndex = startIndex; AddComponent(new ComponentGeometry("Drone.obj")); AddComponent(new ComponentMaterial("Drone.png")); AddComponent(new ComponentCollider_Sphere(0.5f, true, transform)); AddComponent(new ComponentSound(new string[] { "Audio/buzz.wav", "Audio/dying.wav" })); callUpdate = true; c_material = GetComponent <ComponentMaterial>(); Initialize(); Player.ResetEvent += Initialize; }
public void OnAction(Entity entity, float dt) { if ((entity.Mask & MASK) == MASK) { List <IComponent> components = entity.Components; IComponent geometryComponent = components.Find(delegate(IComponent component) { return(component.ComponentType == ComponentTypes.COMPONENT_MODEL); }); Geometry[] geometry = ((ComponentModel)geometryComponent).Geometry(); IComponent positionComponent = components.Find(delegate(IComponent component) { return(component.ComponentType == ComponentTypes.COMPONENT_TRANSFORM); }); ComponentTransform transform = ((ComponentTransform)positionComponent); Vector3 position = transform.Position; Vector3 rotation = transform.Rotation; Vector3 scale = transform.Scale; Matrix4 world = Matrix4.CreateScale(scale) * Matrix4.CreateRotationX(rotation.X) * Matrix4.CreateRotationY(rotation.Y) * Matrix4.CreateRotationZ(rotation.Z) * Matrix4.CreateTranslation(position); // Matrix4 world = Matrix4.CreateTranslation(position); IComponent textureComponent = components.Find(delegate(IComponent component) { return(component.ComponentType == ComponentTypes.COMPONENT_MATERIAL); }); ComponentMaterial mat = (ComponentMaterial)textureComponent; for (int i = 0; i < geometry.Length; i++) { Draw(world, geometry[i], mat); } } }
public ComponentMaterial GetComponentMaterial(Sender sender, Int32 ID) { try { using (ObjectProxy op = new ObjectProxy()) { ComponentMaterial obj = new ComponentMaterial(); obj.ID = ID; if (op.LoadComponentMaterial(obj) == 0) { return(null); } return(obj); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
public void OnAction(Entity entity) { if (camera == null) { return; } if ((entity.Mask & MASK) == MASK) { ComponentGeometry geometryComponent = entity.GetComponent <ComponentGeometry>(); ComponentTransform transform = entity.transform; ComponentMaterial materialComponent = entity.GetComponent <ComponentMaterial>(); ComponentSound sound = entity.GetComponent <ComponentSound>(); if (sound != null) { AL.Source(sound.souce[0], ALSource3f.Position, ref transform.position); //sound.playsoundonce(1); } Draw(transform.GetTransformMatrix(), geometryComponent.Geometry(), materialComponent); } }
public void Draw(Matrix4 model, Geometry geometry, ComponentMaterial material) { GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); GL.Enable(EnableCap.Texture2D); GL.UseProgram(material.Shader.ShaderProgramID); // send texture to shader GL.Uniform1(material.Shader.uniform_stex, 0); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, material.Texture.TextureID); // send tint color if (material.Shader.uniform_tint_color != -1) { GL.Uniform4(material.Shader.uniform_tint_color, material.tintColor); } // send matrices to the shader GL.UniformMatrix4(material.Shader.uniform_mat_model, false, ref model); Matrix4 viewMatrix = camera.GetViewMatrix(); GL.UniformMatrix4(material.Shader.uniform_mat_view, false, ref viewMatrix); Matrix4 projectionMatrix = camera.GetProjectionMatrix(); GL.UniformMatrix4(material.Shader.uniform_mat_proj, false, ref projectionMatrix); // light GL.Uniform3(material.Shader.uniform_light_dir, light.transform.forward); GL.Uniform3(material.Shader.uniform_view_dir, camera.transform.forward); geometry.Render(); GL.BindVertexArray(0); GL.UseProgram(0); }
/// <summary> /// 加载组件物料数据,ComponentMaterialExtension /// </summary> /// <param name="lstAllRow"></param> /// <param name="componentTypeLevel"></param> /// <param name="lstProductComponent"></param> protected void LoadComponentMaterialList(List <DataRow> lstAllRow, List <string> componentTypeLevel, List <ProductComponent> lstProductComponent, ref List <ComponentMaterial> lstComponentMaterial) { //当前是第几阶层 string currentTypeLevel = componentTypeLevel[componentTypeLevel.Count - 1]; //获取每一阶层下所有的组件类型 List <string> lstChildType = lstAllRow.Select(x => x.Field <string>(currentTypeLevel)).Distinct().ToList(); Dictionary <string, List <DataRow> > dicTypeListRow = lstAllRow.GroupBy(x => x.Field <string>(currentTypeLevel)).ToDictionary(group => group.Key, group => group.ToList()); if (dicTypeListRow == null || dicTypeListRow.Count == 0) { return; } foreach (KeyValuePair <string, List <DataRow> > kvp in dicTypeListRow) { //如果阶层的组件类型名称为空,则继续循环下一阶层 if (string.IsNullOrEmpty(kvp.Key)) { componentTypeLevel.Remove(currentTypeLevel); LoadComponentMaterialList(kvp.Value, componentTypeLevel, lstProductComponent, ref lstComponentMaterial); } else { //确保该组件类型在数据表ProductComponent中是存在并且有效的,防止错误数据导入 var productComponent = lstProductComponent.FirstOrDefault(x => x.ComponentTypeName.Equals(kvp.Key)); if (productComponent == null) { continue; } foreach (DataRow dr in kvp.Value) { ComponentMaterial model = new ComponentMaterial() { ComponentID = productComponent.ComponentID, MaterialCode = dr["材料编码"].ToString(), MaterialName = dr["材料名称"].ToString(), Specification = dr["材料规格"].ToString(), Unit = dr["单位"].ToString(), Amount = dr["用量"] == null ? 0 : Convert.ToDecimal(dr["用量"]), Quantity = dr["数量"] == null ? 0 : Convert.ToDecimal(dr["数量"]), PlateName = dr["工件名称"].ToString(), Material = dr["材料"].ToString(), //Color = dr["颜色"].ToString(), Length = dr["长"].ToString(), Width = dr["宽"].ToString(), Height = dr["厚"].ToString(), CutLength = dr["开料长"].ToString(), CutWidth = dr["开料宽"].ToString(), //CutHeight = dr["开料厚"].ToString(), CutArea = dr["开料面积"].ToString(), EdgeFront = dr["前封边"].ToString(), EdgeBack = dr["后封边"].ToString(), EdgeLeft = dr["左封边"].ToString(), EdgeRight = dr["右封边"].ToString(), Veins = dr["纹路"].ToString(), Routing = dr["工艺路线"].ToString(), IsOptimization = dr["是否需要优化"] == null ? false : (dr["是否需要优化"].ToString() == "1" ? true : false), Status = false, ExtensionModel = new ComponentMaterialExtension() { Barcode = dr["条形码"].ToString(), OutputName = dr["输出名称"].ToString(), MprA = dr["A"].ToString(), MprB = dr["B"].ToString(), MachineFile = dr["加工程序"].ToString(), Remark = dr["工件备注"].ToString() } }; lstComponentMaterial.Add(model); } } } }