2012-01-26 4 views
3

link을 사용하여 체크 아웃 할 수있는 CarouselExample에 대한 도움이 필요합니다. 수직으로 회전시키고 싶습니다. .rs 파일에서 getMatrixForCard라는 메소드를 발견했습니다.이 메소드는 카드 행렬의 변환이 완료된 곳입니다. 방법은 다음과 같습니다.수직 회전식 둘러보기 렌더 스크립트

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로 변경하면 효과가 있음을 알 수 있습니다.

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

그러나 그렇지 않습니다. 제발 누군가가이 예제를 확인하고 나에게 도움이되는 방법을 알고 회전 목마를 수직으로 만들면 제발 고맙겠습니다.

+0

를 따를 때 출력이 될 것입니다 될 수 있습니다 수직 회전식을 했니? – zaiff

답변

2

이 기능으로 변경할 필요가 없습니다, 당신은 carousel.rs에서

파일

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 
}; 

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 
}; 

을 대체 할 다른 PARAMS으로 변경해야

CarouselTestActivity.java 변경

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); 
} 

을 따를

private static final int CARD_SLOTS = 56; 

private static final int CARD_SLOTS = 30; 

변경 에서 onCreate() 당신이 얼마나 정교하게시겠습니까 Vertical Carousel

+0

나는 이미 수직 회전 목마를 만들었지 만 답장을 위해 대단히 감사합니다. 내 렌더 스크립트 질문에 답하는 사람은 많지 않습니다. 시간이 있으면 확인해 보겠습니다. – Sandra

+0

렌더 스크립트없이 어떻게 했습니까 ?? –

+0

@ 하켄, 3D 컨베이어 소스는 어디에서 찾을 수 있습니까? 나는 그것이 /견본/android-11/RenderScript 아래에 http://developer.android.com/guide/topics/renderscript/index.html에서 말한 것처럼 보이지 않는다. – mdupls