Lars,
if i understand you correctly, you are rendering a bunch of glutSolidCubes
together to form a larger shape. and now you want to rotate that larger
shape (all the individual glutSolidCubes together) as one solid shape.
if you understand how to rotate one of the individual glutSolidCubes, then
you can use the same method to rotate the larger shape. the difference lies
in where you make your glRotate*() call. when you make a rotate call, it
modifies the current model-view matrix in OpenGL. this matrix will affect
everything you render for the remainder of the rendering frame. so, you
have to add a new glRotate call in your display method before you render
any of your glutSolidCubes. this additional rotate will apply to all the
small cubes, and it will rotate them all around the axis of rotation that
you provide in the rotate call.
if this didn't make sense, or i screwed up the explanation, then you can
see Chapter 3 in the OpenGL "Red" book for a good descriptoin.
-mark
Lars Beyer-Olsen wrote:
> First posting.
>
> I'm really new at this, so I hope this question is not to simple.
> What I want to do is to draw a wired cube consisting of glutSolidCubes,
> and rotate the cube like it was one object.
>
> This is the code for drawing the one of the six sides of the cube.
>
> //Left-side
> gl.glLoadIdentity();
> gl.glTranslatef(-1.0f, 2.0f, -20.0f);
> gl.glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
> gl.glScalef(6.0f, 0.5f, 0.6f);
> glut.glutSolidCube(1.0f);
>
> //Lower-side
> gl.glLoadIdentity();
> gl.glTranslatef(1.0f, 0.0f, -20.0f);
> gl.glScalef(6.0f, 0.5f, 0.6f);
> glut.glutSolidCube(1.0f);
>
> //Right-side
> gl.glLoadIdentity();
> gl.glTranslatef(3.0f, 2.0f, -20.0f);
> gl.glPushMatrix();
> gl.glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
> gl.glScalef(6.0f, 0.5f, 0.6f);
> glut.glutSolidCube(1.0f);
>
> //Upper-side
> gl.glLoadIdentity();
> gl.glTranslatef(1.0f, 4.0f, -20.0f);
> gl.glScalef(6.0f, 0.5f, 0.6f);
> glut.glutSolidCube(1.0);
>
> I build the rest of the cube in the same way, just translating the
> glutSolidCubes around.
> My problem arises when i want to rotate all the glutSolidCubes as one
> object.
> I know how to rotate the glutSolidCubes as individual objects, but I
> don't get anywhere
> with that (do I ?).
>
> Anyone with a solution?
>
> Lars
>
> _______________________________________________
> gl4java-usergroup mailing list
> gl4...@li...
> https://lists.sourceforge.net/lists/listinfo/gl4java-usergroup
|