2013-02-16 76 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