2012-07-16 132 views
4

我可以使用旋轉動畫而不使用任何OpenGL或任何第三方工具。我只想在佈局layout.yout中應用順時針旋轉的3D汽車對象。我可以旋轉3D車對象嗎

+0

[你試過嗎?(http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html) – Praveenkumar 2012-07-16 09:17:24

+0

那只是一個翻轉動畫沿調整大小寬度,它不是真的像這樣旋轉。您不會看到3D物體的多個面,只有平面物體的兩面。 – 2012-07-16 09:20:01

回答

0

除非你有某種模擬3D汽車的精靈動畫序列,否則我不明白你是如何做到這一點的。我可能是錯誤的,雖然可能錯過了Android的東西,但對我來說這是一個經典的OpenGL情況。

通過精靈動畫我也意味着任何形式的二維序列圖像,例如GIF動畫。

+0

這意味着你想告訴我,使用OpenGL是我做這種類型的任務的最佳選擇...? – Maddy 2012-07-16 10:08:53

+0

在我眼裏,要麼你必須使用OpenGL,要麼你需要首先在android之外進行動畫製作(例如在blender/3dsMax/Maya等),然後把每一幀都保存爲gif的一部分。 – 2012-07-16 10:18:53

+0

使用OpenGL將允許用戶進行交互,並允許它們以任何他們希望的方向旋轉,如果允許它們放大和縮小。使用GIF他們可以互動,但只能在動畫序列中前後移動。它更加有限,所以它確實是基於您希望用戶能夠使用3D模型做出的決定。 – 2012-07-16 10:20:19

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.