C++ 在opengl中通过头文件进行旋转、平移?
我有一个名为base.h的头文件,它有所有的初始显示和类似的东西, 我的主要目标是模拟一个具有自由度的机器人C++ 在opengl中通过头文件进行旋转、平移?,c++,visual-studio,opengl,translation,rotation,C++,Visual Studio,Opengl,Translation,Rotation,我有一个名为base.h的头文件,它有所有的初始显示和类似的东西, 我的主要目标是模拟一个具有自由度的机器人 class center_rods { public: center_rods() { } void draw_center_rod() { glPushMatrix(); glTranslatef(0,1,0);
class center_rods
{
public:
center_rods()
{
}
void draw_center_rod()
{
glPushMatrix();
glTranslatef(0,1,0);
glRotatef(90.0,1.0,0.0,0.0);
glScalef(0.3,5,0.3);
glColor3f(0,0,1);
glutSolidCube(1.0);
glPopMatrix();
}
/* design and implementation of clamp holder of center rod, needs to be done */
};
class base_of_robot: public base1
{
public:
base_of_robot()
{
}
在名为robo.cpp的主程序中,我想实现这些目标
- 我可以将参数从主程序传递到头文件吗?因为我使用的是glutkeyBoardFunc(),所以我需要我的机械臂根据关键点进行平移和旋转,如下所示:
- 如何将参数传递到头文件,因为所有重新显示都是由头文件控制的李>
退一步说,你应该搜索一个关于使用glut的基本教程,它将向你展示如何构建你的程序(例如)。其中很多都是用C编写的(或者是很大程度上是程序化的),所以它们通常不说明你所暗示的面向对象的设计。我用C++实现这个,所以做OOP方式,所以根据你,在类的头文件中,我需要定义自定义函数,然后通过对象。我会试着再回来,谢谢。。。
case 'a':
to_arm = 0, fro_arm = 0;
glutTimerFunc(100, myTimerFunc, 3);
break;