Changing openGL coordinates

Problems with Canvas, OpenGL, etc...

Changing openGL coordinates

Postby harrry » Mon Jul 25, 2011 5:57 pm

Hi all,
i am developing an openGL application, where different images are positioned in a circle.
See picture:
Image
Turning the circle works perfect.

But my big problem is, to move all images to the front image.

My draw()-methode in the renderer is this:
Code: Select all
// -10° around x-axis
gl.glRotatef(10, 1, 0, 0);
// turns the circle (y-axis)
gl.glRotatef(m_Modell.getRotation(), 0, 1, 0);

for (int i = 0; i < m_Modell.getNrOfCovers() ; i++)
{
cover = m_Modell.getCover(i);
gl.glPushMatrix();

fX = cover.getX();
fY = 0;
fZ = cover.getZ();

// moves the cover to the position
gl.glTranslatef(fX, fY, fZ);
// turns each cover against the rotation (Y-axis)
gl.glRotatef(-m_Modell.getRotation(), 0, 1, 0);
// turns each cover against the x-rotation
gl.glRotatef(-10, 1, 0, 0);
// moves the cover to center
gl.glTranslatef(-fX, -fY, -fZ);

// DRAWING
// loading cover coordinates
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, m_alCoverPoints.get(i));
// reset color
gl.glColor4f(0, 0, 0, 0);
// bind texture
gl.glBindTexture(GL10.GL_TEXTURE_2D, cover.getClip().getCoverTexturId());
// load texture coordinates
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, m_fbTexturPunkte);
// draw
gl.glDrawElements(GL10.GL_TRIANGLES, 2 * 3, GL10.GL_UNSIGNED_SHORT, m_sbIndices);

gl.glPopMatrix();
}


In m_Modell i change de cover coordinates with this calculation formula:

Xnew = Xold + (Xgoal - Xold) * movingProgress // moving progress 0.0 - 1.0 where 0.0 = no moving
Znew = Zold + (Zgoal - Zold) * movingProgress

This works in one position from the carousel, but in all different positions the images moving confused.

I hope you understand my bad english.
I need your help.

Thx and regards Harry
harrry
Freshman
Freshman
 
Posts: 4
Joined: Mon Jul 25, 2011 5:22 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests