我可以旋转3D汽车对象吗?

时间:2012-07-16 09:13:01

标签: android 3d

我可以在不使用任何OpenGL或任何第三方工具的情况下使用旋转动画。我只想在修复layout.yout中应用顺时针旋转的3D汽车对象。

2 个答案:

答案 0 :(得分:0)

除非你有某种模拟3D汽车的精灵动画序列,否则我看不出你是如何做到这一点的。我可能错了,可能在机器人中遗漏了一些东西,但对我来说这是一个典型的openGL情况。

通过精灵动画我也指任何类型的2D图像序列,例如GIF动画。

答案 1 :(得分:0)

1) Well, you first have to set the car in 3D space;
To model a 3D object, you must define all the vertices of the car as if you were modeling with points and after , linking this point you get the car in wireframe.


Pont  A {x = 3, y = 10, z = 8}
Point B {x = 5, y = 12, z = 2}
Point C {x = 6, y = 40, z = 6}
Point D {x = 7, y = 12, z = 3}
Point E {x = 3, y = 10, z = 8}
...

2) After modeling the car in points, you must define the links of points to form lines, there you have called wireframe modeling, if you want to modeling shapes is different, but with the wireframe already a good idea of the object in the real world.

Line AB = Point A -> Point B
Line BC = Point B -> Point C


3) To spin perfectly the car, you should position it in the center of coordinates,applying in each point the formula translation T with measure the match the distance to the subject from the center at the origin of the axes.

New point x:
x = x - Tx 
New point y;
y = y - Ty
New point z:
z = z - Tz


4) With the car in position to  spin it into an angle "g" should be applied to each point the rotation transformation, the formula is:
 
Find the new point x:
xt = (x * 1) (* y 0) (z * 0);
Find the new point y:
yt = (X * 0) (y * Math.cos (g)) (z * (Math.sin-(g)));
Find the new point z:
zt = (X * 0) (y * Math.sin (g)) (z * Math.cos (g));


5) After applying the rotation effect, you must return the object to its point of origin, making a reverse translation to step 3.

New point x:
x = Tx x
New point y;
y = y Ty
New point z:
z = z Tz


This is a  roughly explanation but is the most basic way, of course it has more complex formulas that are faster these changes, but to become more didactic I put this way.