⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.htm

📁 功能:基于windows mobile 的地图查看器。使用vs2005开发
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>/cfWorldWind : Pocket World Wind</title>
<script language="javascript" type="text/javascript">
</script>
</HEAD>
	<body>
		<TABLE id="Table2" cellSpacing="1" cellPadding="1" width="100%" border="0">
			<TR>
				<TD>
					<H1>/cfWorldWind</H1>
				</TD>
				<TD align="right"><A href="javascript:window.open('http://www.brains-N-brawn.com/Comment/default.aspx?article=cfworldwind','','scrollbars=yes,width=550,height=550');void('');"><FONT size="2">comment(s)</FONT></A>&nbsp;</TD>
			</TR>
		</TABLE>
		<H2>WorldWind with the Compact Framework</H2>
		<P><A href="http://www.brains-N-brawn.com/cfWorldWind">http://www.brains-N-brawn.com/cfWorldWind</A>
            5/13/2005
            <IMG alt="casey chesnut" src="mailtoCaseyChesnut.png" border="0"></P>
        <h3>
            Introduction&nbsp;</h3>
        <p>
            the following explains how this article came about. ... it all begins with me sitting
            at work minding my own business. when i overhear a coworker explain to my boss about
            how he should check out this program called WorldWind (WW). the key words i picked up
            were : NASA, C#, FREE, and SOURCE CODE. that caught my interest so i took a note
            to check it out later. that night i downloaded it and was absolutely blown away.
            it was one of the coolest applications i had played with in a long while. plus it
            had source! so i shut down the installer version and grabbed the code. built both
            the solutions, moved the data over, and it ran ... way too easy. looked around the
            code for a bit and saw that it was using Managed DirectX (MDX). i didnt know anything
            about 3D programming, let alone MDX ... but i did know that the next version of
            the Compact Framework (CF) was getting Managed Direct3D Mobile (MD3DM). then it clicked
            ... make WorldWind (WW) run on a Pocket PC (PPC). the world in the palm of your hand ... if
            you will. shot off an email to my MVP lead, and Microsoft got me hooked up with
            a Pocket PC that had the newer OS bits i would need to start developing. also got
            a hold of an early version of Visual Studio 2005 Beta 2. i seriously didnt know
            anything about DirectX ... so i had to write the <a href="http://www.brains-n-brawn.com/cfMDX/">
                /cfMDX</a> article ...
            to get warmed up. that helped me to understand the basics about Direct3D (D3D), and what
            would be involved when porting an MDX app to MD3DM.
        </p>
        <p>
            of course there are ulterior motives. first, i've been looking for an excuse to
            learn 3D. but i dont play games, nor do i want to write games. instead, i would
            like to start using the advanced visualization techniques for application development.
            second, i want to do more location based development, so i saw this as a way to
            get more into GIS and such. third, i needed an excuse to write something using v2
            of the Compact Framework (CF). and i didnt want it to be some cheesy little contacts
            app. fourth, out of pride for the .NET platform. theres a thread on the WorldWind
            forums about why C# and DirectX was chosen. plus people are bitching about why its
            not written in OpenGL / C++. and there are also alot of posts asking for ports to
            other platforms. instead of whining, i decided to just port/rewrite (the basics
            of) it myself. fifth, i needed a challenge. nobody was asking for it to be ported
            to a mobile device ... but it seemed like that would up the difficulty to get it
            to run on a resource constrained device. sixth, WorldWind was getting alot of link
            juice, and i wanted to leech off of that. by leech, i mean the blood sucking kind.
            that was more than enough to get me to devote a month of my spare time to throw
            this together. seventh, to give back to the community. WW has very little documentation.
            and for the people that say code is self documenting, please refer to my upwards
            raised middle finger. there is a smack load of code, so any sort of docs would have
            helped. maybe people can use this doc to help get jump started a little quicker.
            eigth, to work on something that i have no clue about. i love it when you start
            working on a project and have no clue about the technologies or domain. you just
            keep pushing along, and then at some point, something clicks into place. my favorite
            projects are when i really dont know if they can be done ... or not</p>
        <h3>
            Port or Rewrite
        </h3>
        <p>
            that was the first question i asked myself. i would have preferred to just create
            a bunch of CF projects and fix the bugs as builds failed. this wasnt really feasible
            because of the amount of code, the richness of the UI on the desktop, etc... so
            a full port was out of the question. the next level is to do a limited port. rewrite
            the main application and just port over small pieces of the desktop code. this is
            the process i started out with. set up the application shell and just started bringing
            bits and pieces over. this worked until i quickly pegged the CPU of the device.
            the reason being is that WW does very little caching of data. it does most of the
            calculations for what to render over and over. knew that wasn't going to work, so
            i started reworking the code to better fit a caching model. meaning the calculations
            would be done up front and cached off, then rendering would only have to draw the
            current view. so the actual code ends up being a mix of a targeted port and a rewrite
            to allow for caching.
        </p>
        <p>
            just to be clear, i'm an independent consultant ... so i do not represent NASA or
            Microsoft.
        </p>
        <h3>
            Data
        </h3>
        <p>
            even though the code is great, WW is nothing without the data ... so i looked at
            that next. the install comes with 555 megs of data! 330 megs of textures for the
            Earth called BlueMarbleTextures. 10 megs of boundary, and 215 megs of placename
            information. so that data gets you off the ground and still makes the app relatively
            cool without requiring an internet connection. beyond that, it gets data from a
            number of different servers for weather info and satellite images (including TerraServer).
            this ends up being mass quantities of data. i've heard them say terabytes of data
            for satellite imagery. and to bring down this data requires big pipes, meaning you
            really need a broadband connection to use it. the current Pocket PCs and US wireless
            networks arent great at handling transfers of large data in this manner, so i didnt
            plan on having the application call out to the satellite imaging servers from the
            beginning. instead, i decided to make this 1st release only work with the data that
            was provided in the install. this still required a decent amount of work, because
            the data was made to work on the desktop and not a device. to get around this i
            had to write a desktop appp to preprocess the data and make it device friendly.
            but there is also a 3rd option between only using local data and calling out to
            the servers. this involves having a desktop application that could pull down the
            data and cache it off. WW does this, as well as some community developed apps. V2
            of this app would take that approach to use richer data (such as satellite imagery)
            that has been pulled down and cached on the desktop and then copied over to a storage
            card of the device.
        </p>
        <p>
            those were the major decisions. i was going to write it to run on a Pocket PC with
            an early version of the next WindowsMobile OS. it would be written using C# and
            the new MD3DM libraries for the Compact Framework. the code would be partially ported
            / rewritten to support a caching model to improve performance. and the 1st version
            would only use the local data that was provided during the install of WW. this would
            make the 1st version provide just the base functionality
        </p>
        <h3>
            Getting WW to build
        </h3>
        <p>
            because there was no documentation i needed to get WW running in debug mode first.
            to be able to step through the code and see exactly what was going on. the first
            thing i did was download and install the binary release WW 1.3. then i downloaded
            and unzipped the source code. next, i moved the \Data\Earth\ directory from the
            installed directory to the code \bin\Debu\ directory. also, i created a single solution
            containing all the projects from the WorldWind and WorldWindow solutions. to get
            that to build i had to change all assembly references to project references. then
            the single solution would build and i could run WW in debug mode.
        </p>
        <h3>
            On the 1st day, "let there be light"
        </h3>
        <p>
            started out by creating a new application and getting the render loop setup. the
            dev environment was Visual Studion 2005 and the version was a pre-release of Beta
            2. also had the SDK installed for an early version of the Magneto OS which provided
            the new project types. for the base application i used one of the MD3DM samples
            that comes with VS 2005. this created the device, setup the render loop, and just
            blacked out the screen. then i looked at the code in \PluginSDK\Camera.cs to get
            the initial placement of the camera. the world ends up being drawn at the orgin
            of World space, and the camera just moves position around it. this is different
            than most Direct3D samples which have the camera in a stationary place, and just
            transform the object in World space. WW is different than everything else i had
            looked at too because it uses a RH rendering model, while DirectX is LH by default.
            the main changes i made here was to not read the settings from an XML file. instead
            i added them as constants to the program for speed. also, i decided to do all the
            rendering in the main loop, while WW does rendering on a separate thread. finally,
            i turned on ambient lighting. this just rendered a black screen as empty space.
        </p>
        <p>
            <img src="images/black.JPG" />&nbsp;<img border="1" src="images/about.jpg" /></p>
        <ul>
            <li>before the big bang</li>
            <li>got to get the about screen out of the way :)</li>
        </ul>
        <h3>
            On the 2nd day, "let the mesh have texture"
        </h3>
        <p>
            now that we had an empty universe, it was time to create earth. WW starts out by
            creating a spherical mesh and then applying a texture from the BlueMarbleTextures
            to it. the initial texture is of the entire earth and applied to the entire sphere.
            specifically, the texture file is land_shallow_topo_2048.dds, which is 1024x2048
            and 1 meg large. i went about creating the Mesh 1st. in MD3DM you can create a sphere
            as a primitive : Mesh.CreateSphere(). this isnt really useful because you cannot
            apply a texture to it because it lacks normals. so i grabbed the code from \PluginSDK\ImageLayer.createMesh()
            which creates a sphere that will render in the RH space. i changed this code by
            using less vertices and also saving the Mesh off to a file. NOTE MD3DM does not
            support .X mesh files, but provides helper classes for a binary .md3dm format. then
            the program can just load the mesh from file instead of having to do any calculations

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -