public DxForm(string ApplicationName, string ApplicationVersion) { APPLICATION_NAME = ApplicationName; APPLICATION_VERSION = ApplicationVersion; #if RENDER_0 APPLICATION_VERSION += " [version without 3D models rendering]"; #endif InitializeComponent(); #if RENDER_1 Application.AddMessageFilter(new CScrollPanelMessageFilter(this.PanelDirectX)); // neaded to get event about scroll wheal in the panel this.PanelDirectX.MouseMove += new System.Windows.Forms.MouseEventHandler(ClEventSender.getInstance().BroadcastMouseMoveEvent); this.PanelDirectX.MouseDown += new System.Windows.Forms.MouseEventHandler(ClEventSender.getInstance().BroadcastMouseButtonDownEvent); this.PanelDirectX.MouseUp += new System.Windows.Forms.MouseEventHandler(ClEventSender.getInstance().BroadcastMouseButtonUpEvent); this.PanelDirectX.MouseWheel += new System.Windows.Forms.MouseEventHandler(ClEventSender.getInstance().BroadcastMouseWheelEvent); #endif ClInformationReciver viewer = new ClInformationReciver(this); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eDebugText); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eError); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eProgress); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eTextInternal); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eTextExternal); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eStartProcessing); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eStopProcessing); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eColorMapChanged); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eNextRecognitionScore); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eWindowInfo); this.Text = APPLICATION_NAME + " ver. " + APPLICATION_VERSION; #if RENDER_1 ClRender Render = ClRender.getInstance(); Render.CreateDevice(this.PanelDirectX); ClCamera Camera = new ClCamera(); // Create camera object Camera.RegisterForEvent(ClEventSender.eEvents.e_MouseMove); Camera.RegisterForEvent(ClEventSender.eEvents.e_MouseButtonDown); Camera.RegisterForEvent(ClEventSender.eEvents.e_MouseButtonUp); Camera.RegisterForEvent(ClEventSender.eEvents.e_MouseWheel); Render.SetCamera(Camera); // Register camera as a render object // Render.AddRenderObj(new ClCoordinateSystem()); #endif List <string> fileTypes = Cl3DModel.sm_ListManagedFilesExtensions; string filter = ""; string AllNames = "All supported types"; string AllExt = ""; foreach (string type in fileTypes) { AllExt += "*." + type + ";"; filter += type.ToUpper() + "|*." + type + "|"; } filter = filter.Remove(filter.Length - 1); AllExt = AllExt.Remove(AllExt.Length - 1); openFileDialog.Filter = AllNames + "|" + AllExt + "|" + filter; }
/* public void ChangeLightPosition(float p_LightPosX, float p_LightPosY, float p_LightPosZ) { if (m_dDevice.Lights.Count == 0) throw new Exception("No lights in device"); m_dDevice.Lights[0].Position = new Vector3(p_LightPosX, p_LightPosY, p_LightPosZ); } public void ChangeLightDirection(float p_LightDirectionX, float p_LightDirectionY, float p_LightDirectionZ) { if (m_dDevice.Lights.Count == 0) throw new Exception("No lights in device"); m_dDevice.Lights[0].Direction = new Vector3(p_LightDirectionX, p_LightDirectionY, p_LightDirectionZ); } */ public void SetCamera(ClCamera p_RenderObject) { m_rCamera = p_RenderObject; }
public DxForm(string ApplicationName, string ApplicationVersion) { APPLICATION_NAME = ApplicationName; APPLICATION_VERSION = ApplicationVersion; #if RENDER_0 APPLICATION_VERSION += " [version without 3D models rendering]"; #endif InitializeComponent(); #if RENDER_1 Application.AddMessageFilter(new CScrollPanelMessageFilter(this.PanelDirectX)); // neaded to get event about scroll wheal in the panel this.PanelDirectX.MouseMove += new System.Windows.Forms.MouseEventHandler(ClEventSender.getInstance().BroadcastMouseMoveEvent); this.PanelDirectX.MouseDown += new System.Windows.Forms.MouseEventHandler(ClEventSender.getInstance().BroadcastMouseButtonDownEvent); this.PanelDirectX.MouseUp += new System.Windows.Forms.MouseEventHandler(ClEventSender.getInstance().BroadcastMouseButtonUpEvent); this.PanelDirectX.MouseWheel += new System.Windows.Forms.MouseEventHandler(ClEventSender.getInstance().BroadcastMouseWheelEvent); #endif ClInformationReciver viewer = new ClInformationReciver(this); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eDebugText); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eError); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eProgress); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eTextInternal); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eTextExternal); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eStartProcessing); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eStopProcessing); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eColorMapChanged); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eNextRecognitionScore); ClInformationSender.RegisterReceiver(viewer, ClInformationSender.eInformationType.eWindowInfo); this.Text = APPLICATION_NAME+" ver. "+APPLICATION_VERSION; #if RENDER_1 ClRender Render = ClRender.getInstance(); Render.CreateDevice(this.PanelDirectX); ClCamera Camera = new ClCamera(); // Create camera object Camera.RegisterForEvent(ClEventSender.eEvents.e_MouseMove); Camera.RegisterForEvent(ClEventSender.eEvents.e_MouseButtonDown); Camera.RegisterForEvent(ClEventSender.eEvents.e_MouseButtonUp); Camera.RegisterForEvent(ClEventSender.eEvents.e_MouseWheel); Render.SetCamera(Camera); // Register camera as a render object // Render.AddRenderObj(new ClCoordinateSystem()); #endif List<string> fileTypes = Cl3DModel.sm_ListManagedFilesExtensions; string filter = ""; string AllNames = "All supported types"; string AllExt = ""; foreach (string type in fileTypes) { AllExt += "*." + type + ";"; filter += type.ToUpper() + "|*." + type+"|"; } filter = filter.Remove(filter.Length - 1); AllExt = AllExt.Remove(AllExt.Length - 1); openFileDialog.Filter = AllNames+"|"+AllExt+"|"+filter; }
/* public void ChangeLightPosition(float p_LightPosX, float p_LightPosY, float p_LightPosZ) * { * if (m_dDevice.Lights.Count == 0) * throw new Exception("No lights in device"); * * m_dDevice.Lights[0].Position = new Vector3(p_LightPosX, p_LightPosY, p_LightPosZ); * } * * public void ChangeLightDirection(float p_LightDirectionX, float p_LightDirectionY, float p_LightDirectionZ) * { * if (m_dDevice.Lights.Count == 0) * throw new Exception("No lights in device"); * * m_dDevice.Lights[0].Direction = new Vector3(p_LightDirectionX, p_LightDirectionY, p_LightDirectionZ); * } */ public void SetCamera(ClCamera p_RenderObject) { m_rCamera = p_RenderObject; }
public override void Render(Device p_dDevice, Control p_cRenderWindow) { if (m_Base3DModel.IsModelChanged) { //ClInformationSender.SendInformation("Creating render object ("+m_Base3DModel.ModelPointsCount+" points)...", ClInformationSender.eInformationType.eTextExternal); m_lRenderModelVertex.Clear(); m_lRenderLines.Clear(); m_Base3DModel.ResetVisitedPoints(); Cl3DModel.Cl3DModelPointIterator iterator = m_Base3DModel.GetIterator(); List <KeyValuePair <string, Cl3DModel.Cl3DModelPointIterator> > specificPoints = m_Base3DModel.GetAllSpecificPoints(); float meanX = 0; float meanY = 0; float meanZ = 0; if (iterator.IsValid()) { do { meanX += -iterator.X; meanY += iterator.Y; meanZ += iterator.Z; Color pointColor = new Color(); bool isSpecificPoint = false; foreach (KeyValuePair <string, Cl3DModel.Cl3DModelPointIterator> specificPoint in specificPoints) { if (iterator.PointID == specificPoint.Value.PointID) { isSpecificPoint = true; break; } } if (!isSpecificPoint) { pointColor = iterator.Color; } else { pointColor = Color.Red; } m_lRenderModelVertex.Add(new CustomVertex.PositionColored(-iterator.X, iterator.Y, iterator.Z, pointColor.ToArgb())); List <Cl3DModel.Cl3DModelPointIterator> neighbors = iterator.GetListOfNeighbors(); foreach (Cl3DModel.Cl3DModelPointIterator neighbor in neighbors) { if (!neighbor.AlreadyVisited) { m_lRenderLines.Add(new CustomVertex.PositionColored(-iterator.X, iterator.Y, iterator.Z, pointColor.ToArgb())); m_lRenderLines.Add(new CustomVertex.PositionColored(-neighbor.X, neighbor.Y, neighbor.Z, neighbor.Color.ToArgb())); } } iterator.AlreadyVisited = true; }while (iterator.MoveToNext()); } m_Base3DModel.IsModelChanged = false; m_Base3DModel.ResetVisitedPoints(); #if RENDER_1 ClCamera camera = ClRender.getInstance().getCamera(); if (camera != null) { meanX /= m_lRenderModelVertex.Count; meanY /= m_lRenderModelVertex.Count; meanZ /= m_lRenderModelVertex.Count; camera.MoveCameraLookAt(meanX, meanY, meanZ); // ClRender.getInstance().AddRenderObj(new ClCoordinateSystem(meanX,meanY,meanZ)); } #endif } if (m_lRenderModelVertex.Count != 0) { p_dDevice.VertexFormat = CustomVertex.PositionColored.Format; if (m_lRenderLines.Count != 0) { p_dDevice.DrawUserPrimitives(PrimitiveType.LineList, m_lRenderLines.Count / 2, m_lRenderLines.ToArray()); } p_dDevice.DrawUserPrimitives(PrimitiveType.PointList, m_lRenderModelVertex.Count, m_lRenderModelVertex.ToArray()); } }