android下匯入3ds檔案解決方案

來源:互聯網
上載者:User

網上可以搜尋到很多的引擎,通過jpct—ae的引擎可以很快的解決問題,具體的代碼可以參考官方的demo。

幾天前寫的很簡陋,現在補上我學到的一些內容

class MyRenderer implements GLSurfaceView.Renderer{

……

}這是一個render的繼承,是要完成渲染繪圖的工作

public void onDrawFrame(GL10 gl) 將緩衝中的內容畫出的函數

public void onSurfaceChanged(GL10 gl, int w, int h) 介面變化時候的函數

public void onSurfaceCreated(GL10 gl, EGLConfig config) 這個是在建立的時候要執行的函數,是非常重要的

 

 

TextureManager.getInstance().flush();

先將texure管理器重的緩衝清空


world = new World();

建立新的世界


Resources res = getResources();

得到資源檔

TextureManager tm = TextureManager.getInstance();
Texture manp = new Texture(res.openRawResource(R.raw.manp));        

從raw檔案中讀取manp(自己複製過去的檔案)到texture

 

 

 

private Object3D plane = null;

建立一個Object3D的實體

plane = Loader.load3DS(res.openRawResource(R.raw.plane), 5)[0];

匯入raw檔案的plane中的第0個元素,可以用數組匯入多個元素

plane.setTexture(name);

在palne的表面載入貼圖

 

 

world.addObject(plane);載入plane到世界中

 

world.buildAllObjects();建立所有的對象

 

 

sun = new Light(world);建立燈光

 

Camera cam = world.getCamera();

cam.moveCamera(Camera.CAMERA_MOVEOUT, 250);

cam.moveCamera(Camera.CAMERA_MOVEUP, 100);

建立調整camera的位置

 

sun.setIntensity(250, 250, 250);光照強度

 

SimpleVector sv = new SimpleVector();

//sv.set(plane.getTransformedCenter());

sv.y -= 500;

sv.x -= 100;

sv.z += 200;

sun.setPosition(sv);光照位置

 

fb.clear();

world.renderScene(fb);

world.draw(fb);

//blitNumber(lfps, 5, 5);

 

fb.display();

fb是framebuffer也就是幀緩衝中的東西,先清空,再將world渲染到fb中,最後display出來

 

 

還有在demo中的keyup keydown等幾個函數比較簡單

 

上面是最基本的一些東東,還有一些材質的以後看懂再寫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.