Android 中的 3D 轮播 [英] 3D Carousel in Android
问题描述
我正在开发适用于 android 的 3D Carousel.
我正在使用这个
以下接近我的要求:
从这个我回答我说:
mCamera.rotateY(-((CarouselItem) child).getCurrentAngle());
在 Carousel.java
的 getChildStaticTransformation()
方法中,但我没有得到完美的结果.
请帮我解决.
您正在使用一个名为 Calculate3DPosition 的函数,该函数从角度计算 X、Y、Z 位置,然后在 matrix.translate 调用中使用这些位置.
您需要的实际上要简单得多 - 您只需要使用角度调用 matrix.rotate 即可.当您完成后,它可能看起来非常简单,但老实说,您复制的 3D 代码中唯一的复杂性是试图让所有东西都面向用户而不是让它旋转......
I am working on 3D Carousel for android.
I am using this code and the following is my current output.
I want to develop the following 3D shaped carousel.
I refered to the following questions which are already asked in SO.
The following is near to my requirement:
From this I answer I put:
mCamera.rotateY(-((CarouselItem) child).getCurrentAngle());
inside getChildStaticTransformation()
method of Carousel.java
but I'm not getting a perfect result.
Please help me to solve it.
You are using a function called Calculate3DPosition which calculates X, Y, Z positions from the angle and then those are used in a matrix.translate call.
What you need is actually much simpler - you just need to call matrix.rotate with the angle. It might look surprisingly easy when you've finished, but honestly, the only complexity in the 3D code you have copied is from attempting to keep everything facing the user instead of letting it rotate ...
这篇关于Android 中的 3D 轮播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!