2013-02-16 23 views
0

我想在動態壁紙中加載3d .obj文件並對其進行動畫處理。我使用RAJAWALI庫來加載它。問題是3d obj文件加載和動畫成功,但加載背景圖像不加載一些Android設備。代碼如下:加載3d .obj文件,並添加背景圖像在android動態壁紙?

protected void initScene() { 


    DirectionalLight localDirectionalLight = new DirectionalLight(0.0F, 0.6F, 0.4F); 
localDirectionalLight.setPower(3.0F); 
PointLight mLight = new PointLight(); 
mLight.setPosition(0, 0, 0); 
mLight.setPower(13); 
Plane plane = new Plane(70, 70, 1, 1, 1); 
plane.addLight(mLight); 
plane.setMaterial(new SimpleMaterial()); 
plane.addTexture(mTextureManager.addTexture(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.pozadina))); 
addChild(plane);  
plane.setZ(10); 

    try 
    { 
     ObjParser localObjParser = new ObjParser(this.mContext.getResources(), this.mTextureManager, R.raw.allah); 
     localObjParser.parse(); 
     this.strela = localObjParser.getParsedObject(); 
     this.strela.addLight(localDirectionalLight); 
     if (this.tekstura == null) 
     { 
     BitmapFactory.Options localOptions2 = new BitmapFactory.Options(); 
     localOptions2.inPurgeable = true; 

     this.strela.setColor(Color.WHITE); 
     } 
     this.strela.setScale(2.0F); 
     addChild(this.strela); 
     this.mCamera.setPosition(0.0F, 0.0F, -50.0F); 
     this.mCamera.setFarPlane(1000.0F); 
     Number3D localNumber3D = new Number3D(0.0F, 1.0F, 0.0F); 
     localNumber3D.normalize(); 
     this.mAnim = new RotateAnimation3D(localNumber3D, 360.0F); 
     this.mAnim.setDuration(10000L); 
     this.mAnim.setRepeatCount(-1); 
     this.mAnim.setTransformable3D(this.strela); 

     return; 
    } 
    catch (Exception localException) 
    { 
     while (true) 
     localException.printStackTrace(); 
    } 


} 

它給SAMSUNG NEXUS android v4.1的問題。

請幫助我該怎麼做?

+0

你有沒有解決這個問題? – 2013-04-03 05:20:08

回答

2

這是測試,並在銀河S3工作。所以它也應該適合你。我在我的壁紙中使用它。試試這個:

SimpleMaterial localSimpleMaterial = new SimpleMaterial(); 
    Bitmap localBitmap = BitmapFactory.decodeResource(this.mContext.getResources(), R.drawable.image); 
    localSimpleMaterial.addTexture(this.mTextureManager.addTexture(localBitmap)); 
    Plane localPlane = new Plane(10.0F, 10.0F, 1, 1); 
    localPlane.setRotZ(-90.0F); 
    localPlane.setScale(3.7F); 
    localPlane.setPosition(0.0F, 0.0F, 10.0F); 
    localPlane.setMaterial(localSimpleMaterial); 
    addChild(localPlane); 

只要確保你的形象是兩個電源,即256×256,512×512等讓我知道它是如何爲你的作品。

編輯:另外,還要確保你導入rajawali.primitives不rajawali.math

+1

我會檢查它。如果它適合我​​,那麼我會將答案標記爲正確。 – 2013-04-26 10:13:16

0

問題解決了嗎? 那些飛機沒有被渲染的設備是什麼?那些三星? 也請告訴我,它是呈現灰色或完全不呈現?

我在問,因爲我遇到了同樣的問題,解決方案是調整mip-mapping。這需要時間,因爲我是一個初學者的話,但有一個非常簡單的解決辦法:

Textures are not displayed on the sphere for Samsung Galaxy SL