//////////////////////////////////////////////////////////////////////////////////////////
#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);
//glBegin(GL_QUADS);
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);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -180.0f); //UCIEKAMY Z KAMERKĄ WSTECZ(z obiektem tak na prawdę)
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);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45,ratio,3.2,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
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;
}
Rotating shape across the axis
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
[Edited by - wit0ld on February 7, 2008 6:03:12 AM]
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).
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).
Quote:Original post by wit0ldA good first step would be to edit your post and enclose the code in [source] tags.
Why no one is replying? Is it too hard, or too noobish? Maybe Im hidden in another posts forest.
A lot of people (myself included) won't bother looking at large blocks of code that aren't formatted correctly.
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement