简体   繁体   English

RenderScript支持库上缺少网格类

[英]Missing Mesh class on RenderScript support library

I'm following this sample in order to learn about RenderScript. 我正在关注此样本 ,以了解RenderScript。 I added the following at project.properties: 我在project.properties中添加了以下内容:

renderscript.target=19
renderscript.support.mode=true
sdk.buildtools=23.0.2

I wrote my .rs file, the ScriptC_myfilename was generated at gen folder but the android.support.v8.renderscript could not be resolved to a type, so I added the renderscript-v8.jar located at sdk/build-tools/android-4.4W/renderscript/lib as a library (configure Build Path >> Libraries >> add External JARs) and the problem was fixed. 我写我.RS文件时,ScriptC_myfilename在文件夹中生成,但android.support.v8.renderscript不能被解析为一个类型,所以我增加了renderscript-v8.jar位于SDK /构建工具/ android-将4.4W / renderscript / lib作为库(配置“构建路径>>库>>添加外部JAR”),此问题已得到解决。

After codding, I couldn't compile the code due to this error, found on ScriptC_filename.java at gen folder: 编码后,由于此错误,我无法编译代码,该错误在gen文件夹的ScriptC_filename.java上找到:

Mesh cannot be resolved to a Type

I search about the issue, trying to find the missing class and, I don't know, maybe manually implement this class as a part of my project, so Eclipse would be allowed to import it and fix the error, but I'm a bit confused since the Mesh class isn't cited even on android docs . 我搜索了这个问题,试图找到缺少的类,但我不知道,也许可以将该类作为我的项目的一部分手动实现,因此允许Eclipse导入它并修复错误,但是我是有点困惑,因为即使在android docs上也没有引用Mesh类。

I also tried to import the renderscript-v8.jar at sdk\\build-tools\\android-4.4.2\\renderscript\\lib , as well as add import android.support.v8.renderscript.Mesh but with no success. 我还尝试在sdk \\ build-tools \\ android-4.4.2 \\ renderscript \\ lib处导入renderscript-v8.jar ,以及添加import android.support.v8.renderscript.Mesh但没有成功。

I don't know if this would help, but this is my ScriptC_Snow.java file (everything here was generated, I didn't edit it), The comments is the error showed on Eclipse 我不知道这是否有帮助,但这是我的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);
    }

}

This is my renderscript code (.rs file): 这是我的渲染脚本代码(.rs文件):

#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++;

    }

}

I only used the SDK Manager to obtain the files, is there anything I'm missing? 我仅使用SDK Manager来获取文件,我缺少什么吗? Anyone can give me a link to donwload the latest version of renderscript-v8.jar? 任何人都可以给我链接以下载最新版本的renderscript-v8.jar吗? Is there any link that I could use to see the missing class, in order to implement it in my project, so Eclipse'd be allowed to import and use it? 有什么链接可以用来查看缺少的类,以便在项目中实现它,因此允许Eclipse导入和使用它?

Thanks in advance. 提前致谢。

You can't use the support library with rs_graphics.rsh. 您不能将支持库与rs_graphics.rsh一起使用。 It doesn't support objects like rs_mesh, rs_font, or rs_program*. 它不支持rs_mesh,rs_font或rs_program *之类的对象。 The support library is only for accessing RenderScript compute. 支持库仅用于访问RenderScript计算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM