XDL Manual (piXoneer XDL Tutorial)
NXPlanetView¸¦ Ȱ¿ëÇÏ¿© ±¸ ±â¹Ý 2D µµ½Ã ȯ°æ¿¡¼ ±â´ÉȰ¿ë¹ýÀ» ÀÍÈ÷°í ¸¶¿ì½º À§Ä¡¿¡ µû¸¥ ÁÂÇ¥ µµ½Ã, ³ªÄ§¹Ý µµ½Ã, µµ½Ã ±â´ÉÀ» ±¸ÇöÇØ º¾´Ï´Ù.
2017. 01. ¼öÁ¤ 2019. 02.
|
1 »ç¿ëÇϱâ
1.1 XDL ¿£Áø¼³Ä¡ ÇÁ·Î±×·¥À¸·Î ¹èÆ÷µÇ´Â XDL ¿£ÁøÀº Visual Studio 2010 x86 Release ¹öÀüÀ¸·Î, Visual Studio 2010 ÀÌ»óÀÇ ¹öÀü¿¡¼ »ç¿ë °¡´ÉÇÏ´Ù. ¾Æ·¡ÀÇ ¼³¸íÀº Visual Studio 2010À» ±âÁØÀ¸·Î ÇϰڴÙ. 2 NXPlanetView¸¦ ÀÌ¿ëÇÑ ¿¹Á¦ ÇÁ·Î±×·¥ ¸¸µé±âl º» ¿¹Á¦ ÇÁ·Î±×·¥Àº NXPlanetView¿Í NXPlantLayer¸¦ ÀÌ¿ëÇÏ¿© Planet2D ¸ðµå »ó¿¡¼ ±âº» »ç¿ë¹ýÀ» ÀÍÈ÷°í °£´ÜÇÑ µµ½Ã±â´ÉÀ» Ãß°¡ÇØ º¸µµ·Ï ÇÑ´Ù. 2.1 ±âº» ÇÁ·Î±×·¥ ÀÛ¼º2.1.1 Visual Studio 2010À» ½ÇÇàÇÑ´Ù.2.1.2 ¸Þ´º [ÆÄÀÏ]-[»õ·Î ¸¸µé±â]-[ÇÁ·ÎÁ§Æ®]¸¦ ¼±ÅÃÇÑ´Ù.2.1.3 [»õ ÇÁ·ÎÁ§Æ®] ´ëÈ»óÀÚ¿¡¼ ¿ÞÂÊÀÇ ÅÛÇø´ â¿¡¼ ¡°Visual C#¡±À» ¼±ÅÃÇϰí, ´ëÈ»óÀÚ Áß°£ÀÇ ¸ñ·Ï¿¡¼ ¡°Windows Forms ÀÀ¿ë ÇÁ·Î±×·¥¡±À» ¼±ÅÃÇÑ´Ù. ÇÁ·ÎÁ§Æ®ÀÇ À̸§(XDL_PlanetView1)À» ÀÔ·ÂÇϰí [»õ ÇÁ·ÎÁ§Æ®] ´ëÈ»óÀÚÀÇ ¡°È®ÀΡ± ¹öưÀ» Ŭ¸¯ÇÑ´Ù.¡°È®ÀΡ± ¹öưÀ» ´©¸£¸é ÇÁ·ÎÁ§Æ®°¡ ±âº»ÀûÀ¸·Î »ý¼ºµÇ°í, ȸ鿡 FormÀ» µðÀÚÀÎÇÒ ¼ö Àִ ȸéÀÌ »ý¼ºµÈ´Ù. ¸¸¾à ¾Æ·¡¿Í °°ÀÌ Form µðÀÚÀΠȸéÀÌ »ý¼ºµÇÁö ¾ÊÀ¸¸é, [¼Ö·ç¼Ç Ž»ö±â] â¿¡¼ ¡°Form1.cs¡±¸¦ ¸¶¿ì½º ´õºí Ŭ¸¯ÇÏ¿© µðÀÚÀÎȸéÀ» ¿¬´Ù.
2.1.4 [µµ±¸»óÀÚ]ÀÇ [Ç׸ñ¼±ÅÃ]À» ¼±ÅÃÇÑ´Ù.[µµ±¸ »óÀÚ] âÀÇ ¡°ÀϹݡ±¿¡¼ ¸¶¿ì½º ¿À¸¥ÂÊ ¹öưÀ» Ŭ¸¯ÇÏ¿© »ý¼ºµÇ´Â ÆË¾÷¸Þ´º¿¡¼ ¡°Ç׸ñ ¼±Åá± ¸Þ´º¸¦ ¼±ÅÃÇÑ´Ù.
¸Þ´º¸¦ ¼±ÅÃÇÏ¸é ¾Æ·¡¿Í °°ÀÌ [µµ±¸ »óÀÚ Ç׸ñ ¼±ÅÃ] ´ëÈ»óÀÚ°¡ ³ªÅ¸³ª¸ç, ´ëÈ»óÀÚ ¾Æ·¡ÂÊ¿¡ ÀÖ´Â ¡°Ã£¾Æº¸±â¡± ¹öưÀ» Ŭ¸¯ÇÑ´Ù.
¿±â ´ëÈ»óÀÚ¿¡¼ ¡°C:\Pixoneer\XDL1.2\bin\NXPlanet.dll¡± ÆÄÀÏÀ» ¼±ÅÃÇÑ ÈÄ ¡°¿±â¡±¸¦ Ŭ¸¯Çϰí, [µµ±¸ »óÀÚ Ç׸ñ ¼±ÅÃ] ´ëÈ»óÀÚÀÇ ¡°È®ÀΡ± ¹öưÀ» Ŭ¸¯ÇÑ´Ù.
.Net Framework ±¸¼º¿ä¼Ò ÅÇ¿¡ ´Ù¾çÇÑ ·¹À̾î¿Í NXPlanetView°¡ ¼³Á¤µÈ´Ù. ¡°È®ÀΡ±¹öưÀ» Ŭ¸¯ÇÑ´Ù. [µµ±¸»óÀÚ]¿¡ ´Ù¾çÇÑ PlanetLayerµé°ú NXPlanetView°¡ Ãß°¡µÊÀ» È®ÀÎÇÑ´Ù.
2.1.5 ¼Ö·ç¼Ç Ž»ö±âÀÇ ÇÁ·ÎÁ§Æ® ÇϺÎÀÇ [ÂüÁ¶]ÀÇ ¿À¸¥ÂÊ ¸¶¿ì½º Ŭ¸¯À» ÅëÇØ [ÂüÁ¶Ãß°¡]¸¦ ¼±ÅÃÇÑ´Ù.2.1.6 [ã¾Æº¸±â]ÅÇÀ¸·Î À̵¿ÇÑ ÈÄ ¡°C:\Pixoneer\XDL1.2\bin\¡±°æ·Î·Î À̵¿ÇÑ´Ù. Ctrl۸¦ ´©¸¥ ä ¡°NXDL.dll¡±, ¡°NXPlanet.dll¡±, ¡°NXDLgr.dll¡±À» ¼±ÅÃÇÑ ÈÄ ¡°È®ÀΡ±¹öưÀ» ¼±ÅÃÇÑ´Ù.2.1.7 ¼Ö·ç¼Ç Ž»ö±âÀÇ ÇÁ·ÎÁ§Æ® ÇϺÎÀÇ [ÂüÁ¶]Ç׿¡ NXDL, NXDLgr, NXPlanetÀÌ Ãß°¡µÇ¾úÀ½À» È®ÀÎÇÑ´Ù.
2.2 ÇÁ·Î±×·¥ µðÀÚÀÎ
2.2.1 [µµ±¸ »óÀÚ]ÀÇ ¡°SplitContainer¡±¸¦ ¼±ÅÃÇϰí Form1¿¡ ²ø¾î´Ù°¡ ³õ´Â´Ù.
Form1¿¡ splitContainer1ÀÌ Ãß°¡µÇ¸ç ¾Æ·¡¿Í °°ÀÌ ¡°Panel1¡±°ú ¡°Panel2¡±°¡ »ý±ä´Ù. Panel1¿¡´Â ¨ç~¨ïÀÇ ÄÁÆ®·ÑÀ» Ãß°¡ÇÏ¿© µðÀÚÀÎÇϰí, Panel2¿¡´Â ¨ð, ¨ñ ÄÁÆ®·ÑÀ» Ãß°¡ÇÑ´Ù. Panel1ÀÇ µðÀÚÀÎÀº À§ÀÇ Ç¥¸¦ Âü°í·Î ±¸¼ºÇϵµ·Ï ÇÏ¸ç ¿©±â¿¡¼´Â »ý·«Çϵµ·Ï ÇÑ´Ù.
2.2.2 [µµ±¸ »óÀÚ]ÀÇ [ÀϹÝ]¿¡¼ NXPlanetView¸¦ ¼±ÅÃÇÑ µÚ µå·¡±×ÇÏ¿© Form1ÀÇ Panel2¿¡ ³õ´Â´Ù. Form1 À§¿¡ NXPlanetView ÄÁÆ®·ÑÀÌ »ý¼ºµÈ´Ù.
2.2.3 »ý¼ºµÈ NXPlanetView ÄÁÆ®·ÑÀÇ ¿À¸¥ÂÊ »ó´Ü¿¡ ¡°►¡± ±âÈ£¸¦ Ŭ¸¯ÇÏ¸é ¡°ºÎ¸ð ÄÁÅ×À̳ʿ¡¼ µµÅ·¡± ¹öưÀÌ »ý¼ºµÇ´Âµ¥ ÀÌ ¹öưÀ» Ŭ¸¯ÇÑ´Ù.
2.2.4 NXPlanetView ÄÁÆ®·ÑÀÌ Form1¿¡ µµÅ·µÇ¾î ÀüüÄÁÆ®·Ñ ¿µ¿ªÀ¸·Î È®´ëµÈ´Ù.
Form1.Designer.cs¿¡¼ º¸¸é ÄÁÆ®·Ñ nxPlanetView1 ¸â¹öº¯¼ö°¡ Ãß°¡µÊÀ» È®ÀÎÇÒ ¼ö ÀÖ´Ù. NXPlanetView´Â ´Ù¾çÇÑ NXPlanetLayerXXXXXµéÀ» ´ãÀ» ¼ö ÀÖ´Â ÄÁÅ×À̳ÊÀÌ´Ù. Áï, NXPlanetView´Â ´Ù¾çÇÑ °èÃøÀÇ ·¹À̾î·Î ±¸¼ºÇÏ¿© ±¸ ±â¹Ý ±â´ÉÀ» ´Ù¾çÇÏ°Ô ±¸ÇöÇÒ ¼ö ÀÖ´Ù. 2.2.5 [µµ±¸ »óÀÚ]ÀÇ [ÀϹÝ]¿¡¼ NXPlanetLayer¸¦ ¼±ÅÃÇÑ µÚ µå·¡±×ÇÏ¿© nxPlanetView1 À§¿¡ ³õ´Â´Ù.NXPlanetLayer´Â PlanetView¿¡ Ãß°¡µÇ¾î XDL ¿£Áø¿¡¼ ¹ß»ýÇÏ´Â À̺¥Æ®¸¦ ¿ÜºÎ ¾îÇø®ÄÉÀ̼ǿ¡¼ ó¸®ÇÒ ¼ö ÀÖ´Ù. Form1.Designer.cs¿¡¼ º¸¸é ´ÙÀ½°ú °°ÀÌ ÄÁÆ®·Ñ nxPlanetLayer1 ¸â¹öº¯¼ö°¡ Ãß°¡µÊÀ» È®ÀÎÇÒ ¼ö ÀÖ´Ù.
2.2.6 ¼Ö·ç¼ÇÀ» ºôµåÇÏ°í ½ÇÇàÇÑ´Ù.
2.3 ±â´É ¹× À̺¥Æ® Ãß°¡2.3.1
Form1À» ¼±ÅÃÇϰí [¼Ó¼º] â - [À̺¥Æ®
|
public partial class Form1 : Form { private XVertex2d scrPos = new XVertex2d(); private XTextPrinter textPrinter = new XTextPrinter(); private XTexture compassTexture = new XTexture(); public Form1() { InitializeComponent(); nxPlanetView1.BackColor = Color.Black;
Font coordFont = new Font("Gulim", 12, FontStyle.Regular | FontStyle.Bold); if (!textPrinter.Initialize(coordFont)) { System.Diagnostics.Debug.WriteLine( "Fail to initialize text printer for coordinate display!"); }
if (!compassTexture.Load("c:\\Pixoneer\\XDL1.2\\Resource\\compass.png")) { System.Diagnostics.Debug.WriteLine( "Fail to load compass texture!"); } } |
³ªÄ§¹Ý À̹ÌÁö·Î »ç¿ëÇÏ´Â ¡°compass.png¡± ÆÄÀÏÀÌ ¿¹Á¦ ÄÚµå¿Í °°Àº °æ·Î¿¡ ¾øÀ¸¸é, ¿¹Á¦ »ùÇà ÇÁ·Î±×·¥ ¾ÐÃà ÆÄÀÏ¿¡ ÀÖ´Â ÆÄÀÏÀ» ÀÌ¿ëÇϱ⠹ٶõ´Ù.
OnWndProc À̺¥Æ®´Â NXPlanetLayer°¡ Ãß°¡µÇ¾î ÀÖ´Â ViewÀÇ À©µµ¿ì À̺¥Æ®¸¦ ¿ÜºÎ¿¡¼ ¹Þ¾Æ¼ »ç¿ëÇÒ ¼ö ÀÖµµ·Ï ÇÑ´Ù. OnOrthoRender´Â NXPlanetLayer°¡ Ãß°¡µÇ¾î ÀÖ´Â ViewÀÇ Ortho-renderingÀÌ ¿Ï·áµÈ ÈÄ ¾îÇø®ÄÉÀ̼ǿ¡¼ Ãß°¡ÀûÀÎ ÀÛ¾÷À» ±¸ÇöÇØ¾ß ÇÒ Çʿ䰡 ÀÖÀ» ¶§ »ç¿ëÇÏ¸é µÈ´Ù. Âü°í·Î NXPlanetViewÀÇ ³»ºÎ Rendering ¼öÇà->OnRender À̺¥Æ® ¹ß»ý->NXPlanetViewÀÇ ³»ºÎ OrthoRendering ¼öÇà->OnOrthoRender À̺¥Æ® ¹ß»ý ¼ø¼·Î ÀÌ·ç¾îÁø´Ù.
ÄÚµå´Â ¾Æ·¡¿Í °°´Ù.
private bool nxPlanetLayer1_OnWndProc(object sender, NXPlanetDrawArgs e, ref Message m) { if (m.Msg == Pixoneer.NXDL.XWndMsg.XWM_MOUSEMOVE) { scrPos.x = Pixoneer.NXDL.XWndMsg.GetLowValue(m.LParam); scrPos.y = Pixoneer.NXDL.XWndMsg.GetHighValue(m.LParam); nxPlanetView1.RefreshScreen(); }
return default(bool); }
private bool nxPlanetLayer1_OnOrthoRender(object sender, NXPlanetDrawArgs e) { if (nxPlanetView1 == null) return false;
XVertex3d posWorld = new XVertex3d(); // ȸé ÁÂÇ¥¸¦ À§°æµµ ÁÂÇ¥·Î º¯È¯ XGeoPoint gpPoint = nxPlanetView1.ScreenToGeographic(scrPos.x, scrPos.y); posWorld.x = scrPos.x; posWorld.y = scrPos.y; posWorld.z = 0.0;
String str = gpPoint.lond.ToString() + ", " + gpPoint.latd.ToString();
// ȸ鿡 ÅØ½ºÆ® ÁÂÇ¥¸¦ µµ½Ã bool result = textPrinter.Print(str, posWorld, Pixoneer.NXDL.NGR.eTextAlign.Align_Center, Color.White, true, Color.DarkBlue);
// ³ªÄ§¹Ý µµ½Ã if (!compassTexture.SendTextureToDevice()) return false;
NXCameraState state = nxPlanetView1.GetCameraState();
int nXSize = compassTexture.Width; int nYSize = compassTexture.Height;
e.Graphics.glDisable(XGraphics.GL_DEPTH_TEST); e.Graphics.glEnable(XGraphics.GL_BLEND);
e.Graphics.glBindTexture(XGraphics.GL_TEXTURE_2D, (uint)compassTexture.GLTextureID); e.Graphics.glColor3f(1.0f, 1.0f, 1.0f);
e.Graphics.glPushMatrix(); e.Graphics.glTranslated(100.0, 100.0); e.Graphics.glRotated(-state.azimuth.deg, 0.0, 0.0, 1.0);
e.Graphics.glBegin(XGraphics.GL_QUADS); e.Graphics.glTexCoord2f(0, 1); e.Graphics.glVertex3d(-nXSize / 2, -nYSize / 2, 0); e.Graphics.glTexCoord2f(0, 0); e.Graphics.glVertex3d(-nXSize / 2, nYSize / 2, 0); e.Graphics.glTexCoord2f(1, 0); e.Graphics.glVertex3d(nXSize / 2, nYSize / 2, 0); e.Graphics.glTexCoord2f(1, 1); e.Graphics.glVertex3d(nXSize / 2, -nYSize / 2, 0); e.Graphics.glEnd();
e.Graphics.glPopMatrix();
e.Graphics.glDisable(XGraphics.GL_BLEND); e.Graphics.glEnable(XGraphics.GL_DEPTH_TEST);
return default(bool); } |