Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

50ld13r

display lists lesson 12

This topic is 5230 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi instead of rotating the individual cubes can you just rotate the whole collection of cubes? is this even possible? cheers

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
yup,

if the rotation function is in the display list.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Or do you mean rotate the collection around one point? Thats possible too.

Just use One rotation function before you draw the cubes. Use gltranslate to specify the point you want to rotate around.

Be sure to use counter rotation and translation function once the cubes are drawn

Share this post


Link to post
Share on other sites
thanks for your replies i do mean to rotate all the objects about a single fixed point however performing a rotation before the drawing routine doesnt seem to work as glLoadIdentity is called every time a single cube is draw.(doesnt that just reset everything)

ive tried putting glloadidentity outside the drawing loop but strange things happen

can anyone help

Share this post


Link to post
Share on other sites
Right I''ve found me password.

To be honest the function of glLoadIndentity is a bit of a mystery to me.

I usually use it a couple of times at the screen initialisation and thats it.

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, -100.0, 100);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glShadeModel(GL_SMOOTH);

The only other time I find I need to use it is when I switch the matrix mode to GL_TEXTURE.

So I guess my question is what find of strange things happen when you leave glLoadIndentity out?

Share this post


Link to post
Share on other sites
this is takes directly from lesson 12 in the DrawGLScene function

for (yloop=1;yloop<6;yloop++)
{

for (xloop=0;xloop {
glLoadIdentity(); // Reset The View
glTranslatef(1.4f+(float(xloop)*2.8f)-(float(yloop)*1.4f),((6.0f-float(yloop))*2.4f)-7.0f,-20.0f);
glRotatef(45.0f-(2.0f*yloop)+xrot,1.0f,0.0f,0.0f);
glRotatef(45.0f+yrot,0.0f,1.0f,0.0f);
glColor3fv(boxcol[yloop-1]);
glCallList(box);
glColor3fv(topcol[yloop-1]);
glCallList(top);
}
}

if you leave gl load identity out nothing seems to get drawn
if you put it in the first loop the left side of the triangular shape gets drawn
if you put it at the beginning of the loop cubes everywhere

im still messing around with the code trying to get the whole object of cubes to rotate about one fixed point however still had no luck. Am i going about this all wrong (quite possible)

cheers

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
ok, use glloadidentity before the first loop but at the end of the inner loop once the cube is drawn retrace your translation and rotation, like so:_

glTranslatef(-(1.4f+(float(xloop)*2.8f)-(float(yloop)*1.4f)),-((6.0f-float(yloop))*2.4f)-7.0f,20.0f);
glRotatef(-(45.0f-(2.0f*yloop)+xrot),1.0f,0.0f,0.0f);
glRotatef(-(45.0f+yrot),0.0f,1.0f,0.0f);

This should do what glLoadidentity is being used for in this instance.

Share this post


Link to post
Share on other sites
its looks good loads of cubes wizzing round but not exactly what i was hoping for. Giving me ideas for intro sequences.

code so far

int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer

glBindTexture(GL_TEXTURE_2D, texture[0]);

glLoadIdentity();

for (yloop=1;yloop<6;yloop++)
{
for (xloop=0;xloop {

glTranslatef(1.4f+(float(xloop)*2.8f)-(float(yloop)*1.4f),((6.0f-float(yloop))*2.4f)-7.0f,-20.0f);
glRotatef(45.0f-(2.0f*yloop)+xrot,1.0f,0.0f,0.0f);
glRotatef(45.0f+yrot,0.0f,1.0f,0.0f);
glColor3fv(boxcol[yloop-1]);
glCallList(box);
glColor3fv(topcol[yloop-1]);
glCallList(top);

glTranslatef(-(1.4f+(float(xloop)*2.8f)-(float(yloop)*1.4f)),-((6.0f-float(yloop))*2.4f)-7.0f,20.0f);
glRotatef(-(45.0f-(2.0f*yloop)+xrot),1.0f,0.0f,0.0f);
glRotatef(-(45.0f+yrot),0.0f,1.0f,0.0f);
}
}
return TRUE; // Keep Going
}

again i might just b a dumb a$$ and misunderstood your explaination. Its getting closer to the solution( yeah what do i know) but still not rotating the trangular set of cubes about a fixed point

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Good glad we are getting closer.

What is it doing wrong/not doing?

Do you perhaps need to move the translation and rotation in to the outer loop?

Yeah I''ve found loadsa nice effects by accident.

Share this post


Link to post
Share on other sites
the program i posted earlier rotates the first cube fine about the centre of that cube. However in drawing the rest of the cubes is where the problem is as there all over the screen. seemingly to rotate possible about the centre point of the correctly drawn cube. However because there drawn all over the place and not in the trangular structure rotating doesn''t give the desired effect. Im not sure if i have been clear in my explaination of what i want the program to do so i will try again.

i want the program to draw the triangular structure that is created in the default example ofound on the nehe opengl web site lesson 12 - display lists. however instead of rotating all the individual cubes i want it to rotate the whole collection of cubes about 1 single point but to still stay in the triangular structure when rotated about that rotation point.
also ignore the omissions that are on the inner loop(x loop) in the previous post its supposed to read: for (xloop=0;xloop
i have tried putting the code in may places with no luck

hope that helps in understanding my problem, hopefully we might get it cracked soon

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!