垂直传送带renderscript [英] vertical carousel renderscript

查看:124
本文介绍了垂直传送带renderscript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助,可使用此的链接。我希望把它垂直旋转。我发现称为getMatrixForCard在.RS文件的方法,其中上的卡基质的转化完成。这里是方法:

I need some help with the CarouselExample that can be checked out using this link. I want to make it spin vertically. I found a method in the .rs file called getMatrixForCard where the transformations on the matrix of the cards is done. Here is the method:

static bool getMatrixForCard(rs_matrix4x4* matrix, int i, bool enableSway, bool   
enableCardMatrix)
{
float theta = cardPosition(i);
float swayAngle = getSwayAngleForVelocity(velocity, enableSway);
rsMatrixRotate(matrix, degrees(theta), 0, 1, 0);
rsMatrixTranslate(matrix, radius, getVerticalOffsetForCard(i), 0); 
/* rsMatrixTranslate(matrix, 0, radius, 0);*/
float rotation = cardRotation + swayAngle;
if (!cardsFaceTangent) {
  rotation -= theta;
}
rsMatrixRotate(matrix, degrees(rotation), 0, 1, 0);
bool stillAnimating = false;
if (i == animatedSelection) {
    float3 scale;
    stillAnimating = getAnimatedScaleForSelected(&scale);
    rsMatrixScale(matrix, scale.x, scale.y, scale.z);
}
// TODO(jshuma): Instead of ignoring this matrix for the detail texture, use card 
bounding box
if (enableCardMatrix) {
    rsMatrixLoadMultiply(matrix, matrix, &cards[i].matrix);
}
return stillAnimating;
}

所以,我猜测,从该行为Y改变x的值,就会使其工作。

So i guessed that changing the values of x with y from this line, would make it work.

rsMatrixTranslate(matrix, radius, getVerticalOffsetForCard(i), 0); 

但事实并非如此。请如果有人检查了这个例子,并且知道如何帮助我,使垂直旋转木马,我会AP preciate它。

But it does not. Please if someone has checked this example and knows how to help me and make the carousel vertical, i would appreciate it.

推荐答案

您不需要此功能改变,你需要一些其他的PARAMS改变

you don't need to change in this function, you need to change in some other params

carousel.rs 文件替换

static const float3 cardVertices[4] = {
        { -1.0, -1.0, 0.0 },
        { 1.0, -1.0, 0.0 },
        { 1.0, 1.0, 0.0 },
        {-1.0, 1.0, 0.0 }
};
// Default camera
static PerspectiveCamera camera = {
        {2,2,2}, // from
        {0,0,0}, // at
        {0,1,0}, // up
        25.0f,   // field of view
        1.0f,    // aspect
        0.1f,    // near
        100.0f   // far
};

static const float3 cardVertices[4] = {
        { 0.0, -1.0, -1.0 },
        { 0.0, -1.0, 1.0 },
        { 0.0, 1.0, 1.0 },
        { 0.0, 1.0, -1.0 }
};

static PerspectiveCamera camera = {
        {2,2,2}, // from
        {0,0,0}, // at
        {0,1,0}, // up
        40.0f,   // field of view
        1.0f,    // aspect
        0.1f,    // near
        100.0f   // far
};

和在 CarouselTestActivity.java 更改

private static final int CARD_SLOTS = 56;

private static final int CARD_SLOTS = 30;

和变化的的onCreate(),以作为后续

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.carousel_test);
    mView = (CarouselView) findViewById(R.id.carousel);
    mView.getHolder().setFormat(PixelFormat.RGBA_8888);
    mPaint.setColor(0xffffffff);
    final Resources res = getResources();

    mHelper = new LocalCarouselViewHelper(this);
    mHelper.setCarouselView(mView);
    mView.setSlotCount(CARD_SLOTS);
    mView.createCards(INCREMENTAL_ADD ? 1: TOTAL_CARDS);
    mView.setVisibleSlots(SLOTS_VISIBLE);
    mBorder = BitmapFactory.decodeResource(res, R.drawable.border);
    mView.setDefaultBitmap(mBorder);
    mView.setLoadingBitmap(mBorder);
    mView.setBackgroundColor(0.25f, 0.25f, 0.5f, 0.5f);
    mView.setRezInCardCount(3.0f);
    mView.setFadeInDuration(250);
    mView.setVisibleDetails(VISIBLE_DETAIL_COUNT);
    mView.setDragModel(CarouselView.DRAG_MODEL_CYLINDER_INSIDE);

    // New settings
    mView.setStartAngle((float) -(11.7f*Math.PI / 10));
    mView.setVisibleDetails(6);
    mView.setRowCount(3);
    mView.setRadius(10f);
    float mEye[] = { 2f, 0f, 0f };
    float mAt[] = { 0.0f, 0.0f, 0.0f };
    float mUp[] = { 0.0f, 1.0f, 0.0f };
    mView.setLookAt(mEye, mAt, mUp);
    mView.setCardsFaceTangent(true);

    if (INCREMENTAL_ADD) {
        mView.postDelayed(mAddCardRunnable, 2000);
    }

    mGlossyOverlay = BitmapFactory.decodeResource(res, R.drawable.glossy_overlay);
}

的输出将是如下

the output will be as follow

这篇关于垂直传送带renderscript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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