OpenGL ES Learning - some question about rotating -


hy there! new opengl es, saw many examples in net, have question rotations.

how can double rotating @ 1 time? need rotate object on center, , @ same time, need rotate object on circle, has center point, in space.

the second thing:

i create code:

glloadidentity... gltranslatef 0,0,0.. glrotatef...  drawsomeobject...  glloadidentity... gltranslatef 0,3,0.. glrotatef...  drawsomeobject... 

it good, code can rotate drawing objects on it's own center. how can rotate or translate objects group?

so this:

//translate, , rotate in group1 gltranslatef 0,0,0.. glrotatef...  group1  glloadidentity... gltranslatef 0,0,0.. glrotatef...  drawsomeobject...  glloadidentity... gltranslatef 0,3,0.. glrotatef...  drawsomeobject...  end group1   //translate, , rotate in group1 gltranslatef 2,0,0.. glrotatef...  group2  glloadidentity... gltranslatef 0,0,0.. glrotatef...  drawsomeobject...  glloadidentity... gltranslatef 0,3,0.. glrotatef...  drawsomeobject...  end group2 

apply following scheme (pseudocode):

loadidentity translate (group translation)  rotate(group rotation)  pushmatrix   translate object1 rotate object1 drawobject1  popmatrix  pushmatrix  translate object2 rotate object2 drawobject2  popmatrix  ...  

so not return identity each object, rather return group state, can preserved using pushmatrix , popmatrix on modelview matrix. commands store current state on internal opengl stack (pushmatrix) , retrieve matrix stack @ later point (popmatrix).

here link related tutorial: http://www.swiftless.com/tutorials/opengl/pop_and_push_matrices.html


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -