【正文】
。 實(shí)際上,在手機(jī)這種計(jì)算能力仍然十分有限的設(shè)備上,繪制真正的 3D場景(使用 OpenGL ES標(biāo)準(zhǔn))的確存在很大的瓶頸。 由于移動(dòng)設(shè)備硬件的不斷發(fā)展升級,用戶越來越渴望移動(dòng)設(shè)備能有更好的用戶體驗(yàn)。而基于 OpenGL ES 的 3D主題樣式則通過在 3D場景上繪制正 N 棱體,棱體的每個(gè)側(cè)面是相對應(yīng)的 Workspace 子視圖圖像,用戶通過選擇不同的側(cè)面來進(jìn)入不同的子視圖。本論文主要是討論與研究 基于安卓智能手機(jī)操作系統(tǒng)桌面 3d 特效(模擬 3D主題樣式 ③ 與基于 OpenGL ES 的 3D主題樣式 ④ )的開發(fā)及其性能優(yōu)化,以期能對 3D開發(fā)有更深入的理解,以便能提出 3D開發(fā)方面的見解。 模擬 3D與基于 OpenGL ES 的 3D主題樣式都是通過修改 Android Launcher 源碼 中的Workspace 類來實(shí)現(xiàn)。 關(guān)鍵詞: 安卓,桌面主題, OpenGL ES, Launcher, 3D,開發(fā) ① google 公司官網(wǎng) . ② 安卓開發(fā)者官網(wǎng) . ③ 本論文第 3 章將會(huì)介紹 ④ 本論文第 4 章將會(huì)介紹 基于 Android手機(jī)系統(tǒng)的 3D桌面主題開發(fā) 3 頁 ABSTRACT 2020,google has developed the Android smartphone operating system, which swept the world, making software engineers to develop on this system. And this thesis is to discuss the development of 3d desktop(the simulate 3D desktop and the 3D desktop based on OpenGL ES) based on the Android smart phone operating system and its optimized performance, in order to have a deeper understanding of the 3D development and put forward the views in the field. Both the simulate 3D desktop and the 3D desktop based on OpenGL ES are to modify the class named Workspace in the Android Launcher code. The difference is that this two desktop change screen in different ways to achieve the jump between Workspace child views. When changing screen, the simulate 3D desktop is to draw two images of the two related child views on the same screen at a fixed angle, a different visual direction. However, the 3D desktop based on OpenGL ES is to draw a N prism in the 3D scene, and each side of the prism is a corresponding image of the Workspace child view. Entering the corresponding child view of Workspace when user selects a side of the prism. Key Words: Android , Desktop Themes, OpenGL ES, Launcher,3D,develop 基于 Android手機(jī)系統(tǒng)的 3D桌面主題開發(fā) 4 頁 目錄 中文摘要 .............................................................. 1 ABSTRACT ............................................................. 3 目錄 ................................................................. 4 第 1 章 引言 ........................................................... 6 第 2 章 關(guān)鍵技術(shù)介紹 ................................................... 7 JAVA 反射機(jī)制 ......................................................... 7 Android Launcher ...................................................... 7 界面模型 .......................................................... 8 觸摸事件處理 ...................................................... 9 Launcher 開發(fā) ..................................................... 10 Opengl ES 標(biāo)準(zhǔn) ....................................................... 11 Opengl 標(biāo)準(zhǔn)簡介 ................................................... 11 OpenGL ES 管道 .................................................... 12 投影方式 ......................................................... 12 光照效果 ......................................................... 14 法向量 ........................................................... 15 物體的材質(zhì) ....................................................... 15 紋理貼圖 ......................................................... 16 第 3 章 開發(fā)模擬 3D 主題樣式 ............................................ 18 說明與概述 ........................................................... 18 解決方案 ............................................................. 18 優(yōu)化方案 ............................................................. 20 第 4 章 開發(fā) Opengl ES 3D 主題樣式 ....................................... 22 說明與概述 ........................................................... 22 解決方案 ............................................................. 23 坐標(biāo)計(jì)算 ......................................................... 23 方案一 ....................................................... 23 方案二 ....................................................... 24 比較方案 ..................................................... 26 方案修正 ..................................................... 27 鏡像技術(shù) ......................................................... 29 優(yōu)化方案 ............................................................. 36 總結(jié) ................................................................. 38 基于 Android手機(jī)系統(tǒng)的 3D桌面主題開發(fā) 5 頁 參考文獻(xiàn) ............................................................. 40 致 謝 .............................................................. 41 基于 Android手機(jī)系統(tǒng)的 3D桌面主題開發(fā) 6 頁 第 1 章 引言 進(jìn)入 21世紀(jì),信息技術(shù)高速發(fā)展。如在移動(dòng)設(shè)備上實(shí)現(xiàn)各種 3D 效果等。主要是由于在三維場景到二維屏幕的轉(zhuǎn)換過程需要大量的計(jì)算,而且這種計(jì)算需要重復(fù)地運(yùn)行,可是移動(dòng)設(shè)備難以承擔(dān)這種計(jì)算負(fù)載。 基于 Android手機(jī)系統(tǒng)的 3D桌面主題開發(fā) 7 頁 第 2 章 關(guān)鍵技術(shù)介紹 JAVA 反射機(jī)制 JAVA 反射機(jī)制是在運(yùn)行狀態(tài)中,對于任意一個(gè)類,都能夠獲知此類的所有屬性和方法;對于任意一個(gè)對象,都能夠調(diào)用它的任意方法;這種動(dòng)態(tài)獲取信息以及動(dòng)態(tài)調(diào)用對象方法的功能稱為 JAVA 語言的反射機(jī)制。 在本論文的工程中, Workspace 類中通過 java 反射機(jī)制來實(shí)例化當(dāng)前主題樣式 proxy,并在相應(yīng)的方法中調(diào)用 proxy 的相應(yīng)方法。 通過在 Android 官網(wǎng)上下載 Android Launcher 源碼包,并解壓到 myeclipse 工程目錄下,引入工程并添加相應(yīng)的 jar 包,消除錯(cuò)誤后,便可以進(jìn)行開發(fā) (工程截圖 如圖 )。 界面模型 圖 Launcher 界面模型 CellLayout(由 N 個(gè) cellLayout 組成的workspace) 狀態(tài)欄 垃圾桶 基于 Android手機(jī)系統(tǒng)的 3D桌面主題開發(fā) 9 頁 圖 HomeScreen 基本結(jié)構(gòu)圖 由于 Launcher 需要管理各種圖標(biāo)等,而 Android 自帶的視圖不足以實(shí)現(xiàn)如此復(fù)雜的界面。而 在 根視圖 上workspace 占了絕大部分的空間 。判斷的規(guī)則如下: 事件首先會(huì)傳遞到 onInterceptTouchEvent()方法 如果 父視圖 的 onInterceptTouchEvent(MotionEvent)方法 在接收到 事件處理完成之后 返回 false,那么后續(xù)的, 等事件將繼續(xù)會(huì)先傳遞給該 父視圖 ,之后才和 事件 一起 傳遞給 下一級 的目標(biāo) 子視圖 的. Workspace (ViewGroup) . CellLayout (ViewGroup) (FrameLayout) SlidingDrawer (FrameLayout) . CellLayout (ViewGroup) . CellLayout (ViewGroup) . HandlerView (ImageView) . AllAppsGirdView (GirdView) 基于 Android手機(jī)系統(tǒng)的 3D桌面主題開發(fā) 10頁 onTouchEvent(MotionEvent)處理。 Launcher 開發(fā) 通過上面的介紹,對 Launcher 有了初步的了解。觸摸狀態(tài)改為 RESET。 如果接收到的是 事件,那么就把觸摸狀態(tài)改為 RESET,并更新壁紙。 如果接收到的是 事件,那么就把當(dāng)前的觸摸坐標(biāo)記錄為前一次觸摸坐標(biāo)以及保持觸摸狀態(tài)不變,并按照某種方式進(jìn)行轉(zhuǎn)動(dòng)屏幕。為此,定義一個(gè)主題樣式接口,如代碼 。 /**處理傳遞過來的所有觸摸事件 */ void destro