Java RenderScript支持库中缺少网格类

Java RenderScript支持库中缺少网格类,java,android,eclipse,renderscript,Java,Android,Eclipse,Renderscript,我下面是为了了解RenderScript。我在project.properties中添加了以下内容: renderscript.target=19 renderscript.support.mode=true sdk.buildtools=23.0.2 我编写了我的.rs文件,ScriptC_myfilename是在gen文件夹中生成的,但是android.support.v8.renderscript无法解析为类型,因此我添加了renderscript-v8.jar作为库,该库位于sdk/b

我下面是为了了解RenderScript。我在project.properties中添加了以下内容:

renderscript.target=19
renderscript.support.mode=true
sdk.buildtools=23.0.2
我编写了我的.rs文件,ScriptC_myfilename是在gen文件夹中生成的,但是
android.support.v8.renderscript
无法解析为类型,因此我添加了
renderscript-v8.jar
作为库,该库位于sdk/build tools/android-4.4W/renderscript/lib(配置生成路径>>库>>添加外部JAR),问题已修复

编码后,由于此错误,我无法编译代码,该错误可在ScriptC_filename.java的gen文件夹中找到:

Mesh cannot be resolved to a Type
我搜索这个问题,试图找到缺少的类,我不知道,可能是手动实现这个类作为我项目的一部分,所以Eclipse可以导入它并修复错误,但我有点困惑,因为
Mesh
类甚至没有被引用

我还尝试在sdk\build tools\android-4.4.2\renderscript\lib导入renderscript-v8.jar,以及添加
import android.support.v8.renderscript.Mesh
,但没有成功

我不知道这是否有帮助,但这是我的ScriptC_Snow.java文件(这里的所有内容都是生成的,我没有编辑),注释是Eclipse上显示的错误

    public class ScriptC_Snow extends ScriptC {
    private static final String __rs_resource_name = "snow";

    public  ScriptC_Snow(RenderScript rs) {
        this(rs,
             rs.getApplicationContext().getResources(),
             rs.getApplicationContext().getResources().getIdentifier(
                 __rs_resource_name, "raw",
                 rs.getApplicationContext().getPackageName()));
    }

    public  ScriptC_Snow(RenderScript rs, Resources resources, int id) {
        super(rs, resources, id);
        __MESH = Element.MESH(rs); //the method MESH(RenderScript) is undefined for the type Element
        __F32_2 = Element.F32_2(rs);
    }

    private Element __F32_2;
    private Element __MESH;
    private FieldPacker __rs_fp_F32_2;
    private FieldPacker __rs_fp_MESH;
    private final static int mExportVarIdx_snowMesh = 0;
    private Mesh mExportVar_snowMesh; // Mesh cannot be resolved to a type
    public synchronized void set_snowMesh(Mesh v) { // Mesh cannot be resolved to a type
        setVar(mExportVarIdx_snowMesh, v);
        mExportVar_snowMesh = v; // Mesh cannot be resolved to a type
    }

    public Mesh get_snowMesh() { // Mesh cannot be resolved to a type
        return mExportVar_snowMesh; // Mesh cannot be resolved to a type
    }

    public Script.FieldID getFieldID_snowMesh() {
        return createFieldID(mExportVarIdx_snowMesh, null);
    }

    private final static int mExportVarIdx_snow = 1;
    private ScriptField_Snow mExportVar_snow;
    public void bind_snow(ScriptField_Snow v) {
        mExportVar_snow = v;
        if (v == null) bindAllocation(null, mExportVarIdx_snow);
        else bindAllocation(v.getAllocation(), mExportVarIdx_snow);
    }

    public ScriptField_Snow get_snow() {
        return mExportVar_snow;
    }

    private final static int mExportVarIdx_wind = 2;
    private Float2 mExportVar_wind;
    public synchronized void set_wind(Float2 v) {
        mExportVar_wind = v;
        FieldPacker fp = new FieldPacker(8);
        fp.addF32(v);
        int []__dimArr = new int[1];
        __dimArr[0] = 4;
        setVar(mExportVarIdx_wind, fp, __F32_2, __dimArr);
    }

    public Float2 get_wind() {
        return mExportVar_wind;
    }

    public Script.FieldID getFieldID_wind() {
        return createFieldID(mExportVarIdx_wind, null);
    }

    private final static int mExportVarIdx_grav = 3;
    private Float2 mExportVar_grav;
    public synchronized void set_grav(Float2 v) {
        mExportVar_grav = v;
        FieldPacker fp = new FieldPacker(8);
        fp.addF32(v);
        int []__dimArr = new int[1];
        __dimArr[0] = 4;
        setVar(mExportVarIdx_grav, fp, __F32_2, __dimArr);
    }

    public Float2 get_grav() {
        return mExportVar_grav;
    }

    public Script.FieldID getFieldID_grav() {
        return createFieldID(mExportVarIdx_grav, null);
    }

    private final static int mExportFuncIdx_initSnow = 0;
    public void invoke_initSnow() {
        invoke(mExportFuncIdx_initSnow);
    }

}
这是我的renderscript代码(.rs文件):

布拉格语版本(1) #pragma rs java_包名称(com.mypackage.script) #包括“rs_graphics.rsh” rs_网雪网; typedef结构属性(压缩、对齐(4))雪花{ 在这里输入代码 漂浮速度; 浮动2位; uchar4颜色; 在这里输入代码 }雪; 雪,雪; 浮标2风; 浮球2个; int root(){ rsgClearColor(0.0f、0.0f、0.0f、0.0f); rsgDrawMesh(雪地网格); 返回0; } void init(){ 重力x=0; 重力y=18; 风x=rsRand(50)+20; 风y=rsRand(4)-2; } void initSnow(){ 在这里输入代码 常量浮点w=rsgGetWidth(); 常量浮点h=rsgGetHeight(); int snowCount=rsAllocatingETDIMX(rsGetAllocation(snow)); 雪\u t*pSnow=雪; 对于(int i=0;iposition.x=rsRand(w); pSnow->position.y=rsRand(h); pSnow->velocity.y=rsRand(60); pSnow->velocity.x=rsRand(100); pSnow->velocity.x-=50; uchar4c=rsPackColorTo8888(255,255,255); pSnow->color=c; pSnow++; } } 我只使用SDK管理器来获取文件,有什么我缺少的吗?任何人都可以给我一个链接来加载renderscript-v8.jar的最新版本吗?有没有任何链接可以用来查看缺少的类,以便在我的项目中实现它,以便允许Eclipse导入并使用它


提前感谢。

您不能将支持库与rs\u graphics.rsh一起使用。它不支持诸如rs\u mesh、rs\u font或rs\u program*之类的对象。支持库仅用于访问RenderScript compute。

您能发布您的RenderScript代码吗?哦,我现在明白了。mesh类已被弃用。但如果我不能使用re\u mesh,仍然会有问题例如,使用renderscript制作1000个粒子?我知道OpenGL,但renderscript看起来更好。你有什么建议吗?我想制作各种粒子的动画,只是为了学习。谢谢@StephenHines
#pragma version(1)

#pragma rs java_package_name(com.mypackage.script)

#include "rs_graphics.rsh"

rs_mesh snowMesh;

typedef struct __attribute__((packed, aligned(4))) Snow {
enter code here
    float2 velocity;
    float2 position;
    uchar4 color;
enter code here
} Snow_t;

Snow_t *snow;

float2 wind;
float2 grav;

int root() {

    rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    rsgDrawMesh(snowMesh);
    return 0;

}

void init() {

    grav.x = 0;
    grav.y = 18;
    wind.x = rsRand(50)+20;
    wind.y = rsRand(4) - 2;

}

void initSnow() {
enter code here
    const float w = rsgGetWidth();
    const float h = rsgGetHeight();

    int snowCount = rsAllocationGetDimX(rsGetAllocation(snow));

    Snow_t *pSnow = snow;
    for (int i=0; i < snowCount; i++) {
        pSnow->position.x = rsRand(w);
        pSnow->position.y = rsRand(h);

        pSnow->velocity.y = rsRand(60);
        pSnow->velocity.x = rsRand(100);
        pSnow->velocity.x -= 50;

        uchar4 c = rsPackColorTo8888(255, 255, 255);
        pSnow->color = c;
        pSnow++;

    }

}