绘制动画圈内的OpenGL ES 2.0 [英] Drawing animated circle with OpenGL ES 2.0

查看:261
本文介绍了绘制动画圈内的OpenGL ES 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个圆形物体,使用OpenGL顶点创建的。

I have a circle object, created with OpenGL vertices.

在圈内被感动了,我想缩放动画被激活。直到它达到一定半径的圆的半径将变得更大,然后在圆圈将变换回到原来的半径。

When the circle is being touched, I want a scaling animation to be activated. The circle radius will grow bigger until it reaches a certain radius, and then the circle will transform back to its original radius.

什么是实现这个动画的最佳方式?

What is the best way to implement this animation?

推荐答案

您有几种可能性。最简单的是只创造出将举行一个比例因子你的圈子和渲染之前乘以它的所有顶点的变量。然后使用一些定时器,并及时调整缩放因子,您可以创建动画。
我要补充一点,如果你想用它的中心扩展你的圈子,那么你必须先翻译界的顶点,所以圆的中心将在(0,0)点,再由因子规模和翻译一圈又回到其初始位置。

You have a few possibilities. The simplest would be to just create a variable which would hold a scaling factor for your circle and multiply all vertices by it before rendering. Then using some timers and adjusting the scaling factor in time, you could create your animation. I should add that if you want to scale your circle by its center then you have to first translate the circle vertices so that circle's center will be at (0, 0) point, then scale by the factor and translate the circle back to its initial position.

如果你想实现圆动画是某种你的GUI元素,则另一种方式它在我脑海的是:

If the circle animation you're trying to implement is some kind of your GUI element then another way which comes to my mind is to:


  1. 创建XML或动态地code。将ImageView的

  1. create an ImageView in xml or dynamically in code

借鉴它的顶点

创建一个XML机器人动画,只要你想申请就

create an XML android animation and apply it whenever you want

这里的code的草案借鉴了ImageView的一个圆:

Here's a draft of the code for drawing a circle on the ImageView:

Bitmap tempBitmap = Bitmap.createBitmap(yourCircleWidth, yourCircleHeight, Bitmap.Config.ARGB_8888);
                Canvas tempCanvas = new Canvas(tempBitmap);

                //Draw the circle into the canvas               
                tempCanvas.drawColor(Color.WHITE);
                Paint paint = new Paint();
                paint.setStyle(Paint.Style.FILL);
                tempCanvas.drawCircle(circleCenterX, circleCenterY, yourCircleRadius, paint);

            //Attach the canvas to the ImageView
            yourImageView.setImageDrawable(new BitmapDrawable(yourImageView.getResources(), tempBitmap));

有关XML动画,这里是一个很好的参考:
http://www.androidhive.info/2013/06/ Android的劳动与-XML的动画/

For XML animations, here's a good reference: http://www.androidhive.info/2013/06/android-working-with-xml-animations/

这篇关于绘制动画圈内的OpenGL ES 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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