با سلام
کد و شکلی که ضمیمه میکنم سعی کردم در opengl پیاده سازی کنم تا حدودی این کار را انجام دادم تنها مشکل موجوداینه که در زاویه 3 بعدی با نورپردازی مثل شکل به صورت ثابت نگه داشته بشه،در صورت ممکن از دوستان خواهشاً حداقل تو این مشکل منو کمک کنن ممنون میشم.

با تشکرchaosGame.jpg


#include <windows.h>
#pragma comment( linker, "/entry:\"mainCRTStartup\"" )
#include <GL/glu.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glaux.h>
#include <GL/glext.h>
#include <math.h>
#include <cmath>
# include <iostream>
using namespace std;

//angle of rotation
GLfloat angle = 70000.0;

//diffuse light color variables
GLfloat dlr = 1.0;
GLfloat dlg = 1.0;
GLfloat dlb = 1.0;

//ambient light color variables
GLfloat alr = 2.0;
GLfloat alg = 1.0;
GLfloat alb = 1.0;

//light position variables
GLfloat lx = 0.0;
GLfloat ly = 0.0;
GLfloat lz = 1.0;
GLfloat lw = 0.0;

//draw the Plot
void Plot (void) {

double x=0.65554433;
double y=0.78877776;
double z=0.32122333;

glRotatef(angle, x, 0.0, 0.0); //rotate on the x axis
glRotatef(angle, 0.0, y, 0.0); //rotate on the y axis
glRotatef(angle, 0.0, 0.0, z); //rotate on the z axis

int BNo=5;
double rx[5]={0,0,1,1,0.5};
double ry[5]={0,1,0,1,0.5};
double rz[5]={0,0,0,0,1};

int r;
double xx,yy,zz;
for(int i=0;i<100000;i++)
{
glColor3f(1,0,0);
glEnable(GL_POINT_SMOOTH);
glPointSize(4.0);
glBegin(GL_POINTS);


if(i % 3 ==0)
r=(((long long) ceil( x* pow(10,15.0))) % BNo);
else if(i % 3 ==1)
r=(((long long) ceil( y* pow(10,15.0))) % BNo);
else
r=(((long long) ceil( z* pow(10,15.0))) % BNo);



x=x+0.55*(rx[r]-x);
y=y+0.55*(ry[r]-y);
z=z+0.55*(rz[r]-z);

xx=-1+2*x;
yy=-1+2*y;
zz=-1+2*z;

glVertex3f(xx,yy,zz);
}
glEnd();
glutSwapBuffers();
}

void init (void) {
glEnable (GL_DEPTH_TEST); //enable the depth testing
glEnable (GL_LIGHTING); //enable the lighting
glEnable (GL_LIGHT0); //enable LIGHT0, our Diffuse Light
glEnable (GL_LIGHT1); //enable LIGHT1, our Ambient Light
glShadeModel (GL_SMOOTH); //set the shader to smooth shader
glEnable(GL_COLOR_MATERIAL); // uses glColor to set the color


}

void initGL() {
glClearColor(1.0f, 1.0f, 1.0f, 0.0f); // Set background color to black and opaque
glClearDepth(6.0f); // Set background depth to farthest
glEnable(GL_DEPTH_TEST); // Enable depth testing for z-culling
glDepthFunc(GL_LEQUAL); // Set the type of depth-test
glShadeModel(GL_SMOOTH); // Enable smooth shading
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Nice perspective corrections
glEnable(GL_COLOR_MATERIAL);
}


void display (void) {

// glClearColor (1,1,1,0); //clear the screen to black
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the color buffer and the depth buffer
glLoadIdentity();
GLfloat Dif[] = {dlr, dlg, dlb}; //set DiffuseLight[] to the specified values
GLfloat Amb[] = {alr, alg, alb}; //set AmbientLight[] to the specified values
GLfloat Spec[] = {1.0, 1.0, 1.0, 1.0};
GLfloat Shine[] = {1.0, 1.0, 1.0, 1.0};

glMaterialfv(GL_LIGHT_MODEL_AMBIENT, GL_AMBIENT, Amb);
glMaterialfv(GL_LIGHT0, GL_DIFFUSE, Dif);
glMaterialfv(GL_FRONT, GL_SPECULAR, Spec);
glMaterialf(GL_FRONT, GL_SHININESS, 100.0);
gluLookAt (0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); //camera position, x,y,z, looking at x,y,z, Up Positions of the camera

glScalef (1.0, 1.0, 1.0); /* modeling transformation */
glOrtho(-1, 1, -1, 1, -2, 1); //the views will be: Front, Back, Top, Bottom, Left, and Right
Plot(); //call the cube drawing function
glutSwapBuffers(); //swap the buffers
angle++; //increase the angle


}


void reshape (int w, int h) {
glViewport (0, 0, (GLsizei)w, (GLsizei)h); //set the viewport to the current window specifications
glMatrixMode (GL_PROJECTION); //set the matrix to projection
glLoadIdentity ();
gluPerspective (60, (GLfloat)w / (GLfloat)h, 1.0, 100.0); //set the perspective (angle of sight, width, height, , depth)
glMatrixMode (GL_MODELVIEW); //set the matrix back to model

}

void keyboard (unsigned char key, int x, int y) {
if (key=='r') {
dlr = 1.0; //change light to red
dlg = 0.0;
dlb = 0.0;
}
if (key=='g') {
dlr = 0.0; //change light to green
dlg = 1.0;
dlb = 0.0;
}
if (key=='b') {
dlr = 0.0; //change light to blue
dlg = 0.0;
dlb = 1.0;
}
if (key=='w') {
ly += 10.0; //move the light up
}
if (key=='s') {
ly -= 10.0; //move the light down
}
if (key=='a') {
lx -= 10.0; //move the light left
}
if (key=='d') {
lx += 10.0; //move the light right
}
}

int main (int argc, char **argv) {
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_DEPTH); //set the display to Double buffer, with depth
glutInitWindowSize (1600, 1024); //set the window size
glutInitWindowPosition (100, 100); //set the position of the window
glutCreateWindow ("A 3D Camera Plot"); //the caption of the window
init (); //call the init function
glutDisplayFunc (display); //use the display function to draw everything
glutIdleFunc (display); //update any variables in display, display can be changed to anyhing, as long as you move the variables to be updated, in this case, angle++;
glutReshapeFunc (reshape); //reshape the window accordingly
glutKeyboardFunc (keyboard); //check the keyboard
glutMainLoop (); //call the main loop
return 0;
}