在RenderScript支持库缺少网格类 [英] Missing Mesh class on RenderScript support library

查看:265
本文介绍了在RenderScript支持库缺少网格类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的为了了解RenderScript此示例。我加在project.properties以下内容:

I'm following this sample in order to learn about RenderScript. I added the following at project.properties:

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

我写我的.RS文件时,ScriptC_myfilename在文件夹,但 android.support.v8.renderscript 产生的无法解析一个类型,所以我增加了 renderscript-v8.jar 位于 SDK /构建工具/ Android为4.4W / renderscript / lib目录作为库(配置构建路径>> >>库添加外部JAR),问题是固定的。

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.

在作弄我,我无法编译code,由于这个错误,在上ScriptC_filename.java发现的文件夹:

After codding, I couldn't compile the code due to this error, found on ScriptC_filename.java at gen folder:

Mesh cannot be resolved to a Type

我搜索一下这个问题,试图找到失踪的类,我不知道,也许手动实现这个类作为我的项目的一部分,这样的Eclipse将被允许进口,并修复错误,但我M有点糊涂了,因为网​​类没有引用甚至在的 Android的文档

我也试过在导入 renderscript-v8.jar SDK \\集结TOOLS \\ Android的4.4.2 \\ renderscript \\ lib中,以及添加进口android.support.v8.renderscript.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.

我不知道这是否会有所帮助,但是这是我的ScriptC_Snow.java文件(这里的一切都发生了,我并没有修改),该意见是在Eclipse上显示误差

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

    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 code(.RS文件):

This is my renderscript code (.rs file):

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

    }

}

我只用了SDK管理器来获得这些文件,有什么我失踪?任何人都可以给我一个链接到donwload最新版本renderscript-v8.jar的?是否有任何联系,我可以用它来查看丢失的类,以实现它在我的项目,所以Eclipse'd被允许进口和使用它吗?

I only used the SDK Manager to obtain the files, is there anything I'm missing? Anyone can give me a link to donwload the latest version of 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?

先谢谢了。

推荐答案

您不能rs_graphics.rsh使用支持库。它不支持像rs_mesh,rs_font或rs_program对象*。支持库仅用于访问RenderScript计算。

You can't use the support library with rs_graphics.rsh. It doesn't support objects like rs_mesh, rs_font, or rs_program*. The support library is only for accessing RenderScript compute.

这篇关于在RenderScript支持库缺少网格类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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