加载3D obj文件,并添加背景图片动态壁纸在android的? [英] Load 3d .obj file and add background image to live wallpaper in android?

查看:781
本文介绍了加载3D obj文件,并添加背景图片动态壁纸在android的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要加载的动态壁纸三维obj文件和动画它。我使用拉贾瓦利库加载它。的问题是,在三维物镜文件是负载和动画成功但加载背景图像不在某些机器人装置加载。 code是如下:

i want to load a 3d .obj file in live wallpaper and animate it. i use RAJAWALI library to load it. the problem is that the the 3d obj file is load and animate successfully but Loading background image are not loaded in some android devices. code is follow:

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();
    }


}

这给问题的三星Nexus的Andr​​oid 4.1版。

it give problem on SAMSUNG NEXUS android v4.1.

请帮我该怎么办呢?

推荐答案

这是测试工作的Galaxy S3。所以它应该为你工作为好。我在我的墙纸使用。试试这个:

This is tested and working on Galaxy S3. So it should work for you as well. I use it in my wallpapers. Try this:

    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,等我知道它是如何为你工作。

Just make sure that your image is power of two, i.e., 256x256, 512x512, etc. Let me know how it works for you.

编辑:另外,还要确保你导入rajawali.primitives不rajawali.math

Also make sure you import rajawali.primitives not rajawali.math

这篇关于加载3D obj文件,并添加背景图片动态壁纸在android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆