glScaled

Started by
21 comments, last by iSina 15 years, 9 months ago
Okay, I will play with the material and light properties until I get the desired result (so that some shadows appear on the edges of the ellipsoids to make them look more like 3d). As of rotation it is like this. When a rotation key is pressed from keyboard, it recalls the function which builds the model. So I am not really rotating the camera but I am rotating the model though my intention is to rotate the camera.

Also there will be one interconnected object not multiple ones. Calculations and lots of other things are done from the user interface I already built. This screen is just for viewing the result and evaluating it by examination. There will no functionality to change the model from this screen. Thus the aim is simple, just to be able rotate the camera to examine different parts of the polymer molecule.

sub DrawGLScene {    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);      glLoadIdentity();	    glColor4f(0.2,0.8,0.6,.95);    glTranslatef(-1.5, 0.0, -6.0);     ##Here are the translations that are done in response to key pressing,    ##At the start these values are zero    glTranslatef(0.0,0.0,$Z_Off);    glRotatef($Y_Speed,0.0,1.0,0.0);    glRotatef($X_Speed,1.0,0.0,0.0);    		for ($index=0; $index<5; $index++){		glPushMatrix();					glScaled(2.0, 1.1, 1.1);		glTranslatef(5*$index,0,0);				glBegin (GL_QUADS);				gluSphere($newQuad,1, 32, 16);		glEnd ;				glPopMatrix();						}    glutSwapBuffers;}
Advertisement
Quote:Original post by iSina
Okay, I will play with the material and light properties until I get the desired result (so that some shadows appear on the edges of the ellipsoids to make them look more like 3d).
There won't be true shadows without more work, but you'll get shading - areas that are darker than others thanks to their normals. A tiny difference, but I felt like making it clear so you're not expecting something you're not going to get. Also, I fear something's still not quite right, as enabling lighting should have caused your shapes to disappear completely when the lights shining on them were black. If you find that you still can't get the lighting to work, post more code, ideally a very very simple but complete program that replicates the problem.

Quote:As of rotation it is like this. When a rotation key is pressed from keyboard, it recalls the function which builds the model. So I am not really rotating the camera but I am rotating the model though my intention is to rotate the camera.
Does it really rebuild the model? I see no need for this - redraw it, certainly, which is what happens in the code you've presented - call glRotate and draw the model. That's not really rebuilding, as it's happening every frame whether you rotate anything or not. This system will work fine for one interconnected object, no need for anything fancier.

Looks like you're on your way, but post back (or start a new thread, now that scaling's working) if you run into problems!
Changing light values seem to produce no effect. Shadow was a bit fancy, I will be just happy enough to achieve some shading. I will try for some more and if I get stuck with ligts I will start a new topic later then..

By rebuilding I was meaning redrawing yes. My model will be simple anyway.

Thanks alot for the help :)

This topic is closed to new replies.

Advertisement