السلام عليكم ,,
يسعدني الانضمام لاسره من جديد ,
انا مهتم بالبرمجه بشكل عام والجرافيكس خاص ,
استفساري كالاتي , ما احاول عمله بختصار هو شخص ماسك جله وماشي بيها ,اي كالصوره التاليه :

الان انا بالمرحله التاليه (العجله تتحرك مع الموجه نحو اليمين او اليسار بالتحكم بالفاره) : -

هذه الكود :
#include "GL/glut.h"
#include <math.h>
double const PI = 4*atan(1.0);
double start=0;
double delta=0.1;
void init()
{
glClearColor(0.0,0.0,0.0,0); // Set background color
glOrtho(-1,1,-1,1,-0.5,50); //near must negative -0.5
}
void DrawSinMotion()
{
double x,y;
glColor3d(0.0,0.9,0.0); // green
glLineWidth(3);
glBegin(GL_LINE_STRIP);
for(x=-10;x<10;x+=0.01) {
//y=0.7*sin(100*x)*sin(6*x+start);
y=0.2*sin(2*x+start*0.01);
glVertex2d(x,y);
}
glEnd();
}
void DrawSin()
{
double x,y;
glColor3d(0.0,0.9,0.0); // green
glLineWidth(3);
glBegin(GL_LINE_STRIP);
for(x=-10;x<10;x+=0.01) {
// y=0.2*sin(3*x);
y=0.2*sin(2*x+start*0.01); // moveing the sin
glVertex2d(x,y);
}
glEnd();
}
void DrawWheel()
{
double x,y,alpha;
glColor3d(0.9,0.7,0.3);
glBegin(GL_LINE_LOOP );
for(alpha=0;alpha<=360;alpha+=5)
{
x = cos(alpha*PI/180);
y = sin(alpha*PI/180);
glVertex2d(x,y);
}
glEnd();
glLineWidth(1);
//################################### al5t
glBegin(GL_LINES);
for(alpha=0;alpha<=20;alpha+=1)
{
x = cos(alpha*PI/180);
// y = sin(alpha*PI/180);
x = x + 2;
glVertex2d(x,5);
glVertex2d(0,0);
}
glEnd();
}
//####################################
void display()
{
double y,x;
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity(); // Set matrix of painting to Identity
// glPushMatrix(); // start local transformations
////////////Cicle Motion ///////////////////////
DrawSin();
x=-1+start*2*PI*0.1/360;
//y=0.2*sin(3*x);
y=0.2*sin(2*x+start*0.01); // moving the sin
glTranslated(x,0.1+y,0);
///////////////////////////////////////////////
glScaled(0.1,0.1,1);
glRotated(-start,0,0,1);
DrawWheel();
// glPopMatrix(); // end local transformations
glutSwapBuffers();
}
void Idle()
{
// Sleep(10);
start+=delta;
glutPostRedisplay();
}
void MyMouse(int button, int state,int x, int y)
{
if(button == GLUT_LEFT_BUTTON && state==GLUT_DOWN)
if(delta == 0)
delta=0.1;
else delta=-delta;
if(button == GLUT_RIGHT_BUTTON && state==GLUT_DOWN)
delta=0;
}
void main(int argc, char** argv)
{
// All this is from first.cpp
// Lookup in google for glutInit*
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(600,600);
glutInitWindowPosition(200,100);
glutCreateWindow("First example");
glutDisplayFunc(display);
glutIdleFunc(Idle);
glutMouseFunc(MyMouse);
init();
glutMainLoop();
}اي ما احتاجه الان رسم باقي الخطوط بالطريقه المناسبه وجعل الشخص يتحرك مع العجله (طبعا ليس هوناك حاجه بتقليد مشي الانسان مجرد حركه او زحف)
لقد حاولت استخدام ال :
glBegin(GL_LINES)
مثلما واضح بالكود بفرع "###" لكن الخط يدور مع العجله ...
ارجو مساعدتي بتصميم الحل .. الكود ركبتو من عده برامج وانا مبتدأ :happy:
تقبلو تحياتي ,

