# Rotating shape across the axis

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

## Recommended Posts

All I wana do is to move shape across the axis. I dont know how this operation can be called by pros but youll understand what I want to do when youll compile my child - allready? So that what you see we can call wireframe, I want it be solid ;p ps. sory for possible speach mistakes ps2. little monkeys shows the place where you should look when youre kind man who wants to help the lost sheep
//////////////////////////////////////////////////////////////////////////////////////////

#define GLUT_DISABLE_ATEXIT_HACK

#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <stdlib.h>
#include <math.h>

GLuint szczala;

GLfloat prostata(GLfloat pozycja)
{
return (3*(sin(pozycja)))/*VAWES*/
+(pow(pozycja,2))*(0.01)/*SHAPE*/;//@@@@@@@@@@@@@@@@@@@@@
}

static void objekt_szczalki()
{
szczala=glGenLists(1);
glNewList(szczala, GL_COMPILE);
GLfloat yy,xx;

for (GLfloat dupka = 0; dupka < 360; dupka++) {//@@@@@@@@@@@@@@@@@@@@@
//REPRODUCTION OF OUR LINES (PSEUDO WIREFRAME)
glTranslatef(20,0,0);
glBegin(GL_LINE_STRIP);
for (GLfloat aa = -50; aa < 100/*zakres kreskowania*/; aa+=0.5)//@@@@@@@@@@@@@@@@@@@@@
//LOOP FOR ONE LINE HERE
{ yy=xx=aa;

glColor3f(1,cos(aa),sin(aa));

glVertex3f(prostata(xx), yy, 0.0f);
glVertex3f(prostata(xx+0.5), yy+0.5, 0.0f);

//TERORETICALY FROM HERE
glRotatef(dupka,0,1,0);
glTranslatef(20,20,20);
glVertex3f(prostata(xx+0.5), yy+0.5, 0.0f);
glVertex3f(prostata(xx), yy, 0.0f);
glRotatef(-dupka,0,1,0);
glTranslatef(200,-20,-20);
//TO HERE IT SHOULD CREATE GREAT QUAD BU PUTTING
//TWO POINTS THAN ROTATING TO THE POSITION OF NEXT LINE(NOW)
//THEN PUTTING ANOTHER TWO POINTS
//BUT PROBABLY ROTATION DOESNT WORK INSIDE glBegin-glEnd

//HOW CAN I MODULATE IT??

}
glEnd();
glTranslatef(-20,0,0);
glRotatef(dupka,0,1,0);
}
// }

glEndList();
}

GLfloat klocek;

static void display(void) {

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glTranslatef(0.0f, 0.0f, -180.0f);  //UCIEKAMY Z KAMERK&#260; WSTECZ(z obiektem tak na prawd&#281;)

glRotatef(1*klocek,0,0.0001,0);
glCallList(szczala);

klocek+=0.02;

glutSwapBuffers();
}

void changeSize(int w, int h) {
if(h == 0)
h = 1;
float ratio = 1.0* w / h;
glMatrixMode(GL_PROJECTION);
glViewport(0, 0, w, h);
gluPerspective(45,ratio,3.2,1000);
glMatrixMode(GL_MODELVIEW);

gluLookAt(0.0,0.0,5.0, 0.0,0.0,-1.0, 0.0f,1.0f,0.0f);
}

static void key(unsigned char key, int x, int y){
switch (key)
{
case 27 :
case 'q':
exit(0);
break;

default: break;
}

glutPostRedisplay();
}

static void idle(void){
glutPostRedisplay();
}

int main(int argc, char *argv[]){
glutInit(&argc, argv);
glutInitWindowSize(800,600);
glutInitWindowPosition(0,0);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

glutCreateWindow("LAB01");

glutReshapeFunc(changeSize);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutIdleFunc(idle);

glClearColor(0,0,0,0);
//    glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);

objekt_szczalki();

glutMainLoop();

return EXIT_SUCCESS;
}


[Edited by - wit0ld on February 7, 2008 6:03:12 AM]

##### Share on other sites
Why no one is replying? Is it too hard, or too noobish? Maybe Im hidden in another posts forest.

AD: Using Z axis for positing points doesnt work. When I put two points which should be rotated (but probably rotation doesnt work inside glBegin-glEnd) at Z(10) then it looks quite nice but there are holes when function has high values (far from center), and polygons are too big and are hiding each other when function has low values (nearest polys from center).

##### Share on other sites
Quote:
 Original post by wit0ldWhy no one is replying? Is it too hard, or too noobish? Maybe Im hidden in another posts forest.
A good first step would be to edit your post and enclose the code in [source] tags.

A lot of people (myself included) won't bother looking at large blocks of code that aren't formatted correctly.

##### Share on other sites
OK I modified it. All youre interested is inside objekt_szczalki()
I cuted some code which is not a topic, but there are still thing needed to be in this code if you want just to put it inside your ide and compile aesilly.

I replaced Polish comments with its English version. Now there should be no communication troubles.

[Edited by - wit0ld on February 7, 2008 6:43:49 AM]

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 10
• 11
• 13
• 9
• ### Forum Statistics

• Total Topics
634094
• Total Posts
3015468
×