我是android开发的新手,我知道一些基本的活动、地图、sqlite等等。我希望能够实现一些3D对象,以便能够在我的应用程序中进行交互。经过一番搜索,我发现拉贾瓦利似乎是最好的方法。正如您所做的,我从第一个教程开始,从示例文档中读取源代码。当我迷失方向时,我已经逐字逐句地遵循了教程,而且由于脚本中的错误,我无法运行应用程序。如果以前有人用过Rajawali,我会给出一些关于我哪里出了错的建议。(本教程是两个月前更新的,所以是最近更新的)。教程
这是我的源代码
MainActivity:
package rajawali.tutorials;
import rajawali.RajawaliActivity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends RajawaliActivity {
private Renderer mRenderer;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRenderer = new Renderer(this);
mRenderer.setSurfaceView(mSurfaceView);
super.setRenderer(mRenderer);
}
}渲染器:
package rajawali.tutorials;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import rajawali.lights.DirectionalLight;
import rajawali.materials.textures.ATexture.TextureException;
import rajawali.materials.textures.Texture;
import rajawali.primitives.Sphere;
import rajawali.renderer.RajawaliRenderer;
public class Renderer extends RajawaliRenderer {
private DirectionalLight mLight;
Sphere mSphere;
public Renderer(Context context) {
super(context);
setFrameRate(60);
}
public void initScene() {
mLight = new DirectionalLight(1f, 0.2f, -1.0f);
mLight.setColor(1.0f, 1.0f, 1.0f);
mLight.setPower(2);
try {
*DiffuseMaterial* material = new *DiffuseMaterial*(); //there is an error here (DiffuseMaterial cannot be rsolved as a type)
material.addTexture(new *Texture(R.drawable.earthtruecolor_nasa_big)*); //here (constructor Texture(int) cannot be defined)
mSphere = new Sphere(1, 24, 24);
mSphere.setMaterial(material);
mSphere.*addLight(mLight)*; //and here (The method addLight(DirectionalLight) is undefined for the type Sphere)
addChild(mSphere);
} catch (TextureException e) {
e.printStackTrace();
}
getCurrentCamera().setZ(4.2f);
}
@Override
public void onDrawFrame(GL10 glUnused) {
super.onDrawFrame(glUnused);
mSphere.setRotY(mSphere.getRotY() + 1);
}
}如果我能帮上忙的话,我真的不想成为勺子的饲料代码,但是看起来错误在'DiffuseMaterial‘中。为什么除了使用min3D或Rajawali之外,还有更好的方法来操作3D对象?
发布于 2014-02-21 02:56:59
看起来这与Rajawali的版本有关。
在此页上,它说不要使用master分支:
无论您选择克隆还是下载,您都可能希望使用其中的一个发布标记。库和示例的主分支用于开发,对于生产代码来说应该被认为是不稳定的。当我们发布一个稳定的版本,它将被标记。如果您正在克隆,您可以简单地签出一个标记。
如果使用Rajawali克隆git,则需要从标记中签出。若要列出标签:
$ git tag
v0.9在撰写本报告时,v0.9是您唯一的选择。
$ git checkout v0.9现在您可以使用DiffuseMaterial了。然而,其他一些类仍然缺少。
编辑:
看起来,本教程既不适用于v0.9,也不适用于最新的主分支。我制作了一个教程1的工作版本,其中你可以在这里找到链接。
发布于 2015-01-28 03:44:26
您还可以使用我编写的RajawaliExamples应用程序(它由贡献的示例组成)作为使用主分支的演示。
https://github.com/MasDennis/RajawaliExamples
另外,为了澄清Deans的引用,这里的声明劝阻了人们不要因为API在他们下面的变化而抓狂--当jwoolston做了很大的更改以支持场景图的时候,这是最相关的。大部分工作已经完成,如果完成了,api可能会从当前状态大幅度改变,因为其他主要项目已经完成。这些项目是像动画,更多的解析选项,灵活的渲染,等等。
https://stackoverflow.com/questions/19127206
复制相似问题